diff options
| author | Michael <[email protected]> | 2017-04-16 13:31:23 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-04-16 13:31:23 -0400 |
| commit | 538f99faf7b381717079ea700d4f2e6e908537ea (patch) | |
| tree | 8d8494581c8af53ddc90121e0b69466ea06e6889 /ShiftOS.WinForms/WidgetManager.cs | |
| parent | a0fc2b5e701659d1ed17eba9c2888cae6d519c1e (diff) | |
| download | shiftos_thereturn-538f99faf7b381717079ea700d4f2e6e908537ea.tar.gz shiftos_thereturn-538f99faf7b381717079ea700d4f2e6e908537ea.tar.bz2 shiftos_thereturn-538f99faf7b381717079ea700d4f2e6e908537ea.zip | |
Begin work on Desktop Widgets
Diffstat (limited to 'ShiftOS.WinForms/WidgetManager.cs')
| -rw-r--r-- | ShiftOS.WinForms/WidgetManager.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/WidgetManager.cs b/ShiftOS.WinForms/WidgetManager.cs new file mode 100644 index 0000000..125c804 --- /dev/null +++ b/ShiftOS.WinForms/WidgetManager.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms +{ + public static class WidgetManager + { + public static Dictionary<DesktopWidgetAttribute, Type> GetAllWidgetTypes() + { + Dictionary<DesktopWidgetAttribute, Type> types = new Dictionary<WinForms.DesktopWidgetAttribute, Type>(); + foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exe.EndsWith(".exe") || exe.EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exe); + foreach(var type in asm.GetTypes()) + { + if (type.GetInterfaces().Contains(typeof(IDesktopWidget))) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + foreach (var attrib in type.GetCustomAttributes(false)) + { + if (attrib is DesktopWidgetAttribute) + { + var dw = attrib as DesktopWidgetAttribute; + types.Add(dw, type); + } + } + } + } + } + } + catch { } + } + } + return types; + } + + + } +} |
