Example #1
0
 private void dgvImages_QueryActualDestination(object sender, Controls.QueryActualDestinationEventArgs e)
 {
     e.Effect = DragDropEffects.Move;
     if (e.Source.Name == "dgvBookmarks")
     {
         e.ActualDestination = -1;
     }
 }
Example #2
0
        DragHitTestInfo GetDragHitTestInfo(DragEventArgs de)
        {
            Point pt    = PointToClient(new Point(de.X, de.Y));
            int   index = HitTest(pt.X, pt.Y).RowIndex;

            if (index < 0)
            {
                if (RowCount == 0)
                {
                    index = 0;
                }
                else if (pt.Y > GetRowDisplayRectangle(RowCount - 1, false).Bottom)
                {
                    index = RowCount;
                }
            }
            var obj        = de.Data.GetData(typeof(DataGridViewMovedRows)) as DataGridViewMovedRows;
            int actualdest = index;

            if (obj.Source == this)
            {
                var rowIndex = obj.SourceRows.Aggregate(int.MaxValue, (work, next) => work > next.Index ? next.Index : work);
                if (index > rowIndex + obj.SourceRows.Count)
                {
                    actualdest = index - obj.SourceRows.Count;
                }
                else if (index >= rowIndex)
                {
                    actualdest = -1;
                }
            }
            QueryActualDestinationEventArgs ev = new QueryActualDestinationEventArgs(actualdest, DragDropEffects.Move, obj.Source);

            OnQueryActualDestination(ev);
            if (ev.ActualDestination < 0)
            {
                de.Effect = DragDropEffects.None;
            }
            else
            {
                de.Effect = ev.Effect;
            }
            return(new DragHitTestInfo(index, ev.ActualDestination));
        }
		/// <summary><see cref="QueryActualDestination"/> イベントを発生させます。</summary>
		protected virtual void OnQueryActualDestination(QueryActualDestinationEventArgs e) { QueryActualDestination?.Invoke(this, e); }
		DragHitTestInfo GetDragHitTestInfo(DragEventArgs de)
		{
			Point pt = PointToClient(new Point(de.X, de.Y));
			int index = HitTest(pt.X, pt.Y).RowIndex;
			if (index < 0)
			{
				if (RowCount == 0)
					index = 0;
				else if (pt.Y > GetRowDisplayRectangle(RowCount - 1, false).Bottom)
					index = RowCount;
			}
			var obj = de.Data.GetData(typeof(DataGridViewMovedRows)) as DataGridViewMovedRows;
			int actualdest = index;
			if (obj.Source == this)
			{
				var rowIndex = obj.SourceRows.Aggregate(int.MaxValue, (work, next) => work > next.Index ? next.Index : work);
				if (index > rowIndex + obj.SourceRows.Count)
					actualdest = index - obj.SourceRows.Count;
				else if (index >= rowIndex)
					actualdest = -1;
			}
			QueryActualDestinationEventArgs ev = new QueryActualDestinationEventArgs(actualdest, DragDropEffects.Move, obj.Source);
			OnQueryActualDestination(ev);
			if (ev.ActualDestination < 0)
				de.Effect = DragDropEffects.None;
			else
				de.Effect = ev.Effect;
			return new DragHitTestInfo(index, ev.ActualDestination);
		}
Example #5
0
 /// <summary><see cref="QueryActualDestination"/> イベントを発生させます。</summary>
 protected virtual void OnQueryActualDestination(QueryActualDestinationEventArgs e)
 {
     QueryActualDestination?.Invoke(this, e);
 }
Example #6
0
 private void dgvBookmarks_QueryActualDestination(object sender, Controls.QueryActualDestinationEventArgs e)
 {
     e.Effect = e.Source == dgvBookmarks ? DragDropEffects.Move : DragDropEffects.Link;
 }