public bool changeSyncPath() { string old_path = Core.settings.sync_path; string new_path = null; System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog(); folderBrowser.ShowNewFolderButton = true; folderBrowser.Description = "Choose where the saves will be synced."; folderBrowser.SelectedPath = old_path; bool try_again = false; do { if (folderBrowser.ShowDialog(this.GetIWin32Window()) == System.Windows.Forms.DialogResult.OK) { new_path = folderBrowser.SelectedPath; if (PermissionsHelper.isReadable(new_path)) { if (PermissionsHelper.isWritable(new_path)) { Core.settings.sync_path = new_path; if (new_path != old_path) { Core.rebuild_sync = true; } return(new_path != old_path); } else { this.displayError("Config File Error", "You don't have permission to write to the selected sync folder:" + Environment.NewLine + new_path); try_again = true; } } else { this.displayError("Config File Error", "You don't have permission to read from the selected sync folder:" + Environment.NewLine + new_path); try_again = true; } } else { try_again = false; } } while (try_again); return(false); }
public bool addSavePath(AWindow window) { string new_path; System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog(); folderBrowser.ShowNewFolderButton = true; folderBrowser.Description = Strings.GetLabelString("SelectAltPath"); bool try_again = false; do { if (folderBrowser.ShowDialog(window.GetIWin32Window()) == System.Windows.Forms.DialogResult.OK) { new_path = folderBrowser.SelectedPath; if (PermissionsHelper.isReadable(new_path)) { if (Core.settings.addSavePath(new_path)) { try_again = false; return(true); } else { this.showTranslatedError("SelectAltPathDuplicate"); try_again = true; } } else { this.showTranslatedError("SelectAltPathDuplicate"); try_again = true; } } else { try_again = false; } } while (try_again); return(false); }
protected virtual void doWork(object sender, DoWorkEventArgs e) { ProgressHandler.state = ProgressState.Indeterminate; if (!initialized) { TranslatingProgressHandler.setTranslatedMessage("LoadingSettings"); if (!settings.IsReady) { initialized = false; TranslatingMessageHandler.SendError("CriticalSettingsFailure"); return; } Core.locations.setup(); settings.PropertyChanged += new PropertyChangedEventHandler(settings_PropertyChanged); monitor = new Monitor.Monitor(); TranslatingProgressHandler.setTranslatedMessage("ValidatingBackupPath"); if (settings.IsBackupPathSet && (!PermissionsHelper.isReadable(settings.backup_path) || !PermissionsHelper.isWritable(settings.backup_path))) settings.clearBackupPath(); if (!locations.ready) return; //task = new Task.TaskHandler(); initialized = true; } //ProgressHandler.progress_state = ProgressState.Normal; }