/// <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)); }
private bool tryAddTag(string tag) { var success = this.AddTag(tag); if (success) { TagAdded?.Invoke(this, tag); } return(success); }
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); }
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(); }
/// <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(); }
public void Apply(TagAdded e) => Tags.Add(e.Name);
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)); } }
internal void RaiseTagAdded(TagItem tag) { UpdateSelectedTagsOnAdd(tag); Debug.WriteLine($"RaiseTagAdded: {tag.Text}"); TagAdded?.Invoke(this, new TagEventArgs(tag)); }
internal void Apply(TagAdded bookCreated) => Tags = Tags.Concat(new[] { bookCreated.Tag.ToLower() }).ToList();
private void Apply(TagAdded e) => _tags.Add(e.Name);
public BookActor() { PersistenceId = Context.Self.Path.Name; Command <CreateBook>(createBook => { var bookCreated = new BookCreated ( id: createBook.Id, title: createBook.Title, author: createBook.Author, tags: createBook.Tags, cost: createBook.Cost, inventoryAmount: createBook.InventoryAmount ); Persist(bookCreated, _ => { _logger.Info($"Book created: {bookCreated}"); _aggregate.Apply(bookCreated); }); }); Command <AddTag>(addTag => { var tagAdded = new TagAdded(id: addTag.Id, tag: addTag.Tag); Persist(tagAdded, _ => { _logger.Info(tagAdded.ToString()); _aggregate.Apply(tagAdded); }); }); Command <RemoveTag>(removeTag => { var tagRemoved = new TagRemoved(id: removeTag.Id, tag: removeTag.Tag); Persist(tagRemoved, _ => { _logger.Info(tagRemoved.ToString()); _aggregate.Apply(tagRemoved); }); }); Command <GetBook>(getBook => { var bookDto = new BookDto ( id: _aggregate.Id, title: _aggregate.Title, author: _aggregate.Author, tags: _aggregate.Tags ?? new string[] { }, cost: _aggregate.Cost ); Sender.Tell(bookDto); }); Recover <BookCreated>(bookCreated => _aggregate.Apply(bookCreated)); Recover <TagAdded>(tagAdded => _aggregate.Apply(tagAdded)); Recover <TagRemoved>(tagRemoved => _aggregate.Apply(tagRemoved)); }