#774: Saving all config when main window minimize to tray

This commit is contained in:
Jaex 2015-07-08 02:43:04 +03:00
parent 5dba6f96c6
commit 87790e404e
4 changed files with 23 additions and 13 deletions

View file

@ -79,7 +79,7 @@ public bool Save(string filePath)
return SettingsHelper.Save(this, FilePath, SerializationType);
}
private void Save()
public void Save()
{
Save(FilePath);
}
@ -89,7 +89,7 @@ public void SaveAsync(string filePath)
TaskEx.Run(() => Save(filePath));
}
private void SaveAsync()
public void SaveAsync()
{
SaveAsync(FilePath);
}

View file

@ -166,7 +166,7 @@ private string GetMetadata(string title, string parentID)
private void SetPermissions(string fileID, GoogleDrivePermissionRole role, GoogleDrivePermissionType type, string value, bool withLink)
{
if (!CheckAuthorization()) return null;
if (!CheckAuthorization()) return;
string url = string.Format("https://www.googleapis.com/drive/v2/files/{0}/permissions", fileID);

View file

@ -847,7 +847,7 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
Hide();
Program.Settings.SaveAsync(Program.ApplicationConfigFilePath);
Program.SaveSettingsAsync();
}
}

View file

@ -431,6 +431,13 @@ public static void SaveSettings()
if (HotkeysConfig != null) HotkeysConfig.Save(HotkeysConfigFilePath);
}
public static void SaveSettingsAsync()
{
if (Settings != null) Settings.SaveAsync(ApplicationConfigFilePath);
UploadersConfigSaveAsync();
if (HotkeysConfig != null) HotkeysConfig.SaveAsync(HotkeysConfigFilePath);
}
public static void BackupSettings()
{
Helpers.BackupFileWeekly(ApplicationConfigFilePath, BackupFolder);
@ -548,16 +555,19 @@ private static void ReloadUploadersConfig(string filePath)
public static void UploadersConfigSaveAsync()
{
if (uploaderConfigWatcher != null) uploaderConfigWatcher.EnableRaisingEvents = false;
if (UploadersConfig != null)
{
if (uploaderConfigWatcher != null) uploaderConfigWatcher.EnableRaisingEvents = false;
TaskEx.Run(() =>
{
UploadersConfig.Save(UploadersConfigFilePath);
},
() =>
{
if (uploaderConfigWatcher != null) uploaderConfigWatcher.EnableRaisingEvents = true;
});
TaskEx.Run(() =>
{
UploadersConfig.Save(UploadersConfigFilePath);
},
() =>
{
if (uploaderConfigWatcher != null) uploaderConfigWatcher.EnableRaisingEvents = true;
});
}
}
public static string GetGitHash()