示例#1
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);
        }
示例#2
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();
        }
        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();
        }