internal void TagApplied(object sender, TokenizedTagEventArgs e) { if (TreeViewSelectedItem == null || e.Item == null || e.Item.Text == null) { return; } var myTag = from tag in TreeViewSelectedItem.Elements("Tag") where string.Equals(tag.Value, e.Item.Text) select tag; if (myTag.Count() == 0) { TreeViewSelectedItem.Add(new XElement(XName.Get("Tag"), e.Item.Text)); // then all rounds and all videos since preferences may have changed RaisePropertyChanged("AllRounds"); RaisePropertyChanged("AllVideos"); } // maybe add it to the tag db? var myTag2 = from tag in TagDBElement.Descendants("Tag") where string.Equals(tag.Value, e.Item.Text) select tag; if (myTag2.Count() == 0) { var uncategorizedTags = from tagCat in TagDBElement.Elements(XName.Get("TagCategory")) where tagCat.Attribute(XName.Get("id")).Value.Equals("None") select tagCat; uncategorizedTags.First().Add(new XElement(XName.Get("Tag"), e.Item.Text)); RaisePropertyChanged("UncategorizedTags"); } }
internal void TagRemoved(object sender, TokenizedTagEventArgs e) { if (TreeViewSelectedItem == null || e.Item == null || e.Item.Text == null) { return; } var myTag = from tag in TreeViewSelectedItem.Elements("Tag") where string.Equals(tag.Value, e.Item.Text) select tag; myTag.Remove(); // see if this tag is anywhere else var tagStillInCHDB = from tag in CHDBElement.Descendants("Tag") where string.Equals(tag.Value, e.Item.Text) select tag; var tagStillInInWork = from tag in InWorkElement.Descendants("Tag") where string.Equals(tag.Value, e.Item.Text) select tag; if ((tagStillInCHDB.Count() + tagStillInInWork.Count()) == 0) { var tagInTagDB = from tag in TagDBElement.Descendants("Tag") where string.Equals(tag.Value, e.Item.Text) select tag; tagInTagDB.Remove(); // fire all three since i am lazy RaisePropertyChanged("BlacklistTags"); RaisePropertyChanged("WhitelistTags"); RaisePropertyChanged("UncategorizedTags"); } // then all rounds and all videos since preferences may have changed RaisePropertyChanged("AllRounds"); RaisePropertyChanged("AllVideos"); }