private void btnCategoriesAdd_Click(object sender, RoutedEventArgs e) { var ibw = new InputBoxWindow("Enter the name of the new category"); if (ibw.ShowDialog() == true) { string fn = MainWindow.input; if (!Helper.IsValidFilename(fn)) { MessageBox.Show(String.Format("'{0}' is not a valid filename.", fn)); return; } if (Directory.Exists(MainWindow.ProfilesPath + "\\" + fn)) { MessageBox.Show(String.Format("'{0}' already exists as a category.", fn)); return; } Directory.CreateDirectory(MainWindow.ProfilesPath + "\\" + fn); RefreshCategoriesList(); lstCategories.SelectedItem = fn; } }
private void btnProfilesRename_Click(object sender, RoutedEventArgs e) { if (lstProfiles.SelectedIndex == -1) return; var ibw = new InputBoxWindow("Enter the new name for the profile", lstCategories.SelectedItem.ToString()); if (ibw.ShowDialog() == true) { string fn = MainWindow.input; if (!Helper.IsValidFilename(fn)) { MessageBox.Show(String.Format("'{0}' is not a valid filename.", fn)); return; } if (Directory.Exists(MainWindow.ProfilesPath + "\\" + lstCategories.SelectedItem + "\\" + fn)) { MessageBox.Show(String.Format("'{0}' already exists as a profile.", fn)); return; } File.Move(MainWindow.ProfilesPath + "\\" + lstCategories.SelectedItem + "\\" + lstProfiles.SelectedItem, MainWindow.ProfilesPath + "\\" + lstCategories.SelectedItem + "\\" + fn); RefreshProfilesList(); lstProfiles.SelectedItem = fn; } }
private void btnProfilesAdd_Click(object sender, RoutedEventArgs e) { if (lstCategories.SelectedIndex == -1) { MessageBox.Show("You need to select a category first."); return; } var ibw = new InputBoxWindow("Enter the name of the new profile"); if (ibw.ShowDialog() == true) { string fn = MainWindow.input; if (!Helper.IsValidFilename(fn)) { MessageBox.Show(String.Format("'{0}' is not a valid filename.", fn)); return; } if (Directory.Exists(MainWindow.ProfilesPath + "\\" + lstCategories.SelectedItem + "\\" + fn)) { MessageBox.Show(String.Format("'{0}' already exists as a profile.", fn)); return; } FileStream fs = File.Create(MainWindow.ProfilesPath + "\\" + lstCategories.SelectedItem + "\\" + fn); fs.Close(); RefreshProfilesList(); lstProfiles.SelectedItem = fn; } }