Beispiel #1
0
        public override void SetupDialog(IShiftOSWindow win)
        {
            var brdr = new WpfWindowBorder(win);

            brdr.IsDialog = true;
            AppearanceManager.OpenForms.Add(brdr);
        }
Beispiel #2
0
 // Sets the title text of the specified window.
 public static void SetWindowTitle(IShiftOSWindow window, string title)
 {
     if (window == null)
     {
         throw new ArgumentNullException("window", "The window cannot be null.");
     }
     winmgr.SetTitle(window, title);
 }
Beispiel #3
0
 public static void SetTitle(this IShiftOSWindow win, string title)
 {
     foreach (var frm in AppearanceManager.OpenForms)
     {
         if (frm.ParentWindow == win)
         {
             frm.Text = title;
         }
     }
 }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 // Decorates a window with a border, then shows the window, as a dialog box.
 public static void SetupDialog(IShiftOSWindow form)
 {
     if (form == null)
     {
         //NULLLLLLLLL
         throw new ArgumentNullException("form");
     }
     if (winmgr == null)
     {
         //ASGDFHASDGF
         throw new EngineModuleDisabledException();
     }
     winmgr.SetupDialog(form);
     Desktop.ResetPanelButtons();
 }
Beispiel #6
0
 // Closes the specified window. SHOCKED YOU ARE I KNOW, HOW COULD YOU HAVE GUESSED
 public static void Close(IShiftOSWindow win)
 {
     if (win == null)
     {
         //NOPE SHOULDNT BE NULL
         throw new ArgumentNullException("win");
     }
     if (winmgr == null)
     {
         //WHY IS THIS NULL
         throw new EngineModuleDisabledException();
     }
     winmgr.Close(win);
     Desktop.ResetPanelButtons();
 }
Beispiel #7
0
 // Decorates a window with a border, then shows the window.
 public static void SetupWindow(IShiftOSWindow form)
 {
     if (form == null)
     {
         //YOU GET THE POINT THIS REALLY SHOULDNT BE NULL
         throw new ArgumentNullException("form");
     }
     if (winmgr == null)
     {
         //SAME HERE
         throw new EngineModuleDisabledException();
     }
     winmgr.SetupWindow(form);
     Desktop.ResetPanelButtons();
 }
Beispiel #8
0
        public static bool CanOpenWindow(IShiftOSWindow form)
        {
#if !MUD_RAPIDDEV
            if (ServerManager.IsSingleplayer)
            {
                foreach (var attr in form.GetType().GetCustomAttributes(false))
                {
                    if (attr is MultiplayerOnlyAttribute)
                    {
                        return(false);
                    }
                }
            }
#endif
            return(true);
        }
        public void SetupAdvancedCategory(string cat)
        {
            flapps.Controls.Clear();

            foreach (var app in LauncherItemList[cat])
            {
                var catbtn = new Button();
                catbtn.Font      = LoadedSkin.AdvALItemFont;
                catbtn.FlatStyle = FlatStyle.Flat;
                catbtn.FlatAppearance.BorderSize         = 0;
                catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected;
                catbtn.FlatAppearance.MouseDownBackColor = LoadedSkin.Menu_MenuItemPressedGradientBegin;
                catbtn.BackColor   = LoadedSkin.Menu_ToolStripDropDownBackground;
                catbtn.ForeColor   = LoadedSkin.Menu_TextColor;
                catbtn.MouseEnter += (o, a) =>
                {
                    catbtn.ForeColor = LoadedSkin.Menu_SelectedTextColor;
                };
                catbtn.MouseLeave += (o, a) =>
                {
                    catbtn.ForeColor = LoadedSkin.Menu_TextColor;
                };
                catbtn.TextAlign  = ContentAlignment.MiddleLeft;
                catbtn.Text       = (app is LuaLauncherItem) ? app.DisplayData.Name : NameChangerBackend.GetNameRaw(app.LaunchType);
                catbtn.Width      = flapps.Width;
                catbtn.ImageAlign = ContentAlignment.MiddleRight;
                catbtn.Height     = 24;
                catbtn.Image      = (app.LaunchType == null) ? null : SkinEngine.GetIcon(app.LaunchType.Name);

                flapps.Controls.Add(catbtn);
                catbtn.Show();
                catbtn.Click += (o, a) =>
                {
                    pnladvancedal.Hide();
                    if (app is LuaLauncherItem)
                    {
                        var interp = new LuaInterpreter();
                        interp.ExecuteFile((app as LuaLauncherItem).LaunchPath);
                    }
                    else
                    {
                        IShiftOSWindow win = Activator.CreateInstance(app.LaunchType) as IShiftOSWindow;
                        AppearanceManager.SetupWindow(win);
                    }
                };
            }
        }
Beispiel #10
0
        public override void Close(IShiftOSWindow win)
        {
            IWindowBorder brdrToClose = null;

            foreach (WpfWindowBorder brdr in AppearanceManager.OpenForms)
            {
                if (brdr.ParentWindow == win)
                {
                    brdrToClose = brdr;
                }
            }

            if (brdrToClose != null)
            {
                brdrToClose.Close();
                AppearanceManager.OpenForms.Remove(brdrToClose);
            }
        }
Beispiel #11
0
 public static string GetName(IShiftOSWindow win)
 {
     return(GetNameRaw(win.GetType()));
 }
        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();
        }
Beispiel #13
0
 public abstract void SetupDialog(IShiftOSWindow win);
Beispiel #14
0
 public abstract void SetupWindow(IShiftOSWindow win);
Beispiel #15
0
 public override void Close(IShiftOSWindow win)
 {
     (win as UserControl).Close();
 }
Beispiel #16
0
 public abstract void Maximize(IWindowBorder border);             // ooh this too
 public abstract void Close(IShiftOSWindow win);                  // omg this probably does something
Beispiel #17
0
 public abstract void Close(IShiftOSWindow win);                  // omg this probably does something
 public abstract void SetupWindow(IShiftOSWindow win);            // i cant think of what this does
Beispiel #18
0
 public abstract void SetupWindow(IShiftOSWindow win);            // i cant think of what this does
 public abstract void SetupDialog(IShiftOSWindow win);            // how about this???????
Beispiel #19
0
 public abstract void InvokeAction(Action act);                   // i wonder what this invokes
 public abstract void SetTitle(IShiftOSWindow win, string title); // what is a title again
Beispiel #20
0
        public override void SetupWindow(IShiftOSWindow win)
        {
            var brdr = new WpfWindowBorder(win);

            AppearanceManager.OpenForms.Add(brdr);
        }
Beispiel #21
0
 public static void Close(IShiftOSWindow win)
 {
     winmgr.Close(win);
     Desktop.ResetPanelButtons();
 }
Beispiel #22
0
        public override void SetTitle(IShiftOSWindow win, string title)
        {
            var wb = (win as UserControl).ParentForm as WindowBorder;

            wb.SetTitle(title);
        }
Beispiel #23
0
 public static void SetupDialog(IShiftOSWindow form)
 {
     winmgr.SetupDialog(form);
     Desktop.ResetPanelButtons();
 }
Beispiel #24
0
        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();
        }
Beispiel #25
0
 public abstract void Close(IShiftOSWindow win);
Beispiel #26
0
        public static bool Open(Dictionary <string, object> args)
        {
            try
            {
                if (args.ContainsKey("app"))
                {
                    var app = args["app"] as string;
                    //ANNND now we start reflecting...
                    foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory))
                    {
                        if (asmExec.EndsWith(".exe") || asmExec.EndsWith(".dll"))
                        {
                            var asm = Assembly.LoadFile(asmExec);

                            foreach (var type in asm.GetTypes())
                            {
                                if (type.BaseType == typeof(UserControl))
                                {
                                    foreach (var attr in type.GetCustomAttributes(false))
                                    {
                                        if (attr is WinOpenAttribute)
                                        {
                                            if (app == (attr as WinOpenAttribute).ID)
                                            {
                                                if (SaveSystem.CurrentSave.Upgrades.ContainsKey(app))
                                                {
                                                    if (Shiftorium.UpgradeInstalled(app))
                                                    {
                                                        IShiftOSWindow frm = Activator.CreateInstance(type) as IShiftOSWindow;
                                                        AppearanceManager.SetupWindow(frm);
                                                        return(true);
                                                    }
                                                    else
                                                    {
                                                        throw new Exception($"{app} was not found on your system! Try looking in the shiftorium...");
                                                    }
                                                }
                                                else
                                                {
                                                    IShiftOSWindow frm = Activator.CreateInstance(type) as IShiftOSWindow;
                                                    AppearanceManager.SetupWindow(frm);
                                                    return(true);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Please specify a valid 'app' param.");
                    return(true);
                }
                Console.WriteLine("Couldn't find the specified app on your system.");
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error running script:" + ex);
                return(false);
            }
        }
Beispiel #27
0
        public WpfWindowBorder(IShiftOSWindow ctrl)
        {
            InitializeComponent();
            if (ctrl is UserControl)
            {
                _parent = ctrl as UserControl;
                _isWPF  = true;
            }
            else if (ctrl is System.Windows.Forms.UserControl)
            {
                _isWPF   = false;
                _wParent = ctrl as System.Windows.Forms.UserControl;
                _wParent.Show();
            }
            Shiftorium.Installed += () =>
            {
                SetupUpgradeables();
                ParentWindow.OnUpgrade();
            };
            SkinEngine.SkinLoaded += () =>
            {
                SetupSkin();
                ParentWindow.OnSkinLoad();
            };
            SaveSystem.GameReady += () =>
            {
                Dispatcher.Invoke(() =>
                {
                    SetupUpgradeables();
                    SetupSkin();
                });
            };
            if (_isWPF)
            {
                this.Width         = borderleft.Width + _parent.Width + borderright.Width;
                this.Height        = titlemaster.Height + _parent.Height + borderbottom.Height;
                pgcontents.Content = _parent;
            }
            else
            {
                pgcontents.Width  = _wParent.Width;
                pgcontents.Height = _wParent.Height;

                this.Width         = borderleft.Width + _wParent.Width + borderright.Width;
                this.Height        = titlemaster.Height + _wParent.Height + borderbottom.Height;
                pgcontents.Content = new WindowsFormsHost();
                (pgcontents.Content as WindowsFormsHost).Child = _wParent;
                _wParent.DoWinformsSkinningMagicOnWpf();
            }
            Desktop.ShowWindow(this);
            SetupUpgradeables();
            Loaded += (o, a) =>
            {
                SetupSkin();
                ParentWindow.OnSkinLoad();
                ParentWindow.OnLoad();
            };

            if (!_isWPF)
            {
                _wParent.TextChanged += (o, a) =>
                {
                    this.Text = _wParent.Text;
                };
                this.Text = _wParent.Text;
            }
        }