mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-13 17:34:08 +02:00
Refactor Program.ResetConfig & Program.RestartWithArgs
This commit is contained in:
parent
1a2b967749
commit
b53c672768
@ -174,6 +174,18 @@ public void Reload(){
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset(){
|
||||
try{
|
||||
File.Delete(file);
|
||||
File.Delete(GetBackupFile(file));
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not delete configuration files to reset the options.", true, e);
|
||||
return;
|
||||
}
|
||||
|
||||
Reload();
|
||||
}
|
||||
|
||||
private void LoadInternal(bool backup){
|
||||
Serializer.Read(backup ? GetBackupFile(file) : file, this);
|
||||
|
||||
|
@ -109,7 +109,7 @@ private void btnContinue_Click(object sender, EventArgs e){
|
||||
case State.Reset:
|
||||
if (FormMessage.Warning("Reset TweetDuck Options", "This will reset the selected items. Are you sure you want to proceed?", FormMessage.Yes, FormMessage.No)){
|
||||
if (Flags.HasFlag(ExportFileFlags.UserConfig)){
|
||||
Program.ResetConfig();
|
||||
Program.UserConfig.Reset();
|
||||
}
|
||||
|
||||
if (Flags.HasFlag(ExportFileFlags.SystemConfig)){
|
||||
|
25
Program.cs
25
Program.cs
@ -192,18 +192,6 @@ private static string GetDataStoragePath(){
|
||||
}
|
||||
}
|
||||
|
||||
public static void ResetConfig(){
|
||||
try{
|
||||
File.Delete(UserConfigFilePath);
|
||||
File.Delete(UserConfig.GetBackupFile(UserConfigFilePath));
|
||||
}catch(Exception e){
|
||||
Reporter.HandleException("Configuration Reset Error", "Could not delete configuration files to reset the options.", true, e);
|
||||
return;
|
||||
}
|
||||
|
||||
UserConfig.Reload();
|
||||
}
|
||||
|
||||
public static void Restart(params string[] extraArgs){
|
||||
CommandLineArgs args = Arguments.GetCurrentClean();
|
||||
CommandLineArgs.ReadStringArray('-', extraArgs, args);
|
||||
@ -211,13 +199,14 @@ public static void Restart(params string[] extraArgs){
|
||||
}
|
||||
|
||||
public static void RestartWithArgs(CommandLineArgs args){
|
||||
FormBrowser browserForm = Application.OpenForms.OfType<FormBrowser>().FirstOrDefault();
|
||||
if (browserForm == null)return;
|
||||
|
||||
browserForm.ForceClose();
|
||||
FormBrowser browserForm = FormManager.TryFind<FormBrowser>();
|
||||
|
||||
ExitCleanup();
|
||||
RestartWithArgsInternal(args);
|
||||
if (browserForm != null){
|
||||
browserForm.ForceClose();
|
||||
|
||||
ExitCleanup();
|
||||
RestartWithArgsInternal(args);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RestartWithArgsInternal(CommandLineArgs args){
|
||||
|
Loading…
Reference in New Issue
Block a user