Code aesthetics, unused library cleanup

This commit is contained in:
pointfeev 2021-08-06 22:55:12 -05:00
parent f4491ee8f2
commit d70f683943
6 changed files with 26 additions and 42 deletions

View file

@ -1,5 +1,4 @@
using System;
using System.Drawing;
using System.Drawing;
using System.Windows.Forms;
namespace CreamInstaller

View file

@ -101,6 +101,9 @@ namespace CreamInstaller
}
UpdateProgress(100);
if (!Program.IsProgramRunningDialog(this, selection))
throw new OperationCanceledException();
UpdateProgress(0);
UpdateUser("Installing CreamAPI files for " + selection.ProgramName + " . . . ", LogColor.Operation);
int currentFileCount = 0;
@ -171,26 +174,8 @@ namespace CreamInstaller
Program.Cleanup(cancel: false, logout: false);
bool Check()
{
if (selection.ProgramIsRunning)
{
if (new DialogForm(this).Show(Program.ApplicationName, SystemIcons.Error,
$"ERROR: {selection.ProgramName} is currently running!" +
"\n\nPlease close the program/game to continue . . .",
"Retry", "Cancel") == DialogResult.OK)
return Check();
}
else
{
return true;
}
return false;
}
if (!Check())
{
throw new Exception("The operation was canceled.");
}
if (!Program.IsProgramRunningDialog(this, selection))
throw new OperationCanceledException();
try
{

View file

@ -1,8 +1,6 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Windows.Forms;
using CG.Web.MegaApiClient;

View file

@ -2,6 +2,7 @@ using CG.Web.MegaApiClient;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Reflection;
@ -46,6 +47,23 @@ namespace CreamInstaller
mutex.Close();
}
public static bool IsProgramRunningDialog(Form form, ProgramSelection selection)
{
if (selection.IsProgramRunning)
{
if (new DialogForm(form).Show(ApplicationName, SystemIcons.Error,
$"ERROR: {selection.ProgramName} is currently running!" +
"\n\nPlease close the program/game to continue . . .",
"Retry", "Cancel") == DialogResult.OK)
return IsProgramRunningDialog(form, selection);
}
else
{
return true;
}
return false;
}
public static bool IsFilePathLocked(this string filePath)
{
bool Locked = false;

View file

@ -10,7 +10,7 @@ namespace CreamInstaller
public List<string> SteamApiDllDirectories;
public INode DownloadNode;
public bool ProgramIsRunning
public bool IsProgramRunning
{
get
{

View file

@ -235,23 +235,7 @@ namespace CreamInstaller
{
foreach (ProgramSelection selection in Program.ProgramSelections)
{
bool Check()
{
if (selection.ProgramIsRunning)
{
if (new DialogForm(this).Show(Program.ApplicationName, SystemIcons.Error,
$"ERROR: {selection.ProgramName} is currently running!" +
"\n\nPlease close the program/game to continue . . .",
"Retry", "Cancel") == DialogResult.OK)
return Check();
}
else
{
return true;
}
return false;
}
if (!Check())
if (!Program.IsProgramRunningDialog(this, selection))
return;
}