mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-07 23:39:19 +02:00
- Remove unnecessary code
- Execute `OnValueChanged` event in task
This commit is contained in:
@@ -473,7 +473,6 @@ namespace DesktopMagic
|
|||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
label.Text = eLabel.Value;
|
label.Text = eLabel.Value;
|
||||||
Option_ValueChanged();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -498,7 +497,6 @@ namespace DesktopMagic
|
|||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
button.Content = eButton.Value;
|
button.Content = eButton.Value;
|
||||||
Option_ValueChanged();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -522,7 +520,6 @@ namespace DesktopMagic
|
|||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
checkBox.IsChecked = eCheckBox.Value;
|
checkBox.IsChecked = eCheckBox.Value;
|
||||||
Option_ValueChanged();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -546,7 +543,6 @@ namespace DesktopMagic
|
|||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
textBox.Text = eTextBox.Value;
|
textBox.Text = eTextBox.Value;
|
||||||
Option_ValueChanged();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
_ = stackPanel.Children.Add(textBox);
|
_ = stackPanel.Children.Add(textBox);
|
||||||
@@ -570,7 +566,6 @@ namespace DesktopMagic
|
|||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
integerUpDown.Value = eIntegerUpDown.Value;
|
integerUpDown.Value = eIntegerUpDown.Value;
|
||||||
Option_ValueChanged();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
_ = stackPanel.Children.Add(integerUpDown);
|
_ = stackPanel.Children.Add(integerUpDown);
|
||||||
@@ -596,7 +591,6 @@ namespace DesktopMagic
|
|||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
slider.Value = eSlider.Value;
|
slider.Value = eSlider.Value;
|
||||||
Option_ValueChanged();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -606,20 +600,6 @@ namespace DesktopMagic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Option_ValueChanged()
|
|
||||||
{
|
|
||||||
//Plugin settings save currenty disabled. Not sure if I want to add it back in the future.
|
|
||||||
/*
|
|
||||||
string pluginName = ((Tuple<string, int>)optionsComboBox.SelectedItem).Item1.ToString();
|
|
||||||
|
|
||||||
if (PluginsSettings.ContainsKey(pluginName))
|
|
||||||
{
|
|
||||||
string jsonSettings = JsonSerializer.Serialize(PluginsSettings[pluginName]);
|
|
||||||
File.WriteAllText($"{applicationDataPath}\\Plugins\\{pluginName}\\{pluginName}.save", jsonSettings);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion options
|
#endregion options
|
||||||
|
|
||||||
private void TextBlock_Loaded(object sender, RoutedEventArgs e)
|
private void TextBlock_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -117,15 +117,9 @@ namespace DesktopMagic
|
|||||||
|
|
||||||
private void LoadPlugin()
|
private void LoadPlugin()
|
||||||
{
|
{
|
||||||
string PluginPath;
|
|
||||||
|
|
||||||
pluginFolderPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\{MainWindow.AppName}\\Plugins\\{pluginName}";
|
pluginFolderPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\{MainWindow.AppName}\\Plugins\\{pluginName}";
|
||||||
|
|
||||||
if (File.Exists($"{pluginFolderPath}\\{pluginName}.dll"))
|
if (!File.Exists($"{pluginFolderPath}\\{pluginName}.dll"))
|
||||||
{
|
|
||||||
PluginPath = $"{pluginFolderPath}\\{pluginName}.dll";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
_ = MessageBox.Show("File does not exist!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
_ = MessageBox.Show("File does not exist!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
Exit();
|
Exit();
|
||||||
|
|||||||
@@ -1,28 +1,60 @@
|
|||||||
using DesktopMagicPluginAPI;
|
using DesktopMagicPluginAPI;
|
||||||
using DesktopMagicPluginAPI.Inputs;
|
using DesktopMagicPluginAPI.Inputs;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Diagnostics;
|
using System.Drawing.Imaging;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace DesktopMagicPlugin.Test
|
namespace DesktopMagicPlugin.Test
|
||||||
{
|
{
|
||||||
public class GifPlugin : Plugin
|
public class GifPlugin : Plugin
|
||||||
{
|
{
|
||||||
[Element("Gif path:")]
|
[Element("Gif path:")]
|
||||||
public TextBox input = new TextBox("");
|
private TextBox input = new TextBox("");
|
||||||
|
|
||||||
public override int UpdateInterval { get; set; } = 100;
|
private List<Bitmap> bitmaps = new List<Bitmap>();
|
||||||
|
|
||||||
public override void OnMouseWheel(Point position, int delta)
|
private int frameCount = -1;
|
||||||
|
|
||||||
|
public override void Start()
|
||||||
{
|
{
|
||||||
Debug.WriteLine(position + " | " + delta);
|
input.OnValueChanged += Input_OnValueChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Input_OnValueChanged()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.Exists(input.Value))
|
||||||
|
{
|
||||||
|
Image gif = Image.FromFile(input.Value);
|
||||||
|
PropertyItem item = gif.GetPropertyItem(0x5100); // FrameDelay in libgdiplus
|
||||||
|
|
||||||
|
UpdateInterval = (item.Value[0] + item.Value[1] * 256) * 10; //FrameDelay in ms
|
||||||
|
bitmaps.Clear();
|
||||||
|
for (int i = 0; i < gif.GetFrameCount(FrameDimension.Time); i++)
|
||||||
|
{
|
||||||
|
gif.SelectActiveFrame(FrameDimension.Time, i);
|
||||||
|
|
||||||
|
bitmaps.Add(new Bitmap(gif));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Bitmap Main()
|
public override Bitmap Main()
|
||||||
{
|
{
|
||||||
Bitmap bmp = new Bitmap(100, 100);
|
if (bitmaps.Count == 0)
|
||||||
using Graphics graphics = Graphics.FromImage(bmp);
|
return new Bitmap(1, 1);
|
||||||
graphics.Clear(Application.Color);
|
|
||||||
return bmp;
|
frameCount++;
|
||||||
|
|
||||||
|
if (frameCount >= bitmaps.Count)
|
||||||
|
frameCount = 0;
|
||||||
|
|
||||||
|
return bitmaps[frameCount];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DesktopMagicPluginAPI.Inputs
|
namespace DesktopMagicPluginAPI.Inputs
|
||||||
@@ -48,7 +45,7 @@ namespace DesktopMagicPluginAPI.Inputs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Click()
|
public void Click()
|
||||||
{
|
{
|
||||||
OnClick?.Invoke();
|
_ = Task.Run(() => OnClick?.Invoke());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DesktopMagicPluginAPI.Inputs
|
namespace DesktopMagicPluginAPI.Inputs
|
||||||
{
|
{
|
||||||
@@ -17,7 +18,7 @@ namespace DesktopMagicPluginAPI.Inputs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected void ValueChanged()
|
protected void ValueChanged()
|
||||||
{
|
{
|
||||||
OnValueChanged?.Invoke();
|
_ = Task.Run(() => OnValueChanged?.Invoke());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user