Exemplo n.º 1
0
 protected virtual void OnDropped(OlvDropEventArgs args)
 {
     if (this.Dropped != null)
     {
         this.Dropped(this, args);
     }
 }
Exemplo n.º 2
0
 protected virtual void OnCanDrop(OlvDropEventArgs args)
 {
     if (this.CanDrop != null)
     {
         this.CanDrop(this, args);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Update the state of our sink to reflect the information that
        /// may have been written into the drop event args.
        /// </summary>
        /// <param name="args"></param>
        protected virtual void UpdateAfterCanDropEvent(OlvDropEventArgs args)
        {
            this.DropTargetIndex        = args.DropTargetIndex;
            this.DropTargetLocation     = args.DropTargetLocation;
            this.DropTargetSubItemIndex = args.DropTargetSubItemIndex;

            if (this.Billboard != null)
            {
                Point pt = args.MouseLocation;
                pt.Offset(5, 5);
                if (this.Billboard.Text != this.dropEventArgs.InfoMessage || this.Billboard.Location != pt)
                {
                    this.Billboard.Text     = this.dropEventArgs.InfoMessage;
                    this.Billboard.Location = pt;
                    this.ListView.Invalidate();
                }
            }
        }
 protected virtual void OnDropped(OlvDropEventArgs args) {
     if (this.Dropped != null)
         this.Dropped(this, args);
 }
 protected virtual void OnCanDrop(OlvDropEventArgs args) {
     if (this.CanDrop != null)
         this.CanDrop(this, args);
 }
        /// <summary>
        /// Update the state of our sink to reflect the information that 
        /// may have been written into the drop event args.
        /// </summary>
        /// <param name="args"></param>
        protected virtual void UpdateAfterCanDropEvent(OlvDropEventArgs args) {
            this.DropTargetIndex = args.DropTargetIndex;
            this.DropTargetLocation = args.DropTargetLocation;
            this.DropTargetSubItemIndex = args.DropTargetSubItemIndex;

            if (this.Billboard != null) {
                Point pt = args.MouseLocation;
                pt.Offset(5, 5);
                if (this.Billboard.Text != this.dropEventArgs.InfoMessage || this.Billboard.Location != pt) {
                    this.Billboard.Text = this.dropEventArgs.InfoMessage;
                    this.Billboard.Location = pt;
                    this.ListView.Invalidate();
                }
            }
        }
        /// <summary>
        /// When the mouse is at the given point, what should the target of the drop be?
        /// </summary>
        /// <remarks>This method should update the DropTarget* members of the given arg block</remarks>
        /// <param name="pt">The mouse point, in client co-ordinates</param>
        protected virtual void CalculateDropTarget(OlvDropEventArgs args, Point pt) {
            const int SMALL_VALUE = 3;
            DropTargetLocation location = DropTargetLocation.None;
            int targetIndex = -1;
            int targetSubIndex = 0;

            if (this.CanDropOnBackground)
                location = DropTargetLocation.Background;

            // Which item is the mouse over?
            // If it is not over any item, it's over the background.
            //ListViewHitTestInfo info = this.ListView.HitTest(pt.X, pt.Y);
            OlvListViewHitTestInfo info = this.ListView.OlvHitTest(pt.X, pt.Y);
            if (info.Item != null && this.CanDropOnItem) {
                location = DropTargetLocation.Item;
                targetIndex = info.Item.Index;
                if (info.SubItem != null && this.CanDropOnSubItem)
                    targetSubIndex = info.Item.SubItems.IndexOf(info.SubItem);
            }

            // Check to see if the mouse is "between" rows.
            // ("between" is somewhat loosely defined)
            if (this.CanDropBetween && this.ListView.GetItemCount() > 0) {

                // If the mouse is over an item, check to see if it is near the top or bottom
                if (location == DropTargetLocation.Item) {
                    if (pt.Y - SMALL_VALUE <= info.Item.Bounds.Top)
                        location = DropTargetLocation.AboveItem;
                    if (pt.Y + SMALL_VALUE >= info.Item.Bounds.Bottom)
                        location = DropTargetLocation.BelowItem;
                } else {
                    // Is there an item a little below the mouse?
                    // If so, we say the drop point is above that row
                    info = this.ListView.OlvHitTest(pt.X, pt.Y + SMALL_VALUE);
                    if (info.Item != null) {
                        targetIndex = info.Item.Index;
                        location = DropTargetLocation.AboveItem;
                    } else {
                        // Is there an item a little above the mouse?
                        info = this.ListView.OlvHitTest(pt.X, pt.Y - SMALL_VALUE);
                        if (info.Item != null) {
                            targetIndex = info.Item.Index;
                            location = DropTargetLocation.BelowItem;
                        }
                    }
                }
            }

            args.DropTargetLocation = location;
            args.DropTargetIndex = targetIndex;
            args.DropTargetSubItemIndex = targetSubIndex;
        }
Exemplo n.º 8
0
        /// <summary>
        /// When the mouse is at the given point, what should the target of the drop be?
        /// </summary>
        /// <remarks>This method should update the DropTarget* members of the given arg block</remarks>
        /// <param name="pt">The mouse point, in client co-ordinates</param>
        protected virtual void CalculateDropTarget(OlvDropEventArgs args, Point pt)
        {
            const int          SMALL_VALUE = 3;
            DropTargetLocation location    = DropTargetLocation.None;
            int targetIndex    = -1;
            int targetSubIndex = 0;

            if (this.CanDropOnBackground)
            {
                location = DropTargetLocation.Background;
            }

            // Which item is the mouse over?
            // If it is not over any item, it's over the background.
            //ListViewHitTestInfo info = this.ListView.HitTest(pt.X, pt.Y);
            OlvListViewHitTestInfo info = this.ListView.OlvHitTest(pt.X, pt.Y);

            if (info.Item != null && this.CanDropOnItem)
            {
                location    = DropTargetLocation.Item;
                targetIndex = info.Item.Index;
                if (info.SubItem != null && this.CanDropOnSubItem)
                {
                    targetSubIndex = info.Item.SubItems.IndexOf(info.SubItem);
                }
            }

            // Check to see if the mouse is "between" rows.
            // ("between" is somewhat loosely defined)
            if (this.CanDropBetween && this.ListView.GetItemCount() > 0)
            {
                // If the mouse is over an item, check to see if it is near the top or bottom
                if (location == DropTargetLocation.Item)
                {
                    if (pt.Y - SMALL_VALUE <= info.Item.Bounds.Top)
                    {
                        location = DropTargetLocation.AboveItem;
                    }
                    if (pt.Y + SMALL_VALUE >= info.Item.Bounds.Bottom)
                    {
                        location = DropTargetLocation.BelowItem;
                    }
                }
                else
                {
                    // Is there an item a little below the mouse?
                    // If so, we say the drop point is above that row
                    info = this.ListView.OlvHitTest(pt.X, pt.Y + SMALL_VALUE);
                    if (info.Item != null)
                    {
                        targetIndex = info.Item.Index;
                        location    = DropTargetLocation.AboveItem;
                    }
                    else
                    {
                        // Is there an item a little above the mouse?
                        info = this.ListView.OlvHitTest(pt.X, pt.Y - SMALL_VALUE);
                        if (info.Item != null)
                        {
                            targetIndex = info.Item.Index;
                            location    = DropTargetLocation.BelowItem;
                        }
                    }
                }
            }

            args.DropTargetLocation     = location;
            args.DropTargetIndex        = targetIndex;
            args.DropTargetSubItemIndex = targetSubIndex;
        }