예제 #1
0
 private void DrawPlusMinusButtons()
 {
     using (Graphics graphics = base.CreateGraphics())
     {
         foreach (object obj in base.Items)
         {
             DataTreeListViewItem dataTreeListViewItem = (DataTreeListViewItem)obj;
             Rectangle            bounds = dataTreeListViewItem.Bounds;
             if (bounds.Bottom >= base.ClientRectangle.Top)
             {
                 bounds.Width = base.Columns[0].Width;
                 bounds.Intersect(base.ClientRectangle);
                 if (!dataTreeListViewItem.IsLeaf && !bounds.IsEmpty && dataTreeListViewItem.ChildrenItems.Count > 0)
                 {
                     Region clip = graphics.Clip;
                     graphics.SetClip(LayoutHelper.MirrorRectangle(bounds, this));
                     DataTreeListView.DrawPlusMinusButton(graphics, LayoutHelper.MirrorRectangle(dataTreeListViewItem.GetPlusMinusButtonBound(), this), !dataTreeListViewItem.IsExpanded);
                     graphics.Clip = clip;
                 }
                 else if (bounds.Top > base.ClientRectangle.Bottom)
                 {
                     break;
                 }
             }
         }
     }
 }
예제 #2
0
        protected override void OnDrawItem(DrawListViewItemEventArgs e)
        {
            DataTreeListViewItem dataTreeListViewItem = e.Item as DataTreeListViewItem;

            if (e.State != (ListViewItemStates)0 && dataTreeListViewItem != null)
            {
                Rectangle bounds = dataTreeListViewItem.Bounds;
                bounds.Intersect(base.ClientRectangle);
                if (base.Enabled && !bounds.IsEmpty && !dataTreeListViewItem.Selected && !dataTreeListViewItem.BackColorBegin.IsEmpty && !dataTreeListViewItem.BackColorEnd.IsEmpty)
                {
                    using (Brush brush = new LinearGradientBrush(e.Bounds, dataTreeListViewItem.BackColorBegin, dataTreeListViewItem.BackColorEnd, LinearGradientMode.Horizontal))
                    {
                        e.Graphics.FillRectangle(brush, e.Bounds);
                        goto IL_BE;
                    }
                }
                if (base.Enabled && this.BackgroundImage == this.emptyImage)
                {
                    e.DrawBackground();
                }
IL_BE:
                e.DrawDefault = true;
                base.OnDrawItem(e);
            }
        }
 public void Insert(int index, DataTreeListViewItem item)
 {
     if (index < 0 && index > base.Count)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     if (!this.Contains(item))
     {
         base.List.Insert(index, item);
         item.Parent = this.owner;
         if (item.Parent != null)
         {
             this.owner.IsLeaf = false;
             item.IndentCount  = this.owner.IndentCount + 1;
             if (item.Parent.IsExpanded && item.Parent.IsInListView)
             {
                 item.AddToListView(this.ListView);
                 return;
             }
         }
         else
         {
             item.IndentCount = 1;
             item.AddToListView(this.ListView);
         }
     }
 }
예제 #4
0
        protected override void OnListManagerListChanged(ListChangedEventArgs e)
        {
            switch (e.ListChangedType)
            {
            case ListChangedType.ItemAdded:
            case ListChangedType.ItemDeleted:
            case ListChangedType.ItemMoved:
                base.OnListManagerListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
                return;

            case ListChangedType.ItemChanged:
            {
                DataTreeListViewItem dataTreeListViewItem = this.TopItems[e.NewIndex];
                if (dataTreeListViewItem != null)
                {
                    this.InternalUpdateItem(dataTreeListViewItem);
                    return;
                }
                break;
            }

            default:
                base.OnListManagerListChanged(e);
                break;
            }
        }
예제 #5
0
 private void SetExpandedStatusOnRootItems(bool isExpanded, bool isRecursive)
 {
     foreach (object obj in this.TopItems)
     {
         DataTreeListViewItem item = (DataTreeListViewItem)obj;
         this.SetExpandedStatusOnSubItem(item, isExpanded, isRecursive);
     }
 }
        public void Remove(DataTreeListViewItem item)
        {
            int num = this.IndexOf(item);

            if (num >= 0)
            {
                base.RemoveAt(num);
            }
        }
 public DataTreeListViewItemCollection(DataTreeListViewItem owner)
 {
     if (owner == null)
     {
         throw new NotSupportedException();
     }
     this.owner    = owner;
     this.listView = owner.ListView;
 }
 protected override void OnClear()
 {
     foreach (object obj in this)
     {
         DataTreeListViewItem dataTreeListViewItem = (DataTreeListViewItem)obj;
         dataTreeListViewItem.RemoveFromListView();
         dataTreeListViewItem.ClearChildrenDataSources();
     }
 }
 private void RecreateChildItems()
 {
     if (this.ListView != null && this.DataSource != null && this.childDataSources.Count > 0)
     {
         this.ApplySort();
         if (this.ListView.InvokeRequired)
         {
             this.ListView.Invoke(new MethodInvoker(this.RecreateChildItems));
             return;
         }
         this.ListView.BeginUpdate();
         try
         {
             if (this.ChildrenItems.Count > 0)
             {
                 if (this.ChildrenItems[0].IsInListView)
                 {
                     this.ListView.BackupItemsStates();
                 }
                 this.ChildrenItems.Clear();
             }
             foreach (object obj in this.childDataSources)
             {
                 BindingSource bindingSource = (BindingSource)obj;
                 foreach (object obj2 in bindingSource)
                 {
                     DataTreeListViewItem dataTreeListViewItem = this.ListView.InternalCreateListViewItemForRow(obj2);
                     dataTreeListViewItem.ColumnMapping = (DataTreeListViewColumnMapping)this.dataSource2ColumnMapping[bindingSource];
                     dataTreeListViewItem.UpdateItem();
                     if (dataTreeListViewItem.ColumnMapping.ImageIndex < 0)
                     {
                         if (!string.IsNullOrEmpty(this.ListView.ImagePropertyName))
                         {
                             PropertyDescriptorCollection properties         = TypeDescriptor.GetProperties(obj2);
                             PropertyDescriptor           propertyDescriptor = properties[this.ListView.ImagePropertyName];
                             if (propertyDescriptor != null)
                             {
                                 dataTreeListViewItem.ImageKey = DataListView.GetPropertyValue(obj2, propertyDescriptor).ToString();
                             }
                         }
                     }
                     else
                     {
                         dataTreeListViewItem.ImageIndex = dataTreeListViewItem.ColumnMapping.ImageIndex;
                     }
                     this.ChildrenItems.Add(dataTreeListViewItem);
                 }
             }
             this.ListView.RaiseItemsForRowsCreated(EventArgs.Empty);
         }
         finally
         {
             this.ListView.EndUpdate();
         }
         this.ListView.TrySelectItemBySpecifiedIdentity();
     }
 }
예제 #10
0
 public DataTreeListViewItem(DataTreeListView listView, object row, DataTreeListViewItem parentItem)
 {
     this.dataSource = row;
     this.listView   = listView;
     this.IsLeaf     = true;
     this.Parent     = parentItem;
     if (this.Parent != null)
     {
         this.Parent.ChildrenItems.Add(this);
     }
 }
예제 #11
0
 protected override void OnItemsForRowsCreated(EventArgs e)
 {
     this.TopItems.Clear();
     base.RestoreItemsStates(false);
     foreach (object obj in base.Items)
     {
         DataTreeListViewItem item = (DataTreeListViewItem)obj;
         this.TopItems.Add(item);
     }
     this.UpdateTopItemsFontStyle();
     base.OnItemsForRowsCreated(e);
 }
예제 #12
0
 private void SetExpandedStatusOnSubItem(DataTreeListViewItem item, bool isExpanded, bool isRecursive)
 {
     item.IsExpanded = isExpanded;
     if (isRecursive)
     {
         foreach (object obj in item.ChildrenItems)
         {
             DataTreeListViewItem item2 = (DataTreeListViewItem)obj;
             this.SetExpandedStatusOnSubItem(item2, isExpanded, isRecursive);
         }
     }
 }
예제 #13
0
        private void UpdateTopItemsFontStyle()
        {
            Font font = new Font(this.Font, this.Font.Style | FontStyle.Bold);

            base.SuspendLayout();
            foreach (object obj in this.TopItems)
            {
                DataTreeListViewItem dataTreeListViewItem = (DataTreeListViewItem)obj;
                dataTreeListViewItem.Font = font;
            }
            base.ResumeLayout(false);
        }
예제 #14
0
 private void Collapse()
 {
     if (!this.IsLeaf && !this.IsExpanded && this.ListView != null)
     {
         this.ListView.InternalOnCollapseItem(this);
         foreach (object obj in this.ChildrenItems)
         {
             DataTreeListViewItem dataTreeListViewItem = (DataTreeListViewItem)obj;
             dataTreeListViewItem.RemoveFromListView();
         }
     }
 }
예제 #15
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         DataTreeListViewItem dataTreeListViewItem = base.GetItemAt(e.X, e.Y) as DataTreeListViewItem;
         if (dataTreeListViewItem != null && !dataTreeListViewItem.IsLeaf && dataTreeListViewItem.ChildrenItems.Count > 0 && dataTreeListViewItem.GetPlusMinusButtonBound().Contains(e.X, e.Y))
         {
             dataTreeListViewItem.IsExpanded = !dataTreeListViewItem.IsExpanded;
         }
     }
     base.OnMouseDown(e);
 }
예제 #16
0
 protected override void OnItemActivate(EventArgs e)
 {
     if (Control.MouseButtons == MouseButtons.Left)
     {
         Point pt = base.PointToClient(Control.MousePosition);
         DataTreeListViewItem dataTreeListViewItem = (DataTreeListViewItem)base.GetItemAt(pt.X, pt.Y);
         if (dataTreeListViewItem != null && dataTreeListViewItem.ChildrenItems.Count > 0 && !dataTreeListViewItem.IsLeaf && dataTreeListViewItem.GetPlusMinusButtonBound().Contains(pt))
         {
             return;
         }
     }
     base.OnItemActivate(e);
 }
예제 #17
0
        protected override ListViewItem CreateNewListViewItem(object row)
        {
            DataTreeListViewItem dataTreeListViewItem = new DataTreeListViewItem(this, row);

            dataTreeListViewItem.ImageIndex  = base.ImageIndex;
            dataTreeListViewItem.IndentCount = 1;
            dataTreeListViewItem.IsLeaf      = !this.HasChildDataMember(row);
            if (!dataTreeListViewItem.IsLeaf)
            {
                dataTreeListViewItem.IsExpanded = this.AutoExpandNewItem;
            }
            return(dataTreeListViewItem);
        }
예제 #18
0
 internal void ClearChildrenDataSources()
 {
     foreach (object obj in this.childDataSources)
     {
         BindingSource bindingSource = (BindingSource)obj;
         bindingSource.ListChanged -= this.ChildList_ListChanged;
     }
     this.childDataSources.Clear();
     foreach (object obj2 in this.ChildrenItems)
     {
         DataTreeListViewItem dataTreeListViewItem = (DataTreeListViewItem)obj2;
         dataTreeListViewItem.ClearChildrenDataSources();
     }
 }
예제 #19
0
        internal void InternalUpdateItem(DataTreeListViewItem item)
        {
            if (base.InvokeRequired)
            {
                base.Invoke(new DataTreeListView.InternalUpdateItemInvoker(this.InternalUpdateItem), new object[]
                {
                    item
                });
                return;
            }
            ItemCheckedEventArgs e = new ItemCheckedEventArgs(item);

            this.OnUpdateItem(e);
        }
예제 #20
0
 internal void RemoveFromListView()
 {
     this.isInListView = false;
     if (this.IsExpanded)
     {
         foreach (object obj in this.ChildrenItems)
         {
             DataTreeListViewItem dataTreeListViewItem = (DataTreeListViewItem)obj;
             dataTreeListViewItem.RemoveFromListView();
         }
     }
     if (base.ListView != null)
     {
         base.ListView.Items.Remove(this);
     }
 }
예제 #21
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            DataTreeListViewItem dataTreeListViewItem = base.FocusedItem as DataTreeListViewItem;

            if (dataTreeListViewItem != null)
            {
                switch (e.KeyCode)
                {
                case Keys.Left:
                    if (dataTreeListViewItem.IsExpanded)
                    {
                        dataTreeListViewItem.IsExpanded = false;
                        e.Handled = true;
                    }
                    else if (dataTreeListViewItem.Parent != null)
                    {
                        base.SelectedIndices.Clear();
                        dataTreeListViewItem.Parent.Selected = true;
                        dataTreeListViewItem.Parent.Focused  = true;
                        e.Handled = true;
                    }
                    break;

                case Keys.Right:
                    if (dataTreeListViewItem.IsExpanded)
                    {
                        if (dataTreeListViewItem.ChildrenItems.Count > 0)
                        {
                            base.SelectedIndices.Clear();
                            dataTreeListViewItem.ChildrenItems[0].Selected = true;
                            dataTreeListViewItem.ChildrenItems[0].Focused  = true;
                            e.Handled = true;
                        }
                    }
                    else if (!dataTreeListViewItem.IsLeaf)
                    {
                        dataTreeListViewItem.IsExpanded = true;
                        e.Handled = true;
                    }
                    break;
                }
            }
            if (!e.Handled)
            {
                base.OnKeyDown(e);
            }
        }
예제 #22
0
        private void ChildList_ListChanged(object sender, ListChangedEventArgs e)
        {
            if (this.ListView == null)
            {
                this.ChildrenItems.Clear();
                this.IsExpanded = false;
                this.childDataSources.Clear();
                return;
            }
            IList list = sender as IList;

            if (list != null)
            {
                switch (e.ListChangedType)
                {
                case ListChangedType.Reset:
                case ListChangedType.ItemDeleted:
                    this.ListView.SelectedIndices.Clear();
                    this.ListView.RaiseSelectionChanged();
                    this.RecreateChildItems();
                    return;

                case ListChangedType.ItemChanged:
                {
                    object row = list[e.NewIndex];
                    DataTreeListViewItem dataTreeListViewItem = this.ListView.GetItemFromRow(row) as DataTreeListViewItem;
                    if (dataTreeListViewItem == null)
                    {
                        return;
                    }
                    if (this.ListView.InvokeRequired)
                    {
                        this.ListView.Invoke(new MethodInvoker(dataTreeListViewItem.UpdateItem));
                        return;
                    }
                    dataTreeListViewItem.UpdateItem();
                    return;
                }
                }
                this.RecreateChildItems();
            }
        }
예제 #23
0
 private void Expand()
 {
     if (!this.IsLeaf && this.IsExpanded && this.ListView != null)
     {
         this.ListView.InternalOnExpandItem(this);
         int index = base.Index;
         foreach (object obj in this.ChildrenItems)
         {
             DataTreeListViewItem dataTreeListViewItem = (DataTreeListViewItem)obj;
             dataTreeListViewItem.AddToListView(this.listView);
         }
         foreach (object obj2 in this.ChildrenItems)
         {
             DataTreeListViewItem dataTreeListViewItem2 = (DataTreeListViewItem)obj2;
             if (dataTreeListViewItem2.IsExpanded)
             {
                 dataTreeListViewItem2.Expand();
             }
         }
     }
 }
예제 #24
0
 internal void InternalOnCollapseItem(DataTreeListViewItem item)
 {
     this.OnCollapseItem(new ItemCheckedEventArgs(item));
     base.Invalidate(item.Bounds);
 }
 public void Add(DataTreeListViewItem item)
 {
     this.Insert(base.Count, item);
 }