Skip to content

Commit

Permalink
Allow on demand GUI disablement
Browse files Browse the repository at this point in the history
  • Loading branch information
gus33000 committed Nov 24, 2024
1 parent 9a50da1 commit ddbc87d
Showing 1 changed file with 52 additions and 8 deletions.
60 changes: 52 additions & 8 deletions DriverUpdater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,14 @@ private static void DriverUpdaterAction(string Definition, string DriverRepo, st
return;
}

WizardUx progress = new();
_ = new Progress((object sender, DoWorkEventArgs e) =>
ProgressInterface progress = null;

if (!DISABLE_GUI)
{
progress = new WizardUx();
}

void OfflineOperation()
{
Logging.progress = progress;
try
Expand Down Expand Up @@ -163,17 +169,40 @@ private static void DriverUpdaterAction(string Definition, string DriverRepo, st
}
catch (Exception ex)
{
if (Logging.progress != null)
{
Logging.progress.Close();
Logging.progress = null;
}
Logging.LogMilestone("Something happened!", Logging.LoggingLevel.Error);
Logging.Log(ex.ToString(), Logging.LoggingLevel.Error);
}

progress.Close();
}, progress);
}

if (DISABLE_GUI)
{
OfflineOperation();
}
else
{
_ = new Progress((object sender, DoWorkEventArgs e) =>
{
OfflineOperation();
}, progress);
}
}
else
{
WizardUx progress = new();
_ = new Progress((object sender, DoWorkEventArgs e) =>
ProgressInterface progress = null;

if (!DISABLE_GUI)
{
progress = new WizardUx();
}

void OnlineOperation()
{
Logging.progress = progress;
try
Expand All @@ -182,14 +211,29 @@ private static void DriverUpdaterAction(string Definition, string DriverRepo, st
}
catch (Exception ex)
{
Logging.progress.Close();
Logging.progress = null;
if (Logging.progress != null)
{
Logging.progress.Close();
Logging.progress = null;
}
Logging.LogMilestone("Something happened!", Logging.LoggingLevel.Error);
Logging.Log(ex.ToString(), Logging.LoggingLevel.Error);
}

progress.Close();
}, progress);
}

if (DISABLE_GUI)
{
OnlineOperation();
}
else
{
_ = new Progress((object sender, DoWorkEventArgs e) =>
{
OnlineOperation();
}, progress);
}
}

Logging.Log("Done!");
Expand Down

0 comments on commit ddbc87d

Please sign in to comment.