diff --git a/CreamInstaller/Forms/DebugForm.Designer.cs b/CreamInstaller/Forms/DebugForm.Designer.cs index 23c6e30..43911cf 100644 --- a/CreamInstaller/Forms/DebugForm.Designer.cs +++ b/CreamInstaller/Forms/DebugForm.Designer.cs @@ -66,16 +66,16 @@ partial class DebugForm AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new System.Drawing.Size(560, 337); - ControlBox = false; + ControlBox = true; Controls.Add(testGameButton); Controls.Add(debugTextBox); - FormBorderStyle = FormBorderStyle.FixedSingle; - MaximizeBox = false; - MinimizeBox = false; + FormBorderStyle = FormBorderStyle.Sizable; + MaximizeBox = true; + MinimizeBox = true; Name = "DebugForm"; Padding = new Padding(10); - ShowIcon = false; - ShowInTaskbar = false; + ShowIcon = true; + ShowInTaskbar = true; StartPosition = FormStartPosition.Manual; Text = "Debug"; ResumeLayout(false); diff --git a/CreamInstaller/Forms/DebugForm.cs b/CreamInstaller/Forms/DebugForm.cs index 60b4e76..19b6f45 100644 --- a/CreamInstaller/Forms/DebugForm.cs +++ b/CreamInstaller/Forms/DebugForm.cs @@ -13,8 +13,6 @@ internal sealed partial class DebugForm : CustomForm internal static bool IsOpen { get; private set; } - private Form attachedForm; - private DebugForm() { InitializeComponent(); @@ -36,35 +34,8 @@ internal sealed partial class DebugForm : CustomForm } } - protected override void WndProc(ref Message message) // make form immovable by user + internal void Open(Form owner = null) { - if (message.Msg == 0x0112) // WM_SYSCOMMAND - { - int command = message.WParam.ToInt32() & 0xFFF0; - if (command == 0xF010) // SC_MOVE - return; - } - - base.WndProc(ref message); - } - - internal void Attach(Form form) - { - if (attachedForm is not null) - { - attachedForm.Activated -= OnChange; - attachedForm.LocationChanged -= OnChange; - attachedForm.SizeChanged -= OnChange; - attachedForm.VisibleChanged -= OnChange; - } - - attachedForm = form; - attachedForm.Activated += OnChange; - attachedForm.LocationChanged += OnChange; - attachedForm.SizeChanged += OnChange; - attachedForm.VisibleChanged += OnChange; - UpdateAttachment(); - if (!IsOpen) { IsOpen = true; @@ -85,17 +56,34 @@ internal sealed partial class DebugForm : CustomForm Log(args.Message, color); }; } - } - - private void OnChange(object sender, EventArgs args) => UpdateAttachment(); - - private void UpdateAttachment() - { - if (attachedForm is null || !attachedForm.Visible) - return; - //Size = new(Size.Width, attachedForm.Size.Height); - Location = new(attachedForm.Right, attachedForm.Top); - BringToFrontWithoutActivation(); + if (owner is not null) + { + Owner = owner; + StartPosition = FormStartPosition.Manual; + if (owner.Visible) + { + Location = new(owner.Right, owner.Top); + Show(); + Activate(); + } + else + { + EventHandler onShown = null; + onShown = (_, _) => + { + Location = new(owner.Right, owner.Top); + owner.Shown -= onShown; + Show(); + Activate(); + }; + owner.Shown += onShown; + } + } + else + { + Show(); + Activate(); + } } internal void Log(string text) => Log(text, LogTextBox.Error); @@ -116,4 +104,4 @@ internal sealed partial class DebugForm : CustomForm using TestGameForm form = new(this); _ = form.ShowDialog(this); } -} \ No newline at end of file +} diff --git a/CreamInstaller/Forms/MainForm.cs b/CreamInstaller/Forms/MainForm.cs index 7c133d3..3498be9 100644 --- a/CreamInstaller/Forms/MainForm.cs +++ b/CreamInstaller/Forms/MainForm.cs @@ -1495,7 +1495,7 @@ internal sealed partial class MainForm : CustomForm InheritLocation(form); Show(); #if DEBUG - DebugForm.Current.Attach(this); + DebugForm.Current.Open(this); #endif OnLoad(); } @@ -1505,7 +1505,7 @@ internal sealed partial class MainForm : CustomForm form.Show(); Hide(); #if DEBUG - DebugForm.Current.Attach(form); + DebugForm.Current.Open(form); #endif } diff --git a/CreamInstaller/Forms/UpdateForm.cs b/CreamInstaller/Forms/UpdateForm.cs index 5746106..ea01d1c 100644 --- a/CreamInstaller/Forms/UpdateForm.cs +++ b/CreamInstaller/Forms/UpdateForm.cs @@ -38,7 +38,7 @@ internal sealed partial class UpdateForm : CustomForm form.Show(); Hide(); #if DEBUG - DebugForm.Current.Attach(form); + DebugForm.Current.Open(form); #endif ThemeManager.Apply(form); // apply current theme when transitioning } diff --git a/CreamInstaller/Program.cs b/CreamInstaller/Program.cs index 336c9c9..59755f5 100644 --- a/CreamInstaller/Program.cs +++ b/CreamInstaller/Program.cs @@ -107,7 +107,7 @@ internal static class Program AppSettings = ProgramData.LoadSettings(); // load persisted settings using UpdateForm form = new(); #if DEBUG - DebugForm.Current.Attach(form); + DebugForm.Current.Open(form); #endif // Apply initial theme (dark by default) Utility.ThemeManager.Apply(form);