Esempio n. 1
0
        private void RemoveTags(object obj)
        {
            var bindedTags = (obj as IList)?.Cast <BindedTagVM>();

            if (bindedTags == null)
            {
                var bindedTag = obj as BindedTagVM;

                if (bindedTag == null)
                {
                    return;
                }

                bindedTags = new List <BindedTagVM>
                {
                    bindedTag
                };
            }

            var bindedTagVms = bindedTags as IList <BindedTagVM> ?? bindedTags.ToList();

            foreach (var bindedTag in bindedTagVms)
            {
                var tagToRemove = SelectedTags.FirstOrDefault(x => x.Tag.Id == bindedTag.Tag.Id && x.Value == bindedTag.Value);
                if (tagToRemove != null)
                {
                    SelectedTags.Remove(tagToRemove);
                }
            }
        }
Esempio n. 2
0
 void RemoveTag_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (e.Parameter is string)
     {
         var tag = (string)e.Parameter;
         var col = new List <string>();
         SelectedTags.Remove(tag);
         col.AddRange(SelectedTags);
         SelectedTags = col;
         OnPropertyChanged(nameof(SelectedTags));
     }
 }
Esempio n. 3
0
        private void UpdateSelectedTagsOnAdd(TagItem addedTag)
        {
            var source = (IList <TagItem>)ItemsSource;

            if (source.Count == SelectedTags.Count) //Update SelectedTags list if user edits tags
            {
                SelectedTags.Where(i => source.All(s => !s.Text.Equals(i) || i.Equals(addedTag.Text)))
                .ToList()
                .ForEach(r => SelectedTags.Remove(r));
            }
            SelectedTags.Add(addedTag.Text);
        }
Esempio n. 4
0
        private void RemoveFromSelectedTags()
        {
            if (SelectedTagsSelectedItem != null)
            {
                if (!Tags.Contains(SelectedTagsSelectedItem))
                {
                    Tags.Add(SelectedTagsSelectedItem);
                    SelectedTags.Remove(SelectedTagsSelectedItem);

                    FilterTaggedObjects();
                }
            }
        }
Esempio n. 5
0
        private void ExecuteUnselectTag(object o)
        {
            var tag = o  as Tag;

            if (tag == null)
            {
                return;
            }

            SelectedTags.Remove(tag);

            UpdateSearchResult();
        }
Esempio n. 6
0
 private void UpdateSelectedTagsOnRemove(TagItem removedTag)
 {
     if (removedTag == null)
     {
         return;
     }
     if (!string.IsNullOrEmpty(removedTag.Text)) // Remove if delete button was clicked
     {
         SelectedTags.Remove(removedTag.Text);
     }
     else  // Remove if backspace was used to delete tag (TagItem Text was changed to empty and was then removed)
     {
         var source = (IList <TagItem>)ItemsSource;
         SelectedTags.Where(i => source.All(s => !s.Text.Equals(i)))
         .ToList()
         .ForEach(r => SelectedTags.Remove(r));
     }
 }
Esempio n. 7
0
        public async ValueTask LoadTags()
        {
            try
            {
                if (Interlocked.Increment(ref _loading) != 1)
                {
                    return;
                }
                if (_loaded)
                {
                    return;
                }
                var tags = await Model.ListTags(_query.QueryString, _query.TypeId, _query.Offset, _query.Limit);

                if (tags != null && tags.Count > 0)
                {
                    _query.Offset += _query.Limit;
                    foreach (var tag in tags.Where(it => SelectedTags.All(tag => tag.ObjectId != it.ObjectId)))
                    {
                        var displayTag = new DisplayTag(tag);
                        displayTag.ClickCommand = new AsyncCommand(async() =>
                        {
                            if (SelectedTags.All(it => it.ObjectId != displayTag.ObjectId))
                            {
                                displayTag.ClickCommand = new AsyncCommand(async() =>
                                {
                                    SelectedTags.Remove(displayTag);
                                });
                                SelectedTags.Add(displayTag);
                            }
                        });
                        SearchResult.Add(displayTag);
                    }
                }
                else
                {
                    _loaded = true;
                }
            }
            finally
            {
                Interlocked.Decrement(ref _loading);
            }
        }
Esempio n. 8
0
 void TagClicked(Tag tag)
 {
     if (SelectedTags.Contains(tag))
     {
         SelectedTags.Remove(tag);
     }
     else
     {
         SelectedTags.RemoveAll(t => t.Group == tag.Group);
         SelectedTags.Add(tag);
     }
     if (Button.TagMode == TagMode.Free)
     {
         StartRecording();
     }
     else
     {
         Active     = true;
         delayEvent = true;
     }
     ReDraw();
 }
 private void RemoveTag(string tag)
 {
     SelectedTags.Remove(tag);
     AvailableTags.Add(tag);
 }