aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms
diff options
context:
space:
mode:
authorMichael VanOverbeek <[email protected]>2017-06-11 11:57:31 +0000
committerGitHub <[email protected]>2017-06-11 11:57:31 +0000
commit997a81457ebb6d6523c36ca552cee143e0d92244 (patch)
treeda98985ced112b6d238811f3ca770014d67e34fc /ShiftOS.WinForms
parent0d75f701778a0900a58343c4c80c124279bc231f (diff)
parent107a98686a105468b5f200ebcbd27343c1210ce4 (diff)
downloadshiftos_thereturn-997a81457ebb6d6523c36ca552cee143e0d92244.tar.gz
shiftos_thereturn-997a81457ebb6d6523c36ca552cee143e0d92244.tar.bz2
shiftos_thereturn-997a81457ebb6d6523c36ca552cee143e0d92244.zip
Merge pull request #129 from RogueAI42/master
ReflectMan Saves The Day..............
Diffstat (limited to 'ShiftOS.WinForms')
-rw-r--r--ShiftOS.WinForms/Applications/IconManager.cs99
-rw-r--r--ShiftOS.WinForms/Applications/Shiftnet.cs113
-rw-r--r--ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs7
-rw-r--r--ShiftOS.WinForms/HackerCommands.cs25
-rw-r--r--ShiftOS.WinForms/Program.cs70
-rw-r--r--ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs30
-rw-r--r--ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs57
-rw-r--r--ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs69
-rw-r--r--ShiftOS.WinForms/WidgetManager.cs36
9 files changed, 187 insertions, 319 deletions
diff --git a/ShiftOS.WinForms/Applications/IconManager.cs b/ShiftOS.WinForms/Applications/IconManager.cs
index 0c6e119..7bbeb34 100644
--- a/ShiftOS.WinForms/Applications/IconManager.cs
+++ b/ShiftOS.WinForms/Applications/IconManager.cs
@@ -92,70 +92,51 @@ namespace ShiftOS.WinForms.Applications
{
flbody.Controls.Clear(); //Clear the icon list.
- List<Type> types = new List<Type>();
+ Type[] types = Array.FindAll(ReflectMan.Types, x => x.GetCustomAttributes(false).FirstOrDefault(y => y is DefaultIconAttribute) != null);
- foreach(var exe in System.IO.Directory.GetFiles(Environment.CurrentDirectory))
- {
- if(exe.ToLower().EndsWith(".exe") || exe.ToLower().EndsWith(".dll"))
- {
- try
- {
- var asm = Assembly.LoadFile(exe);
+ pageCount = types.GetPageCount(pageSize);
- var typeList = asm.GetTypes().Where(x => x.GetCustomAttributes(false).FirstOrDefault(y => y is DefaultIconAttribute) != null);
- types.AddRange(typeList);
-
- }
- catch { }
- }
- }
-
- pageCount = types.ToArray().GetPageCount(pageSize);
-
- foreach (var type in types.ToArray().GetItemsOnPage(currentPage, pageSize))
+ foreach (var type in Array.FindAll(types.GetItemsOnPage(currentPage, pageSize), t => Shiftorium.UpgradeAttributesUnlocked(t)))
{
- if (Shiftorium.UpgradeAttributesUnlocked(type))
+ var pnl = new Panel();
+ pnl.Height = 30;
+ pnl.Width = flbody.Width - 15;
+ flbody.Controls.Add(pnl);
+ pnl.Show();
+ var pic = new PictureBox();
+ pic.SizeMode = PictureBoxSizeMode.StretchImage;
+ pic.Size = new Size(24, 24);
+ pic.Image = GetIcon(type.Name);
+ pnl.Controls.Add(pic);
+ pic.Left = 5;
+ pic.Top = (pnl.Height - pic.Height) / 2;
+ pic.Show();
+ var lbl = new Label();
+ lbl.Tag = "header3";
+ lbl.AutoSize = true;
+ lbl.Text = NameChangerBackend.GetNameRaw(type);
+ ControlManager.SetupControl(lbl);
+ pnl.Controls.Add(lbl);
+ lbl.CenterParent();
+ lbl.Show();
+ var btn = new Button();
+ btn.Text = "Change...";
+ btn.AutoSize = true;
+ btn.AutoSizeMode = AutoSizeMode.GrowAndShrink;
+ pnl.Controls.Add(btn);
+ btn.Left = (pnl.Width - btn.Width) - 5;
+ btn.Top = (pnl.Height - btn.Height) / 2;
+ btn.Click += (o, a) =>
{
- var pnl = new Panel();
- pnl.Height = 30;
- pnl.Width = flbody.Width - 15;
- flbody.Controls.Add(pnl);
- pnl.Show();
- var pic = new PictureBox();
- pic.SizeMode = PictureBoxSizeMode.StretchImage;
- pic.Size = new Size(24, 24);
- pic.Image = GetIcon(type.Name);
- pnl.Controls.Add(pic);
- pic.Left = 5;
- pic.Top = (pnl.Height - pic.Height) / 2;
- pic.Show();
- var lbl = new Label();
- lbl.Tag = "header3";
- lbl.AutoSize = true;
- lbl.Text = NameChangerBackend.GetNameRaw(type);
- ControlManager.SetupControl(lbl);
- pnl.Controls.Add(lbl);
- lbl.CenterParent();
- lbl.Show();
- var btn = new Button();
- btn.Text = "Change...";
- btn.AutoSize = true;
- btn.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- pnl.Controls.Add(btn);
- btn.Left = (pnl.Width - btn.Width) - 5;
- btn.Top = (pnl.Height - btn.Height) / 2;
- btn.Click += (o, a) =>
+ var gfp = new GraphicPicker(pic.Image, lbl.Text + " icon", ImageLayout.Stretch, (raw, img, layout) =>
{
- var gfp = new GraphicPicker(pic.Image, lbl.Text + " icon", ImageLayout.Stretch, (raw, img, layout) =>
- {
- pic.Image = img;
- SetIcon(type.Name, raw);
- });
- AppearanceManager.SetupDialog(gfp);
- };
- btn.Show();
- ControlManager.SetupControls(pnl);
- }
+ pic.Image = img;
+ SetIcon(type.Name, raw);
+ });
+ AppearanceManager.SetupDialog(gfp);
+ };
+ btn.Show();
+ ControlManager.SetupControls(pnl);
}
btnnext.Visible = (currentPage < pageCount - 1);
diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs
index 6ccdb19..136f680 100644
--- a/ShiftOS.WinForms/Applications/Shiftnet.cs
+++ b/ShiftOS.WinForms/Applications/Shiftnet.cs
@@ -150,79 +150,60 @@ namespace ShiftOS.WinForms.Applications
{
txturl.Text = url;
- foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory))
+ try
{
- if(exe.EndsWith(".exe") || exe.EndsWith(".dll"))
+ foreach (var type in Array.FindAll(ReflectMan.Types, t => t.GetInterfaces().Contains(typeof(IShiftnetSite)) && t.BaseType == typeof(UserControl) && Shiftorium.UpgradeAttributesUnlocked(t)))
{
- try
+ var attribute = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute && (x as ShiftnetSiteAttribute).Url == url) as ShiftnetSiteAttribute;
+ if (attribute != null)
{
- var asm = Assembly.LoadFile(exe);
- foreach (var type in asm.GetTypes())
- {
- if (type.GetInterfaces().Contains(typeof(IShiftnetSite)))
+ var obj = (IShiftnetSite)Activator.CreateInstance(type, null);
+ obj.GoToUrl += (u) =>
{
- if (type.BaseType == typeof(UserControl))
- {
- var attribute = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute;
- if (attribute != null)
- {
- if (attribute.Url == url)
- {
- if (Shiftorium.UpgradeAttributesUnlocked(type))
- {
- var obj = (IShiftnetSite)Activator.CreateInstance(type, null);
- obj.GoToUrl += (u) =>
- {
- History.Push(CurrentUrl);
- NavigateToUrl(u);
- };
- obj.GoBack += () =>
- {
- string u = History.Pop();
- Future.Push(u);
- NavigateToUrl(u);
- };
- CurrentPage = obj;
- this.pnlcanvas.Controls.Clear();
- this.pnlcanvas.Controls.Add((UserControl)obj);
- ((UserControl)obj).Show();
- ((UserControl)obj).Dock = DockStyle.Fill;
- obj.OnUpgrade();
- obj.OnSkinLoad();
- obj.Setup();
- AppearanceManager.SetWindowTitle(this, attribute.Name + " - Shiftnet");
- return;
- }
- }
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- pnlcanvas.Controls.Clear();
- var tlbl = new Label();
- tlbl.Text = "Server error in \"" + url + "\" application.";
- tlbl.Tag = "header1";
- tlbl.AutoSize = true;
- tlbl.Location = new Point(10, 10);
- tlbl.Dock = DockStyle.Top;
- pnlcanvas.Controls.Add(tlbl);
- tlbl.Show();
-
- var crash = new Label();
- crash.Dock = DockStyle.Fill;
- crash.AutoSize = false;
- crash.Text = ex.ToString();
- pnlcanvas.Controls.Add(crash);
- crash.Show();
- crash.BringToFront();
- ControlManager.SetupControls(pnlcanvas);
- return;
+ History.Push(CurrentUrl);
+ NavigateToUrl(u);
+ };
+ obj.GoBack += () =>
+ {
+ string u = History.Pop();
+ Future.Push(u);
+ NavigateToUrl(u);
+ };
+ CurrentPage = obj;
+ this.pnlcanvas.Controls.Clear();
+ this.pnlcanvas.Controls.Add((UserControl)obj);
+ ((UserControl)obj).Show();
+ ((UserControl)obj).Dock = DockStyle.Fill;
+ obj.OnUpgrade();
+ obj.OnSkinLoad();
+ obj.Setup();
+ AppearanceManager.SetWindowTitle(this, attribute.Name + " - Shiftnet");
+ return;
}
}
}
+ catch (Exception ex)
+ {
+ pnlcanvas.Controls.Clear();
+ var tlbl = new Label();
+ tlbl.Text = "Server error in \"" + url + "\" application.";
+ tlbl.Tag = "header1";
+ tlbl.AutoSize = true;
+ tlbl.Location = new Point(10, 10);
+ tlbl.Dock = DockStyle.Top;
+ pnlcanvas.Controls.Add(tlbl);
+ tlbl.Show();
+
+ var crash = new Label();
+ crash.Dock = DockStyle.Fill;
+ crash.AutoSize = false;
+ crash.Text = ex.ToString();
+ pnlcanvas.Controls.Add(crash);
+ crash.Show();
+ crash.BringToFront();
+ ControlManager.SetupControls(pnlcanvas);
+ return;
+ }
pnlcanvas.Controls.Clear();
var lbl = new Label();
lbl.Text = "Page not found!";
diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs
index eebd897..6886d98 100644
--- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs
+++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs
@@ -114,8 +114,12 @@ namespace ShiftOS.WinForms.Applications
private void SetList()
{
- lbnoupgrades.Hide();
lbupgrades.Items.Clear();
+ if (upgrades.Length == 0)
+ return;
+ lbnoupgrades.Hide();
+ if (CategoryId > upgrades.Length)
+ CategoryId = 0;
try
{
lbupgrades.Items.AddRange(upgrades[CategoryId].Keys.ToArray());
@@ -250,6 +254,7 @@ namespace ShiftOS.WinForms.Applications
private void moveCat(short direction) // direction is -1 to move backwards or 1 to move forwards
{
+ if (cats.Length == 0) return;
CategoryId += direction;
CategoryId %= cats.Length;
if (CategoryId < 0) CategoryId += cats.Length; // fix modulo on negatives
diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs
index 316b7fc..dd8bde8 100644
--- a/ShiftOS.WinForms/HackerCommands.cs
+++ b/ShiftOS.WinForms/HackerCommands.cs
@@ -679,28 +679,13 @@ namespace ShiftOS.WinForms
[Command("list", description ="Lists all story IDs.")]
public static bool ListIds()
{
- foreach(var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory))
- {
- if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll"))
+ foreach(var type in ReflectMan.Types)
+ foreach(var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static))
{
- try
- {
- var asm = Assembly.LoadFile(exec);
- {
- foreach(var type in asm.GetTypes())
- {
- foreach(var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static))
- {
- var attr = method.GetCustomAttributes(false).FirstOrDefault(x => x is StoryAttribute);
- if (attr != null)
- Console.WriteLine(" - " + (attr as StoryAttribute).StoryID);
- }
- }
- }
- }
- catch { }
+ var attr = method.GetCustomAttributes(false).FirstOrDefault(x => x is StoryAttribute);
+ if (attr != null)
+ Console.WriteLine(" - " + (attr as StoryAttribute).StoryID);
}
- }
return true;
}
diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs
index b5fb731..d3530a0 100644
--- a/ShiftOS.WinForms/Program.cs
+++ b/ShiftOS.WinForms/Program.cs
@@ -114,53 +114,39 @@ namespace ShiftOS.WinForms
{
var defaultList = JsonConvert.DeserializeObject<List<ShiftoriumUpgrade>>(Properties.Resources.Shiftorium);
- foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory))
+ foreach (var type in ReflectMan.Types)
{
- if (exe.EndsWith(".exe") || exe.EndsWith(".dll"))
+ var attribs = type.GetCustomAttributes(false);
+ var attrib = attribs.FirstOrDefault(x => x is AppscapeEntryAttribute) as AppscapeEntryAttribute;
+ if (attrib != null)
{
- try
+ var upgrade = new ShiftoriumUpgrade
{
- var asm = Assembly.LoadFile(exe);
- foreach (var type in asm.GetTypes())
- {
- var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is AppscapeEntryAttribute) as AppscapeEntryAttribute;
- if (attrib != null)
- {
- var upgrade = new ShiftoriumUpgrade
- {
- Id = attrib.Name.ToLower().Replace(" ", "_"),
- Name = attrib.Name,
- Description = attrib.Description,
- Cost = attrib.Cost,
- Category = attrib.Category,
- Dependencies = (string.IsNullOrWhiteSpace(attrib.DependencyString)) ? "appscape_handled_nodisplay" : "appscape_handled_nodisplay;" + attrib.DependencyString
- };
- defaultList.Add(upgrade);
- }
-
- var sattrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is StpContents) as StpContents;
- if (sattrib != null)
- {
- var upgrade = new ShiftoriumUpgrade
- {
- Id = sattrib.Upgrade,
- Name = sattrib.Name,
- Description = "This is a hidden dummy upgrade for the .stp file installation attribute \"" + sattrib.Name + "\".",
- Cost = 0,
- Category = "If this is shown, there's a bug in the Shiftorium Provider or the user is a supreme Shifter.",
- Dependencies = "dummy_nodisplay"
- };
- defaultList.Add(upgrade);
- }
-
- }
-
-
-
+ Id = attrib.Name.ToLower().Replace(" ", "_"),
+ Name = attrib.Name,
+ Description = attrib.Description,
+ Cost = attrib.Cost,
+ Category = attrib.Category,
+ Dependencies = (string.IsNullOrWhiteSpace(attrib.DependencyString)) ? "appscape_handled_nodisplay" : "appscape_handled_nodisplay;" + attrib.DependencyString
+ };
+ defaultList.Add(upgrade);
+ }
- }
- catch { }
+ var sattrib = attribs.FirstOrDefault(x => x is StpContents) as StpContents;
+ if (sattrib != null)
+ {
+ var upgrade = new ShiftoriumUpgrade
+ {
+ Id = sattrib.Upgrade,
+ Name = sattrib.Name,
+ Description = "This is a hidden dummy upgrade for the .stp file installation attribute \"" + sattrib.Name + "\".",
+ Cost = 0,
+ Category = "If this is shown, there's a bug in the Shiftorium Provider or the user is a supreme Shifter.",
+ Dependencies = "dummy_nodisplay"
+ };
+ defaultList.Add(upgrade);
}
+
}
return defaultList;
}
diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs
index c7830d0..c9b6f64 100644
--- a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs
+++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs
@@ -207,33 +207,21 @@ namespace ShiftOS.WinForms.ShiftnetSites
if (result == true)
{
SaveSystem.CurrentSave.Codepoints -= upg.Cost;
- foreach (var exe in Directory.GetFiles(Environment.CurrentDirectory))
+ foreach (var type in ReflectMan.Types)
{
- if (exe.EndsWith(".exe") || exe.EndsWith(".dll"))
+ var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is AppscapeEntryAttribute) as AppscapeEntryAttribute;
+ if (attrib != null)
{
- try
+ if (attrib.Name == upg.Name)
{
- var asm = Assembly.LoadFile(exe);
- foreach (var type in asm.GetTypes())
- {
- var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is AppscapeEntryAttribute) as AppscapeEntryAttribute;
- if (attrib != null)
- {
- if (attrib.Name == upg.Name)
- {
- var installer = new Applications.Installer();
- var installation = new AppscapeInstallation(upg.Name, attrib.DownloadSize, upg.ID);
- AppearanceManager.SetupWindow(installer);
- installer.InitiateInstall(installation);
- return;
- }
- }
- }
+ var installer = new Applications.Installer();
+ var installation = new AppscapeInstallation(upg.Name, attrib.DownloadSize, upg.ID);
+ AppearanceManager.SetupWindow(installer);
+ installer.InitiateInstall(installation);
+ return;
}
- catch { }
}
}
-
}
});
}
diff --git a/ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs
index 6e692a7..10ba809 100644
--- a/ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs
+++ b/ShiftOS.WinForms/ShiftnetSites/MainHomepage.cs
@@ -39,49 +39,30 @@ namespace ShiftOS.WinForms.ShiftnetSites
{
//Get the Fundamentals List
flfundamentals.Controls.Clear();
- foreach (var exe in Directory.GetFiles(Environment.CurrentDirectory))
+ foreach (var type in Array.FindAll(ReflectMan.Types, t => t.GetInterfaces().Contains(typeof(IShiftnetSite)) && t.BaseType == typeof(UserControl) && Shiftorium.UpgradeAttributesUnlocked(t)))
{
- if (exe.EndsWith(".exe") || exe.EndsWith(".dll"))
+ var attrs = type.GetCustomAttributes(false);
+ var attribute = attrs.FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute;
+ if (attribute != null)
{
- try
+ if (attrs.OfType<ShiftnetFundamentalAttribute>().Any())
{
- var asm = Assembly.LoadFile(exe);
- foreach (var type in asm.GetTypes())
+ var dash = new Label();
+ dash.Text = " - ";
+ dash.AutoSize = true;
+ flfundamentals.Controls.Add(dash);
+ dash.Show();
+ var link = new LinkLabel();
+ link.Text = attribute.Name;
+ link.Click += (o, a) =>
{
- if (type.GetInterfaces().Contains(typeof(IShiftnetSite)))
- {
- if (type.BaseType == typeof(UserControl))
- {
- var attribute = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute;
- if (attribute != null)
- {
- if (Shiftorium.UpgradeAttributesUnlocked(type))
- {
- if (type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetFundamentalAttribute) != null)
- {
- var dash = new Label();
- dash.Text = " - ";
- dash.AutoSize = true;
- flfundamentals.Controls.Add(dash);
- dash.Show();
- var link = new LinkLabel();
- link.Text = attribute.Name;
- link.Click += (o, a) =>
- {
- GoToUrl?.Invoke(attribute.Url);
- };
- flfundamentals.Controls.Add(link);
- flfundamentals.SetFlowBreak(link, true);
- link.Show();
- link.LinkColor = SkinEngine.LoadedSkin.ControlTextColor;
- }
- }
- }
- }
- }
- }
+ GoToUrl?.Invoke(attribute.Url);
+ };
+ flfundamentals.Controls.Add(link);
+ flfundamentals.SetFlowBreak(link, true);
+ link.Show();
+ link.LinkColor = SkinEngine.LoadedSkin.ControlTextColor;
}
- catch { }
}
}
diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs
index 1593117..9b1c3b4 100644
--- a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs
+++ b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs
@@ -34,53 +34,38 @@ namespace ShiftOS.WinForms.ShiftnetSites
public void SetupListing()
{
fllist.Controls.Clear();
- foreach(var exec in Directory.GetFiles(Environment.CurrentDirectory))
+ foreach (var type in Array.FindAll(ReflectMan.Types, t => t.GetInterfaces().Contains(typeof(IShiftnetSite))))
{
- if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll"))
+ var attr = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute;
+ if (attr != null)
{
- try
+ if (attr.Url.StartsWith("shiftnet/"))
{
- var asm = Assembly.LoadFile(exec);
- var types = asm.GetTypes();
- foreach (var type in types)
+ var lnk = new LinkLabel();
+ lnk.LinkColor = SkinEngine.LoadedSkin.ControlTextColor;
+ lnk.Text = attr.Name;
+ var desc = new Label();
+ desc.AutoSize = true;
+ lnk.AutoSize = true;
+ desc.MaximumSize = new Size(this.Width / 3, 0);
+ desc.Text = attr.Description;
+ desc.Padding = new Padding
{
- if (type.GetInterfaces().Contains(typeof(IShiftnetSite)))
- {
- var attr = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute;
- if (attr != null)
- {
- if (attr.Url.StartsWith("shiftnet/"))
- {
- var lnk = new LinkLabel();
- lnk.LinkColor = SkinEngine.LoadedSkin.ControlTextColor;
- lnk.Text = attr.Name;
- var desc = new Label();
- desc.AutoSize = true;
- lnk.AutoSize = true;
- desc.MaximumSize = new Size(this.Width / 3, 0);
- desc.Text = attr.Description;
- desc.Padding = new Padding
- {
- Bottom = 25,
- Top = 0,
- Left = 10,
- Right = 10
- };
- lnk.Click += (o, a) =>
- {
- GoToUrl?.Invoke(attr.Url);
- };
- fllist.Controls.Add(lnk);
- fllist.Controls.Add(desc);
- ControlManager.SetupControls(lnk);
- lnk.Show();
- desc.Show();
- }
- }
- }
- }
+ Bottom = 25,
+ Top = 0,
+ Left = 10,
+ Right = 10
+ };
+ lnk.Click += (o, a) =>
+ {
+ GoToUrl?.Invoke(attr.Url);
+ };
+ fllist.Controls.Add(lnk);
+ fllist.Controls.Add(desc);
+ ControlManager.SetupControls(lnk);
+ lnk.Show();
+ desc.Show();
}
- catch { }
}
}
}
diff --git a/ShiftOS.WinForms/WidgetManager.cs b/ShiftOS.WinForms/WidgetManager.cs
index fec09f9..81a97af 100644
--- a/ShiftOS.WinForms/WidgetManager.cs
+++ b/ShiftOS.WinForms/WidgetManager.cs
@@ -16,36 +16,12 @@ namespace ShiftOS.WinForms
{
public static Dictionary<DesktopWidgetAttribute, Type> GetAllWidgetTypes()
{
- Dictionary<DesktopWidgetAttribute, Type> types = new Dictionary<WinForms.DesktopWidgetAttribute, Type>();
- foreach(var exe in System.IO.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;
+ var ret = new Dictionary<DesktopWidgetAttribute, Type>();
+ var types = Array.FindAll(ReflectMan.Types, t => t.GetInterfaces().Contains(typeof(IDesktopWidget)) && Shiftorium.UpgradeAttributesUnlocked(t));
+ foreach (var type in types)
+ foreach (var attrib in Array.FindAll(type.GetCustomAttributes(false), a => a is DesktopWidgetAttribute))
+ ret.Add(attrib as DesktopWidgetAttribute, type);
+ return ret;
}
internal static void SaveDetails(Type type, WidgetDetails location)