4using System.Collections.Generic;
7using System.Reflection;
9using System.Threading.Tasks;
16 public static Dictionary<string, IPlugin> Plugins =
new Dictionary<string, IPlugin>();
20 string MenuPath {
get; }
21 bool ContextMenu {
get; }
22 void Execute(
string[] args);
23 void KeyUpEvent(
object o, KeyReleaseEventArgs e);
24 void KeyDownEvent(
object o, KeyPressEventArgs e);
25 void ScrollEvent(
object o, ScrollEventArgs args);
26 void Render(
object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e);
27 void MouseMove(
object o, PointD e, MotionNotifyEventArgs buts);
28 void MouseUp(
object o, PointD e, ButtonReleaseEventArgs buts);
29 void MouseDown(
object o, PointD e, ButtonPressEventArgs buts);
33 public static class Plugins
35 public static void Initialize()
37 foreach (
string s
in Directory.GetFiles(System.IO.Path.GetDirectoryName(Environment.ProcessPath) +
"/Plugins"))
41 if (!s.EndsWith(
".dll") ||
Plugin.Plugins.ContainsKey(Path.GetFileName(s)))
43 string dir = System.IO.Path.GetDirectoryName(Environment.ProcessPath) +
"/Plugins/" + Path.GetFileName(s);
44 dir.Replace(
"\\",
"/");
46 Assembly pluginAssembly = Assembly.LoadFile(dir);
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)
55 App.AddContextMenu(pluginInstance.MenuPath);
57 App.AddMenu(pluginInstance.MenuPath);
62 Console.WriteLine(e.Message.ToString());
67 public static void KeyUpEvent(
object o, KeyReleaseEventArgs e)
69 foreach (IPlugin p
in Plugin.Plugins.Values)
74 public static void KeyDownEvent(
object o, KeyPressEventArgs e)
76 foreach (IPlugin p
in Plugin.Plugins.Values)
81 public static void ScrollEvent(
object o, ScrollEventArgs args)
83 foreach (IPlugin p
in Plugin.Plugins.Values)
85 p.ScrollEvent(o, args);
88 public static void Render(
object o, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e)
90 foreach (IPlugin p
in Plugin.Plugins.Values)
92 ((IPlugin)p).Render(o, e);
95 public static void MouseMove(
object o, PointD e, MotionNotifyEventArgs buts)
97 foreach (IPlugin p
in Plugin.Plugins.Values)
99 p.MouseMove(o, e, buts);
102 public static void MouseUp(
object o, PointD e, ButtonReleaseEventArgs buts)
104 foreach (IPlugin p
in Plugin.Plugins.Values)
106 p.MouseUp(o, e, buts);
109 public static void MouseDown(
object o, PointD e, ButtonPressEventArgs buts)
111 foreach (IPlugin p
in Plugin.Plugins.Values)
113 p.MouseDown(o, e, buts);