public override void SetupDialog(IShiftOSWindow form) { if (!Shiftorium.UpgradeAttributesUnlocked(form.GetType())) { Console.WriteLine("{APP_NOT_FOUND}"); return; } var wb = new WindowBorder(form as UserControl); wb.IsDialog = true; Desktop.ShowWindow(wb); }
public void SetupUI() { flnames.Controls.Clear(); foreach (var type in ReflectMan.Types.Where(x => Shiftorium.UpgradeAttributesUnlocked(x) && x.GetInterfaces().Contains(typeof(IShiftOSWindow)))) { var title = type.GetCustomAttributes(false).FirstOrDefault(x => x is DefaultTitleAttribute) as DefaultTitleAttribute; if (title != null) { var lbl = new Label(); lbl.AutoSize = true; lbl.Text = Localization.Parse(title.Title); lbl.Tag = "header3"; ControlManager.SetupControl(lbl); flnames.Controls.Add(lbl); lbl.Show(); flnames.SetFlowBreak(lbl, true); var txt = new TextBox(); ControlManager.SetupControl(txt); if (!names.ContainsKey(type.Name)) { names.Add(type.Name, title.Title); } txt.Text = Localization.Parse(names[type.Name]); txt.TextChanged += (o, a) => { if (txt.Text == Localization.Parse(title.Title)) { names[type.Name] = title.Title; } else { names[type.Name] = txt.Text; } }; flnames.Controls.Add(txt); txt.Show(); txt.Width = flnames.Width - 10; flnames.SetFlowBreak(txt, true); } } }
public static List <MissionAttribute> GetMissionsList() { var missions = new List <MissionAttribute>(); foreach (var type in ReflectMan.Types) { foreach (var method in type.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) { var attrib = method.GetCustomAttributes(false).FirstOrDefault(x => x is MissionAttribute) as MissionAttribute; if (attrib != null) { if (Shiftorium.UpgradeAttributesUnlocked(method)) { if (!Shiftorium.UpgradeInstalled(attrib.StoryID)) { missions.Add(attrib); } } } } } return(missions); }
public void NavigateToUrl(string url) { txturl.Text = url; try { foreach (var type in Array.FindAll(ReflectMan.Types, t => t.GetInterfaces().Contains(typeof(IShiftnetSite)) && t.BaseType == typeof(UserControl) && Shiftorium.UpgradeAttributesUnlocked(t))) { var attribute = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute && (x as ShiftnetSiteAttribute).Url == url) as ShiftnetSiteAttribute; if (attribute != null) { 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; } pnlcanvas.Controls.Clear(); var lbl = new Label(); lbl.Text = "Page not found!"; lbl.Tag = "header1"; lbl.AutoSize = true; lbl.Location = new Point(10, 10); pnlcanvas.Controls.Add(lbl); lbl.Show(); }
public override void SetupWindow(IShiftOSWindow form) { foreach (var attr in form.GetType().GetCustomAttributes(true)) { if (attr is MultiplayerOnlyAttribute) { if (KernelWatchdog.MudConnected == false) { Infobox.PromptYesNo("Disconnected from MUD", "This application requires a connection to the MUD. Would you like to reconnect?", new Action <bool>((answer) => { if (answer == true) { KernelWatchdog.MudConnected = true; SetupWindow(form); } })); return; } } } if (!Shiftorium.UpgradeAttributesUnlocked(form.GetType())) { Console.WriteLine("{APP_NOT_FOUND}"); return; } if (SaveSystem.CurrentSave != null) { if (!form.GetType().Name.Contains(typeof(Applications.Dialog).Name)) { int maxWindows = 0; //Window manager will step in here. if (Shiftorium.UpgradeInstalled("wm_unlimited_windows")) { maxWindows = 0; } else if (Shiftorium.UpgradeInstalled("wm_4_windows")) { maxWindows = 4; } else if (Shiftorium.UpgradeInstalled("window_manager")) { maxWindows = 2; } else { maxWindows = 1; } if (maxWindows > 0) { var windows = new List <WindowBorder>(); foreach (var WB in AppearanceManager.OpenForms) { if (WB is WindowBorder) { windows.Add(WB as WindowBorder); } } List <WindowBorder> formstoclose = new List <WindowBorder>(windows.Where(x => x.IsDialog == false).ToArray()); while (formstoclose.Count > maxWindows - 1) { this.Close(formstoclose[0].ParentWindow); AppearanceManager.OpenForms.Remove(formstoclose[0]); formstoclose.RemoveAt(0); } } } } var wb = new WindowBorder(form as UserControl); FormClosedEventHandler onClose = (o, a) => { }; onClose = (o, a) => { SetupWindows(); wb.FormClosed -= onClose; }; wb.FormClosed += onClose; Desktop.ShowWindow(wb); SetupWindows(); }
public VirusAttribute GetVirusInformation(string id) { foreach (var type in ReflectMan.Types.Where(x => x.GetInterfaces().Contains(typeof(IVirus)) && Shiftorium.UpgradeAttributesUnlocked(x))) { var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is VirusAttribute) as VirusAttribute; if (attrib != null) { if (attrib.ID == id) { return(attrib); } } } return(null); }
public void SetupUI() { flbody.Controls.Clear(); //Clear the icon list. Type[] types = Array.FindAll(ReflectMan.Types, x => x.GetCustomAttributes(false).FirstOrDefault(y => y is DefaultIconAttribute) != null); pageCount = types.GetPageCount(pageSize); foreach (var type in Array.FindAll(types.GetItemsOnPage(currentPage, pageSize), t => Shiftorium.UpgradeAttributesUnlocked(t))) { 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) => { pic.Image = img; SetIcon(type.Name, raw); }); AppearanceManager.SetupDialog(gfp); }; btn.Show(); ControlManager.SetupControls(pnl); } btnnext.Visible = (currentPage < pageCount - 1); btnprev.Visible = (currentPage > 0); lbcurrentpage.Text = "Page " + (currentPage + 1).ToString() + " of " + pageCount.ToString(); }
public static Dictionary <DesktopWidgetAttribute, Type> GetAllWidgetTypes() { 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); }
public override void SetupWindow(IShiftOSWindow form) { if (!AppearanceManager.CanOpenWindow(form)) { Infobox.Show("{MULTIPLAYER_ONLY}", "{MULTIPLAYER_ONLY_EXP}"); return; } if (!Shiftorium.UpgradeAttributesUnlocked(form.GetType())) { Console.WriteLine("{APP_NOT_FOUND}"); return; } if (SaveSystem.CurrentSave != null) { if (!form.GetType().Name.Contains(typeof(Applications.Dialog).Name)) { int maxWindows = 0; //Window manager will step in here. if (Shiftorium.UpgradeInstalled("wm_unlimited_windows")) { maxWindows = 0; } else if (Shiftorium.UpgradeInstalled("wm_4_windows")) { maxWindows = 4; } else if (Shiftorium.UpgradeInstalled("window_manager")) { maxWindows = 2; } else { maxWindows = 1; } if (maxWindows > 0) { List <WindowBorder> formstoclose = new List <WindowBorder>(); foreach (WindowBorder frm in AppearanceManager.OpenForms) { formstoclose.Add(frm); } while (formstoclose.Count > maxWindows - 1) { formstoclose[0].Close(); formstoclose.RemoveAt(0); } } } } var wb = new WindowBorder(form as UserControl); ControlManager.SetupWindows(); }
public void Setup() { //Get the Fundamentals List flfundamentals.Controls.Clear(); foreach (var type in Array.FindAll(ReflectMan.Types, t => t.GetInterfaces().Contains(typeof(IShiftnetSite)) && t.BaseType == typeof(UserControl) && Shiftorium.UpgradeAttributesUnlocked(t))) { var attrs = type.GetCustomAttributes(false); var attribute = attrs.FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute; if (attribute != null) { if (attrs.OfType <ShiftnetFundamentalAttribute>().Any()) { 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; } } } }