Пример #1
0
        public virtual TreeListViewItem Add(string value, int imageIndex)
        {
            TreeListViewItem treeListViewItem = new TreeListViewItem(value, imageIndex);

            Add(treeListViewItem);
            return(treeListViewItem);
        }
Пример #2
0
        public virtual TreeListViewItem Add(string value)
        {
            TreeListViewItem treeListViewItem = new TreeListViewItem(value);

            Add(treeListViewItem);
            return(treeListViewItem);
        }
Пример #3
0
        private bool ListViewContains(TreeListViewItem item)
        {
            if (TreeListView == null)
            {
                return(false);
            }
            if (TreeListView.InvokeRequired)
            {
                throw new Exception("Invoke required");
            }
            ListView treeListView = TreeListView;

            try
            {
                foreach (ListViewItem item2 in treeListView.Items)
                {
                    if (item2 == item)
                    {
                        return(true);
                    }
                }
            }
            catch
            {
            }
            return(false);
        }
Пример #4
0
        private int GetInsertTreeListViewIndex(TreeListViewItem item, int collectionindex)
        {
            if (TreeListView == null)
            {
                return(-1);
            }
            if (TreeListView != null && TreeListView.InvokeRequired)
            {
                throw new Exception("Invoke required");
            }
            if (Owner != null)
            {
                int num = 0;
                num++;
            }
            int result = -1;

            if (Owner != null && collectionindex != -1)
            {
                result = ((collectionindex != 0) ? (this[collectionindex - 1].LastChildIndexInListView + 1) : 0);
            }
            else if (Parent != null && collectionindex != -1)
            {
                result = ((Parent.Visible && Parent.IsExpanded) ? ((collectionindex == 0) ? (Parent.Index + 1) : (Parent.Items[collectionindex - 1].LastChildIndexInListView + 1)) : (-1));
            }
            return(result);
        }
Пример #5
0
        public virtual bool Contains(TreeListViewItem item)
        {
            if (TreeListView != null && TreeListView.InvokeRequired)
            {
                throw new Exception("Invoke required");
            }
            bool        result     = false;
            IEnumerator enumerator = GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    TreeListViewItem treeListViewItem = (TreeListViewItem)enumerator.Current;
                    if (item == treeListViewItem)
                    {
                        result = true;
                        break;
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            return(result);
        }
Пример #6
0
        private int GetInsertCollectionIndex(TreeListViewItem item)
        {
            if (TreeListView != null && TreeListView.InvokeRequired)
            {
                throw new Exception("Invoke required");
            }
            int num = -1;

            if (!_Sortable)
            {
                num = base.Count;
            }
            else if (!Contains(item) && !ListViewContains(item))
            {
                if (SortOrder == SortOrder.None)
                {
                    num = base.Count;
                }
                else
                {
                    for (int i = 0; i < base.Count; i++)
                    {
                        int num2 = i;
                        int num3 = Comparer.Compare(item, this[num2]);
                        if (num3 <= 0)
                        {
                            num = num2;
                            break;
                        }
                    }
                    num = ((num == -1) ? base.Count : num);
                }
            }
            return(num);
        }
Пример #7
0
 public EditItemInformations(TreeListViewItem item, int column, string label)
 {
     _item        = item;
     _colindex    = column;
     _label       = label;
     CreationTime = DateTime.Now;
 }
Пример #8
0
        public virtual void Remove(TreeListViewItem item)
        {
            TXTreeListView treeListView = TreeListView;

            treeListView?.BeginUpdate();
            RemoveInternal(item);
            treeListView?.EndUpdate();
        }
Пример #9
0
 public bool IsAParentOf(TreeListViewItem item)
 {
     TreeListViewItem[] parentsInHierarch = item.ParentsInHierarch;
     TreeListViewItem[] array             = parentsInHierarch;
     foreach (TreeListViewItem treeListViewItem in array)
     {
         if (treeListViewItem == this)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #10
0
        internal void RemoveInternal(TreeListViewItem item)
        {
            if (TreeListView != null && TreeListView.InvokeRequired)
            {
                throw new Exception("Invoke required");
            }
            int indexOf = GetIndexOf(item);

            if (indexOf != -1)
            {
                RemoveAtInternal(indexOf);
            }
        }
Пример #11
0
        public TreeListViewItem[] ToArray()
        {
            if (TreeListView != null && TreeListView.InvokeRequired)
            {
                throw new Exception("Invoke required");
            }
            int count = base.Count;

            TreeListViewItem[] array = new TreeListViewItem[count];
            for (int i = 0; i < count; i++)
            {
                array[i] = this[i];
            }
            return(array);
        }
Пример #12
0
        public virtual int Add(TreeListViewItem item)
        {
            if (TreeListView != null && TreeListView.InvokeRequired)
            {
                throw new Exception("Invoke required");
            }
            if (TreeListView != null && item.ListView != null)
            {
                throw new Exception("The Item is already in a TreeListView");
            }
            int insertCollectionIndex = GetInsertCollectionIndex(item);

            if (insertCollectionIndex == -1)
            {
                return(-1);
            }
            if (Parent != null)
            {
                item.SetParent(Parent);
            }
            item.Items.Comparer = Comparer;
            int insertTreeListViewIndex = GetInsertTreeListViewIndex(item, insertCollectionIndex);

            if (insertTreeListViewIndex > -1)
            {
                ListView treeListView = TreeListView;
                treeListView.Items.Insert(insertTreeListViewIndex, item);
                if (item.IsExpanded)
                {
                    item.Expand();
                }
                item.SetIndentation();
            }
            if (insertCollectionIndex > -1)
            {
                base.List.Insert(insertCollectionIndex, item);
            }
            if (insertCollectionIndex > -1)
            {
                OnItemAdded(new TreeListViewEventArgs(item, TreeListViewAction.Unknown));
            }
            if (base.Count == 1 && TreeListView != null && Parent != null && Parent.Visible)
            {
                Parent.Redraw();
            }
            return(insertCollectionIndex);
        }
Пример #13
0
        public int GetIndexOf(TreeListViewItem item)
        {
            if (TreeListView != null && TreeListView.InvokeRequired)
            {
                throw new Exception("Invoke required");
            }
            int result = -1;

            for (int i = 0; i < base.Count; i++)
            {
                if (this[i] == item)
                {
                    result = i;
                    break;
                }
            }
            return(result);
        }
Пример #14
0
        private void SetSortOrderRecursively(SortOrder value)
        {
            SortOrder = value;
            IEnumerator enumerator = GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    TreeListViewItem treeListViewItem = (TreeListViewItem)enumerator.Current;
                    treeListViewItem.Items.SortOrderRecursively = value;
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
Пример #15
0
            public int Compare(object x, object y)
            {
                TreeListViewItem treeListViewItem  = (TreeListViewItem)x;
                TreeListViewItem treeListViewItem2 = (TreeListViewItem)y;
                int num = 1;

                if (Column < treeListViewItem.SubItems.Count && Column < treeListViewItem2.SubItems.Count)
                {
                    num = string.CompareOrdinal(treeListViewItem.SubItems[Column].Text.ToUpper(), treeListViewItem2.SubItems[Column].Text.ToUpper());
                }
                switch (SortOrder)
                {
                case SortOrder.Ascending:
                    return(num);

                case SortOrder.Descending:
                    return(-num);

                default:
                    return(1);
                }
            }
Пример #16
0
 internal void SortInternal(bool recursively)
 {
     if (TreeListView != null && TreeListView.InvokeRequired)
     {
         throw new Exception("Invoke required");
     }
     if (_Sortable)
     {
         TreeListViewItem[] array = ToArray();
         ClearInternal();
         TreeListViewItem[] array2 = array;
         foreach (TreeListViewItem item in array2)
         {
             Add(item);
         }
     }
     if (recursively)
     {
         {
             IEnumerator enumerator = GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     TreeListViewItem item = (TreeListViewItem)enumerator.Current;
                     item.Items.SortInternal(recursively: true);
                 }
             }
             finally
             {
                 IDisposable disposable = enumerator as IDisposable;
                 if (disposable != null)
                 {
                     disposable.Dispose();
                 }
             }
         }
     }
 }
Пример #17
0
        internal void RemoveAtInternal(int index)
        {
            if (TreeListView != null && TreeListView.InvokeRequired)
            {
                throw new Exception("Invoke required");
            }
            TreeListViewItem treeListViewItem = this[index];

            if (this[index].Visible && TreeListView != null)
            {
                treeListViewItem.Hide();
            }
            base.List.RemoveAt(index);
            treeListViewItem.SetParent(null);
            if (base.Count == 0 && TreeListView != null && Parent != null)
            {
                Parent.Redraw();
            }
            if (base.Count > 0 && TreeListView != null && index == base.Count)
            {
                this[index - 1].Redraw();
            }
            OnItemRemoved(new TreeListViewEventArgs(treeListViewItem, TreeListViewAction.Unknown));
        }
 public bool Contains(TreeListViewItem item)
 {
     return(Contains((ListViewItem)item));
 }
Пример #19
0
        internal void CollapseInternal()
        {
            if (IsInATreeListView && ListView.InvokeRequired)
            {
                throw new Exception("Invoke Required");
            }
            TreeListViewItem treeListViewItem = null;

            if (TreeListView != null)
            {
                treeListViewItem = TreeListView.FocusedItem;
            }
            if (Visible && _IsExpanded && ListView != null)
            {
                TreeListViewCancelEventArgs treeListViewCancelEventArgs = new TreeListViewCancelEventArgs(this, TreeListViewAction.Collapse);
                ListView.RaiseBeforeCollapse(treeListViewCancelEventArgs);
                if (treeListViewCancelEventArgs.Cancel)
                {
                    return;
                }
            }
            if (Visible)
            {
                foreach (TreeListViewItem item in Items)
                {
                    item.Hide();
                }
            }
            if (Visible && _IsExpanded && IsInATreeListView)
            {
                _IsExpanded = false;
                TreeListViewEventArgs e = new TreeListViewEventArgs(this, TreeListViewAction.Collapse);
                ListView.RaiseAfterCollapse(e);
                if (this.AfterCollapse != null)
                {
                    this.AfterCollapse(this);
                }
            }
            _IsExpanded = false;
            if (IsInATreeListView && treeListViewItem != null)
            {
                if (treeListViewItem.Visible)
                {
                    treeListViewItem.Focused = true;
                }
                else
                {
                    ListView treeListView = TreeListView;
                    treeListView.SelectedItems.Clear();
                    TreeListViewItem[] parentsInHierarch = treeListViewItem.ParentsInHierarch;
                    int num = parentsInHierarch.Length - 1;
                    while (true)
                    {
                        if (num < 0)
                        {
                            return;
                        }
                        if (parentsInHierarch[num].Visible)
                        {
                            break;
                        }
                        num--;
                    }
                    parentsInHierarch[num].Focused = true;
                }
            }
        }
Пример #20
0
        internal void ExpandInternal()
        {
            if (IsInATreeListView && ListView.InvokeRequired)
            {
                throw new Exception("Invoke Required");
            }
            TreeListViewItem treeListViewItem = null;

            if (TreeListView != null)
            {
                treeListViewItem = TreeListView.FocusedItem;
            }
            CheckDirection checkDirection = CheckDirection.All;

            if (ListView != null)
            {
                checkDirection          = ListView.CheckDirection;
                ListView.CheckDirection = CheckDirection.None;
            }
            if (Visible && !_IsExpanded && ListView != null)
            {
                TreeListViewCancelEventArgs treeListViewCancelEventArgs = new TreeListViewCancelEventArgs(this, TreeListViewAction.Expand);
                ListView.RaiseBeforeExpand(treeListViewCancelEventArgs);
                if (treeListViewCancelEventArgs.Cancel)
                {
                    return;
                }
            }
            if (Visible)
            {
                for (int num = Items.Count - 1; num >= 0; num--)
                {
                    TreeListViewItem treeListViewItem2 = Items[num];
                    if (!treeListViewItem2.Visible)
                    {
                        ListView treeListView = TreeListView;
                        treeListView.Items.Insert(base.Index + 1, treeListViewItem2);
                        treeListViewItem2.SetIndentation();
                    }
                    if (treeListViewItem2.IsExpanded)
                    {
                        treeListViewItem2.Expand();
                    }
                }
            }
            if (Visible && !_IsExpanded && IsInATreeListView)
            {
                _IsExpanded = true;
                TreeListViewEventArgs e = new TreeListViewEventArgs(this, TreeListViewAction.Expand);
                ListView.RaiseAfterExpand(e);
                if (this.AfterExpand != null)
                {
                    this.AfterExpand(this);
                }
            }
            _IsExpanded = true;
            if (IsInATreeListView)
            {
                ListView.CheckDirection = checkDirection;
            }
            if (TreeListView != null && treeListViewItem != null && treeListViewItem.Visible)
            {
                treeListViewItem.Focused = true;
            }
        }
Пример #21
0
 public TreeListViewBeforeLabelEditEventArgs(TreeListViewItem item, int column, string label)
     : base(item, column, label)
 {
 }
Пример #22
0
 internal void SetParent(TreeListViewItem parent)
 {
     _Parent = parent;
 }
Пример #23
0
 public TreeListViewLabelEditEventArgs(TreeListViewItem item, int column, string label)
 {
     _Item        = item;
     _columnIndex = column;
     _Label       = label;
 }
Пример #24
0
 public TreeListViewItemCollection(TreeListViewItem parent)
 {
     _Parent = parent;
 }
 public int IndexOf(TreeListViewItem item)
 {
     return(IndexOf((ListViewItem)item));
 }
Пример #26
0
 public TreeListViewEventArgs(TreeListViewItem item, TreeListViewAction action)
 {
     _Item   = item;
     _Action = action;
 }
Пример #27
0
 public TreeListViewCancelEventArgs(TreeListViewItem item, TreeListViewAction action)
     : base(item, action)
 {
 }