mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 17:06: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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user