diff --git a/src/WindowResizer.Configuration/ProfilesFactory.cs b/src/WindowResizer.Configuration/ProfilesFactory.cs index 420c8d3..98d96f1 100644 --- a/src/WindowResizer.Configuration/ProfilesFactory.cs +++ b/src/WindowResizer.Configuration/ProfilesFactory.cs @@ -13,6 +13,7 @@ public static class ProfilesFactory private static string _portableConfigPath = string.Empty; public static bool PortableMode; + public static bool PostponeSaving = false; public static string ConfigPath = string.Empty; public static void SetPath(string roamingPath, string portablePath) @@ -78,7 +79,8 @@ public static void Save() { var json = JsonConvert.SerializeObject(Profiles); new FileInfo(ConfigPath).Directory?.Create(); - File.WriteAllText(ConfigPath, json); + + if (!PostponeSaving) File.WriteAllText(ConfigPath, json); Profiles.Updated(); } diff --git a/src/WindowResizer/TrayContext.cs b/src/WindowResizer/TrayContext.cs index 723e364..ddaeba2 100644 --- a/src/WindowResizer/TrayContext.cs +++ b/src/WindowResizer/TrayContext.cs @@ -389,6 +389,7 @@ private void OnKeyPressed(object sender, KeyPressedEventArgs e) private void SaveAll() { var windows = Resizer.GetOpenWindows(); + ProfilesFactory.PostponeSaving = true; foreach (var window in windows) { if (Resizer.GetWindowState(window) != WindowState.Minimized) @@ -397,6 +398,9 @@ private void SaveAll() } } + ProfilesFactory.PostponeSaving = false; + ProfilesFactory.Save(); + if (ProfilesFactory.Current.NotifyOnSaved) { Toast.ShowToast(