mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 00:46:12 +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>
|
||||
<None Remove="icon.ico" />
|
||||
<None Remove="icons8_volunteering_26_85L_icon.ico" />
|
||||
<None Remove="icon_Dark.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -29,6 +30,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="icon.ico" />
|
||||
<Resource Include="icon_Dark.ico">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
<Resource Include="icon.ico">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -72,6 +72,7 @@ namespace DesktopMagic
|
||||
notifyIcon.Visible = true;
|
||||
notifyIcon.Text = AppName;
|
||||
notifyIcon.Icon = new System.Drawing.Icon(iconStream);
|
||||
notifyIcon.ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
@@ -20,9 +20,6 @@ namespace DesktopMagic
|
||||
|
||||
public Point WindowPosition => new Point((int)window.Left, (int)window.Top);
|
||||
|
||||
public void UpdateWindow()
|
||||
{
|
||||
window.UpdatePluginWindow();
|
||||
}
|
||||
public void UpdateWindow() => window.UpdatePluginWindow();
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ using System.Threading;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace DesktopMagic
|
||||
@@ -249,11 +250,13 @@ namespace DesktopMagic
|
||||
{
|
||||
//Set Arguments
|
||||
SolidBrush newBrush = (SolidBrush)MainWindow.GlobalSystemColor;
|
||||
Color color = newBrush.Color;
|
||||
System.Drawing.Color color = newBrush.Color;
|
||||
string font = MainWindow.GlobalFont;
|
||||
|
||||
Bitmap result = pluginClassInstance.Main();
|
||||
|
||||
valueTimer.Interval = pluginClassInstance.UpdateInterval;
|
||||
|
||||
//Update Image
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
@@ -312,12 +315,20 @@ namespace DesktopMagic
|
||||
|
||||
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)
|
||||
{
|
||||
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
|
||||
|
||||
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.Drawing;
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DesktopMagicPlugin.Test
|
||||
{
|
||||
@@ -12,6 +14,8 @@ namespace DesktopMagicPlugin.Test
|
||||
[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 Color color = Color.Black;
|
||||
|
||||
public InputExamplePlugin()
|
||||
{
|
||||
textBox.OnValueChanged += TextBox_OnValueChanged; //Add an event handler to the "OnValueChanged" event.
|
||||
@@ -19,7 +23,23 @@ namespace DesktopMagicPlugin.Test
|
||||
|
||||
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()
|
||||
@@ -28,8 +48,9 @@ namespace DesktopMagicPlugin.Test
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<AssemblyVersion>0.0.0.2</AssemblyVersion>
|
||||
<PackageProjectUrl></PackageProjectUrl>
|
||||
<FileVersion>0.0.0.2</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
@@ -338,7 +338,7 @@ Gets the window size of the main application.
|
||||
|
||||
##### Summary
|
||||
|
||||
Updates the plugin window
|
||||
Updates the plugin window.
|
||||
|
||||
##### Parameters
|
||||
|
||||
@@ -445,14 +445,14 @@ DesktopMagicPluginAPI
|
||||
|
||||
##### Summary
|
||||
|
||||
The plugin class
|
||||
The plugin class.
|
||||
|
||||
<a name='P-DesktopMagicPluginAPI-Plugin-Application'></a>
|
||||
### Application `property`
|
||||
|
||||
##### Summary
|
||||
|
||||
Informations about the main application
|
||||
Informations about the main application.
|
||||
|
||||
<a name='P-DesktopMagicPluginAPI-Plugin-UpdateInterval'></a>
|
||||
### UpdateInterval `property`
|
||||
|
||||
@@ -263,17 +263,17 @@
|
||||
</member>
|
||||
<member name="M:DesktopMagicPluginAPI.IPluginData.UpdateWindow">
|
||||
<summary>
|
||||
Updates the plugin window
|
||||
Updates the plugin window.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:DesktopMagicPluginAPI.Plugin">
|
||||
<summary>
|
||||
The plugin class
|
||||
The plugin class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:DesktopMagicPluginAPI.Plugin.Application">
|
||||
<summary>
|
||||
Informations about the main application
|
||||
Informations about the main application.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:DesktopMagicPluginAPI.Plugin.UpdateInterval">
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace DesktopMagicPluginAPI
|
||||
Point WindowPosition { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Updates the plugin window
|
||||
/// Updates the plugin window.
|
||||
/// </summary>
|
||||
void UpdateWindow();
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@ using System.Drawing;
|
||||
namespace DesktopMagicPluginAPI
|
||||
{
|
||||
/// <summary>
|
||||
/// The plugin class
|
||||
/// The plugin class.
|
||||
/// </summary>
|
||||
public abstract class Plugin
|
||||
{
|
||||
private IPluginData application = null;
|
||||
|
||||
/// <summary>
|
||||
/// Informations about the main application
|
||||
/// Informations about the main application.
|
||||
/// </summary>
|
||||
public IPluginData Application
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user