本文整理汇总了C#中DragEventArgs.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# DragEventArgs.GetPosition方法的具体用法?C# DragEventArgs.GetPosition怎么用?C# DragEventArgs.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DragEventArgs
的用法示例。
在下文中一共展示了DragEventArgs.GetPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDragLeave
void OnDragLeave(object sender, DragEventArgs e)
{
if (!IsMouseOverTreeView(e.GetPosition(TreeView)))
{
CleanUpAdorners();
}
}
示例2: OnDrop
private void OnDrop(object sender, DragEventArgs e)
{
TreeViewExItem item = GetTreeViewItemUnderMouse(e.GetPosition(TreeView));
if (item == null)
{
CleanUpAdorners();
return;
}
CanInsertReturn canInsertReturn = CanInsert(item, e.GetPosition, e.Data);
if (canInsertReturn != null)
{
// insert and return
item.ParentTreeViewItem.Insert(canInsertReturn.Index, e.Data.GetData(canInsertReturn.Format));
CleanUpAdorners();
return;
}
// check if drop is possible
string dropformat = CanDrop(item, e.Data);
if (dropformat != null)
{
// drop and return
object data = e.Data.GetData(dropformat);
item.DropAction(data);
}
CleanUpAdorners();
}
示例3: OnDragOver
void OnDragOver(object sender, DragEventArgs e)
{
// drag over is the only event which returns the position
// GiveFeedback returns nonsense even from Mouse.GetPosition
Point point = e.GetPosition(TreeView);
if (TryScroll(point)) return;
if (dragAdorner == null)//external drop
{
var content = new DragContent();
content.Add(e.Data);
dragAdorner = new DragAdorner(TreeView, content);
}
dragAdorner.UpdatePosition(point);
if (IsMouseOverAdorner(point)) return;
var itemsPresenter = TreeView.ScrollViewer.Content as ItemsPresenter;
if (itemsPresenter.InputHitTest(e.GetPosition(itemsPresenter)) == null)
{
dragAdorner.Content.CanDrop = false;
dragAdorner.Content.CanInsert = false;
dragAdorner.Content.InsertIndex = -1;
if (insertAdorner != null) insertAdorner.Dispose();
return;
}
if (itemMouseIsOver != null)
{
itemMouseIsOver.IsCurrentDropTarget = false;
}
itemMouseIsOver = GetTreeViewItemUnderMouse(point);
if (itemMouseIsOver == null) return;
CanInsertReturn canInsertReturn = CanInsert(itemMouseIsOver, e.GetPosition, e.Data);
if (canInsertReturn != null)
{
dragAdorner.Content.CanDrop = false;
dragAdorner.Content.CanInsert = true;
dragAdorner.Content.InsertIndex = canInsertReturn.Index;
if (insertAdorner == null)
{
insertAdorner = new InsertAdorner(itemMouseIsOver, new InsertContent { Before = canInsertReturn.Before });
}
else
{
insertAdorner.Dispose();
insertAdorner = new InsertAdorner(itemMouseIsOver, new InsertContent { Before = canInsertReturn.Before });
}
itemMouseIsOver.IsCurrentDropTarget = false;
}
else
{
dragAdorner.Content.CanInsert = false;
dragAdorner.Content.InsertIndex = -1;
if (insertAdorner != null)
{
insertAdorner.Dispose();
insertAdorner = null;
}
dragAdorner.Content.CanDrop = CanDrop(itemMouseIsOver, e.Data) != null;
if (itemMouseIsOver != null)
{
itemMouseIsOver.IsCurrentDropTarget = true;
}
}
}