public void DeleteTag(object obj) { if (deleteTagView.tagsComboBox.SelectedItem.Equals(Tags[0])) { MessageBox.Show("Can't delete the Computer time!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else if (MessageBox.Show("Are You sure you want to delete this tag?", "Question", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) == MessageBoxResult.Yes) { TagModel selected = ((TagModel)deleteTagView.tagsComboBox.SelectedItem); SqliteDataAccess.DeleteTag(selected); // deletes from both Tags and Rules the row with this tagId _tags.Remove(selected); Tagger.UpdateTagList(); // have to make the taggerupdate its rules in the application OnTagDeleted(); // have to update the rules list in the rule view model. deleteTagView.Close(); } }
public void AddTag(object obj) { if (addTagView.NewTagNameTextBox.Text.Length > 0 && addTagView.NewTagColorPicker.SelectedColorText.Length > 0) { SolidColorBrush brush = new SolidColorBrush((Color)addTagView.NewTagColorPicker.SelectedColor); var tag = new TagModel() { TagColor = brush, TagName = addTagView.NewTagNameTextBox.Text, TagTime = new TimeSpan(0, 0, 0) }; tag.TagID = SqliteDataAccess.saveTagAndGetId(tag); Tags.Add(tag); Tagger.UpdateTagList(); addTagView.Close(); } else { MessageBox.Show("Please insert tag name and tag color", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }