mirror of
https://github.com/kwsch/NHSE.git
synced 2026-09-27 20:36:55 -05:00
Add trycatch for sysbot read/write, turn off auto-r/w on fail
Closes #156 turning off auto-r/w won't happen if the auto-r/w itself fails. still pops open a message saying error until you turn it off in the other window.
This commit is contained in:
@@ -50,8 +50,9 @@ private void B_WriteCurrent_Click(object sender, EventArgs e)
|
||||
try
|
||||
{
|
||||
var result = Injector.Write(true);
|
||||
if (result != InjectionResult.Success)
|
||||
WinFormsUtil.Alert(result.ToString());
|
||||
if (result == InjectionResult.Success)
|
||||
return;
|
||||
WinFormsUtil.Alert(result.ToString());
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch (Exception ex)
|
||||
@@ -59,6 +60,7 @@ private void B_WriteCurrent_Click(object sender, EventArgs e)
|
||||
{
|
||||
WinFormsUtil.Error(ex.Message);
|
||||
}
|
||||
TurnOffAuto();
|
||||
}
|
||||
|
||||
private void B_ReadCurrent_Click(object sender, EventArgs e)
|
||||
@@ -66,8 +68,9 @@ private void B_ReadCurrent_Click(object sender, EventArgs e)
|
||||
try
|
||||
{
|
||||
var result = Injector.Read(true);
|
||||
if (result != InjectionResult.Success)
|
||||
WinFormsUtil.Alert(result.ToString());
|
||||
if (result == InjectionResult.Success)
|
||||
return;
|
||||
WinFormsUtil.Alert(result.ToString());
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch (Exception ex)
|
||||
@@ -75,6 +78,15 @@ private void B_ReadCurrent_Click(object sender, EventArgs e)
|
||||
{
|
||||
WinFormsUtil.Error(ex.Message);
|
||||
}
|
||||
TurnOffAuto();
|
||||
}
|
||||
|
||||
private void TurnOffAuto()
|
||||
{
|
||||
if (CHK_AutoRead.Checked)
|
||||
CHK_AutoRead.Checked = false;
|
||||
if (CHK_AutoWrite.Checked)
|
||||
CHK_AutoWrite.Checked = false;
|
||||
}
|
||||
|
||||
private void CHK_AutoWrite_CheckedChanged(object sender, EventArgs e) => Injector.AutoInjectEnabled = CHK_AutoWrite.Checked;
|
||||
|
||||
Reference in New Issue
Block a user