Skip to content

Commit

Permalink
Reduced code complexity in PS_ExecuteNow_Click() private method.
Browse files Browse the repository at this point in the history
  • Loading branch information
xvitaly committed Apr 13, 2024
1 parent 83a2ba0 commit 7c0c888
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions src/srcrepair/FrmMainW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1771,47 +1771,44 @@ private void PS_CleanRegistry_CheckedChanged(object sender, EventArgs e)
/// <param name="e">Event arguments.</param>
private void PS_ExecuteNow_Click(object sender, EventArgs e)
{
if (MessageBox.Show(AppStrings.PS_ExecuteMSG, Properties.Resources.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
if ((PS_CleanBlobs.Checked || PS_CleanRegistry.Checked) && MessageBox.Show(AppStrings.PS_ExecuteMSG, Properties.Resources.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
if (PS_CleanBlobs.Checked || PS_CleanRegistry.Checked)
if (ProcessManager.ProcessTerminate("Steam") != 0)
{
if (ProcessManager.ProcessTerminate("Steam") != 0)
MessageBox.Show(AppStrings.PS_ProcessDetected, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

if (PS_CleanBlobs.Checked)
{
try
{
MessageBox.Show(AppStrings.PS_ProcessDetected, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
App.SteamClient.CleanBlobsNow();
}

if (PS_CleanBlobs.Checked)
catch (Exception Ex)
{
try
{
App.SteamClient.CleanBlobsNow();
}
catch (Exception Ex)
{
Logger.Error(Ex, DebugStrings.AppDbgExClnBlobs);
MessageBox.Show(AppStrings.PS_CleanException, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
Logger.Error(Ex, DebugStrings.AppDbgExClnBlobs);
MessageBox.Show(AppStrings.PS_CleanException, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}

if (PS_CleanRegistry.Checked)
if (PS_CleanRegistry.Checked)
{
try
{
try
{
App.SteamClient.CleanRegistryNow(PS_SteamLang.SelectedIndex);
}
catch (Exception Ex)
{
Logger.Error(Ex, DebugStrings.AppDbgExClnReg);
MessageBox.Show(AppStrings.PS_CleanException, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
App.SteamClient.CleanRegistryNow(PS_SteamLang.SelectedIndex);
}

MessageBox.Show(AppStrings.PS_SeqCompleted, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
if (File.Exists(Path.Combine(App.SteamClient.FullSteamPath, App.Platform.SteamBinaryName)))
catch (Exception Ex)
{
App.Platform.StartRegularProcess(Path.Combine(App.SteamClient.FullSteamPath, App.Platform.SteamBinaryName));
Logger.Error(Ex, DebugStrings.AppDbgExClnReg);
MessageBox.Show(AppStrings.PS_CleanException, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}

MessageBox.Show(AppStrings.PS_SeqCompleted, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
if (File.Exists(Path.Combine(App.SteamClient.FullSteamPath, App.Platform.SteamBinaryName)))
{
App.Platform.StartRegularProcess(Path.Combine(App.SteamClient.FullSteamPath, App.Platform.SteamBinaryName));
}
}
}

Expand Down

0 comments on commit 7c0c888

Please sign in to comment.