public void ReloadTagsData() { List <ColorTagState> backupTags = null; if (TagsList == null) { TagsList = new List <ColorTagState> (); } else { backupTags = new List <ColorTagState> (); backupTags.AddRange(TagsList); TagsList.Clear(); } if (AnnCategoryTagUtil.Instance == null) { return; } var tagList = AnnCategoryTagUtil.Instance.GetTags(); var tempTagList = new List <AnnotationTag> (); tempTagList.AddRange(tagList); if (tagList != null) { foreach (var tag in tempTagList) { var colorTag = new ColorTagState(); colorTag.CheckState = NSCellStateValue.Off; if (backupTags != null) { for (int i = 0; i < backupTags.Count; i++) { if (tag.TagId == backupTags [i].Tag.TagId) { colorTag.CheckState = backupTags [i].CheckState; break; } } } colorTag.Tag = tag; TagsList.Add(colorTag); } } if (backupTags != null) { backupTags.Clear(); backupTags = null; } if (TagsTableView != null) { TagsTableView.ReloadData(); } }
public void SetTagItems(IEnumerable <Tag> tags) { foreach (var tag in tags) { TagsList.Add(new SelectListItem() { Value = tag.TagID.ToString(), Text = tag.TagName }); } }
private void GetTags() { using (var logic = new TagService()) { foreach (var link in Links) { foreach (var tag in logic.GetCollection(link.Id)) { TagsList.Add(tag); } link.Tags = TagsList; } foreach (var tag in logic.GetCollectionTags()) { AllTagsList.Add(tag); } } }
private void OnAddClickHandler(object obj) { if (TagText != string.Empty && TagsList.Count(t => t.Name == TagText) == 0) { Tag newTag = dataRepository.TagCollection.FirstOrDefault(t => t.Name == TagText); if (newTag == null) { newTag = new Tag(); newTag.Name = TagText; dataRepository.CreateTag(newTag); newTag = dataRepository.TagCollection.FirstOrDefault(t => t.Name == TagText); } currentBlurb.Tags.Add(newTag); TagsList.Add(newTag); OnPropertyChanged("TagsList"); TagText = string.Empty; } }
public void AddTagToTableView(string color, string title) { if (this.IsTagEdit) { var curTag = TagsList [this.CurrentTagIndex]; curTag.Color = color; curTag.Title = title; AnnCategoryTagUtil.Instance.UpdateTag(curTag.TagId, title, color); } else { var newTag = new AnnotationTag(); newTag.Color = color; newTag.Title = title; Guid id = AnnCategoryTagUtil.Instance.AddTag(title, color); newTag.TagId = id; TagsList.Add(newTag); } TagTableView.ReloadData(); }
public void ReloadAnnotationData() { if (AnnCategoryTagUtil.Instance == null) { return; } if (TagsList == null) { TagsList = new List <AnnotationTag> (); } else { TagsList.Clear(); } var tag = new AnnotationTag(); tag.Color = string.Empty; tag.Title = "All Tags"; tag.TagId = Guid.Empty; TagsList.Add(tag); var noTag = new AnnotationTag(); noTag.Color = string.Empty; noTag.Title = "No tag"; noTag.TagId = Guid.Empty; TagsList.Add(noTag); var tags = AnnCategoryTagUtil.Instance.GetTags(); TagsList.AddRange(tags); if (TagsTableView != null) { TagsTableView.ReloadData(); } }
public void UpdateTags() { TagsClean = ""; if (tags == null) // TODO: v0.7.7 returns null tags when there are no plugins enabled. { tags = ""; // Use empty string as fallback instead } var separatedTags = tags.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var s in separatedTags) { TagsClean += s.Substring(Math.Max(s.IndexOf(':') + 1, 0)).Trim() + ", "; } TagsClean = TagsClean.Trim().TrimEnd(','); TagsList.Clear(); foreach (var s in separatedTags) { TagsList.Add(s.Trim()); } // TODO: Apparently we can crash here with a COMException try { TagsGroups.Clear(); } catch (Exception e) { // Drop original collection, can cause more COMExceptions TagsGroups = new ObservableCollection <ArchiveTagsGroup>(); #if WINDOWS_UWP Crashes.TrackError(e); #endif } var tmp = new List <ArchiveTagsGroup>(); foreach (var s in separatedTags) { var parts = s.Trim().Split(new char[] { ':' }, 2); var @namespace = parts.Length == 2 ? parts[0] : "other"; var group = tmp.FirstOrDefault(tg => tg.Namespace.Equals(@namespace)); if (group == null) { group = AddTagsGroup(tmp, @namespace); } var tag = parts[parts.Length - 1]; if (parts[0].Equals("date_added")) { if (long.TryParse(tag, out long unixTime)) { tag = Util.UnixTimeToDateTime(unixTime).ToString(); } } group.Tags.Add(new ArchiveTagsGroupTag { FullTag = s.Trim(), Tag = tag, Namespace = @namespace }); } tmp.Sort((a, b) => string.Compare(a.Namespace, b.Namespace)); var c = tmp.Find(g => g.Namespace.Equals("other")); if (c != null) { tmp.Remove(c); tmp.Add(c); } try { tmp.ForEach(g => { g.Namespace = g.Namespace.UpperFirstLetter().Replace('_', ' '); TagsGroups.Add(g); }); } catch (Exception e) { // Handle damaged collection just in case #if WINDOWS_UWP Crashes.TrackError(e); #endif } }