mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 00:46:12 +02:00
Improve loading of built in plugins
This commit is contained in:
@@ -34,6 +34,12 @@ namespace DesktopMagic
|
|||||||
public static List<PluginWindow> Windows { get; } = [];
|
public static List<PluginWindow> Windows { get; } = [];
|
||||||
public static List<string> WindowNames { get; } = [];
|
public static List<string> WindowNames { get; } = [];
|
||||||
|
|
||||||
|
private Dictionary<string, Type> builtInPlugins = new()
|
||||||
|
{
|
||||||
|
{"Music Visualizer", typeof(MusicVisualizerPlugin)},
|
||||||
|
{"Time", typeof(TimePlugin)},
|
||||||
|
{"Date", typeof(DatePlugin)}
|
||||||
|
};
|
||||||
internal static bool EditMode { get; set; } = false;
|
internal static bool EditMode { get; set; } = false;
|
||||||
|
|
||||||
private DesktopMagicSettings Settings
|
private DesktopMagicSettings Settings
|
||||||
@@ -107,9 +113,7 @@ namespace DesktopMagic
|
|||||||
{
|
{
|
||||||
pluginNames.Clear();
|
pluginNames.Clear();
|
||||||
|
|
||||||
pluginNames.Add("MusicVisualizer");
|
pluginNames.AddRange(builtInPlugins.Keys);
|
||||||
pluginNames.Add("Time");
|
|
||||||
pluginNames.Add("Date");
|
|
||||||
|
|
||||||
string pluginsPath = App.ApplicationDataPath + "\\Plugins";
|
string pluginsPath = App.ApplicationDataPath + "\\Plugins";
|
||||||
|
|
||||||
@@ -178,23 +182,9 @@ namespace DesktopMagic
|
|||||||
|
|
||||||
PluginWindow window;
|
PluginWindow window;
|
||||||
|
|
||||||
if (pluginName == "MusicVisualizer")
|
if (builtInPlugins.TryGetValue(pluginName, out Type? pluginType))
|
||||||
{
|
{
|
||||||
window = new PluginWindow(new MusicVisualizerPlugin(), pluginName, pluginSettings)
|
window = new PluginWindow((DesktopMagicPluginAPI.Plugin)Activator.CreateInstance(pluginType)!, pluginName, pluginSettings)
|
||||||
{
|
|
||||||
Title = pluginName
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else if (pluginName == "Time")
|
|
||||||
{
|
|
||||||
window = new PluginWindow(new TimePlugin(), pluginName, pluginSettings)
|
|
||||||
{
|
|
||||||
Title = pluginName
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else if (pluginName == "Date")
|
|
||||||
{
|
|
||||||
window = new PluginWindow(new DatePlugin(), pluginName, pluginSettings)
|
|
||||||
{
|
{
|
||||||
Title = pluginName
|
Title = pluginName
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user