protected virtual void CalculateDropTarget(OlvDropEventArgs args, Point pt)
        {
            BrightIdeasSoftware.DropTargetLocation none = BrightIdeasSoftware.DropTargetLocation.None;
            int index = -1;
            int num2  = 0;

            if (this.CanDropOnBackground)
            {
                none = BrightIdeasSoftware.DropTargetLocation.Background;
            }
            OlvListViewHitTestInfo info = this.ListView.OlvHitTest(pt.X, pt.Y);

            if ((info.Item != null) && this.CanDropOnItem)
            {
                none  = BrightIdeasSoftware.DropTargetLocation.Item;
                index = info.Item.Index;
                if ((info.SubItem != null) && this.CanDropOnSubItem)
                {
                    num2 = info.Item.SubItems.IndexOf(info.SubItem);
                }
            }
            if (this.CanDropBetween && (this.ListView.GetItemCount() > 0))
            {
                if (none == BrightIdeasSoftware.DropTargetLocation.Item)
                {
                    if ((pt.Y - 3) <= info.Item.Bounds.Top)
                    {
                        none = BrightIdeasSoftware.DropTargetLocation.AboveItem;
                    }
                    if ((pt.Y + 3) >= info.Item.Bounds.Bottom)
                    {
                        none = BrightIdeasSoftware.DropTargetLocation.BelowItem;
                    }
                }
                else
                {
                    info = this.ListView.OlvHitTest(pt.X, pt.Y + 3);
                    if (info.Item != null)
                    {
                        index = info.Item.Index;
                        none  = BrightIdeasSoftware.DropTargetLocation.AboveItem;
                    }
                    else
                    {
                        info = this.ListView.OlvHitTest(pt.X, pt.Y - 3);
                        if (info.Item != null)
                        {
                            index = info.Item.Index;
                            none  = BrightIdeasSoftware.DropTargetLocation.BelowItem;
                        }
                    }
                }
            }
            args.DropTargetLocation     = none;
            args.DropTargetIndex        = index;
            args.DropTargetSubItemIndex = num2;
        }
示例#2
0
        private void MoveSelected(int targetIndex, BrightIdeasSoftware.DropTargetLocation targetLocation)
        {
            //buttonRename.Text = e.DropTargetLocation.ToString();

            if (targetIndex == -1)
            {
                return;
            }
            if (olvPreview.SelectedIndex == targetIndex)
            {
                return;
            }

            //olvPreview.LowLevelScroll(0, 20);
            var tmp = new List <string>(fileList);

            if (olvPreview.SelectedIndex > targetIndex)
            {
                tmp.RemoveAt(olvPreview.SelectedIndex);
                tmp.Insert(targetIndex, fileList[olvPreview.SelectedIndex]);
                olvIndex = targetIndex;
            }

            else if (olvPreview.SelectedIndex < targetIndex)
            {
                if (targetLocation == BrightIdeasSoftware.DropTargetLocation.BelowItem)
                {
                    targetIndex++;
                }

                tmp.Insert(targetIndex, fileList[olvPreview.SelectedIndex]);
                tmp.RemoveAt(olvPreview.SelectedIndex);
                olvIndex = targetIndex - 1;
            }

            fileList = tmp.ToArray();
            customSortToolStripMenuItem_Click(customSortToolStripMenuItem, null);
        }