mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 00:46:12 +02:00
- Add MouseButton enum to plugin API to determine which mouse button was pressed
- Add some missing documentation
This commit is contained in:
@@ -210,7 +210,7 @@ namespace DesktopMagic
|
||||
private void LoadOptions(object instance)
|
||||
{
|
||||
Debug.WriteLine(instance.GetType().FullName);
|
||||
FieldInfo[] props = instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
|
||||
FieldInfo[] props = instance.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.GetField);
|
||||
|
||||
List<SettingElement> settingElements = new List<SettingElement>();
|
||||
foreach (FieldInfo prop in props)
|
||||
@@ -330,7 +330,26 @@ namespace DesktopMagic
|
||||
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));
|
||||
|
||||
MouseButton mouseButton;
|
||||
|
||||
switch (e.ChangedButton)
|
||||
{
|
||||
case System.Windows.Input.MouseButton.Left:
|
||||
mouseButton = MouseButton.Left;
|
||||
break;
|
||||
|
||||
case System.Windows.Input.MouseButton.Middle:
|
||||
mouseButton = MouseButton.Middle;
|
||||
break;
|
||||
|
||||
case System.Windows.Input.MouseButton.Right:
|
||||
mouseButton = MouseButton.Right;
|
||||
break;
|
||||
|
||||
default: return;
|
||||
};
|
||||
Clicked(new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY), mouseButton);
|
||||
}
|
||||
|
||||
private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
||||
@@ -346,9 +365,9 @@ namespace DesktopMagic
|
||||
|
||||
#region Plugin Methods
|
||||
|
||||
private void Clicked(System.Drawing.Point positon)
|
||||
private void Clicked(System.Drawing.Point positon, MouseButton mouseButton)
|
||||
{
|
||||
pluginClassInstance.OnMouseClick(positon);
|
||||
pluginClassInstance.OnMouseClick(positon, mouseButton);
|
||||
}
|
||||
|
||||
private void Moved(System.Drawing.Point positon)
|
||||
|
||||
@@ -1,54 +1,28 @@
|
||||
using DesktopMagicPluginAPI;
|
||||
using DesktopMagicPluginAPI.Inputs;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace DesktopMagicPlugin.Test
|
||||
{
|
||||
public class GifPlugin : Plugin
|
||||
{
|
||||
[Element("Gif path:")]
|
||||
private TextBox input = new TextBox("");
|
||||
|
||||
private List<Bitmap> bitmaps = new List<Bitmap>();
|
||||
public TextBox input = new TextBox("");
|
||||
|
||||
public override int UpdateInterval { get; set; } = 100;
|
||||
private int frameCount = -1;
|
||||
|
||||
public GifPlugin()
|
||||
public override void OnMouseClick(Point position, MouseButton mouseButton)
|
||||
{
|
||||
input.OnValueChanged += Input_OnValueChanged;
|
||||
}
|
||||
|
||||
private void Input_OnValueChanged()
|
||||
{
|
||||
if (File.Exists(input.Value))
|
||||
{
|
||||
Image gif = Image.FromFile(input.Value);
|
||||
bitmaps.Clear();
|
||||
for (int i = 0; i < gif.GetFrameCount(FrameDimension.Time); i++)
|
||||
{
|
||||
gif.SelectActiveFrame(FrameDimension.Time, i);
|
||||
|
||||
bitmaps.Add(new Bitmap(gif));
|
||||
}
|
||||
}
|
||||
Debug.WriteLine(position + " | " + mouseButton);
|
||||
}
|
||||
|
||||
public override Bitmap Main()
|
||||
{
|
||||
if (bitmaps.Count == 0)
|
||||
return new Bitmap(1, 1);
|
||||
|
||||
frameCount++;
|
||||
|
||||
if (frameCount >= bitmaps.Count)
|
||||
frameCount = 0;
|
||||
|
||||
return bitmaps[frameCount];
|
||||
Bitmap bmp = new Bitmap(100, 100);
|
||||
using Graphics graphics = Graphics.FromImage(bmp);
|
||||
graphics.Clear(Color.Red);
|
||||
return bmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,19 +4,23 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Company>Stone_Red</Company>
|
||||
<Product>Stone_Red</Product>
|
||||
<Version>0.0.0.2</Version>
|
||||
<Version>0.0.0.4</Version>
|
||||
<RepositoryUrl>https://github.com/Stone-Red-Code/DesktopMagic</RepositoryUrl>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<AssemblyVersion>0.0.0.2</AssemblyVersion>
|
||||
<AssemblyVersion>0.0.0.4</AssemblyVersion>
|
||||
<PackageProjectUrl></PackageProjectUrl>
|
||||
<FileVersion>0.0.0.2</FileVersion>
|
||||
<FileVersion>0.0.0.4</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>C:\Users\David\Programmieren\DesktopMagic\src\DesktopMagicPluginAPI\DesktopMagicPluginAPI.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DocumentationFile>C:\Users\David\Programmieren\DesktopMagic\src\DesktopMagicPluginAPI\DesktopMagicPluginAPI.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
|
||||
<PackageReference Include="Vsxmd" Version="1.4.5">
|
||||
|
||||
@@ -38,11 +38,15 @@
|
||||
- [#ctor(value,bold)](#M-DesktopMagicPluginAPI-Inputs-Label-#ctor-System-String,System-Boolean- 'DesktopMagicPluginAPI.Inputs.Label.#ctor(System.String,System.Boolean)')
|
||||
- [Bold](#P-DesktopMagicPluginAPI-Inputs-Label-Bold 'DesktopMagicPluginAPI.Inputs.Label.Bold')
|
||||
- [Value](#P-DesktopMagicPluginAPI-Inputs-Label-Value 'DesktopMagicPluginAPI.Inputs.Label.Value')
|
||||
- [MouseButton](#T-DesktopMagicPluginAPI-Inputs-MouseButton 'DesktopMagicPluginAPI.Inputs.MouseButton')
|
||||
- [Left](#F-DesktopMagicPluginAPI-Inputs-MouseButton-Left 'DesktopMagicPluginAPI.Inputs.MouseButton.Left')
|
||||
- [Middle](#F-DesktopMagicPluginAPI-Inputs-MouseButton-Middle 'DesktopMagicPluginAPI.Inputs.MouseButton.Middle')
|
||||
- [Right](#F-DesktopMagicPluginAPI-Inputs-MouseButton-Right 'DesktopMagicPluginAPI.Inputs.MouseButton.Right')
|
||||
- [Plugin](#T-DesktopMagicPluginAPI-Plugin 'DesktopMagicPluginAPI.Plugin')
|
||||
- [Application](#P-DesktopMagicPluginAPI-Plugin-Application 'DesktopMagicPluginAPI.Plugin.Application')
|
||||
- [UpdateInterval](#P-DesktopMagicPluginAPI-Plugin-UpdateInterval 'DesktopMagicPluginAPI.Plugin.UpdateInterval')
|
||||
- [Main()](#M-DesktopMagicPluginAPI-Plugin-Main 'DesktopMagicPluginAPI.Plugin.Main')
|
||||
- [OnMouseClick(position)](#M-DesktopMagicPluginAPI-Plugin-OnMouseClick-System-Drawing-Point- 'DesktopMagicPluginAPI.Plugin.OnMouseClick(System.Drawing.Point)')
|
||||
- [OnMouseClick(position,mouseButton)](#M-DesktopMagicPluginAPI-Plugin-OnMouseClick-System-Drawing-Point,DesktopMagicPluginAPI-Inputs-MouseButton- 'DesktopMagicPluginAPI.Plugin.OnMouseClick(System.Drawing.Point,DesktopMagicPluginAPI.Inputs.MouseButton)')
|
||||
- [OnMouseMove(position)](#M-DesktopMagicPluginAPI-Plugin-OnMouseMove-System-Drawing-Point- 'DesktopMagicPluginAPI.Plugin.OnMouseMove(System.Drawing.Point)')
|
||||
- [Start()](#M-DesktopMagicPluginAPI-Plugin-Start 'DesktopMagicPluginAPI.Plugin.Start')
|
||||
- [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider')
|
||||
@@ -325,14 +329,14 @@ Gets the font of the main application.
|
||||
|
||||
##### Summary
|
||||
|
||||
Gets the window position of the main application.
|
||||
Gets the window position of the plugin window.
|
||||
|
||||
<a name='P-DesktopMagicPluginAPI-IPluginData-WindowSize'></a>
|
||||
### WindowSize `property`
|
||||
|
||||
##### Summary
|
||||
|
||||
Gets the window size of the main application.
|
||||
Gets the window size of the plugin window.
|
||||
|
||||
<a name='M-DesktopMagicPluginAPI-IPluginData-UpdateWindow'></a>
|
||||
### UpdateWindow() `method`
|
||||
@@ -437,6 +441,38 @@ Gets or set a value indicating whether the content of the [Label](#T-DesktopMagi
|
||||
|
||||
Gets or sets the text associated with this [Label](#T-DesktopMagicPluginAPI-Inputs-Label 'DesktopMagicPluginAPI.Inputs.Label').
|
||||
|
||||
<a name='T-DesktopMagicPluginAPI-Inputs-MouseButton'></a>
|
||||
## MouseButton `type`
|
||||
|
||||
##### Namespace
|
||||
|
||||
DesktopMagicPluginAPI.Inputs
|
||||
|
||||
##### Summary
|
||||
|
||||
Mouse Buttons
|
||||
|
||||
<a name='F-DesktopMagicPluginAPI-Inputs-MouseButton-Left'></a>
|
||||
### Left `constants`
|
||||
|
||||
##### Summary
|
||||
|
||||
The left mouse button.
|
||||
|
||||
<a name='F-DesktopMagicPluginAPI-Inputs-MouseButton-Middle'></a>
|
||||
### Middle `constants`
|
||||
|
||||
##### Summary
|
||||
|
||||
The middle mouse button.
|
||||
|
||||
<a name='F-DesktopMagicPluginAPI-Inputs-MouseButton-Right'></a>
|
||||
### Right `constants`
|
||||
|
||||
##### Summary
|
||||
|
||||
The right mouse button.
|
||||
|
||||
<a name='T-DesktopMagicPluginAPI-Plugin'></a>
|
||||
## Plugin `type`
|
||||
|
||||
@@ -477,8 +513,8 @@ Occurs when the [UpdateInterval](#P-DesktopMagicPluginAPI-Plugin-UpdateInterval
|
||||
|
||||
This method has no parameters.
|
||||
|
||||
<a name='M-DesktopMagicPluginAPI-Plugin-OnMouseClick-System-Drawing-Point-'></a>
|
||||
### OnMouseClick(position) `method`
|
||||
<a name='M-DesktopMagicPluginAPI-Plugin-OnMouseClick-System-Drawing-Point,DesktopMagicPluginAPI-Inputs-MouseButton-'></a>
|
||||
### OnMouseClick(position,mouseButton) `method`
|
||||
|
||||
##### Summary
|
||||
|
||||
@@ -488,7 +524,8 @@ Occurs when the window is clicked by the mouse.
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| position | [System.Drawing.Point](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Point 'System.Drawing.Point') | |
|
||||
| position | [System.Drawing.Point](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Point 'System.Drawing.Point') | The x- and y-coordinates of the mouse pointer position relative to the plugin window. |
|
||||
| mouseButton | [DesktopMagicPluginAPI.Inputs.MouseButton](#T-DesktopMagicPluginAPI-Inputs-MouseButton 'DesktopMagicPluginAPI.Inputs.MouseButton') | Gets the button associated with the event. |
|
||||
|
||||
<a name='M-DesktopMagicPluginAPI-Plugin-OnMouseMove-System-Drawing-Point-'></a>
|
||||
### OnMouseMove(position) `method`
|
||||
@@ -501,7 +538,7 @@ Occurs when the mouse pointer is moved over the control.
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
| position | [System.Drawing.Point](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Point 'System.Drawing.Point') | |
|
||||
| position | [System.Drawing.Point](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Point 'System.Drawing.Point') | The x- and y-coordinates of the mouse pointer position relative to the plugin window. |
|
||||
|
||||
<a name='M-DesktopMagicPluginAPI-Plugin-Start'></a>
|
||||
### Start() `method`
|
||||
|
||||
@@ -192,6 +192,26 @@
|
||||
<param name="value">The text associated with this <see cref="T:DesktopMagicPluginAPI.Inputs.Label"/></param>
|
||||
<param name="bold">A value indicating whether the content of the <see cref="T:DesktopMagicPluginAPI.Inputs.Label"/> is bold or not.</param>
|
||||
</member>
|
||||
<member name="T:DesktopMagicPluginAPI.Inputs.MouseButton">
|
||||
<summary>
|
||||
Mouse Buttons
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:DesktopMagicPluginAPI.Inputs.MouseButton.Left">
|
||||
<summary>
|
||||
The left mouse button.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:DesktopMagicPluginAPI.Inputs.MouseButton.Middle">
|
||||
<summary>
|
||||
The middle mouse button.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:DesktopMagicPluginAPI.Inputs.MouseButton.Right">
|
||||
<summary>
|
||||
The right mouse button.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:DesktopMagicPluginAPI.Inputs.Slider">
|
||||
<summary>
|
||||
Represents a slider control.
|
||||
@@ -253,12 +273,12 @@
|
||||
</member>
|
||||
<member name="P:DesktopMagicPluginAPI.IPluginData.WindowSize">
|
||||
<summary>
|
||||
Gets the window size of the main application.
|
||||
Gets the window size of the plugin window.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:DesktopMagicPluginAPI.IPluginData.WindowPosition">
|
||||
<summary>
|
||||
Gets the window position of the main application.
|
||||
Gets the window position of the plugin window.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:DesktopMagicPluginAPI.IPluginData.UpdateWindow">
|
||||
@@ -292,17 +312,18 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:DesktopMagicPluginAPI.Plugin.OnMouseClick(System.Drawing.Point)">
|
||||
<member name="M:DesktopMagicPluginAPI.Plugin.OnMouseClick(System.Drawing.Point,DesktopMagicPluginAPI.Inputs.MouseButton)">
|
||||
<summary>
|
||||
Occurs when the window is clicked by the mouse.
|
||||
</summary>
|
||||
<param name="position"></param>
|
||||
<param name="position">The x- and y-coordinates of the mouse pointer position relative to the plugin window.</param>
|
||||
<param name="mouseButton">Gets the button associated with the event.</param>
|
||||
</member>
|
||||
<member name="M:DesktopMagicPluginAPI.Plugin.OnMouseMove(System.Drawing.Point)">
|
||||
<summary>
|
||||
Occurs when the mouse pointer is moved over the control.
|
||||
</summary>
|
||||
<param name="position"></param>
|
||||
<param name="position">The x- and y-coordinates of the mouse pointer position relative to the plugin window.</param>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace DesktopMagicPluginAPI
|
||||
Color Color { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the window size of the main application.
|
||||
/// Gets the window size of the plugin window.
|
||||
/// </summary>
|
||||
Point WindowSize { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the window position of the main application.
|
||||
/// Gets the window position of the plugin window.
|
||||
/// </summary>
|
||||
Point WindowPosition { get; }
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DesktopMagicPluginAPI.Inputs
|
||||
{
|
||||
/// <summary>
|
||||
/// Mouse Buttons
|
||||
/// </summary>
|
||||
public enum MouseButton
|
||||
{
|
||||
/// <summary>
|
||||
/// The left mouse button.
|
||||
/// </summary>
|
||||
Left,
|
||||
|
||||
/// <summary>
|
||||
/// The middle mouse button.
|
||||
/// </summary>
|
||||
Middle,
|
||||
|
||||
/// <summary>
|
||||
/// The right mouse button.
|
||||
/// </summary>
|
||||
Right,
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using DesktopMagicPluginAPI.Inputs;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DesktopMagicPluginAPI
|
||||
@@ -50,15 +51,16 @@ namespace DesktopMagicPluginAPI
|
||||
/// <summary>
|
||||
/// Occurs when the window is clicked by the mouse.
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
public virtual void OnMouseClick(Point position)
|
||||
/// <param name="position">The x- and y-coordinates of the mouse pointer position relative to the plugin window.</param>
|
||||
/// <param name="mouseButton">Gets the button associated with the event.</param>
|
||||
public virtual void OnMouseClick(Point position, MouseButton mouseButton)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the mouse pointer is moved over the control.
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="position">The x- and y-coordinates of the mouse pointer position relative to the plugin window.</param>
|
||||
public virtual void OnMouseMove(Point position)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user