3using SkiaSharp.Views.Desktop;
5using System.Collections.Generic;
8using System.Reflection;
10using System.Threading.Tasks;
17 public static Dictionary<string, IPlugin> Plugins =
new Dictionary<string, IPlugin>();
21 string MenuPath {
get; }
22 bool ContextMenu {
get; }
23 void Execute(
string[] args);
24 void KeyUpEvent(
object o, KeyEventArgs e);
25 void KeyDownEvent(
object o, KeyEventArgs e);
26 void KeyPressEvent(
object o, KeyPressEventArgs e);
27 void ScrollEvent(
object o, MouseEventArgs args);
28 void Paint(
object o, PaintEventArgs e);
29 void Render(
object o, PaintEventArgs e);
30 void MouseMove(
object o, PointD e, MouseEventArgs buts);
31 void MouseUp(
object o, PointD e, MouseEventArgs buts);
32 void MouseDown(
object o, PointD e, MouseEventArgs buts);
36 public static class Plugins
38 public static void Initialize()
40 Directory.CreateDirectory(
"Plugins");
41 foreach (
string s
in Directory.GetFiles(
"Plugins"))
43 if (!s.EndsWith(
".dll") ||
Plugin.Plugins.ContainsKey(Path.GetFileName(s)))
46 Assembly pluginAssembly = Assembly.LoadFile(Environment.CurrentDirectory +
"/" + s);
48 var pluginType = pluginAssembly.GetTypes().FirstOrDefault(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsInterface);
49 if (pluginType !=
null)
52 IPlugin pluginInstance = Activator.CreateInstance(pluginType) as IPlugin;
53 Plugin.Plugins.Add(Path.GetFileName(s), pluginInstance);
54 if (pluginInstance.ContextMenu)
61 Console.WriteLine(
"No plugin found in the assembly: " + s);
65 public static void KeyUpEvent(
object o, KeyEventArgs e)
67 foreach (IPlugin p
in Plugin.Plugins.Values)
72 public static void KeyDownEvent(
object o, KeyEventArgs e)
74 foreach (IPlugin p
in Plugin.Plugins.Values)
79 public static void KeyPressEvent(
object o, KeyPressEventArgs e)
81 foreach (IPlugin p
in Plugin.Plugins.Values)
83 p.KeyPressEvent(o, e);
86 public static void ScrollEvent(
object o, MouseEventArgs args)
88 foreach (IPlugin p
in Plugin.Plugins.Values)
90 p.ScrollEvent(o, args);
93 public static void Paint(
object o, PaintEventArgs e)
95 foreach (IPlugin p
in Plugin.Plugins.Values)
100 public static void Render(
object o, PaintEventArgs e)
102 foreach (IPlugin p
in Plugin.Plugins.Values)
107 public static void MouseMove(
object o, PointD e, MouseEventArgs buts)
109 foreach (IPlugin p
in Plugin.Plugins.Values)
111 p.MouseMove(o, e, buts);
114 public static void MouseUp(
object o, PointD e, MouseEventArgs buts)
116 foreach (IPlugin p
in Plugin.Plugins.Values)
118 p.MouseUp(o, e, buts);
121 public static void MouseDown(
object o, PointD e, MouseEventArgs buts)
123 foreach (IPlugin p
in Plugin.Plugins.Values)
125 p.MouseDown(o, e, buts);
static void AddMenu(string menu, Function f)
static void AddContextMenu(string menu, Function f)