protected virtual void RenameCategory() // Renames category name and alters all records category field. { // getting new name for category (constraints included) List <string> exclusions = new List <string>(_categories); exclusions.Remove(_selectedCategory); TextDialogBox dialogBox = new TextDialogBox("Please enter new name of category:", _selectedCategory + "*", "Rename category", exclusions); // altering elements to meet new category name if ((bool)dialogBox.ShowDialog()) { foreach (IDataManageable element in _allElements) { if (element.Category == _selectedCategory) { element.Category = dialogBox.Answer; } } int index = _categories.IndexOf(_selectedCategory); _categories[index] = dialogBox.Answer; _selectedCategory = dialogBox.Answer; SortCategories(); RaisePropertyChanged("Categories"); RaisePropertyChanged("BufferedCategories"); RaisePropertyChanged("SelectedCategory"); RaisePropertyChanged("ShownCollection"); _Annalist.DisplayStatus(this, "I115"); // I115;Database management;Category has been renamed successfully. UpdateStatus(); IsChangeCommitted = true; } }
protected virtual void AddNewCategory() // Adds new empty category. Empty categories are forgotten after window closed. { // method logic - integrity checking is done on dialogbox level TextDialogBox dialogBox = new TextDialogBox("Please enter name of new category:", "", "Add new category", _categories); if ((bool)dialogBox.ShowDialog()) { if (_categories.Contains(dialogBox.Answer)) { return; } _categories.Add(dialogBox.Answer); _selectedCategory = dialogBox.Answer; SortCategories(); RaisePropertyChanged("Categories"); RaisePropertyChanged("BufferedCategories"); RaisePropertyChanged("SelectedCategory"); RaisePropertyChanged("ShownCollection"); _Annalist.DisplayStatus(this, "I113"); // I113;Database management;New category has been added successfully. UpdateStatus(); IsChangeCommitted = true; } }