示例#1
0
 protected virtual void SetPositionCore(object value)
 {
     if (this.IsGroupingEnabled)
     {
         ListViewDataItemGroup group = value as ListViewDataItemGroup;
         if (group != null)
         {
             this.currentGroupIndex = this.owner.Groups.IndexOf(group);
             this.currentItemIndex  = -1;
         }
         else
         {
             int groupCount = this.owner.Groups.Count;
             for (int i = 0; i < groupCount; i++)
             {
                 if (this.owner.Groups[i].Items.Contains(position))
                 {
                     this.currentGroupIndex = i;
                     this.currentItemIndex  = this.owner.Groups[i].Items.IndexOf(position);
                     break;
                 }
             }
         }
     }
     else
     {
         this.currentGroupIndex = 0;
         this.currentItemIndex  = this.owner.Items.IndexOf(position);
     }
 }
示例#2
0
 protected virtual void SetPositionCore(object value)
 {
     if (this.IsGroupingEnabled)
     {
         ListViewDataItemGroup viewDataItemGroup = value as ListViewDataItemGroup;
         if (viewDataItemGroup != null)
         {
             this.currentGroupIndex = this.owner.Groups.IndexOf(viewDataItemGroup);
             this.currentItemIndex  = -1;
         }
         else
         {
             int count = this.owner.Groups.Count;
             for (int index = 0; index < count; ++index)
             {
                 if (this.owner.Groups[index].Items.Contains(this.position))
                 {
                     this.currentGroupIndex = index;
                     this.currentItemIndex  = this.owner.Groups[index].Items.IndexOf(this.position);
                     break;
                 }
             }
         }
     }
     else
     {
         this.currentGroupIndex = 0;
         this.currentItemIndex  = this.owner.Items.IndexOf(this.position);
     }
 }
示例#3
0
        protected override void OnDoubleClick(EventArgs e)
        {
            base.OnDoubleClick(e);
            ListViewDataItemGroup data = this.Data as ListViewDataItemGroup;

            data.Expanded = !data.Expanded;
        }
示例#4
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == null)
     {
         throw new ArgumentNullException("destinationType");
     }
     if ((destinationType == typeof(InstanceDescriptor)) && (value is ListViewDataItemGroup))
     {
         ListViewDataItemGroup group       = (ListViewDataItemGroup)value;
         ConstructorInfo       constructor = typeof(ListViewDataItemGroup).GetConstructor(new Type[] { typeof(string) });
         if (constructor != null)
         {
             return(new InstanceDescriptor(constructor, new object[] { group.Text }, false));
         }
     }
     if ((destinationType == typeof(string)))
     {
         if (value == null)
         {
             return(String.Empty);
         }
         else if (value is ListViewDataItemGroup)
         {
             ListViewDataItemGroup group = (ListViewDataItemGroup)value;
             return(group.Text);
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
示例#5
0
        private void InitializeGroups(IList <Group <ListViewDataItem> > list)
        {
            HybridDictionary oldGroups = new HybridDictionary(), newGroups = new HybridDictionary();

            foreach (ListViewDataItemGroup group in this.owner.Groups.AutoGroups)
            {
                oldGroups.Add(group.DataGroup, group);
            }

            int index = 0;

            foreach (Group <ListViewDataItem> group in list)
            {
                newGroups.Add(group, index++);
            }

            foreach (ListViewDataItemGroup group in oldGroups.Values)
            {
                if (!newGroups.Contains(group.DataGroup))
                {
                    this.owner.Groups.AutoGroups.Remove(group);
                }
            }

            foreach (Group <ListViewDataItem> group in newGroups.Keys)
            {
                if (!oldGroups.Contains(group))
                {
                    ListViewDataItemGroup newGroup = new ListViewDataItemGroup();
                    newGroup.DataGroup = group;
                    this.owner.Groups.AutoGroups.Add(newGroup);
                }
            }

            int groupsCount = this.owner.Groups.AutoGroups.Count;

            ListViewDataItemGroup[] groups = new ListViewDataItemGroup[groupsCount];
            this.owner.Groups.AutoGroups.CopyTo(groups, 0);

            Array.Sort(groups, new GroupsComparer(newGroups));

            this.owner.Groups.AutoGroups.BeginUpdate();
            for (int i = 0; i < groupsCount; i++)
            {
                this.owner.Groups.AutoGroups[i] = groups[i];
            }
            this.owner.Groups.AutoGroups.EndUpdate();

            //Fixes a bug with items not knowing their group
            //TODO: Should investigate
            foreach (ListViewDataItemGroup group in this.owner.Groups)
            {
                foreach (ListViewDataItem item in group.Items)
                {
                    item.SetGroupCore(group, false);
                }
            }
        }
示例#6
0
        /// <summary>
        /// Handles a press of the Right key.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected virtual void HandleRightKey(KeyEventArgs e)
        {
            ListViewDataItemGroup group = this.owner.CurrentItem as ListViewDataItemGroup;

            if (group != null)
            {
                group.Expanded = true;
            }
        }
 public RadLayoutControlCustomizeDialog()
 {
     this.InitializeComponent();
     this.Icon = Telerik.WinControls.ResFinder.ProgressIcon;
     this.Text = this.GetString("CustomizeDialogText");
     this.radPageViewPage1.Text            = this.GetString("CustomizeDialogPageItems");
     this.radPageViewPage2.Text            = this.GetString("CustomizeDialogPageStructure");
     this.btnSaveLayout.Image              = LayoutControlIcons.SaveLayout;
     this.btnSaveLayout.ImageAlignment     = ContentAlignment.MiddleCenter;
     this.btnSaveLayout.ToolTipTextNeeded += (ToolTipTextNeededEventHandler)((sender, e) => e.ToolTipText = this.GetString("CustomizeDialogSaveLayout"));
     this.btnLoadLayout.Image              = LayoutControlIcons.LoadLayout;
     this.btnLoadLayout.ImageAlignment     = ContentAlignment.MiddleCenter;
     this.btnLoadLayout.ToolTipTextNeeded += (ToolTipTextNeededEventHandler)((sender, e) => e.ToolTipText = this.GetString("CustomizeDialogLoadLayout"));
     this.Icon             = Icon.FromHandle(new Bitmap(LayoutControlIcons.Customize).GetHicon());
     this.hiddenItemsGroup = new ListViewDataItemGroup(this.GetString("CustomizeDialogHiddenItems"));
     this.newItemsGroup    = new ListViewDataItemGroup();
     this.itemsListView.Groups.Add(this.hiddenItemsGroup);
     this.itemsListView.Groups.Add(this.newItemsGroup);
     this.emptySpaceItem       = new ListViewDataItem(this.GetString("CustomizeDialogNewItemsEmptySpace"));
     this.emptySpaceItem.Image = LayoutControlIcons.EmptySpaceItem;
     this.emptySpaceItem.Tag   = (object)typeof(LayoutControlLabelItem);
     this.itemsListView.Items.Add(this.emptySpaceItem);
     this.emptySpaceItem.Group = this.newItemsGroup;
     this.labelItem            = new ListViewDataItem(this.GetString("CustomizeDialogNewItemsLabel"));
     this.labelItem.Image      = LayoutControlIcons.LabelItem;
     this.labelItem.Tag        = (object)typeof(LayoutControlLabelItem);
     this.itemsListView.Items.Add(this.labelItem);
     this.labelItem.Group     = this.newItemsGroup;
     this.separatorItem       = new ListViewDataItem(this.GetString("CustomizeDialogNewItemsSeparator"));
     this.separatorItem.Image = LayoutControlIcons.SeparatorItem;
     this.separatorItem.Tag   = (object)typeof(LayoutControlSeparatorItem);
     this.itemsListView.Items.Add(this.separatorItem);
     this.separatorItem.Group = this.newItemsGroup;
     this.splitterItem        = new ListViewDataItem(this.GetString("CustomizeDialogNewItemsSplitter"));
     this.splitterItem.Image  = LayoutControlIcons.SplitterItem;
     this.splitterItem.Tag    = (object)typeof(LayoutControlSplitterItem);
     this.itemsListView.Items.Add(this.splitterItem);
     this.splitterItem.Group = this.newItemsGroup;
     this.groupItem          = new ListViewDataItem(this.GetString("CustomizeDialogNewItemsGroup"));
     this.groupItem.Image    = LayoutControlIcons.GroupItem;
     this.groupItem.Tag      = (object)typeof(LayoutControlGroupItem);
     this.itemsListView.Items.Add(this.groupItem);
     this.groupItem.Group       = this.newItemsGroup;
     this.tabbedGroupItem       = new ListViewDataItem(this.GetString("CustomizeDialogNewItemsTabbedGroup"));
     this.tabbedGroupItem.Image = LayoutControlIcons.TabbedGroup;
     this.tabbedGroupItem.Tag   = (object)typeof(LayoutControlTabbedGroup);
     this.itemsListView.Items.Add(this.tabbedGroupItem);
     this.tabbedGroupItem.Group = this.newItemsGroup;
     this.newItemsGroup.Text    = string.Format(this.GetString("CustomizeDialogNewItems"), (object)this.newItemsGroup.Items.Count);
     this.itemsListView.ListViewElement.DragDropService.PreviewDragOver += new EventHandler <RadDragOverEventArgs>(this.OnDragServiceDragOver);
     this.itemsListView.ListViewElement.DragDropService.PreviewDragDrop += new EventHandler <RadDropEventArgs>(this.OnDragServiceDragDrop);
     this.itemsListView.ListViewElement.DragDropService.Stopped         += new EventHandler(this.OnDragServiceStopped);
     this.structureTreeView.TreeViewElement.EditMode = TreeNodeEditMode.Value;
     LocalizationProvider <LayoutControlLocalizationProvider> .CurrentProviderChanged += new EventHandler(this.UpdateLocalizableStrings);
     this.Disposed += (EventHandler)((sender, e) => LocalizationProvider <LayoutControlLocalizationProvider> .CurrentProviderChanged -= new EventHandler(this.UpdateLocalizableStrings));
 }
示例#8
0
 internal void SetGroupCore(ListViewDataItemGroup value, bool changeGroupCollection)
 {
     if (changeGroupCollection)
     {
         this.SetGroupCore(value);
     }
     else
     {
         this.group = value;
     }
 }
        private void InitializeGroups(IList <Group <ListViewDataItem> > list)
        {
            HybridDictionary hybridDictionary = new HybridDictionary();
            HybridDictionary keys             = new HybridDictionary();

            foreach (ListViewDataItemGroup autoGroup in (Collection <ListViewDataItemGroup>) this.owner.Groups.AutoGroups)
            {
                hybridDictionary.Add((object)autoGroup.DataGroup, (object)autoGroup);
            }
            int num = 0;

            foreach (Group <ListViewDataItem> group in (IEnumerable <Group <ListViewDataItem> >)list)
            {
                keys.Add((object)group, (object)num++);
            }
            foreach (ListViewDataItemGroup viewDataItemGroup in (IEnumerable)hybridDictionary.Values)
            {
                if (!keys.Contains((object)viewDataItemGroup.DataGroup))
                {
                    this.owner.Groups.AutoGroups.Remove(viewDataItemGroup);
                }
            }
            foreach (Group <ListViewDataItem> key in (IEnumerable)keys.Keys)
            {
                if (!hybridDictionary.Contains((object)key))
                {
                    this.owner.Groups.AutoGroups.Add(new ListViewDataItemGroup()
                    {
                        DataGroup = key
                    });
                }
            }
            int count = this.owner.Groups.AutoGroups.Count;

            ListViewDataItemGroup[] array = new ListViewDataItemGroup[count];
            this.owner.Groups.AutoGroups.CopyTo(array, 0);
            Array.Sort <ListViewDataItemGroup>(array, (IComparer <ListViewDataItemGroup>) new ListViewGroupFactory.GroupsComparer(keys));
            this.owner.Groups.AutoGroups.BeginUpdate();
            for (int index = 0; index < count; ++index)
            {
                this.owner.Groups.AutoGroups[index] = array[index];
            }
            this.owner.Groups.AutoGroups.EndUpdate();
            foreach (ListViewDataItemGroup group in this.owner.Groups)
            {
                foreach (ListViewDataItem listViewDataItem in group.Items)
                {
                    listViewDataItem.SetGroupCore(group, false);
                }
            }
        }
示例#10
0
        private void MeasureGroupElement(BaseListViewGroupVisualItem groupElement)
        {
            ListViewDataItemGroup data = groupElement.Data as ListViewDataItemGroup;

            if (groupElement.HasVisibleItems())
            {
                int   itemSpacing = this.owner.ItemSpacing;
                float num1        = 0.0f;
                float width       = 0.0f;
                float val1        = 0.0f;
                int   num2        = 1;
                foreach (ListViewDataItem listViewDataItem in data.Items)
                {
                    float num3 = num1 + (float)listViewDataItem.ActualSize.Height;
                    if (num2 > 1)
                    {
                        num3 += (float)itemSpacing;
                    }
                    if ((double)num3 > (double)this.clientRect.Height)
                    {
                        num1   = 0.0f;
                        num2   = 1;
                        width += val1;
                        if (this.owner.Orientation == Orientation.Horizontal)
                        {
                            width += (float)itemSpacing;
                        }
                        val1 = 0.0f;
                    }
                    num1 += (float)listViewDataItem.ActualSize.Height;
                    if (num2 > 1)
                    {
                        num1 += (float)itemSpacing;
                    }
                    val1 = Math.Max(val1, (float)listViewDataItem.ActualSize.Width);
                    ++num2;
                }
                if ((double)val1 > 0.0)
                {
                    width += val1;
                }
                int num4 = !this.owner.Owner.AllowArbitraryItemHeight || data.Size.Height <= 0 ? this.owner.GroupItemSize.Height : data.Size.Height;
                groupElement.Measure(new SizeF(width, (float)num4));
            }
            else
            {
                groupElement.Measure(this.clientRect.Size);
                this.currentX += groupElement.DesiredSize.Width;
                this.currentY  = this.clientRect.Top;
            }
        }
示例#11
0
        protected override void HandleRightKey(KeyEventArgs e)
        {
            ListViewDataItemGroup group = this.owner.CurrentItem as ListViewDataItemGroup;

            if (group != null)
            {
                group.Expanded = true;
            }
            else
            {
                ListViewDataItem nextItem = GetNextItem(this.owner.CurrentItem);
                if (nextItem != null)
                {
                    this.ProcessSelection(nextItem, Control.ModifierKeys, false);
                }
            }
        }
示例#12
0
        protected override void HandleLeftKey(KeyEventArgs e)
        {
            ListViewDataItemGroup group = this.owner.CurrentItem as ListViewDataItemGroup;

            if (group != null)
            {
                group.Expanded = false;
            }
            else
            {
                ListViewDataItem previousItem = GetPreviousItem(this.owner.CurrentItem);
                if (previousItem != null)
                {
                    this.ProcessSelection(previousItem, Control.ModifierKeys, false);
                }
            }
        }
示例#13
0
 private void SetGroupCore(ListViewDataItemGroup value)
 {
     if (this.OnNotifyPropertyChanging("Group"))
     {
         return;
     }
     if (this.group != null)
     {
         this.group.Items.InnerList.Remove(this);
     }
     this.group = value;
     if (this.group != null)
     {
         this.group.Items.InnerList.Add(this);
     }
     this.OnNotifyPropertyChanged("Group");
 }
示例#14
0
        protected override void HandleRightKey(KeyEventArgs e)
        {
            ListViewDataItemGroup currentItem = this.Owner.CurrentItem as ListViewDataItemGroup;

            if (currentItem != null)
            {
                currentItem.Expanded = true;
            }
            else
            {
                ListViewDataItem listViewDataItem = this.Orientation == Orientation.Vertical ? this.GetNextItem(this.Owner.CurrentItem) : this.GetDownerItem(this.Owner.CurrentItem);
                if (listViewDataItem == null)
                {
                    return;
                }
                this.ProcessSelection(listViewDataItem, Control.ModifierKeys, false);
            }
        }
 public override object ConvertTo(
     ITypeDescriptorContext context,
     CultureInfo culture,
     object value,
     Type destinationType)
 {
     if ((object)destinationType == null)
     {
         throw new ArgumentNullException(nameof(destinationType));
     }
     if ((object)destinationType == (object)typeof(InstanceDescriptor) && value is ListViewDataItemGroup)
     {
         ListViewDataItemGroup viewDataItemGroup = (ListViewDataItemGroup)value;
         ConstructorInfo       constructor       = typeof(ListViewDataItemGroup).GetConstructor(new Type[1] {
             typeof(string)
         });
         if ((object)constructor != null)
         {
             return((object)new InstanceDescriptor((MemberInfo)constructor, (ICollection) new object[1] {
                 (object)viewDataItemGroup.Text
             }, false));
         }
     }
     if ((object)destinationType == (object)typeof(string))
     {
         if (value == null)
         {
             return((object)string.Empty);
         }
         if (value is ListViewDataItemGroup)
         {
             return((object)((ListViewDataItem)value).Text);
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
示例#16
0
        private void UpdateHorizontalScrollRange()
        {
            int    num1     = 0;
            int    num2     = 0;
            int    num3     = 0;
            object position = this.Traverser.Position;

            this.Traverser.Reset();
            int val1 = 0;

            this.groupsHeight = this.GetGroupsHeight();
            ListViewDataItem current1 = this.Traverser.Current;
            bool             flag     = false;

            while (this.Traverser.MoveNext())
            {
                flag = false;
                int scrollHeight               = this.GetScrollHeight(this.Traverser.Current);
                int currentItemWidth           = this.currentItemWidth;
                ListViewDataItemGroup current2 = this.Traverser.Current as ListViewDataItemGroup;
                if ((double)(num3 + currentItemWidth) > (double)this.ClientSize.Height - (double)this.Scrollbar.DesiredSize.Height || current2 != null)
                {
                    if (current1 != null)
                    {
                        current1.IsLastInRow = true;
                    }
                    if (current2 != null)
                    {
                        num3 = 0;
                        int num4 = num2 + current2.Owner.GroupIndent;
                        if (!current2.Expanded)
                        {
                            num2 = num4 + current2.ActualSize.Width;
                            if (!(current1 is ListViewDataItemGroup))
                            {
                                num2 += val1;
                                flag  = true;
                            }
                        }
                        else
                        {
                            num2 = num4 + val1;
                        }
                    }
                    else
                    {
                        num3  = this.groupsHeight;
                        num2 += val1 + this.ItemSpacing;
                    }
                    val1 = 0;
                }
                else if (current1 != null)
                {
                    current1.IsLastInRow = current1 is ListViewDataItemGroup;
                }
                int num5 = currentItemWidth + this.ItemSpacing;
                num3 += num5;
                ++num1;
                current1 = this.Traverser.Current;
                val1     = Math.Max(val1, scrollHeight);
            }
            if (current1 != null)
            {
                current1.IsLastInRow = true;
            }
            if (num3 != 0 && !flag)
            {
                num2 += val1;
            }
            this.Traverser.Position = position;
            if (num2 < 0)
            {
                return;
            }
            if (this.ScrollMode == ItemScrollerScrollModes.Smooth || this.ScrollMode == ItemScrollerScrollModes.Deferred)
            {
                if (this.Scrollbar.Maximum == num2)
                {
                    return;
                }
                this.Scrollbar.Maximum = num2;
                this.SetScrollBarVisibility();
                this.UpdateScrollValue();
            }
            else
            {
                if (this.Scrollbar.Maximum == num1 - 1 || num1 - 1 <= 0)
                {
                    return;
                }
                this.Scrollbar.Maximum = num1 - 1;
                this.UpdateScrollStep();
                this.SetScrollBarVisibility();
            }
        }
示例#17
0
 protected override void MeasureElements()
 {
     if (this.Grouped && this.Orientation == Orientation.Horizontal)
     {
         int         position   = 0;
         IEnumerator enumerator = this.DataProvider.GetEnumerator();
         if (!enumerator.MoveNext())
         {
             return;
         }
         ListViewDataItem current1 = enumerator.Current as ListViewDataItem;
         if (current1 is ListViewDataItemGroup)
         {
             this.currentX += (float)this.owner.GroupIndent;
         }
         ListViewDataItemGroup current2          = enumerator.Current as ListViewDataItemGroup;
         ListViewDataItemGroup viewDataItemGroup = current2 ?? current1.Group;
         if (current2 != null)
         {
             enumerator.MoveNext();
         }
         bool flag = true;
         do
         {
             BaseListViewGroupVisualItem groupElement = (BaseListViewGroupVisualItem)null;
             if (viewDataItemGroup != null && viewDataItemGroup.Visible)
             {
                 groupElement      = this.UpdateElement(position, (ListViewDataItem)viewDataItemGroup) as BaseListViewGroupVisualItem;
                 viewDataItemGroup = (ListViewDataItemGroup)null;
                 ++position;
             }
             do
             {
                 ListViewDataItem current3 = enumerator.Current as ListViewDataItem;
                 if (current3 is ListViewDataItemGroup)
                 {
                     flag = true;
                     break;
                 }
                 if (current3 != null && this.IsItemVisible(current3))
                 {
                     IVirtualizedElement <ListViewDataItem> element = this.UpdateElement(position, current3);
                     if (element != null)
                     {
                         ++position;
                         if (!this.MeasureElement(element))
                         {
                             flag = false;
                             break;
                         }
                     }
                 }
             }while (enumerator.MoveNext() && !(enumerator.Current is ListViewDataItemGroup));
             if ((double)this.currentY != (double)this.clientRect.Top)
             {
                 this.currentY     = this.clientRect.Top;
                 this.currentX    += this.maxItemWidth;
                 this.maxItemWidth = 0.0f;
             }
             if (groupElement != null)
             {
                 this.MeasureGroupElement(groupElement);
             }
             if (enumerator.Current is ListViewDataItemGroup)
             {
                 viewDataItemGroup = enumerator.Current as ListViewDataItemGroup;
             }
             this.currentX += (float)this.owner.GroupIndent;
             if ((double)this.currentX >= (double)this.clientRect.Right)
             {
                 flag = false;
             }
         }while (flag && enumerator.MoveNext());
         if (viewDataItemGroup != null)
         {
             BaseListViewGroupVisualItem groupElement = this.UpdateElement(position, (ListViewDataItem)viewDataItemGroup) as BaseListViewGroupVisualItem;
             if (groupElement != null)
             {
                 this.MeasureGroupElement(groupElement);
                 ++position;
             }
         }
         while (position < this.Children.Count)
         {
             this.RemoveElement(position);
         }
     }
     else
     {
         base.MeasureElements();
     }
 }
 public ListViewDataGroupAccessibleObject(ListViewDataItemGroup item)
 {
     this.group = item;
 }
示例#19
0
 public ListViewGroupCancelEventArgs(ListViewDataItemGroup group)
 {
     this.group  = group;
     this.Cancel = false;
 }
 public ListViewGroupEventArgs(ListViewDataItemGroup group)
 {
     this.group = group;
 }
示例#21
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;
        }