예제 #1
0
 private void RemoveTag(TagBase tag)
 {
     lock (this.removalInProcess)
     {
         Debug.WriteLine("Beginning delete of tag " + tag);
         if (this.removalInProcessTag != null)
         {
             Debug.WriteLine("RemovalInProcessTag is " + this.removalInProcessTag);
             if (this.removalInProcessTag == tag)
             {
                 Debug.WriteLine("Cannot delete same tag twice");
                 return;
             }
             FinishRemoveTag(this.removalInProcessTag);
         }
         if (Propagating)
         {
             FinishRemoveTag(tag);
         }
         else
         {
             this.removalInProcessTag = tag;
             tag.DeletedCompleted    += FinishRemoveTag;
             tag.DeleteTag();
         }
     }
 }
예제 #2
0
        private void OnTagSearchRequested(TagBase source, string searchText)
        {
            Console.WriteLine("Search requested from " + this.tagPanel.Children.IndexOf(source));

            SearchSource = source;
            if (SearchMethod == null)
            {
                throw new InvalidOperationException("The tagbox is missing and Action<string> delegate for the SearchMethod");
            }

            SearchMethod.Invoke(searchText.Trim());
        }
예제 #3
0
        private void OnTagAdjacentInsertRequested(TagBase left, string adjacentText, int selectionOffset)
        {
            var num = this.tagPanel.Children.IndexOf(left);

            if (num <= this.tagPanel.Children.Count - 1)
            {
                var unresolvedTag = NewUnresolved();
                unresolvedTag.Text = adjacentText;
                InsertTag(num + 1, unresolvedTag);
                unresolvedTag.Focus(selectionOffset);
            }
        }
예제 #4
0
 private void DetachTagEvents(TagBase tag)
 {
     tag.NavigationRequested     -= OnTagNavigationRequested;
     tag.DeleteRequested         -= OnTagDeleteRequested;
     tag.DeletedCompleted        -= FinishRemoveTag;
     tag.SearchRequested         -= OnTagSearchRequested;
     tag.SelectionRequested      -= OnTagSelectionRequested;
     tag.LostFocus               += OnTagLostFocus;
     tag.GotFocus                += OnTagGotFocus;
     tag.AdjacentInsertRequested -= OnTagAdjacentInsertRequested;
     tag.MergeRequested          -= OnTagMergeRequested;
 }
예제 #5
0
 private void AttachTag(TagBase tag)
 {
     Console.WriteLine("Attaching tag " + tag);
     tag.NavigationRequested     += OnTagNavigationRequested;
     tag.DeleteRequested         += OnTagDeleteRequested;
     tag.SearchRequested         += OnTagSearchRequested;
     tag.SelectionRequested      += OnTagSelectionRequested;
     tag.LostFocus               += OnTagLostFocus;
     tag.GotFocus                += OnTagGotFocus;
     tag.AdjacentInsertRequested += OnTagAdjacentInsertRequested;
     tag.MergeRequested          += OnTagMergeRequested;
     tag.DisplayMemberPath        = DisplayMemberPath;
 }
예제 #6
0
        private void OnTagMergeRequested(TagBase left)
        {
            var num = this.tagPanel.Children.IndexOf(left);

            if (num + 1 < this.tagPanel.Children.Count && left is UnresolvedTag)
            {
                if (this.tagPanel.Children[num + 1] is UnresolvedTag)
                {
                    var unresolvedTag  = this.tagPanel.Children[num + 1] as UnresolvedTag;
                    var unresolvedTag2 = (UnresolvedTag)left;
                    this.removalInProcessDirection = NavigateDirection.Left;
                    RemoveTag(unresolvedTag);
                    unresolvedTag2.MergeText(unresolvedTag.Text);
                }
            }
        }
예제 #7
0
        private int GetRelativeIndex(TagBase tag)
        {
            var num = -1;

            foreach (var tagBase in this.tagPanel.Children.OfType <TagBase>())
            {
                if (!tagBase.IsInvalid)
                {
                    num++;
                }
                if (tagBase == tag)
                {
                    break;
                }
            }
            return(num);
        }
예제 #8
0
        private void OnTagSelectionRequested(TagBase source, SelectionType selectionType)
        {
            if (selectionType == SelectionType.Close)
            {
                HideSearchResults();
            }
            else
            {
                if (this.searchResultsListBox.SelectedIndex == -1 && this.searchResultsListBox.Items.Count > 0)
                {
                    this.searchResultsListBox.SelectedIndex = 0;
                }

                if (this.searchResultsListBox.SelectedItem != null && this.searchResultsPopup.IsOpen)
                {
                    AddSelectedItem(this.searchResultsListBox.SelectedItem);
                    HideSearchResults();
                }
            }
        }
예제 #9
0
        private void FinishRemoveTag(TagBase tag)
        {
            Console.WriteLine("Finish removal of tag");

            var relativeIndex = GetRelativeIndex(tag);
            var num           = this.tagPanel.Children.IndexOf(tag);

            this.tagPanel.Children.Remove(tag);
            DetachTagEvents(tag);

            var num2 = num;

            if (this.removalInProcessDirection == NavigateDirection.Left)
            {
                num2--;
            }

            if (num2 >= this.tagPanel.Children.Count)
            {
                num2 = this.tagPanel.Children.Count - 1;
            }

            if (!Propagating && num2 >= 0)
            {
                Console.WriteLine("focus called as part of removal " + num2);
                ((TagBase)this.tagPanel.Children[num2]).Focus();
            }

            EnableChangePropagation = false;

            if (!Propagating && ItemsSource != null && !tag.IsInvalid)
            {
                ItemsSource.RemoveAt(relativeIndex);
            }

            EnableChangePropagation  = true;
            this.removalInProcessTag = null;
        }
예제 #10
0
        private void OnTagNavigationRequested(TagBase source, NavigateDirection direction)
        {
            switch (direction)
            {
            case NavigateDirection.Up:
                MoveSearchResultsIndex(-1);
                break;

            case NavigateDirection.Down:
                MoveSearchResultsIndex(1);
                break;

            default:
                var num  = this.tagPanel.Children.IndexOf(source);
                var num2 = (int)(num + direction);
                if (num2 >= 0 && num2 < this.tagPanel.Children.Count)
                {
                    Console.WriteLine("focus called after navigation requested: " + direction);
                    ((TagBase)this.tagPanel.Children[num2]).Focus(direction);
                }
                break;
            }
        }
예제 #11
0
        private void OnTagDeleteRequested(TagBase source, NavigateDirection direction)
        {
            var num = this.tagPanel.Children.IndexOf(source);

            Console.WriteLine(string.Concat("DeleteRequested ", num, " ", direction));

            var num2 = (int)(num + direction);

            if (num2 >= 0 && num2 < this.tagPanel.Children.Count)
            {
                var tagBase = this.tagPanel.Children[num2] as TagBase;

                this.removalInProcessDirection = direction;

                if (tagBase is UnresolvedTag && (tagBase as UnresolvedTag).Text.Length > 0)
                {
                    tagBase.Focus(direction);
                }
                else
                {
                    RemoveTag(tagBase);
                }
            }
        }
예제 #12
0
 private void InsertTag(int index, TagBase tag)
 {
     this.tagPanel.Children.Insert(index, tag);
     AttachTag(tag);
 }
예제 #13
0
 private void AddTag(TagBase tag)
 {
     this.tagPanel.Children.Add(tag);
     AttachTag(tag);
 }