Disconnect on form close too

same as 39205c975e
This commit is contained in:
Kurt 2020-05-09 10:35:14 -07:00
parent 60f3fa84a3
commit 6eff348fa5
2 changed files with 19 additions and 1 deletions

View File

@ -104,7 +104,7 @@ private void InitializeComponent()
this.GB_Inject.TabStop = false;
this.GB_Inject.Text = "Injector";
//
// numericUpDown1
// NUD_Offset
//
this.NUD_Offset.Location = new System.Drawing.Point(73, 39);
this.NUD_Offset.Maximum = new decimal(new int[] {
@ -178,6 +178,7 @@ private void InitializeComponent()
this.Name = "SysBotRAMEdit";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "SysBotUI";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SysBotRAMEdit_FormClosing);
this.GB_Inject.ResumeLayout(false);
this.GB_Inject.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_Offset)).EndInit();

View File

@ -28,6 +28,23 @@ private void B_Connect_Click(object sender, EventArgs e)
GB_Inject.Enabled = true;
}
private void SysBotRAMEdit_FormClosing(object sender, FormClosingEventArgs e)
{
if (!Bot.Bot.Connected)
return;
try
{
Bot.Bot.Disconnect();
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
Console.WriteLine(ex.Message);
}
}
private void B_Edit_Click(object sender, EventArgs e)
{
var offset = StringUtil.GetHexValue(RamOffset.Text);