Esempio n. 1
0
        protected virtual ListViewDataItem GetUpperItem(ListViewDataItem currentItem)
        {
            ListViewTraverser enumerator = this.Scroller.Traverser.GetEnumerator() as ListViewTraverser;

            enumerator.Position = (object)currentItem;
            int num1 = 0;

            while (enumerator.MovePrevious() && enumerator.Current != null && !enumerator.Current.IsLastInRow)
            {
                num1 += this.GetItemFlowOffset(enumerator.Current);
            }
            if (!(currentItem is ListViewDataItemGroup) && currentItem != null)
            {
                num1 += this.GetItemFlowOffset(currentItem) / 2;
            }
            if (enumerator.Position == null)
            {
                return((ListViewDataItem)null);
            }
            do
            {
                ;
            }while (enumerator.MovePrevious() && enumerator.Current != null && !enumerator.Current.IsLastInRow);
            int num2 = 0;

            while (enumerator.MoveNext() && !enumerator.Current.IsLastInRow && num2 + this.GetItemFlowOffset(enumerator.Current) < num1)
            {
                num2 += this.GetItemFlowOffset(enumerator.Current);
            }
            return(enumerator.Current);
        }
        public bool Remove(ListViewDataItem item)
        {
            ListViewTraverser traverser = this.owner.ViewElement.Scroller.Traverser.GetEnumerator() as ListViewTraverser;

            traverser.Position = item;
            if (traverser.MovePrevious() && traverser.Current != null && traverser.Current != item)
            {
                this.owner.SelectedItem = traverser.Current;
            }
            else
            {
                traverser.Position = item;
                if (traverser.MoveNext() && traverser.Current != item)
                {
                    this.owner.SelectedItem = traverser.Current;
                }
                else
                {
                    this.owner.SelectedItem = null;
                }
            }

            bool result = this.owner.ListSource.Remove(item);

            item.Owner = null;
            this.owner.SelectedItems.ProcessSelectedItem(item);
            return(result);
        }
Esempio n. 3
0
        public override AccessibleObject GetChild(int index)
        {
            ListViewTraverser enumerator = this.ListView.ListViewElement.ViewElement.Scroller.Traverser.GetEnumerator() as ListViewTraverser;

            enumerator.Reset();
            int num = -1;

            if (this.ListView.ViewType == ListViewType.DetailsView && this.ListView.ShowColumnHeaders)
            {
                if (index == 0)
                {
                    return((AccessibleObject) new ListViewHeaderRowAccessibleObject((this.listView.ListViewElement.ViewElement as DetailListViewElement).ColumnContainer, this.ListView.ListViewElement));
                }
                num = 0;
            }
            while (enumerator.MoveNext())
            {
                ++num;
                if (num == index)
                {
                    if (enumerator.Current is ListViewDataItemGroup)
                    {
                        return((AccessibleObject) new ListViewDataGroupAccessibleObject(enumerator.Current as ListViewDataItemGroup));
                    }
                    if (this.ListView.ViewType == ListViewType.DetailsView)
                    {
                        return((AccessibleObject) new ListViewRowAccessibleObject(enumerator.Current));
                    }
                    return((AccessibleObject) new ListViewDataItemAccessibleObject(enumerator.Current));
                }
            }
            return((AccessibleObject)null);
        }
Esempio n. 4
0
 protected override void ProcessLassoSelection(Rectangle selectionRect)
 {
     if (!this.Owner.MultiSelect)
     {
         base.ProcessLassoSelection(selectionRect);
     }
     else
     {
         ListViewTraverser enumerator = this.Scroller.Traverser.GetEnumerator() as ListViewTraverser;
         int headerHeight             = (int)this.Owner.HeaderHeight;
         enumerator.Reset();
         while (enumerator.MoveNext())
         {
             if (enumerator.Current.Owner == this.Owner)
             {
                 Rectangle rectangle = new Rectangle(new Point(!this.Owner.ShowGroups || this.Owner.Groups.Count <= 0 || !this.Owner.EnableCustomGrouping && !this.Owner.EnableGrouping ? 0 : this.GroupIndent, headerHeight), enumerator.Current.ActualSize);
                 if (this.RightToLeft)
                 {
                     rectangle = LayoutUtils.RTLTranslateNonRelative(rectangle, this.ViewElement.ControlBoundingRectangle);
                 }
                 this.ProcessItemLassoSelection(enumerator.Current, selectionRect.IntersectsWith(rectangle));
                 headerHeight += enumerator.Current.ActualSize.Height + this.ItemSpacing;
             }
         }
     }
 }
Esempio n. 5
0
        protected override void EnsureItemVisibleVerticalCore(ListViewDataItem item)
        {
            int offset    = 0;
            int maxHeight = 0;
            ListViewTraverser traverser = (ListViewTraverser)this.Scroller.Traverser.GetEnumerator();

            BaseListViewVisualItem visualItem = null;

            while (traverser.MoveNext())
            {
                maxHeight = Math.Max(maxHeight, (int)ViewElement.ElementProvider.GetElementSize(traverser.Current).Height + this.ItemSpacing);

                if (!traverser.Current.IsLastInRow)
                {
                    continue;
                }

                this.SetScrollValue(this.VScrollBar, this.VScrollBar.Value + offset);
                this.UpdateLayout();
                visualItem = this.GetElement(item);

                if (visualItem != null)
                {
                    if (visualItem.ControlBoundingRectangle.Bottom > this.ViewElement.ControlBoundingRectangle.Bottom)
                    {
                        this.EnsureItemVisible(item);
                    }

                    break;
                }

                offset += maxHeight;
            }
        }
Esempio n. 6
0
        public bool HasVisibleItems()
        {
            ListViewTraverser enumerator = this.Data.Owner.ViewElement.Scroller.Traverser.GetEnumerator() as ListViewTraverser;

            enumerator.Position = (object)this.Data;
            return(enumerator.MoveNext() && !(enumerator.Current is ListViewDataItemGroup));
        }
Esempio n. 7
0
        public System.Collections.IEnumerator GetEnumerator()
        {
            if (enumerator == null)
            {
                this.enumerator = new ListViewTraverser(this.owner);
            }

            this.enumerator.Position          = this.position;
            this.enumerator.currentItemIndex  = this.currentItemIndex;
            this.enumerator.currentGroupIndex = this.currentGroupIndex;
            return(enumerator);
        }
Esempio n. 8
0
 protected override void EnsureItemVisibleVerticalCore(ListViewDataItem item)
 {
     if (this.Orientation == Orientation.Horizontal)
     {
         this.EnsureItemVisibleHorizontal(item);
     }
     else
     {
         int val1 = 0;
         BaseListViewVisualItem element1 = this.GetElement(item);
         if (element1 == null)
         {
             this.Scroller.ScrollToItem(item);
             this.Scroller.Scrollbar.PerformLargeDecrement(1);
             this.ViewElement.UpdateLayout();
             element1 = this.GetElement(item);
         }
         if (element1 != null)
         {
             if (element1.ControlBoundingRectangle.Bottom <= this.ViewElement.ControlBoundingRectangle.Bottom)
             {
                 return;
             }
             this.EnsureItemVisible(item);
         }
         else
         {
             ListViewTraverser enumerator = (ListViewTraverser)this.Scroller.Traverser.GetEnumerator();
             while (enumerator.MoveNext())
             {
                 val1 = Math.Max(val1, (int)this.ViewElement.ElementProvider.GetElementSize(enumerator.Current).Height + this.ItemSpacing);
                 if (enumerator.Current.IsLastInRow)
                 {
                     this.SetScrollValue(this.VScrollBar, this.VScrollBar.Value + val1);
                     val1 = 0;
                     this.UpdateLayout();
                     BaseListViewVisualItem element2 = this.GetElement(item);
                     if (element2 != null)
                     {
                         if (element2.ControlBoundingRectangle.Bottom <= this.ViewElement.ControlBoundingRectangle.Bottom)
                         {
                             break;
                         }
                         this.EnsureItemVisible(item);
                         break;
                     }
                 }
             }
         }
     }
 }
Esempio n. 9
0
        private int GetGroupsHeight()
        {
            int val1 = 0;
            ListViewTraverser enumerator = this.Traverser.GetEnumerator() as ListViewTraverser;

            enumerator.Reset();
            while (enumerator.MoveNext())
            {
                if (enumerator.Current is ListViewDataItemGroup)
                {
                    val1 = Math.Max(val1, enumerator.Current.ActualSize.Height);
                }
            }
            return(val1);
        }
Esempio n. 10
0
        /// <summary>
        /// Gets the next visible item of a given <see cref="ListViewDataItem"/>.
        /// </summary>
        /// <param name="currentItem">The current item.</param>
        /// <returns>The next item.</returns>
        protected virtual ListViewDataItem GetNextItem(ListViewDataItem currentItem)
        {
            ListViewTraverser enumerator = this.Scroller.Traverser.GetEnumerator() as ListViewTraverser;

            enumerator.Position = currentItem;

            if (enumerator.MoveNext())
            {
                return(enumerator.Current);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 11
0
        protected virtual ListViewDataItem GetDownerItem(ListViewDataItem currentItem)
        {
            ListViewTraverser enumerator = this.Scroller.Traverser.GetEnumerator() as ListViewTraverser;

            enumerator.Position = currentItem;
            int currentItemX = 0;

            while (enumerator.MovePrevious() &&
                   enumerator.Current != null && !enumerator.Current.IsLastInRow)
            {
                currentItemX += enumerator.Current.ActualSize.Width;
            }

            if (!(currentItem is ListViewDataItemGroup) && currentItem != null)
            {
                currentItemX += currentItem.ActualSize.Width / 2;
            }

            enumerator.Position = currentItem;

            while (currentItem != null &&
                   !currentItem.IsLastInRow &&
                   enumerator.MoveNext() &&
                   !enumerator.Current.IsLastInRow)
            {
            }

            int x = 0;

            while (enumerator.MoveNext())
            {
                if (x + enumerator.Current.ActualSize.Width >= currentItemX)
                {
                    return(enumerator.Current);
                }

                x += enumerator.Current.ActualSize.Width;

                if (enumerator.Current.IsLastInRow)
                {
                    break;
                }
            }

            return(null);
        }
Esempio n. 12
0
        public override int GetChildCount()
        {
            if (this.ListView.IsDisposed)
            {
                return(0);
            }
            ListViewTraverser enumerator = this.ListView.ListViewElement.ViewElement.Scroller.Traverser.GetEnumerator() as ListViewTraverser;

            enumerator.Reset();
            int num = 0;

            while (enumerator.MoveNext())
            {
                ++num;
            }
            return(num);
        }
Esempio n. 13
0
        private int GetItemIndex(ListViewDataItem item)
        {
            ListViewTraverser enumerator = (ListViewTraverser)this.Scroller.Traverser.GetEnumerator();

            enumerator.Position = null;
            int index = 0;

            while (enumerator.MoveNext())
            {
                if (enumerator.Current == item)
                {
                    return(index);
                }

                index++;
            }

            return(-1);
        }
Esempio n. 14
0
        public bool Remove(ListViewDataItem item)
        {
            ListViewTraverser enumerator = this.owner.ViewElement.Scroller.Traverser.GetEnumerator() as ListViewTraverser;

            enumerator.Position = (object)item;
            if (enumerator.MovePrevious() && enumerator.Current != null && enumerator.Current != item)
            {
                this.owner.SelectedItem = enumerator.Current;
            }
            else
            {
                enumerator.Position     = (object)item;
                this.owner.SelectedItem = !enumerator.MoveNext() || enumerator.Current == item ? (ListViewDataItem)null : enumerator.Current;
            }
            bool flag = this.owner.ListSource.Remove(item);

            item.Owner = (RadListViewElement)null;
            this.owner.SelectedItems.ProcessSelectedItem(item);
            this.owner.CheckedItems.ProcessCheckedItem(item);
            return(flag);
        }
Esempio n. 15
0
        /// <summary>
        /// Ensures that a given <see cref="ListViewDataItem"/> is visible when it is below the last visible item in the view.
        /// </summary>
        /// <param name="item">The item to ensure visibility of.</param>
        protected virtual void EnsureItemVisibleVerticalCore(ListViewDataItem item)
        {
            if (item == null)
            {
                return;
            }

            bool                   start       = false;
            int                    offset      = 0;
            ListViewDataItem       lastVisible = ((BaseListViewVisualItem)this.ViewElement.Children[this.ViewElement.Children.Count - 1]).Data;
            ListViewTraverser      traverser   = (ListViewTraverser)this.Scroller.Traverser.GetEnumerator();
            BaseListViewVisualItem visualItem  = null;

            while (traverser.MoveNext())
            {
                if (traverser.Current == item)
                {
                    this.SetScrollValue(this.VScrollBar, this.VScrollBar.Value + offset);
                    this.UpdateLayout();
                    visualItem = this.GetElement(item);

                    if (visualItem != null &&
                        visualItem.ControlBoundingRectangle.Bottom > this.ViewElement.ControlBoundingRectangle.Bottom)
                    {
                        this.EnsureItemVisible(item);
                    }
                    break;
                }
                if (traverser.Current == lastVisible)
                {
                    start = true;
                }
                if (start)
                {
                    offset += (int)ViewElement.ElementProvider.GetElementSize(traverser.Current).Height + this.ItemSpacing;
                }
            }
        }
Esempio n. 16
0
 protected override void ProcessLassoSelection(Rectangle selectionRect)
 {
     if (!this.Owner.MultiSelect)
     {
         base.ProcessLassoSelection(selectionRect);
     }
     else
     {
         Rectangle rectangle1 = new Rectangle(this.ViewElement.Padding.Left, this.ViewElement.Padding.Top, this.ViewElement.Size.Width - this.ViewElement.Padding.Horizontal, this.ViewElement.Size.Height - this.ViewElement.Padding.Vertical);
         if (this.RightToLeft)
         {
             rectangle1 = LayoutUtils.RTLTranslateNonRelative(rectangle1, this.ControlBoundingRectangle);
         }
         selectionRect.Offset(-rectangle1.Location.X, -rectangle1.Location.Y);
         ListViewTraverser enumerator = this.Scroller.Traverser.GetEnumerator() as ListViewTraverser;
         int x1 = rectangle1.X;
         int y  = rectangle1.Y;
         enumerator.Reset();
         int val1_1 = 0;
         int val1_2 = 0;
         while (enumerator.MoveNext())
         {
             if (enumerator.Current.Owner == this.Owner)
             {
                 Size actualSize = enumerator.Current.ActualSize;
                 val1_1 = Math.Max(val1_1, actualSize.Height);
                 val1_2 = Math.Max(val1_2, actualSize.Width);
                 if (enumerator.Current is ListViewDataItemGroup)
                 {
                     if (x1 != rectangle1.X)
                     {
                         int x2 = rectangle1.X;
                         y     += val1_1;
                         val1_1 = actualSize.Height;
                     }
                     x1 = rectangle1.X;
                     y += actualSize.Height + this.ItemSpacing;
                 }
                 else
                 {
                     if (x1 + actualSize.Width > rectangle1.Right && this.Orientation == Orientation.Vertical)
                     {
                         x1     = rectangle1.X;
                         y     += val1_1 + this.ItemSpacing;
                         val1_1 = actualSize.Height;
                     }
                     else if (y + actualSize.Height > rectangle1.Bottom && this.Orientation == Orientation.Horizontal)
                     {
                         y      = rectangle1.Y;
                         x1    += val1_2 + this.ItemSpacing;
                         val1_2 = actualSize.Width;
                     }
                     if (x1 == rectangle1.X && this.Owner.ShowGroups && (this.Owner.EnableCustomGrouping || this.Owner.EnableGrouping) && (this.Owner.Groups.Count > 0 && !this.Owner.FullRowSelect))
                     {
                         x1 += this.Owner.GroupIndent;
                     }
                     Rectangle rectangle2 = new Rectangle(new Point(x1, y), actualSize);
                     if (this.RightToLeft)
                     {
                         rectangle2 = LayoutUtils.RTLTranslateNonRelative(rectangle2, rectangle1);
                     }
                     this.ProcessItemLassoSelection(enumerator.Current, selectionRect.IntersectsWith(rectangle2));
                     if (this.Orientation == Orientation.Vertical)
                     {
                         x1 += actualSize.Width + this.ItemSpacing;
                     }
                     else
                     {
                         y += actualSize.Height + this.ItemSpacing;
                     }
                 }
             }
         }
     }
 }
Esempio n. 17
0
        /// <summary>
        /// Processes the selection of a specified item.
        /// </summary>
        /// <param name="item">The <see cref="ListViewDataItem"/> which is being processed.</param>
        /// <param name="modifierKeys">The modifier keys which are pressed during selection.</param>
        /// <param name="isMouseSelection">[true] if the selection is triggered by mouse input, [false] otherwise.</param>
        internal virtual void ProcessSelection(ListViewDataItem item, Keys modifierKeys, bool isMouseSelection)
        {
            if (item == null)
            {
                this.ClearSelection();
                return;
            }

            bool isShiftPressed   = (modifierKeys & Keys.Shift) == Keys.Shift;
            bool isControlPressed = (modifierKeys & Keys.Control) == Keys.Control;
            bool clearSelection   = this.owner.MultiSelect && ((isShiftPressed && !isControlPressed) || !isControlPressed ||
                                                               (!isMouseSelection && !isShiftPressed && !isControlPressed));

            if (clearSelection)
            {
                this.ClearSelection();
            }

            if (this.owner.MultiSelect)
            {
                if (isShiftPressed)
                {
                    ListViewTraverser enumerator = this.Scroller.Traverser.GetEnumerator() as ListViewTraverser;
                    if (enumerator == null)
                    {
                        return;
                    }

                    ListViewDataItemGroup group = item as ListViewDataItemGroup;

                    if (group != null)
                    {
                        if (group.Items.Count == 0)
                        {
                            this.owner.CurrentItem = item;
                            return;
                        }
                        else
                        {
                            item = group.Items[group.Items.Count - 1];
                        }
                    }

                    enumerator.Position = null;
                    bool shouldSelectItem = false;

                    while (enumerator.MoveNext())
                    {
                        if (!shouldSelectItem && (enumerator.Current == item || enumerator.Current == anchor))
                        {
                            if (!(enumerator.Current is ListViewDataItemGroup))
                            {
                                enumerator.Current.Selected = true;
                            }

                            shouldSelectItem = item != anchor;
                            continue;
                        }

                        if (shouldSelectItem && !(enumerator.Current is ListViewDataItemGroup))
                        {
                            enumerator.Current.Selected = true;
                        }

                        if ((enumerator.Current == item || enumerator.Current == anchor))
                        {
                            break;
                        }
                    }

                    this.owner.SetSelectedItem(item);
                }
                else if (isControlPressed)
                {
                    if (isMouseSelection)
                    {
                        item.Selected = !item.Selected;
                        if (item.Selected)
                        {
                            this.owner.SetSelectedItem(item);
                        }
                        else
                        {
                            this.owner.SetSelectedItem(this.owner.SelectedItems.Count > 0 ?
                                                       this.owner.SelectedItems[this.owner.SelectedItems.Count - 1] : null);
                        }
                        this.anchor = item;
                    }
                }
                else
                {
                    item.Selected = true;
                    this.owner.SetSelectedItem(item);
                    this.anchor = item;
                }
            }
            else
            {
                if (!isControlPressed && !(item is ListViewDataItemGroup))
                {
                    this.ClearSelection();
                    item.Selected = true;
                    this.owner.SetSelectedItem(item);
                    this.anchor = item;
                }
            }

            this.owner.CurrentItem = item;
        }