private void buttonAdd_Click(object sender, RoutedEventArgs e) { AddTag addTag = new AddTag(); addTag.Show(); }
private void buttonAddNewTag_Click(object sender, RoutedEventArgs e) { // if it hasn't been found in database, open dialog to add it if (Database.GetTag(autoCompleteBoxTags.Text) == null) { AddTag dialog; if (string.IsNullOrWhiteSpace(autoCompleteBoxTags.Text)) { dialog = new AddTag(); } else { dialog = new AddTag(autoCompleteBoxTags.Text); } dialog.ShowDialog(); // If it has successfully added a new tag if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { ManifestationTag tag = new ManifestationTag(Database.getInstance().Tags.Last()); // make sure tag is't already added bool found = false; foreach (var manifestationTag in Manifestation.Tags) { if (manifestationTag.Id.Equals(tag.Id)) { found = true; SelectedTags.Add(manifestationTag); } } if (!found) { Manifestation.Tags.Add(tag); SelectedTags.Add(tag); } } } // if it has been found in database else { ManifestationTag tag = new ManifestationTag(Database.GetTag(autoCompleteBoxTags.Text)); // make sure tag is't already added bool found = false; foreach (var manifestationTag in Manifestation.Tags) { if (manifestationTag.Id.Equals(tag.Id)) { found = true; SelectedTags.Add(manifestationTag); } } if (!found) { Manifestation.Tags.Add(tag); SelectedTags.Add(tag); } } // reset field autoCompleteBoxTags.SelectedItem = null; autoCompleteBoxTags.Text = string.Empty; }