Esempio n. 1
0
        protected override void OnDragDrop(DragEventArgs e)
        {
            EVEMon.Common.Skill dragSkill = GetDraggingSkill(e);
            if (dragSkill != null)
            {
                base.OnDragDrop(e);
                return;
            }
            base.OnDragDrop(e);
            m_dragging = false;
            ClearDropMarker();
            if (!this.AllowRowReorder)
            {
                return;
            }
            if (base.SelectedItems.Count == 0)
            {
                return;
            }
            Point cp = base.PointToClient(new Point(e.X, e.Y));
            ListViewItem dragToItem = base.GetItemAt(cp.X, cp.Y);
            if (dragToItem == null)
            {
                return;
            }
            int dropIndex = dragToItem.Index;
            if (dropIndex > base.SelectedItems[0].Index)
            {
                dropIndex++;
            }

            if (ListViewItemsDragging != null)
            {
                ListViewDragEventArgs args = new ListViewDragEventArgs(base.SelectedItems[0].Index,
                                                                       base.SelectedItems.Count, dropIndex);
                ListViewItemsDragging(this, args);
                if (args.Cancel)
                {
                    return;
                }
            }

            ArrayList insertItems = new ArrayList(base.SelectedItems.Count);
            // Make a copy of all the selected items

            foreach (ListViewItem item in base.SelectedItems)
            {
                insertItems.Add(item.Clone());
            }

            // insert the copied items in reverse order at the drop index so 
            // they appear in the right order after they've all been inserted
            for (int i=insertItems.Count-1; i>=0; i--)
            {
                base.Items.Insert(dropIndex, (ListViewItem)insertItems[i]);
            }
            // remove the selected items
            foreach (ListViewItem item in base.SelectedItems)
            {
                // must clear the items icon index or an exception is thrown when it is removed
                item.StateImageIndex = -1;
                base.Items.Remove(item);
            }

            if (ListViewItemsDragged != null)
            {
                ListViewItemsDragged(this, new EventArgs());
            }

            // if the item was dragged to the end of the plan.
            if (dropIndex >= Items.Count)
            {
                base.EnsureVisible(Items.Count - 1);
            }
            else
            {
                base.EnsureVisible(dropIndex);
            }
        }
Esempio n. 2
0
        protected override void OnDragDrop(DragEventArgs e)
        {
            EVEMon.Common.Skill dragSkill = GetDraggingSkill(e);
            if (dragSkill != null)
            {
                base.OnDragDrop(e);
                return;
            }
            base.OnDragDrop(e);
            m_dragging = false;
            ClearDropMarker();
            if (!this.AllowRowReorder)
            {
                return;
            }
            if (base.SelectedItems.Count == 0)
            {
                return;
            }
            Point        cp         = base.PointToClient(new Point(e.X, e.Y));
            ListViewItem dragToItem = base.GetItemAt(cp.X, cp.Y);

            if (dragToItem == null)
            {
                return;
            }
            int dropIndex = dragToItem.Index;

            if (dropIndex > base.SelectedItems[0].Index)
            {
                dropIndex++;
            }

            if (ListViewItemsDragging != null)
            {
                ListViewDragEventArgs args = new ListViewDragEventArgs(base.SelectedItems[0].Index,
                                                                       base.SelectedItems.Count, dropIndex);
                ListViewItemsDragging(this, args);
                if (args.Cancel)
                {
                    return;
                }
            }

            ArrayList insertItems = new ArrayList(base.SelectedItems.Count);

            // Make a copy of all the selected items

            foreach (ListViewItem item in base.SelectedItems)
            {
                insertItems.Add(item.Clone());
            }

            // insert the copied items in reverse order at the drop index so
            // they appear in the right order after they've all been inserted
            for (int i = insertItems.Count - 1; i >= 0; i--)
            {
                base.Items.Insert(dropIndex, (ListViewItem)insertItems[i]);
            }
            // remove the selected items
            foreach (ListViewItem item in base.SelectedItems)
            {
                // must clear the items icon index or an exception is thrown when it is removed
                item.StateImageIndex = -1;
                base.Items.Remove(item);
            }

            if (ListViewItemsDragged != null)
            {
                ListViewItemsDragged(this, new EventArgs());
            }
            base.EnsureVisible(dropIndex);
        }