예제 #1
0
        /// <summary>
        /// Callback to determine if an item in the tree is filtered in (return true) or out</summary>
        /// <param name="item">Item tested for filtering</param>
        /// <returns>True if filtered in, false if filtered out</returns>
        public bool DefaultFilter(object item)
        {
            IItemView itemView = TreeView.As <IItemView>();

            if (itemView != null)
            {
                ItemInfo info = new WinFormsItemInfo();
                itemView.GetInfo(item, info);
                return(SearchInputUI.IsNullOrEmpty() || SearchInputUI.Matches(info.Label));
            }
            return(true); // Don't filter anything if the context doesn't implement IItemView
        }
        private void TreeControl_NodeExpandedChanging(object sender, TreeControl.CancelNodeEventArgs e)
        {
            var treeView = TreeView.As <FilteredTreeView>();

            // early exit
            if (m_updating || !m_searching || e.Node.Tag == null ||
                treeView == null)
            {
                return;
            }

            // is the node or any of its decendants passed filter
            if (treeView.IsMatched(e.Node.Tag))
            {
                if (e.Node.Expanded)
                {
                    if (!treeView.IsFullyExpaned(e.Node.Tag))
                    {
                        // add all the children that did not pass
                        // the filtering to the exempted set.
                        treeView.AddToExemptSet(e.Node.Tag);

                        // save e.Node and expand it in NodeExpandedChanged event handler.
                        m_toExpand = e.Node;
                    }

                    if (RestoreSubExpansion)
                    {
                        treeView.SaveExpansion(e.Node);
                    }
                } // end of if (e.Node.Expanded )
                else
                { // e.Node about to expand. Remove all its children from exempted set.
                  // so normal filtering will be applied.
                    treeView.RemoveFromExemptSet(e.Node.Tag);
                }
            }//  end of if(treeView.IsMatched(e.Node.Tag))
            else
            {
                if (e.Node.Expanded)
                {
                    if (RestoreSubExpansion)
                    {
                        treeView.SaveExpansion(e.Node);
                    }
                }
                else
                {
                    treeView.AddToExemptSet(e.Node.Tag);
                }
            }
        }
        /// <summary>
        /// Callback to determine if an item in the tree is filtered in (return true) or out</summary>
        /// <param name="item">Item tested for filtering</param>
        /// <returns>True if filtered in, false if filtered out</returns>
        public bool DefaultFilter(object item)
        {
            bool      result   = true;
            IItemView itemView = TreeView.As <IItemView>();

            if (!SearchInputUI.IsNullOrEmpty())
            {
                ItemInfo info = new WinFormsItemInfo();
                itemView.GetInfo(item, info);
                result = info.Label != null && SearchInputUI.Matches(info.Label);
            }
            return(result);
        }
예제 #4
0
        /// <summary>
        /// Callback to determine if an item in the tree is filtered in (return true) or out</summary>
        /// <param name="item">Item tested for filtering</param>
        /// <returns>True if filtered in, false if filtered out</returns>
        public bool DefaultFilter(object item)
        {
            bool      result   = true;
            IItemView itemView = TreeView.As <IItemView>();

            if (m_TagPanel.TagList.Count != 0)
            {
                ItemInfo info = new WinFormsItemInfo();
                itemView.GetInfo(item, info);
                result = info.Label != null && m_TagPanel.Matches(info.Label);
            }
            return(result);
        }
예제 #5
0
        /// <summary>
        /// Gets header for the specified item; columns are optional.
        /// </summary>
        IEnumerable GetHeader(TreeView TreeView, TreeViewItem TreeViewItem)
        {
            var Source = new ObservableCollection <object>();

            if (TreeView is TreeViewExt && TreeView.As <TreeViewExt>().Columns.Count > 0)
            {
                var t = TreeView as TreeViewExt;
                t.Columns.For(0, t.Columns.Count, (a, b) => Source.Add(GetColumnContent(a[b], TreeViewItem)));
            }
            else
            {
                Source.Add(GetDefaultHeader(TreeViewItem));
            }
            return(Source);
        }
예제 #6
0
        /// <summary>
        /// Delete selected objects</summary>
        private bool Delete()
        {
            var instancingContext = TreeView.As <IInstancingContext>();

            if (instancingContext.CanDelete())
            {
                var transactionContext = TreeView.As <ITransactionContext>();
                transactionContext.DoTransaction(
                    delegate
                {
                    instancingContext.Delete();
                    ISelectionContext selectionContext = TreeView.As <ISelectionContext>();
                    if (selectionContext != null)
                    {
                        selectionContext.Clear();
                    }
                },
                    m_deleteBookmark.Text);
                return(true);
            }
            return(false);
        }