diff options
| author | Michael <[email protected]> | 2017-04-03 18:36:13 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-04-03 18:36:13 -0400 |
| commit | f43f6fe17d054f83c686b552201d6b4bfc83524d (patch) | |
| tree | b66ca011496569fc99df3fbe53bfc5d212557bab /ShiftOS.WinForms/Tools/ControlManager.cs | |
| parent | 29a88a5c46dff19358b44defdc52bb75db12b9ad (diff) | |
| download | shiftos_thereturn-f43f6fe17d054f83c686b552201d6b4bfc83524d.tar.gz shiftos_thereturn-f43f6fe17d054f83c686b552201d6b4bfc83524d.tar.bz2 shiftos_thereturn-f43f6fe17d054f83c686b552201d6b4bfc83524d.zip | |
LOADS of optimizations and Pong fixes.
Diffstat (limited to 'ShiftOS.WinForms/Tools/ControlManager.cs')
| -rw-r--r-- | ShiftOS.WinForms/Tools/ControlManager.cs | 107 |
1 files changed, 15 insertions, 92 deletions
diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 52663d7..a2a76b7 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -67,91 +67,6 @@ namespace ShiftOS.WinForms.Tools } - public static void SetupWindows() - { - if (SaveSystem.CurrentSave != null) - { - int screen_height_start = 0; - if (Shiftorium.UpgradeInstalled("wm_free_placement")) - { - } - else if (Shiftorium.UpgradeInstalled("wm_4_windows")) - { - int screen_width_half = Screen.PrimaryScreen.Bounds.Width / 2; - int screen_height_half = (Screen.PrimaryScreen.Bounds.Height - screen_height_start) / 2; - - for (int i = 0; i < OpenForms.Count; i++) - { - var frm = OpenForms[i] as WindowBorder; - - switch (i) - { - case 0: - frm.Location = new System.Drawing.Point(0, screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 1) ? screen_width_half : screen_width_half * 2, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - - break; - case 1: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - break; - case 2: - frm.Location = new System.Drawing.Point(0, screen_height_half + screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 3) ? screen_width_half : screen_width_half * 2, screen_height_half); - break; - case 3: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_half + screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - break; - } - } - - } - else if (Shiftorium.UpgradeInstalled("window_manager")) - { - int screen_width_half = Screen.PrimaryScreen.Bounds.Width / 2; - int screen_height = (Screen.PrimaryScreen.Bounds.Height) - screen_height_start; - - - - for (int i = 0; i < OpenForms.Count; i++) - { - - - var frm = OpenForms[i] as WindowBorder; - switch (i) - { - case 0: - frm.Location = new System.Drawing.Point(0, screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 1) ? screen_width_half : screen_width_half * 2, screen_height); - break; - case 1: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, screen_height); - break; - } - OpenForms[i] = frm; - } - } - else - { - var frm = OpenForms[0] as WindowBorder; - frm.Location = new Point(0, 0); - frm.Size = Desktop.Size; - OpenForms[0] = frm; - - } - } - else - { - var frm = OpenForms[0] as WindowBorder; - frm.Location = new Point(0, 0); - frm.Size = Desktop.Size; - OpenForms[0] = frm; - - } - } - internal static Color ConvertColor(ConsoleColor cCol) { switch (cCol) @@ -214,9 +129,22 @@ namespace ShiftOS.WinForms.Tools #endif } + /// <summary> + /// Centers the control along its parent. + /// </summary> + /// <param name="ctrl">The control to center (this is an extension method - you can call it on a control as though it was a method in that control)</param> + public static void CenterParent(this Control ctrl) + { + ctrl.Location = new Point( + (ctrl.Parent.Width - ctrl.Width) / 2, + (ctrl.Parent.Height - ctrl.Height) / 2 + ); + } + public static void SetupControl(Control ctrl) { SuspendDrawing(ctrl); + ctrl.SuspendLayout(); SetCursor(ctrl); if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { @@ -270,13 +198,7 @@ namespace ShiftOS.WinForms.Tools a.SuppressKeyPress = true; - if (SaveSystem.CurrentSave != null) - { - if (Shiftorium.UpgradeInstalled("window_manager")) - { - Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); - } - } + Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); } ShiftOS.Engine.Scripting.LuaInterpreter.RaiseEvent("on_key_down", a); @@ -293,6 +215,7 @@ namespace ShiftOS.WinForms.Tools } MakeDoubleBuffered(ctrl); + ctrl.ResumeLayout(); ResumeDrawing(ctrl); } |
