/// <summary>
        /// Adds a tag to the collection
        /// </summary>
        internal void AddTag(TokenizedTagItem tag)
        {
            TokenizedTagItem itemToSelect = null;

            if (this.SelectedItem == null && this.Items.Count > 0)
            {
                itemToSelect = (TokenizedTagItem)this.SelectedItem;
            }
            ((IList)this.ItemsSource).Add(tag); // assume IList for convenience
            this.Items.Refresh();

            // select the previous item
            if (!object.ReferenceEquals(itemToSelect, null))
            {
                // && !object.ReferenceEquals(TagApplied, null)
                //TagApplied.Invoke(this, new TokenizedTagEventArgs(appliedTag));
                RaiseTagClick(itemToSelect);
                if (this.IsSelectable)
                {
                    this.SelectedItem = itemToSelect;
                }
            }

            // update values
            //UpdateAllTagsProperty();
            TagAdded?.Invoke(this, new TokenizedTagEventArgs(tag));
        }
Exemplo n.º 2
0
        private bool tryAddTag(string tag)
        {
            var success = this.AddTag(tag);

            if (success)
            {
                TagAdded?.Invoke(this, tag);
            }
            return(success);
        }
Exemplo n.º 3
0
        public ITag CreateTag(string name)
        {
            var tag = new Tag(name);

            _tagByName.Add(name, tag);
            _uncategorizedTagNames.Add(name);

            TagAdded?.Invoke(this, new TagEventArgs(tag));
            TagsChanged?.Invoke(this, EventArgs.Empty);
            return(tag);
        }
Exemplo n.º 4
0
        public void AddTag(TagAnnotation tag)
        {
            if (!Valid)
            {
                return;
            }

            Undo.RecordObject(m_Asset, $"Add {TagAttribute.GetDescription(tag.Type)} tag");
            tags.Add(tag);
            TagAdded?.Invoke(tag);
            NotifyChanged();
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Adds a tag to the collection
        /// </summary>
        internal void AddTag(TokenizedTagItem tag)
        {
            TokenizedTagItem itemToSelect = null;

            if (SelectedItem == null && Items.Count > 0)
            {
                itemToSelect = (TokenizedTagItem)SelectedItem;
            }
            ((ObservableCollection <TokenizedTagItem>)ItemsSource).Add(tag);             // assume IList for convenience
            Items.Refresh();

            // select the previous item
            if (!ReferenceEquals(itemToSelect, null))
            {
                RaiseTagClick(itemToSelect);
                if (IsSelectable)
                {
                    SelectedItem = itemToSelect;
                }
            }

            TagAdded?.Invoke(this, new TokenizedTagEventArgs(tag));
        }
        private async Task SaveTag()
        {
            if (string.IsNullOrWhiteSpace(Tag.Name))
            {
                await pageService.DisplayAlert("Error", "Tag Name Cannot be Blank", "OK");

                return;
            }

            if (Tag.TagId == 0)   // New Tag
            {
                await tagStore.AddTag(Tag);

                TagAdded?.Invoke(this, Tag);
            }
            else     // Exisiting Tag
            {
                await tagStore.UpdateTag(Tag);

                TagUpdated?.Invoke(this, Tag);
            }

            await pageService.PopAsync();
        }
Exemplo n.º 7
0
        public IEnumerable <ITagSpan <IClassificationTag> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            if (spans.Count == 0 ||
                Config.Instance.SpecialHighlightOptions.MatchFlags(SpecialHighlightOptions.SpecialComment) == false)
            {
                yield break;
            }

            var snapshot = spans[0].Snapshot;
            IEnumerable <IMappingTagSpan <IClassificationTag> > tagSpans;

            try {
                if (_Tags.LastParsed == 0)
                {
                    // perform a full parse for the first time
                    Debug.WriteLine("Full parse");
                    tagSpans         = _Aggregator.GetTags(new SnapshotSpan(snapshot, 0, snapshot.Length));
                    _Tags.LastParsed = snapshot.Length;
                }
                else
                {
                    //var start = spans[0].Start;
                    //var end = spans[spans.Count - 1].End;
                    //Debug.WriteLine($"Get tag [{start.Position}..{end.Position})");

                    tagSpans = _Aggregator.GetTags(spans);
                }
            }
            catch (ObjectDisposedException ex) {
                // HACK: TagAggregator could be disposed during editing, to be investigated further
                Debug.WriteLine(ex.Message);
                yield break;
            }

            TaggedContentSpan ts, s = null;

            foreach (var tagSpan in tagSpans)
            {
#if DEBUG
                var c = tagSpan.Tag.ClassificationType.Classification;
                if (_ClassificationTypes.Add(c))
                {
                    Debug.WriteLine("Classification type: " + c);
                }
#endif
                ts = TagComments(tagSpan.Span.GetSpans(snapshot)[0], tagSpan);
                if (ts != null)
                {
                    if (s == null)
                    {
                        s = ts;
                    }
                    yield return(_Tags.Add(ts));
                }
            }
            if (s != null)
            {
                TagAdded?.Invoke(this, EventArgs.Empty);
                // note: Don't use the TagsChanged event, otherwise infinite loops will occur
                //TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(s.Span));
            }
        }
Exemplo n.º 8
0
 internal void RaiseTagAdded(TagItem tag)
 {
     UpdateSelectedTagsOnAdd(tag);
     Debug.WriteLine($"RaiseTagAdded: {tag.Text}");
     TagAdded?.Invoke(this, new TagEventArgs(tag));
 }