Esempio n. 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);
            form.OnLoad();
            form.OnSkinLoad();
            form.OnUpgrade();
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShiftOS.WinForms.WindowBorder"/> class.
        /// </summary>
        /// <param name="win">Window.</param>
        public WindowBorder(UserControl win)
        {
            InitializeComponent();
            IsFocused       = true;
            this.Activated += (o, a) =>
            {
                IsFocused = true;
                SetupSkin();
            };
            this.Deactivate += (o, a) =>
            {
                IsFocused = false;
                SetupSkin();
            };
            this._parentWindow    = win;
            Shiftorium.Installed += () =>
            {
                try
                {
                    this.ParentForm.Invoke(new Action(() =>
                    {
                        Setup();
                    }));
                }
                catch { }
            };
            SkinEngine.SkinLoaded += () =>
            {
                try
                {
                    Setup();
                    (ParentWindow as IShiftOSWindow).OnSkinLoad();
                    ControlManager.SetupControls(this.pnlcontents);
                }
                catch
                {
                }
            };

            this.Width  = (LoadedSkin.LeftBorderWidth * 2) + _parentWindow.Width + LoadedSkin.RightBorderWidth;
            this.Height = (LoadedSkin.TitlebarHeight * 2) + _parentWindow.Height + LoadedSkin.BottomBorderWidth;

            this.pnlcontents.Controls.Add(this._parentWindow);
            this._parentWindow.Dock = DockStyle.Fill;
            this._parentWindow.Show();
            SetupControls(this);
            ControlManager.SetupControls(this._parentWindow);

            Shiftorium.Installed += () =>
            {
                Setup();
                ParentWindow.OnUpgrade();
            };
            Setup();
            this._parentWindow.TextChanged += (o, a) =>
            {
                Setup();
                Desktop.ResetPanelButtons();
            };


            if (!this.IsDialog)
            {
                Engine.AppearanceManager.OpenForms.Add(this);
            }

            SaveSystem.GameReady += () =>
            {
                if (Shiftorium.UpgradeInstalled("wm_free_placement"))
                {
                    AppearanceManager.Invoke(new Action(() =>
                    {
                        this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2;
                        this.Top  = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2;
                    }));
                }
                AppearanceManager.Invoke(new Action(() =>
                {
                    Setup();
                }));
            };
        }
Esempio n. 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();
        }