当前位置: 首页>>代码示例>>C#>>正文


C# DragEventArgs.GetPosition方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:YoshihiroIto,项目名称:TreeViewEx,代码行数:7,代码来源:DragNDropController.cs

示例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();
        }
开发者ID:ArsenShnurkov,项目名称:TreeViewEx,代码行数:30,代码来源:DragNDropController.cs

示例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;
                }
            }
        }
开发者ID:ArsenShnurkov,项目名称:TreeViewEx,代码行数:70,代码来源:DragNDropController.cs


注:本文中的DragEventArgs.GetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。