mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-08 07:46:13 +02:00
UpdateInterval can now be changed while the plugin is running and updated the Icon.
This commit is contained in:
Binary file not shown.
@@ -12,6 +12,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="icon.ico" />
|
<None Remove="icon.ico" />
|
||||||
<None Remove="icons8_volunteering_26_85L_icon.ico" />
|
<None Remove="icons8_volunteering_26_85L_icon.ico" />
|
||||||
|
<None Remove="icon_Dark.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -29,6 +30,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="icon.ico" />
|
<Resource Include="icon_Dark.ico">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Resource>
|
||||||
|
<Resource Include="icon.ico">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Resource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -72,6 +72,7 @@ namespace DesktopMagic
|
|||||||
notifyIcon.Visible = true;
|
notifyIcon.Visible = true;
|
||||||
notifyIcon.Text = AppName;
|
notifyIcon.Text = AppName;
|
||||||
notifyIcon.Icon = new System.Drawing.Icon(iconStream);
|
notifyIcon.Icon = new System.Drawing.Icon(iconStream);
|
||||||
|
notifyIcon.ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip();
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ namespace DesktopMagic
|
|||||||
|
|
||||||
public Point WindowPosition => new Point((int)window.Left, (int)window.Top);
|
public Point WindowPosition => new Point((int)window.Left, (int)window.Top);
|
||||||
|
|
||||||
public void UpdateWindow()
|
public void UpdateWindow() => window.UpdatePluginWindow();
|
||||||
{
|
|
||||||
window.UpdatePluginWindow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ using System.Threading;
|
|||||||
using System.Timers;
|
using System.Timers;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
namespace DesktopMagic
|
namespace DesktopMagic
|
||||||
@@ -249,11 +250,13 @@ namespace DesktopMagic
|
|||||||
{
|
{
|
||||||
//Set Arguments
|
//Set Arguments
|
||||||
SolidBrush newBrush = (SolidBrush)MainWindow.GlobalSystemColor;
|
SolidBrush newBrush = (SolidBrush)MainWindow.GlobalSystemColor;
|
||||||
Color color = newBrush.Color;
|
System.Drawing.Color color = newBrush.Color;
|
||||||
string font = MainWindow.GlobalFont;
|
string font = MainWindow.GlobalFont;
|
||||||
|
|
||||||
Bitmap result = pluginClassInstance.Main();
|
Bitmap result = pluginClassInstance.Main();
|
||||||
|
|
||||||
|
valueTimer.Interval = pluginClassInstance.UpdateInterval;
|
||||||
|
|
||||||
//Update Image
|
//Update Image
|
||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
@@ -312,12 +315,20 @@ namespace DesktopMagic
|
|||||||
|
|
||||||
private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
Clicked(new System.Drawing.Point((int)e.GetPosition(this).X, (int)e.GetPosition(this).Y));
|
ImageSource imageSource = image.Source;
|
||||||
|
BitmapSource bitmapImage = (BitmapSource)imageSource;
|
||||||
|
double pixelMousePositionX = e.GetPosition(image).X * bitmapImage.PixelWidth / image.ActualHeight;
|
||||||
|
double pixelMousePositionY = e.GetPosition(image).Y * bitmapImage.PixelHeight / image.ActualHeight;
|
||||||
|
Clicked(new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
||||||
{
|
{
|
||||||
Moved(new System.Drawing.Point((int)e.GetPosition(this).X, (int)e.GetPosition(this).Y));
|
ImageSource imageSource = image.Source;
|
||||||
|
BitmapSource bitmapImage = (BitmapSource)imageSource;
|
||||||
|
double pixelMousePositionX = e.GetPosition(image).X * bitmapImage.PixelWidth / image.ActualHeight;
|
||||||
|
double pixelMousePositionY = e.GetPosition(image).Y * bitmapImage.PixelHeight / image.ActualHeight;
|
||||||
|
Moved(new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Window Events
|
#endregion Window Events
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 137 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 137 KiB |
@@ -2,6 +2,8 @@
|
|||||||
using DesktopMagicPluginAPI.Inputs;
|
using DesktopMagicPluginAPI.Inputs;
|
||||||
using DesktopMagicPluginAPI.Drawing;
|
using DesktopMagicPluginAPI.Drawing;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
|
||||||
namespace DesktopMagicPlugin.Test
|
namespace DesktopMagicPlugin.Test
|
||||||
{
|
{
|
||||||
@@ -12,6 +14,8 @@ namespace DesktopMagicPlugin.Test
|
|||||||
[Element("Text:")] //Mark the property as element with the specified description
|
[Element("Text:")] //Mark the property as element with the specified description
|
||||||
private TextBox textBox = new TextBox("abc"); //Create a text box with the specified default value.
|
private TextBox textBox = new TextBox("abc"); //Create a text box with the specified default value.
|
||||||
|
|
||||||
|
private Color color = Color.Black;
|
||||||
|
|
||||||
public InputExamplePlugin()
|
public InputExamplePlugin()
|
||||||
{
|
{
|
||||||
textBox.OnValueChanged += TextBox_OnValueChanged; //Add an event handler to the "OnValueChanged" event.
|
textBox.OnValueChanged += TextBox_OnValueChanged; //Add an event handler to the "OnValueChanged" event.
|
||||||
@@ -19,7 +23,23 @@ namespace DesktopMagicPlugin.Test
|
|||||||
|
|
||||||
private void TextBox_OnValueChanged()
|
private void TextBox_OnValueChanged()
|
||||||
{
|
{
|
||||||
Application.UpdateWindow(); //Update the pugin window. (Calls the "Main" method.)
|
Application.UpdateWindow(); //Update the plugin window. (Calls the "Main" method.)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnMouseMove(Point position)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(position.X);
|
||||||
|
Debug.WriteLine(500);
|
||||||
|
if (500 < position.X && color == Color.Black)
|
||||||
|
{
|
||||||
|
color = Color.White;
|
||||||
|
Application.UpdateWindow();
|
||||||
|
}
|
||||||
|
else if (500 > position.X && color == Color.White)
|
||||||
|
{
|
||||||
|
color = Color.Black;
|
||||||
|
Application.UpdateWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Bitmap Main()
|
public override Bitmap Main()
|
||||||
@@ -28,8 +48,9 @@ namespace DesktopMagicPlugin.Test
|
|||||||
|
|
||||||
using (Graphics g = Graphics.FromImage(bmp))
|
using (Graphics g = Graphics.FromImage(bmp))
|
||||||
{
|
{
|
||||||
g.Clear(Application.Color); //Set the background color to the color specified in the Desktop Magic application.
|
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.
|
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.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<AssemblyVersion>0.0.0.2</AssemblyVersion>
|
<AssemblyVersion>0.0.0.2</AssemblyVersion>
|
||||||
<PackageProjectUrl></PackageProjectUrl>
|
<PackageProjectUrl></PackageProjectUrl>
|
||||||
|
<FileVersion>0.0.0.2</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ Gets the window size of the main application.
|
|||||||
|
|
||||||
##### Summary
|
##### Summary
|
||||||
|
|
||||||
Updates the plugin window
|
Updates the plugin window.
|
||||||
|
|
||||||
##### Parameters
|
##### Parameters
|
||||||
|
|
||||||
@@ -445,14 +445,14 @@ DesktopMagicPluginAPI
|
|||||||
|
|
||||||
##### Summary
|
##### Summary
|
||||||
|
|
||||||
The plugin class
|
The plugin class.
|
||||||
|
|
||||||
<a name='P-DesktopMagicPluginAPI-Plugin-Application'></a>
|
<a name='P-DesktopMagicPluginAPI-Plugin-Application'></a>
|
||||||
### Application `property`
|
### Application `property`
|
||||||
|
|
||||||
##### Summary
|
##### Summary
|
||||||
|
|
||||||
Informations about the main application
|
Informations about the main application.
|
||||||
|
|
||||||
<a name='P-DesktopMagicPluginAPI-Plugin-UpdateInterval'></a>
|
<a name='P-DesktopMagicPluginAPI-Plugin-UpdateInterval'></a>
|
||||||
### UpdateInterval `property`
|
### UpdateInterval `property`
|
||||||
|
|||||||
@@ -263,17 +263,17 @@
|
|||||||
</member>
|
</member>
|
||||||
<member name="M:DesktopMagicPluginAPI.IPluginData.UpdateWindow">
|
<member name="M:DesktopMagicPluginAPI.IPluginData.UpdateWindow">
|
||||||
<summary>
|
<summary>
|
||||||
Updates the plugin window
|
Updates the plugin window.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:DesktopMagicPluginAPI.Plugin">
|
<member name="T:DesktopMagicPluginAPI.Plugin">
|
||||||
<summary>
|
<summary>
|
||||||
The plugin class
|
The plugin class.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:DesktopMagicPluginAPI.Plugin.Application">
|
<member name="P:DesktopMagicPluginAPI.Plugin.Application">
|
||||||
<summary>
|
<summary>
|
||||||
Informations about the main application
|
Informations about the main application.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:DesktopMagicPluginAPI.Plugin.UpdateInterval">
|
<member name="P:DesktopMagicPluginAPI.Plugin.UpdateInterval">
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace DesktopMagicPluginAPI
|
|||||||
Point WindowPosition { get; }
|
Point WindowPosition { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the plugin window
|
/// Updates the plugin window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void UpdateWindow();
|
void UpdateWindow();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ using System.Drawing;
|
|||||||
namespace DesktopMagicPluginAPI
|
namespace DesktopMagicPluginAPI
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The plugin class
|
/// The plugin class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class Plugin
|
public abstract class Plugin
|
||||||
{
|
{
|
||||||
private IPluginData application = null;
|
private IPluginData application = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Informations about the main application
|
/// Informations about the main application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IPluginData Application
|
public IPluginData Application
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user