From ae490367eeaea28bd8afcbeda62f8ee1491b3565 Mon Sep 17 00:00:00 2001 From: Stone-Red-Code <56473591+Stone-Red-Code@users.noreply.github.com> Date: Sun, 22 Aug 2021 12:50:28 +0200 Subject: [PATCH] Actually implement the Start method correctly --- src/DesktopMagic/Plugin/PluginWindow.xaml.cs | 1 + src/DesktopMagicPlugin.Test/PluginScript.cs | 32 ++++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/DesktopMagic/Plugin/PluginWindow.xaml.cs b/src/DesktopMagic/Plugin/PluginWindow.xaml.cs index bb37451..51dd430 100644 --- a/src/DesktopMagic/Plugin/PluginWindow.xaml.cs +++ b/src/DesktopMagic/Plugin/PluginWindow.xaml.cs @@ -204,6 +204,7 @@ namespace DesktopMagic valueTimer.Interval = 1000; valueTimer.Elapsed += ValueTimer_Elapsed; + pluginClassInstance.Start(); UpdatePluginWindow(); if (pluginClassInstance.UpdateInterval > 0) diff --git a/src/DesktopMagicPlugin.Test/PluginScript.cs b/src/DesktopMagicPlugin.Test/PluginScript.cs index 4d4c927..a5deb03 100644 --- a/src/DesktopMagicPlugin.Test/PluginScript.cs +++ b/src/DesktopMagicPlugin.Test/PluginScript.cs @@ -16,11 +16,26 @@ namespace DesktopMagicPlugin.Test private Color color = Color.Black; - public InputExamplePlugin() + public override void Start() { textBox.OnValueChanged += TextBox_OnValueChanged; //Add an event handler to the "OnValueChanged" event. } + public override Bitmap Main() + { + Bitmap bmp = new Bitmap(1000, 1000); + + using (Graphics g = Graphics.FromImage(bmp)) + { + g.InterpolationMode = InterpolationMode.HighQualityBilinear; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + g.Clear(color); + g.DrawStringFixedWidth(textBox.Value, new Font(Application.Font, 100), Brushes.Black, new PointF(0, 0), 120); //Draw the value of the text box to the image. + } + + return bmp; //Return the image. + } + private void TextBox_OnValueChanged() { Application.UpdateWindow(); //Update the plugin window. (Calls the "Main" method.) @@ -41,20 +56,5 @@ namespace DesktopMagicPlugin.Test Application.UpdateWindow(); } } - - public override Bitmap Main() - { - Bitmap bmp = new Bitmap(1000, 1000); - - using (Graphics g = Graphics.FromImage(bmp)) - { - g.InterpolationMode = InterpolationMode.HighQualityBilinear; - g.PixelOffsetMode = PixelOffsetMode.HighQuality; - g.Clear(color); - g.DrawStringFixedWidth(textBox.Value, new Font(Application.Font, 100), Brushes.Black, new PointF(0, 0), 120); //Draw the value of the text box to the image. - } - - return bmp; //Return the image. - } } } \ No newline at end of file