diff options
Diffstat (limited to 'ShiftOS.WinForms')
| -rw-r--r-- | ShiftOS.WinForms/Applications/Terminal.cs | 9 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Resources/Shiftorium.txt | 6 | ||||
| -rw-r--r-- | ShiftOS.WinForms/WindowBorder.cs | 46 | ||||
| -rw-r--r-- | ShiftOS.WinForms/WinformsDesktop.cs | 93 |
4 files changed, 123 insertions, 31 deletions
diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 7b55ec2..54a89d7 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -134,10 +134,13 @@ namespace ShiftOS.WinForms.Applications TerminalBackend.PrefixEnabled = true; TerminalBackend.InStory = false; Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - if (SaveSystem.CurrentSave.StoryPosition == 6) + if (Shiftorium.UpgradeInstalled("wm_free_placement")) { - Infobox.Show("Welcome to ShiftOS.", "Welcome to the ShiftOS multi-user domain. Your goal is to upgrade your system as much as possible, and gain as much wealth as possible. The first step is to get a feel for the environment. Go forth and explore, young Shifter."); - SaveSystem.CurrentSave.StoryPosition++; + this.ParentForm.Width = 640; + this.ParentForm.Height = 480; + this.ParentForm.Left = (Screen.PrimaryScreen.Bounds.Width - 640) / 2; + this.ParentForm.Top = (Screen.PrimaryScreen.Bounds.Height - 480) / 2; + } })); } diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 7d4d7b7..1aff2db 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -217,6 +217,12 @@ Name: "Minimize Command", Cost: 1250, Description: "Use the win.mini{id} command to minimize/restore windows.", + Dependencies: "useful_panel_buttons" + }, + { + Name: "Useful Panel Buttons", + Cost: 250, + Description: "Minimize and restore windows by clicking their Panel Button!", Dependencies: "desktop" }, { diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index bb9b478..46dd76a 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -354,21 +354,49 @@ namespace ShiftOS.WinForms /// <param name="e">E.</param> private void pnlmaximize_Click(object sender, EventArgs e) { - TerminalBackend.InvokeCommand($"win.max{{id:{this.ParentForm.GetHashCode()}}}"); + if (maximized == false) + Desktop.MaximizeWindow(this); + else + Desktop.RestoreWindow(this); + maximized = !maximized; } - /// <summary> - /// Pnlminimizes the click. - /// </summary> - /// <returns>The click.</returns> - /// <param name="sender">Sender.</param> - /// <param name="e">E.</param> + bool minimized = false; + bool maximized = false; + + public bool IsMinimized + { + get + { + return minimized; + } + } + + public bool IsMaximized + { + get + { + return maximized; + } + } + + + /// <summary> + /// Pnlminimizes the click. + /// </summary> + /// <returns>The click.</returns> + /// <param name="sender">Sender.</param> + /// <param name="e">E.</param> private void pnlminimize_Click(object sender, EventArgs e) { - TerminalBackend.InvokeCommand($"win.mini{{id:{this.ParentForm.GetHashCode()}}}"); + if (minimized == false) + Desktop.MinimizeWindow(this); + else + Desktop.RestoreWindow(this); + minimized = !minimized; } - + /// <summary> /// The W m NCLBUTTONDOW. /// </summary> diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 9490850..c45feee 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -35,6 +35,7 @@ using ShiftOS.Engine; using static ShiftOS.Engine.SkinEngine; using ShiftOS.WinForms.Tools; using ShiftOS.WinForms.Applications; +using Newtonsoft.Json; /// <summary> /// Winforms desktop. @@ -125,6 +126,26 @@ namespace ShiftOS.WinForms { if (form.Visible == true) { + EventHandler onClick = (o, a) => + { + if(form == focused) + { + if (form.IsMinimized) + { + RestoreWindow(form); + } + else + { + MinimizeWindow(form); + } + } + else + { + form.BringToFront(); + focused = form; + } + }; + var pnlbtn = new Panel(); pnlbtn.Margin = new Padding(2, LoadedSkin.PanelButtonFromTop, 0, 0); pnlbtn.BackColor = LoadedSkin.PanelButtonColor; @@ -151,6 +172,12 @@ namespace ShiftOS.WinForms this.panelbuttonholder.Controls.Add(pnlbtn); pnlbtn.Show(); pnlbtntext.Show(); + + if (Shiftorium.UpgradeInstalled("useful_panel_buttons")) + { + pnlbtn.Click += onClick; + pnlbtntext.Click += onClick; + } } } } @@ -342,6 +369,11 @@ namespace ShiftOS.WinForms public void ShowWindow(IWindowBorder border) { var brdr = border as Form; + focused = border; + brdr.GotFocus += (o, a) => + { + focused = border; + }; brdr.FormBorderStyle = FormBorderStyle.None; brdr.Show(); brdr.TopMost = true; @@ -354,17 +386,26 @@ namespace ShiftOS.WinForms /// <param name="border">Border.</param> public void KillWindow(IWindowBorder border) { - throw new NotImplementedException(); + border.Close(); } - /// <summary> - /// Minimizes the window. - /// </summary> - /// <returns>The window.</returns> - /// <param name="brdr">Brdr.</param> + private IWindowBorder focused = null; + + + /// <summary> + /// Minimizes the window. + /// </summary> + /// <param name="brdr">Brdr.</param> public void MinimizeWindow(IWindowBorder brdr) { - throw new NotImplementedException(); + var loc = (brdr as WindowBorder).Location; + var sz = (brdr as WindowBorder).Size; + (brdr as WindowBorder).Tag = JsonConvert.SerializeObject(new + { + Size = sz, + Location = loc + }); + (brdr as WindowBorder).Location = new Point(this.GetSize().Width * 2, this.GetSize().Height * 2); } /// <summary> @@ -374,24 +415,38 @@ namespace ShiftOS.WinForms /// <param name="brdr">Brdr.</param> public void MaximizeWindow(IWindowBorder brdr) { - throw new NotImplementedException(); + int startY = (LoadedSkin.DesktopPanelPosition == 1) ? 0 : LoadedSkin.DesktopPanelHeight; + int h = this.GetSize().Height - LoadedSkin.DesktopPanelHeight; + var loc = (brdr as WindowBorder).Location; + var sz = (brdr as WindowBorder).Size; + (brdr as WindowBorder).Tag = JsonConvert.SerializeObject(new + { + Size = sz, + Location = loc + }); + (brdr as WindowBorder).Location = new Point(0, startY); + (brdr as WindowBorder).Size = new Size(this.GetSize().Width, h); + } - /// <summary> - /// Restores the window. - /// </summary> - /// <returns>The window.</returns> - /// <param name="brdr">Brdr.</param> + /// <summary> + /// Restores the window. + /// </summary> + /// <returns>The window.</returns> + /// <param name="brdr">Brdr.</param> public void RestoreWindow(IWindowBorder brdr) { - throw new NotImplementedException(); + dynamic tag = JsonConvert.DeserializeObject<dynamic>((brdr as WindowBorder).Tag.ToString()); + (brdr as WindowBorder).Location = tag.Location; + (brdr as WindowBorder).Size = tag.Size; + } - /// <summary> - /// Invokes the on worker thread. - /// </summary> - /// <returns>The on worker thread.</returns> - /// <param name="act">Act.</param> + /// <summary> + /// Invokes the on worker thread. + /// </summary> + /// <returns>The on worker thread.</returns> + /// <param name="act">Act.</param> public void InvokeOnWorkerThread(Action act) { this.Invoke(act); |
