예제 #1
0
        private void OnTreeViewItemMouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                draggedItem = null;

                Point currentPosition            = e.GetPosition(InternalTreeView);
                LibraryItemViewModel draggedView = (LibraryItemViewModel)InternalTreeView.SelectedItem;
                if (draggedView != null)
                {
                    draggedItem = draggedView.LibraryItem;
                }
                if ((draggedItem != null) && (draggedItem.Level > 0))
                {
                    DragDropEffects dragEffect;

                    while ((draggedItem.ItemType == NodeType.None) && (draggedItem.Children != null))
                    {
                        draggedItem = draggedItem.Children[0];
                    }
                    if (draggedItem.ItemType != NodeType.None)
                    {
                        dragEffect = DragDrop.DoDragDrop(InternalTreeView, draggedItem,
                                                         DragDropEffects.Move);
                    }
                }
            }
        }
        private LibraryItemViewModel(LibraryItem libraryItem, LibraryItemViewModel parent, LibraryView libraryView)
        {
            this.libraryView = libraryView;

            this.libraryItem = libraryItem;
            this.parent      = parent;
            this.children    = new ObservableCollection <LibraryItemViewModel>();

            this.isExpanded = false;
            this.isSelected = false;
            this.visibility = Visibility.Visible;

            //this.header = new List<LibraryView.DecoratedString>();
            //LibraryView.DecoratedString item = new LibraryView.DecoratedString();
            //item.isHilighted = false;
            //item.text = this.libraryItem.DisplayText;
            //this.header.Add(item);

            this.prePiece       = this.libraryItem.DisplayText;
            this.highlightPiece = string.Empty;
            this.postPiece      = string.Empty;

            if (this.libraryItem.Children != null && this.libraryItem.Children.Count > 0)
            {
                foreach (LibraryItem childItem in libraryItem.Children)
                {
                    this.children.Add(new LibraryItemViewModel(childItem, this, libraryView));
                }
            }
        }
예제 #3
0
        private void OnTreeViewItemAddToCanvas(object sender, RoutedEventArgs e)
        {
            LibraryItemViewModel libraryItem = ((MenuItem)sender).DataContext as LibraryItemViewModel;

            if (libraryItem != null)
            {
                graphControl.CurrentGraphCanvas.VisualHost.HandleAddNodeToCanvas(libraryItem.LibraryItem);
            }
        }
예제 #4
0
        private void HighlightItemHeader(LibraryItemViewModel libraryItem)
        {
            String displayText = libraryItem.DisplayText.ToLower();
            int    index       = displayText.IndexOf(keyword.ToLower());

            libraryItem.PrePiece       = libraryItem.DisplayText.Substring(0, index);
            libraryItem.HighlightPiece = libraryItem.DisplayText.Substring(index, keyword.Count());
            libraryItem.PostPiece      = libraryItem.DisplayText.Substring(index + keyword.Count());
        }
예제 #5
0
        private bool UpdateTreeViewItem(LibraryItemViewModel libraryItem)
        {
            //if (libraryItem.Children.Count < 1)
            //    return false;

            bool isChildVisible = false;

            // update child
            foreach (LibraryItemViewModel childItem in libraryItem.Children)
            {
                bool isVisible = false;

                isVisible = UpdateTreeViewItem(childItem);
                if (isVisible)
                {
                    isChildVisible = true;
                }
            }

            if (libraryItem.Visibility == Visibility.Visible)
            {
                // libraryItem matches the search keyword, highlight the text
                HighlightItemHeader(libraryItem);

                // if the root is the fully match the search keywords, then all the child of the root should be shown
                if (libraryItem.DisplayText.ToLower() == keyword.ToLower())
                {
                    ExpandChildItem(libraryItem);
                }
                else if (isChildVisible)
                {
                    libraryItem.IsExpanded = true;
                }
            }
            else
            {
                ResetItemHeader(libraryItem);
                if (isChildVisible) //if there is child that is visible, the root should be visible as well,
                {
                    libraryItem.Visibility = Visibility.Visible;
                    libraryItem.IsExpanded = true;
                }
                else if (libraryItem.Level == 0)
                {
                    libraryItem.Visibility = Visibility.Visible;
                }
                else
                {
                    libraryItem.Visibility = Visibility.Collapsed;
                    return(false);   // when there is no child visible and it self is not visible, the whole item is hidden
                }
            }

            return(true);
        }
예제 #6
0
        private void OnTreeViewItemRefresh(object sender, RoutedEventArgs e)
        {
            LibraryItemViewModel libraryItem = ((MenuItem)sender).DataContext as LibraryItemViewModel;

            if (libraryItem == null)
            {
                return;
            }

            ClassFactory.CurrCoreComponent.RefreshAssembly(libraryItem.DisplayText);
        }
예제 #7
0
        private void OnTreeViewItemCollapse(object sender, RoutedEventArgs e)
        {
            LibraryItemViewModel libraryItem = ((MenuItem)sender).DataContext as LibraryItemViewModel;

            if (libraryItem == null)
            {
                return;
            }

            libraryItem.IsSelected = true;
            libraryItem.IsExpanded = false;
        }
예제 #8
0
        private void ResetTreeView()
        {
            libraryTree.RootItems[0].Visibility = Visibility.Collapsed;

            for (int i = 1; i < libraryTree.RootItems.Count; i++)
            {
                LibraryItemViewModel libraryItem = libraryTree.RootItems[i];
                ResetTreeViewItem(libraryItem);
                libraryItem.Visibility = Visibility.Visible;
                libraryItem.IsExpanded = false;
                ResetItemHeader(libraryItem);
            }
        }
예제 #9
0
        private void OnTreeViewItemDoubleClick(object sender, MouseEventArgs e)
        {
            LibraryItemViewModel selectedItem = ((TreeViewItem)sender).Header as LibraryItemViewModel;

            if (selectedItem != null)
            {
                LibraryItem selectedLibraryItem = selectedItem.LibraryItem;
                if (selectedLibraryItem.ItemType != NodeType.None)
                {
                    graphControl.CurrentGraphCanvas.VisualHost.HandleAddNodeToCanvas(selectedLibraryItem);
                }
            }
            e.Handled = true;
        }
예제 #10
0
        private void OnTreeViewItemExpandCollapse(object sender, MouseEventArgs e)
        {
            LibraryItemViewModel libraryItem  = null;
            TreeViewItem         treeViewItem = ((Border)sender).TemplatedParent as TreeViewItem;

            if (treeViewItem != null)
            {
                libraryItem = treeViewItem.Header as LibraryItemViewModel;
            }

            if (libraryItem == null)
            {
                return;
            }

            libraryItem.IsSelected = true;

            if (libraryItem.Children != null && libraryItem.Children.Count > 0)
            {
                if (libraryItem.IsExpanded && libraryItem.IsChildVisible)
                {
                    libraryItem.IsExpanded = false;
                }
                else
                {
                    libraryItem.IsExpanded = true;

                    // make the filtered out item visible
                    ExpandChildItem(libraryItem);
                }
            }

            //Request Bring into View
            if (libraryItem.IsExpanded && libraryItem.Level == 0)
            {
                internalRequestBeingIntoView = true;
                treeViewItem.BringIntoView();

                // to ensure the header of the item is shown
                Border bd = FindVisualChild <Border>(treeViewItem, "Exp");
                if (bd != null)
                {
                    internalRequestBeingIntoView = true;
                    bd.BringIntoView();
                }
            }

            e.Handled = true;
        }
예제 #11
0
        private void ResetTreeViewItem(LibraryItemViewModel libraryItem)
        {
            if (libraryItem.Children.Count <= 0)
            {
                return;
            }

            foreach (LibraryItemViewModel childItem in libraryItem.Children)
            {
                ResetTreeViewItem(childItem);
                childItem.Visibility = Visibility.Visible;
                childItem.IsExpanded = false;
                ResetItemHeader(childItem);
            }
        }
예제 #12
0
        private void ExpandAllChildItem(LibraryItemViewModel libraryItem)
        {
            if (libraryItem.Children.Count <= 0)
            {
                return;
            }

            foreach (LibraryItemViewModel childItem in libraryItem.Children)
            {
                childItem.Visibility = Visibility.Visible;
                ExpandAllChildItem(childItem);
            }

            libraryItem.IsExpanded = true;
        }
예제 #13
0
        private int GetExpansionLevel()
        {
            int maxExpansionLevel = -1;

            for (int i = 1; i < libraryTree.RootItems.Count; i++)
            {
                LibraryItemViewModel item = libraryTree.RootItems[i];
                int expansionLevel        = GetExpansionLevel(item);
                if (maxExpansionLevel < expansionLevel)
                {
                    maxExpansionLevel = expansionLevel;
                }
            }

            return(maxExpansionLevel);
        }
예제 #14
0
        private void OnTreeViewItemExpand(object sender, RoutedEventArgs e)
        {
            LibraryItemViewModel libraryItem = ((MenuItem)sender).DataContext as LibraryItemViewModel;

            if (libraryItem == null)
            {
                return;
            }

            libraryItem.IsSelected = true;
            if (!libraryItem.IsExpanded)
            {
                libraryItem.IsExpanded = true;
                ExpandChildItem(libraryItem);
            }
        }
예제 #15
0
        private void InitializeSearchList(LibraryItemViewModel libraryItem)
        {
            if (libraryItem.Children == null)
            {
                return;
            }

            foreach (LibraryItemViewModel item in libraryItem.Children)
            {
                SearchItem searchItem = new SearchItem();
                searchItem.searchItem = item;
                searchItem.searchName = item.DisplayText.ToLower(); //ignore the letter case
                searchList.Add(searchItem);

                InitializeSearchList(item);
            }
        }
예제 #16
0
        private void ToggleLibraryItem(LibraryItemViewModel libraryItem, ExpansionFlag expansion)
        {
            bool expanded = expansion == ExpansionFlag.DeepExpanded;

            foreach (LibraryItemViewModel item in libraryItem.Children)
            {
                item.IsExpanded = expanded;
                if (item.Children.Count > 0)
                {
                    ToggleLibraryItem(item, expansion);
                }
                if (expanded) // expand overloaded method
                {
                    ExpandChildItem(item);
                }
            }
        }
        public LibraryTreeViewModel(LibraryItem libary, LibraryView libraryView)
        {
            this.libraryView = libraryView;

            this.libary = new LibraryItemViewModel(libary, libraryView);
            rootItems   = new ObservableCollection <LibraryItemViewModel>();

            foreach (LibraryItem rootItem in libary.Children)
            {
                rootItems.Add(new LibraryItemViewModel(rootItem, libraryView));
            }

            if (rootItems[0].DisplayText == Configurations.NoResultMessage)
            {
                rootItems[0].Visibility = Visibility.Collapsed;
            }
        }
예제 #18
0
        private void UpdateTreeView()
        {
            for (int i = 1; i < libraryTree.RootItems.Count(); i++)
            {
                UpdateTreeViewItem(libraryTree.RootItems[i]);
            }

            LibraryItemViewModel notFoundItem = libraryTree.RootItems[0];

            if (resultList.Count() == 0)
            {
                notFoundItem.Visibility = Visibility.Visible;
                for (int i = 1; i < libraryTree.RootItems.Count(); i++)
                {
                    libraryTree.RootItems[i].Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                notFoundItem.Visibility = Visibility.Collapsed;
            }
        }
예제 #19
0
        private void ExpandChildItem(LibraryItemViewModel libraryItem)
        {
            if (libraryItem.Children.Count <= 0)
            {
                return;
            }

            // Set the visibility to true to all the child
            // (applies to items expand items after search)
            // Expand the child if it's a overload folder
            foreach (LibraryItemViewModel childItem in libraryItem.Children)
            {
                childItem.Visibility = Visibility.Visible;

                // expand overloaded method
                if (childItem.Children != null && childItem.Children.Count > 0 && childItem.IsOverloaded)
                {
                    ExpandChildItem(childItem);
                }
            }

            libraryItem.IsExpanded = true;
        }
예제 #20
0
        private int GetExpansionLevel(LibraryItemViewModel libraryItem)
        {
            int MaxChildExpansionLevel = -1;

            if (libraryItem.Children.Count < 1 || !libraryItem.IsExpanded)
            {
                return(1);
            }
            if (libraryItem.IsExpanded && libraryItem.IsOverloaded) // overloaded function folder
            {
                return(1);
            }

            foreach (LibraryItemViewModel item in libraryItem.Children)
            {
                int childExpansionLevel = GetExpansionLevel(item);
                if (MaxChildExpansionLevel < childExpansionLevel)
                {
                    MaxChildExpansionLevel = childExpansionLevel;
                }
            }

            return(MaxChildExpansionLevel + 1);
        }
예제 #21
0
 private void ResetItemHeader(LibraryItemViewModel libraryItem)
 {
     libraryItem.PrePiece       = libraryItem.DisplayText;
     libraryItem.HighlightPiece = string.Empty;
     libraryItem.PostPiece      = string.Empty;
 }