private void NewTag() { if (!string.IsNullOrEmpty(TagNameText) && SelectedTag > -1) { if (EditTagID == Guid.Empty)//New Tag { var tag = AnnCategoryTagUtil.Instance.AddAndReturnTag(TagNameText, AnnotationTools.TagColors[SelectedTag].ColorValue); var tagItem = new TagItem { Tag = tag, IsCheck = false }; TagCollections.Add(tagItem); } else// Edit Tag { var tag = AnnCategoryTagUtil.Instance.UpdateAndReturnTag(EditTagID, TagNameText, AnnotationTools.TagColors[SelectedTag].ColorValue); var editTagIndex = TagCollections.ToList <TagItem>().FindIndex(x => x.Tag.TagId == EditTagID); if (editTagIndex > -1) { TagCollections[editTagIndex] = new TagItem { Tag = tag, IsCheck = TagCollections[editTagIndex].IsCheck }; } } SwitchAnnoAndTag(true); } }
private void TagOrderChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: AnnCategoryTagUtil.Instance.Sort(TagCollections.Select(x => x.Tag).ToList <AnnotationTag>()); break; } }
public void EditDialogOpen(Guid guid) { SwitchAnnoAndTag(false); var tag = TagCollections.FirstOrDefault(x => x.Tag.TagId == guid); SelectedTag = AnnotationTools.TagColors.FindIndex(x => x.ColorValue == tag.Tag.Color); EditTagID = guid; NewTagTitle = ResourceLoader.GetString("EditTagTitle"); TagNameText = tag.Tag.Title; }
public void DeleteTag(Guid guid) { AnnCategoryTagUtil.Instance.DeleteTag(guid); var deleteTag = TagCollections.FirstOrDefault(x => x.Tag.TagId == guid); if (deleteTag != null) { TagCollections.Remove(deleteTag); } }