private void _listView_MouseUp(object sender, MouseEventArgs e)
{
// if (_mouseDownLocation == default(Point))
// {
// _currentTarget = null;
// _currentDraggingItem = null;
// return;
// }
//
// var mouseDownLocation = _mouseDownLocation;
// _mouseDownLocation = default(Point);
Capture = false;
Debug.WriteLine("MouseUp");
_intentionallyChangingSelection = false;
if (Control.MouseButtons == MouseButtons.Left)
return;
Cursor = Cursors.Default;
bool notPointingAtOriginalLocation= _listView.GetItemAt(e.X, e.Y) != _currentDraggingItem;
// var horizontalMovement = Math.Abs(mouseDownLocation.X - e.X);
// var verticalMovement = Math.Abs(mouseDownLocation.Y - e.Y);
// bool sufficientDistance = horizontalMovement > _thumbnailImageList.ImageSize.Width
// || verticalMovement > _thumbnailImageList.ImageSize.Height;
if (notPointingAtOriginalLocation && RelocatePageEvent != null && _currentDraggingItem != null)
{
Debug.WriteLine("Re-ordering");
if (_currentTarget == null ||
_currentTarget == _currentDraggingItem) //should never happen, but to be safe
{
_currentTarget = null;
_currentDraggingItem = null;
return;
}
var relocatePageInfo = new RelocatePageInfo((IPage) _currentDraggingItem.Tag, _currentTarget.Index - _numberofEmptyListItemsAtStart);
RelocatePageEvent.Raise(relocatePageInfo);
if (relocatePageInfo.Cancel)
return;
_listView.BeginUpdate();
_listView.Items.Remove(_currentDraggingItem);
_listView.Items.Insert(_currentTarget.Index, _currentDraggingItem);
_listView.EndUpdate();
_currentTarget = null;
_currentDraggingItem = null;
UpdateThumbnailCaptions();
_listView.Invalidate();
}
else
{
_currentTarget = null;
_currentDraggingItem = null;
}
}