public TagBlock(Cairo.Context cr, string tag) { bool isKnownOn = tag.StartsWith("known_on_"); bool isNotOn = tag.StartsWith("not_on_"); if (isKnownOn || isNotOn) { this.IsSiteTag = true; this.Text = tag.Replace("known_on_", "").Replace("not_on_", ""); this.Color = isKnownOn ? new Color(.7, 1, .7) : new Color(1, .7, .7); } else { this.IsSiteTag = false; this.Text = tag; var tagDetails = BooruApp.BooruApplication.Database.GetTag(tag); if (tagDetails == null) { this.Color = new Color(1, 1, 1); } else { this.Color = TagDetails.GetTagTypeColor(tagDetails.Type); } } Cairo.TextExtents extents = cr.TextExtents(this.Text); this.Position = new PointD(0.0, 0.0); this.Width = extents.XAdvance; this.Height = cr.FontExtents.Height; }
private void CacheTags() { using (var cursor = Queries.Tags.GetAll.Execute()) { while (cursor.Read()) { TagDetails details = cursor.Value; if (details.Tag != null) { lock (this.tagIds) this.tagIds [details.Tag] = details.ID; lock (this.usedTagList) this.usedTagList [details.ID] = details; if (details.Count > this.maxCount) { this.maxCount = details.Count; } this.TagEntryCompletionStore.AppendValues(details.Tag + " ", details.Count); } } } var implications = Queries.TagImplications.Get.Execute(); lock (this.tagImplications) { this.tagImplications.Clear(); foreach (var kv in implications) { this.tagImplications.Add(kv); } } }
public bool ReplaceTag(string fromTag, List <string> toTags) { long fromTagId = this.GetTagId(fromTag); List <long> toTagIds = new List <long> (toTags.Count); foreach (string toTag in toTags) { long toTagId = this.GetTagId(toTag); if (toTagId == -1) { return(false); } toTagIds.Add(toTagId); } Queries.ImageTags.Replace.Execute(fromTagId, toTagIds); lock (this.usedTagList) { TagDetails fromDetails = this.usedTagList [fromTagId]; foreach (long toTagId in toTagIds) { this.usedTagList [toTagId].Replace(fromDetails); } this.usedTagList.Remove(fromTagId); } return(true); }
private bool UnfilteredIterFromPath(out TreeIter iter, TreePath path) { TreeIter filteredIter; iter = default(TreeIter); if (!this.TagTreeView.Model.GetIter(out filteredIter, path)) { return(false); } if (this.TagTreeView.Model == this.allTagsStore) { iter = filteredIter; return(true); } if (!this.allTagsStore.GetIterFirst(out iter)) { return(false); } TagDetails filteredDetails = (TagDetails)this.TagTreeView.Model.GetValue(filteredIter, 5); do { TagDetails unfilteredDetails = (TagDetails)this.allTagsStore.GetValue(iter, 5); if (unfilteredDetails.ID == filteredDetails.ID) { return(true); } } while(this.allTagsStore.IterNext(ref iter)); return(false); }
private void OnTagsCursorChanged(object o, EventArgs args) { TreePath path; TreeViewColumn column; this.TagTreeView.GetCursor(out path, out column); TreeIter iter; if (this.TagTreeView.Model.GetIter(out iter, path)) { this.loadingTag = true; this.activeTag = (TagDetails)this.TagTreeView.Model.GetValue(iter, 5); TagLabel.Text = this.activeTag.Tag; var similar = BooruApp.BooruApplication.Database.FindSimilarTags(this.activeTag.Tag, Math.Min(5, Math.Max(1, TagLabel.Text.Length - 1))).Where(x => x.Tag != this.activeTag.Tag).Distinct().ToList(); var gridChldren = this.SimilarTagBox.Children; foreach (var child in gridChldren) { this.SimilarTagBox.Remove(child); this.RecycleSimilarTagWidget(child); } if (similar.Count == 0) { Gtk.Button emptyLabelButton = new Gtk.Button(); emptyLabelButton.Label = "No similar tags found..."; emptyLabelButton.SetAlignment(0.0f, 0.5f); emptyLabelButton.FocusOnClick = false; emptyLabelButton.Relief = ReliefStyle.None; emptyLabelButton.Sensitive = false; this.SimilarTagBox.PackStart(emptyLabelButton, false, false, 0); } else { for (int i = 0; i < similar.Count; i++) { this.SimilarTagBox.PackStart(this.GetSimilarTagWidget(similar[i].Tag), false, false, 0); } } this.SimilarTagBox.ShowAll(); this.ReplaceEntry.StyleContext.RemoveClass("entryWrong"); this.typeButtons[(int)this.activeTag.Type].Active = true; this.impliesStore.Clear(); foreach (var implied in BooruApp.BooruApplication.Database.GetTagImplications(this.activeTag.Tag)) { this.impliesStore.AppendValues(implied); } this.loadingTag = false; } }
public void SetTagType(TagDetails tag, TagDetails.TagType type) { long tagId = this.GetTagId(tag.Tag); if (tagId == -1) { return; } lock (this.usedTagList) this.usedTagList [tagId].UpdateType(type); BooruApp.BooruApplication.TaskRunner.StartTaskAsync("Set tag type", () => Queries.Tags.SetType.Execute(tagId, type)); }
protected long CreateTag(string tag) { try { Queries.Tags.Add.Execute(tag); long tagId = Queries.Tags.GetID.Execute(tag); TagDetails tagData = new TagDetails(tagId, tag, TagDetails.TagType.Normal); lock (this.tagIds) this.tagIds[tag] = tagId; lock (this.usedTagList) this.usedTagList[tagId] = tagData; this.TagEntryCompletionStore.AppendValues(tag, tagData.Count); } catch (Exception ex) { Logger.Log(ex, "Caught exception while trying to create tag " + tag); } return(this.GetTagId(tag)); }
public void Replace(TagDetails replaced) { this.count += replaced.count; this.score += replaced.score; }