mirror of
https://github.com/FroggMaster/CreamInstaller.git
synced 2026-07-28 14:47:04 -07:00
Make Debug Window Expandable/Movable
- Makes the debug window expandable - Removes debug form attachment from main form so it's moveable
This commit is contained in:
+6
-6
@@ -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);
|
||||
|
||||
@@ -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 (owner is not null)
|
||||
{
|
||||
if (attachedForm is null || !attachedForm.Visible)
|
||||
return;
|
||||
//Size = new(Size.Width, attachedForm.Size.Height);
|
||||
Location = new(attachedForm.Right, attachedForm.Top);
|
||||
BringToFrontWithoutActivation();
|
||||
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);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user