Пример #1
0
 /// <summary>
 /// Windows the border load.
 /// </summary>
 /// <returns>The border load.</returns>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void WindowBorder_Load(object sender, EventArgs e)
 {
     this.DoubleBuffered = true;
     this.Left           = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2;
     this.Top            = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2;
     ParentWindow.OnLoad();
     ParentWindow.OnSkinLoad();
     ParentWindow.OnUpgrade();
 }
Пример #2
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);
            form.OnLoad();
            form.OnSkinLoad();
            form.OnUpgrade();
        }
Пример #3
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();
            form.OnLoad();
            form.OnSkinLoad();
            form.OnUpgrade();
        }