private void mnuSetVariable_Click(object sender, EventArgs e) { var varName = InputBoxForm.GetStrInput("Name of variable:", "$base"); if (!string.IsNullOrEmpty(varName) && varName.StartsWith("$")) { var val = InputBoxForm.GetStrInput("Value of variable:", ""); if (!string.IsNullOrEmpty(val)) { this.m_variables[varName] = val; } } // Refresh UI this.listBoxConfigs_SelectedIndexChanged(null, null); }
private void mnuSetDeletedPath_Click(object sender, EventArgs e) { var prevDir = this.m_globalSettings.m_directoryForDeletedFiles ?? "c:\\"; var sNewName = InputBoxForm.GetStrInput("Please enter a directory where manually deleted files will be moved, or enter no text to disable this feature:", prevDir); if (string.IsNullOrEmpty(sNewName)) { return; } else if (!Directory.Exists(sNewName)) { MessageBox.Show("Directory does not exist"); return; } else { this.m_globalSettings.m_directoryForDeletedFiles = sNewName; RbcpyGlobalSettings.Serialize(this.m_globalSettings, "configs/globalconfig.xml"); } }
private void mnuSaveAs_Click(object sender, EventArgs e) { var currentName = GetCurrentConfigName(); currentName = currentName != null ? "" : currentName; var sNewName = InputBoxForm.GetStrInput("Choose a name:", currentName); if (sNewName == null) { return; } if (sNewName.Contains("\\") || sNewName.Contains("/") || sNewName.Contains(".")) { MessageBox.Show("Invalid character in name."); return; } var newFilename = "configs/" + sNewName + ".xml"; if (File.Exists(newFilename)) { MessageBox.Show("A configuration already exists with this name."); return; } SyncConfiguration.Serialize(this.GetCurrentConfigFromUI(), newFilename); this.CreateSyncMain_Load(null, null); var justName = Path.GetFileNameWithoutExtension(newFilename); foreach (var item in listBoxConfigs.Items) { if ((item as SavedConfigForListbox).m_filename == justName) { listBoxConfigs.SelectedItem = item; break; } } }