Exemplo n.º 1
0
        public bool RemoveTag(string tag)
        {
            Tag element;

            if (!this.tags.TryGetValue(tag, out element))
            {
                return(false);
            }

            this.panel.Children.Remove(element);
            this.tags.Remove(tag);
            this.controller?.RemoveTag(tag);

            if (this.orderedTags.Count > 0 && this.orderedTags.Peek() == tag)
            {
                this.orderedTags.Pop();
            }

            element.Dispose();

            if (tags.Count == 0)
            {
                this.SetEmptyText();
            }

            TagRemoved?.Invoke(this, tag);

            return(true);
        }
Exemplo n.º 2
0
 public void RemoveTag(TagAnnotation tag)
 {
     Undo.RecordObject(m_Asset, $"Remove {TagAttribute.GetDescription(tag.Type)} tag");
     tags.RemoveAll(x => x == tag);
     tag.Dispose();
     TagRemoved?.Invoke(tag);
     NotifyChanged();
 }
Exemplo n.º 3
0
 public void Apply(TagRemoved e) => Tags.Remove(e.Name);
Exemplo n.º 4
0
 private void RaiseTagRemoved(TagItem tag)
 {
     UpdateSelectedTagsOnRemove(tag);
     Debug.WriteLine($"RaiseTagRemoved: {tag.Text}");
     TagRemoved?.Invoke(this, new TagEventArgs(tag));
 }
Exemplo n.º 5
0
 internal void Apply(TagRemoved tagRemoved) =>
 Tags = Tags.Where(x => !string.Equals(x, tagRemoved.Tag.ToLower())).ToList();
Exemplo n.º 6
0
 private void Apply(TagRemoved e) => _tags.Remove(e.Name);
Exemplo n.º 7
0
        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));
        }