aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications/Shiftnet.cs
diff options
context:
space:
mode:
authorwilliam341 <[email protected]>2017-06-18 16:43:30 -0700
committerGitHub <[email protected]>2017-06-18 16:43:30 -0700
commitba80dcf3f80018cbb041b62ad8a40268427d1311 (patch)
treef0bd18b2355d34c07c744c3cd82a4725a799eecd /ShiftOS.WinForms/Applications/Shiftnet.cs
parent771c20cfb3a703e0f1550fdcf9eb07b78298c944 (diff)
parent12acff8742f4c64976bfabee1b70dc515190fc7c (diff)
downloadshiftos_thereturn-ba80dcf3f80018cbb041b62ad8a40268427d1311.tar.gz
shiftos_thereturn-ba80dcf3f80018cbb041b62ad8a40268427d1311.tar.bz2
shiftos_thereturn-ba80dcf3f80018cbb041b62ad8a40268427d1311.zip
Merge pull request #2 from shiftos-game/master
wew
Diffstat (limited to 'ShiftOS.WinForms/Applications/Shiftnet.cs')
-rw-r--r--ShiftOS.WinForms/Applications/Shiftnet.cs114
1 files changed, 49 insertions, 65 deletions
diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs
index 7f5d3c1..136f680 100644
--- a/ShiftOS.WinForms/Applications/Shiftnet.cs
+++ b/ShiftOS.WinForms/Applications/Shiftnet.cs
@@ -80,6 +80,7 @@ namespace ShiftOS.WinForms.Applications
txturl.Location = new Point(btnforward.Left + btnforward.Width + 2, 2);
txturl.Width = flcontrols.Width - btnback.Width - 2 - btnforward.Width - 2 - (btngo.Width*2) - 2;
btngo.Location = new Point(flcontrols.Width - btngo.Width - 2, 2);
+ flcontrols.BackColor = SkinEngine.LoadedSkin.TitleBackgroundColor;
}
public bool OnUnload()
@@ -147,79 +148,62 @@ namespace ShiftOS.WinForms.Applications
public void NavigateToUrl(string url)
{
+
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(u);
- 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();
- 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!";