- Add OnMouseWheel event

This commit is contained in:
Stone-Red-Code
2021-09-11 17:13:02 +02:00
parent 36e09acd0e
commit f94f24297e
7 changed files with 55 additions and 22 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
<Grid>
<Rectangle x:Name="panel" Fill="#4CBAFFEF" Stroke="White" Margin="0,0,0,0" Visibility="Collapsed" />
<Viewbox StretchDirection="Both" Stretch="Uniform">
<Image x:Name="image" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Stretch="Uniform" MouseDown="Window_MouseDown" MouseMove="Window_MouseMove" />
<Image x:Name="image" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Stretch="Uniform" MouseDown="Window_MouseDown" MouseMove="Window_MouseMove" MouseWheel="Window_MouseWheel"/>
</Viewbox>
</Grid>
<WindowChrome.WindowChrome>
+17 -16
View File
@@ -349,7 +349,9 @@ namespace DesktopMagic
default: return;
};
Clicked(new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY), mouseButton);
System.Drawing.Point point = new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY);
pluginClassInstance.OnMouseClick(point, mouseButton);
}
private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
@@ -358,23 +360,22 @@ 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;
Moved(new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY));
System.Drawing.Point point = new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY);
pluginClassInstance.OnMouseMove(point);
}
private void Window_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
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;
System.Drawing.Point point = new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY);
pluginClassInstance.OnMouseWheel(point, e.Delta);
}
#endregion Window Events
#region Plugin Methods
private void Clicked(System.Drawing.Point positon, MouseButton mouseButton)
{
pluginClassInstance.OnMouseClick(positon, mouseButton);
}
private void Moved(System.Drawing.Point positon)
{
pluginClassInstance.OnMouseMove(positon);
}
#endregion Plugin Methods
}
}
@@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.2.1" />
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
</ItemGroup>
+2 -2
View File
@@ -12,9 +12,9 @@ namespace DesktopMagicPlugin.Test
public override int UpdateInterval { get; set; } = 100;
public override void OnMouseClick(Point position, MouseButton mouseButton)
public override void OnMouseWheel(Point position, int delta)
{
Debug.WriteLine(position + " | " + mouseButton);
Debug.WriteLine(position + " | " + delta);
}
public override Bitmap Main()
@@ -48,6 +48,7 @@
- [Main()](#M-DesktopMagicPluginAPI-Plugin-Main 'DesktopMagicPluginAPI.Plugin.Main')
- [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)')
- [OnMouseWheel(position,Delta)](#M-DesktopMagicPluginAPI-Plugin-OnMouseWheel-System-Drawing-Point,System-Int32- 'DesktopMagicPluginAPI.Plugin.OnMouseWheel(System.Drawing.Point,System.Int32)')
- [Start()](#M-DesktopMagicPluginAPI-Plugin-Start 'DesktopMagicPluginAPI.Plugin.Start')
- [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider')
- [#ctor(min,max,value)](#M-DesktopMagicPluginAPI-Inputs-Slider-#ctor-System-Double,System-Double,System-Double- 'DesktopMagicPluginAPI.Inputs.Slider.#ctor(System.Double,System.Double,System.Double)')
@@ -525,7 +526,7 @@ 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') | 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. |
| mouseButton | [DesktopMagicPluginAPI.Inputs.MouseButton](#T-DesktopMagicPluginAPI-Inputs-MouseButton 'DesktopMagicPluginAPI.Inputs.MouseButton') | The button associated with the event. |
<a name='M-DesktopMagicPluginAPI-Plugin-OnMouseMove-System-Drawing-Point-'></a>
### OnMouseMove(position) `method`
@@ -540,6 +541,20 @@ Occurs when the mouse pointer is moved over the control.
| ---- | ---- | ----------- |
| 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-OnMouseWheel-System-Drawing-Point,System-Int32-'></a>
### OnMouseWheel(position,Delta) `method`
##### Summary
Occurs when the user rotates the mouse wheel while the mouse pointer is over this element.
##### Parameters
| 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') | The x- and y-coordinates of the mouse pointer position relative to the plugin window. |
| Delta | [System.Int32](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Int32 'System.Int32') | A value that indicates the amount that the mouse wheel has changed. |
<a name='M-DesktopMagicPluginAPI-Plugin-Start'></a>
### Start() `method`
@@ -317,7 +317,7 @@
Occurs when the window is clicked by the mouse.
</summary>
<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>
<param name="mouseButton">The button associated with the event.</param>
</member>
<member name="M:DesktopMagicPluginAPI.Plugin.OnMouseMove(System.Drawing.Point)">
<summary>
@@ -325,5 +325,12 @@
</summary>
<param name="position">The x- and y-coordinates of the mouse pointer position relative to the plugin window.</param>
</member>
<member name="M:DesktopMagicPluginAPI.Plugin.OnMouseWheel(System.Drawing.Point,System.Int32)">
<summary>
Occurs when the user rotates the mouse wheel while the mouse pointer is over this element.
</summary>
<param name="position">The x- and y-coordinates of the mouse pointer position relative to the plugin window.</param>
<param name="Delta">A value that indicates the amount that the mouse wheel has changed.</param>
</member>
</members>
</doc>
+10 -1
View File
@@ -52,7 +52,7 @@ namespace DesktopMagicPluginAPI
/// Occurs when the window is clicked by the mouse.
/// </summary>
/// <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>
/// <param name="mouseButton">The button associated with the event.</param>
public virtual void OnMouseClick(Point position, MouseButton mouseButton)
{
}
@@ -64,5 +64,14 @@ namespace DesktopMagicPluginAPI
public virtual void OnMouseMove(Point position)
{
}
/// <summary>
/// Occurs when the user rotates the mouse wheel while the mouse pointer is over this element.
/// </summary>
/// <param name="position">The x- and y-coordinates of the mouse pointer position relative to the plugin window.</param>
/// <param name="Delta">A value that indicates the amount that the mouse wheel has changed.</param>
public virtual void OnMouseWheel(Point position, int Delta)
{
}
}
}