On Aug 1, 8:56*am, Pavel Minaev <int...@gmail.comwrote:
DragSize is actually an instance of struct Size, so it defines Width
and Height of the drag rectangle - if horizontal mouse delta is larger
than Width, or if vertical delta is larger than Height, then it's time
to start dragging.
I got it!
Thanks for the help. I had to do a (old.X - new.X >= DragSize.Width)
|| (old.Y - new.Y >= DragSize.Height).
And the dragdrop was exciting. (I am posting it for those looking to
figure this bloody technology out. It was hard enough to find I hope
this helps others.)
Once you have established that you are dragging (see above) you do the
following:
DataObject tempDataObject = new DataObject(this.BackColor);
DoDragDrop(tempDataObject, DragDropEffects.Copy);
This creates a DataObject and stores the data you want to pass to the
drop target in it (in my case a Color object). This is the only method
that you look at from the "draggers" point of view. The other events
are fired by the Drop target (don't forget the drop target could be
the same as the object that started the drag so it might look
confusing).
Then, in the DragEnter and DragOver events you check your object and
make sure you are accepting the data that is being dragged by checking
the DataFormats like so...
List<stringlstTest;
lstTest = new List<string>(drgevent.Data.GetFormats());
if (lstTest.Contains("FileDrop"))
{
//If you want to do different things based on different keys then
check those too..
if ((drgevent.KeyState & 8) == 8)
{
drgevent.Effect = DragDropEffects.Copy;
}
else
{
drgevent.Effect = DragDropEffects.Move;
}
}
Then, in the DragDrop event you get the object out of the DragObject
structure...
List<stringItemFormats;
ItemFormats = new List<string>(drgevent.Data.GetFormats());
if (ItemFormats.Contains("System.Drawing.Color"))
{
this.BackColor = (Color)drgevent.Data.GetData(typeof(Color));
}
Then process the data any way you feel you need to.
Hope this helps others.
Tom P.