Minor update for UI to reflect session state

This commit is contained in:
x1nixmzeng 2018-01-02 23:39:42 +00:00
parent 2d8b832f71
commit 01ff3b57c7
2 changed files with 95 additions and 48 deletions

View File

@ -28,62 +28,74 @@
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.btnRestart = new System.Windows.Forms.Button();
this.btnSuspend = new System.Windows.Forms.Button();
this.btnResume = new System.Windows.Forms.Button();
this.lbConsole = new System.Windows.Forms.ListBox();
this.btnClearLog = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
// btnRestart
//
this.button1.Location = new System.Drawing.Point(12, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(63, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Restart Session";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
this.btnRestart.Location = new System.Drawing.Point(12, 12);
this.btnRestart.Name = "btnRestart";
this.btnRestart.Size = new System.Drawing.Size(63, 23);
this.btnRestart.TabIndex = 0;
this.btnRestart.Text = "Restart Session";
this.btnRestart.UseVisualStyleBackColor = true;
this.btnRestart.Click += new System.EventHandler(this.button1_Click);
//
// button2
// btnSuspend
//
this.button2.Location = new System.Drawing.Point(81, 12);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(63, 23);
this.button2.TabIndex = 1;
this.button2.Text = "Suspend";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
this.btnSuspend.Location = new System.Drawing.Point(81, 12);
this.btnSuspend.Name = "btnSuspend";
this.btnSuspend.Size = new System.Drawing.Size(63, 23);
this.btnSuspend.TabIndex = 1;
this.btnSuspend.Text = "Suspend";
this.btnSuspend.UseVisualStyleBackColor = true;
this.btnSuspend.Click += new System.EventHandler(this.button2_Click);
//
// button3
// btnResume
//
this.button3.Location = new System.Drawing.Point(150, 12);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(63, 23);
this.button3.TabIndex = 1;
this.button3.Text = "Resume";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
this.btnResume.Location = new System.Drawing.Point(150, 12);
this.btnResume.Name = "btnResume";
this.btnResume.Size = new System.Drawing.Size(63, 23);
this.btnResume.TabIndex = 1;
this.btnResume.Text = "Resume";
this.btnResume.UseVisualStyleBackColor = true;
this.btnResume.Click += new System.EventHandler(this.button3_Click);
//
// listBox1
// lbConsole
//
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
this.lbConsole.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(12, 47);
this.listBox1.Name = "listBox1";
this.listBox1.ScrollAlwaysVisible = true;
this.listBox1.Size = new System.Drawing.Size(506, 212);
this.listBox1.TabIndex = 2;
this.lbConsole.FormattingEnabled = true;
this.lbConsole.Location = new System.Drawing.Point(12, 47);
this.lbConsole.Name = "lbConsole";
this.lbConsole.ScrollAlwaysVisible = true;
this.lbConsole.Size = new System.Drawing.Size(506, 212);
this.lbConsole.TabIndex = 2;
//
// btnClearLog
//
this.btnClearLog.Location = new System.Drawing.Point(455, 12);
this.btnClearLog.Name = "btnClearLog";
this.btnClearLog.Size = new System.Drawing.Size(63, 23);
this.btnClearLog.TabIndex = 3;
this.btnClearLog.Text = "Clear";
this.btnClearLog.UseVisualStyleBackColor = true;
this.btnClearLog.Click += new System.EventHandler(this.btnClearLog_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(530, 271);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.btnClearLog);
this.Controls.Add(this.lbConsole);
this.Controls.Add(this.btnResume);
this.Controls.Add(this.btnSuspend);
this.Controls.Add(this.btnRestart);
this.Name = "Form1";
this.Text = "Cxbx-Reloaded Debugger";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
@ -93,10 +105,11 @@
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button btnRestart;
private System.Windows.Forms.Button btnSuspend;
private System.Windows.Forms.Button btnResume;
private System.Windows.Forms.ListBox lbConsole;
private System.Windows.Forms.Button btnClearLog;
}
}

View File

@ -34,6 +34,8 @@ namespace CxbxDebugger
CachedArgs = items.ToArray();
SetDebugProcessActive(false);
// TODO: Wait for user to start this?
StartDebugging();
}
@ -112,19 +114,49 @@ namespace CxbxDebugger
public void DebugEvent(string Message)
{
if( listBox1.InvokeRequired )
if( lbConsole.InvokeRequired )
{
// Ensure we Add items on the right thread
listBox1.Invoke(new MethodInvoker(delegate ()
lbConsole.Invoke(new MethodInvoker(delegate ()
{
listBox1.Items.Add(Message);
lbConsole.Items.Add(Message);
}));
}
else
{
listBox1.Items.Add(Message);
lbConsole.Items.Add(Message);
}
}
public void SetDebugProcessActive(bool Active)
{
if (btnRestart.InvokeRequired)
{
btnRestart.Invoke(new MethodInvoker(delegate ()
{
// Disable when active
btnRestart.Enabled = !Active;
// Enable when active
btnSuspend.Enabled = Active;
btnResume.Enabled = Active;
}));
}
else
{
// Disable when active
btnRestart.Enabled = !Active;
// Enable when active
btnSuspend.Enabled = Active;
btnResume.Enabled = Active;
}
}
private void btnClearLog_Click(object sender, EventArgs e)
{
lbConsole.Items.Clear();
}
}
class DebuggerFormEvents : DebuggerEventListener
@ -138,11 +170,13 @@ namespace CxbxDebugger
public override void OnDebugStart()
{
frm.SetDebugProcessActive(true);
frm.DebugEvent("Started debugging session");
}
public override void OnDebugEnd()
{
frm.SetDebugProcessActive(false);
frm.DebugEvent("Ended debugging session");
}