Skip to content

Commit

Permalink
do not load UI settings if running in Preload OS mode
Browse files Browse the repository at this point in the history
  • Loading branch information
d2phap committed May 18, 2024
1 parent 246506b commit bf6b19d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Source/ImageGlass/FrmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ private void HandleImage_LastReached()

private void ImageTransform_Changed(object? sender, EventArgs e)
{
_uiReporter.Report(new ProgressReporterEventArgs(e, nameof(ImageTransform_Changed)));
_uiReporter.Report(new(e, nameof(ImageTransform_Changed)));
}


Expand Down
41 changes: 21 additions & 20 deletions Source/ImageGlass/FrmMain/FrmMain.Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ public partial class FrmMain

private void SetUpFrmMainConfigs()
{
// run Preload OS mode
if (Program.IsPreloadWithOs)
{
RunAsPreloadOsMode();
}


SuspendLayout();

// Toolbar
Expand Down Expand Up @@ -216,6 +223,10 @@ private void InitializeToolbarContext()

private void FrmMain_Load(object sender, EventArgs e)
{
// do not load UI settings if running in Preload OS mode
if (Program.IsPreloadWithOs) return;


Local.FrmMainUpdateRequested += Local_FrmMainUpdateRequested;


Expand Down Expand Up @@ -267,22 +278,14 @@ private void FrmMain_Load(object sender, EventArgs e)
}


// hide app window
if (Program.IsPreloadWithOs)
// start slideshow
if (Config.EnableSlideshow)
{
RunAsPreloadOsMode();
IG_ToggleSlideshow();
}
else
{
// start slideshow
if (Config.EnableSlideshow)
{
IG_ToggleSlideshow();
}

// load first image
LoadImagesFromCmdArgs(Environment.GetCommandLineArgs());
}
// load first image
LoadImagesFromCmdArgs(Environment.GetCommandLineArgs());


// load other low priority data after 500ms
Expand All @@ -300,7 +303,6 @@ private void RunAsPreloadOsMode()
ShowInTaskbar = false;
Visible = false;


Task.Run(async () =>
{
await Task.Delay(3000);
Expand Down Expand Up @@ -345,13 +347,12 @@ private void LoadLowPriorityFormData()

private void FrmMainConfig_FormClosing(object? sender, FormClosingEventArgs e)
{
// do not save configs when preloading with OS
if (!Program.IsPreloadWithOs)
{
_ = SaveConfigsOnClosing();
}
// immediately exit
if (Program.IsPreloadWithOs) return;


ToolbarContext.Dispose();
// save settings
_ = SaveConfigsOnClosing();
}


Expand Down

0 comments on commit bf6b19d

Please sign in to comment.