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


C# DragEventArgs.GetPosition方法代码示例

本文整理汇总了C#中System.Windows.DragEventArgs.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# DragEventArgs.GetPosition方法的具体用法?C# DragEventArgs.GetPosition怎么用?C# DragEventArgs.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.DragEventArgs的用法示例。


在下文中一共展示了DragEventArgs.GetPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: designPanel_DragOver

		void designPanel_DragOver(object sender, DragEventArgs e)
		{
			try {
				IDesignPanel designPanel = (IDesignPanel)sender;
				e.Effects = DragDropEffects.Copy;
				e.Handled = true;
				Point p = e.GetPosition(designPanel);

				if (moveLogic == null) {
					if (e.Data.GetData(typeof(CreateComponentTool)) != this) return;
					// TODO: dropLayer in designPanel
					designPanel.IsAdornerLayerHitTestVisible = false;
					DesignPanelHitTestResult result = designPanel.HitTest(p, false, true);
					
					if (result.ModelHit != null) {
						designPanel.Focus();
						DesignItem createdItem = CreateItem(designPanel.Context);
						if (AddItemWithDefaultSize(result.ModelHit, createdItem, e.GetPosition(result.ModelHit.View))) {
							moveLogic = new MoveLogic(createdItem);
							createPoint = p;
						} else {
							changeGroup.Abort();
						}
					}
				} else if ((moveLogic.ClickedOn.View as FrameworkElement).IsLoaded) {
					if (moveLogic.Operation == null) {
						moveLogic.Start(createPoint);
					} else {
						moveLogic.Move(p);
					}
				}
			} catch (Exception x) {
				DragDropExceptionHandler.RaiseUnhandledException(x);
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:35,代码来源:CreateComponentTool.cs

示例2: OnDragOver

        protected override void OnDragOver(DragEventArgs e)
        {
            base.OnDragEnter(e);

            HitTestResult result = VisualTreeHelper.HitTest(this, e.GetPosition(this));

            if ((result.VisualHit as UIElement).IsDescendantOf(this))
            {
                UIElement element = (result.VisualHit as UIElement);
                DragDropTreeViewItem targetNode = GetNearestContainer(e.Source as UIElement);
                if (e.GetPosition(targetNode).Y < targetNode.ActualHeight * 0.2f)
                {
                    // meter em cima
                    //Console.WriteLine("cima");
                    DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Top;
                    DragDropHelper.CreateInsertionAdorner(targetNode, true);
                }
                else if (e.GetPosition(targetNode).Y > targetNode.ActualHeight * 0.8f)
                {
                    //Console.WriteLine("baixo");
                    DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Bottom;
                    DragDropHelper.CreateInsertionAdorner(targetNode, false);
                }
                else
                {
                    //Console.WriteLine("centro");
                    DragDropHelper.RemoveInsertionAdorner();
                    DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Center;
                    var converter = new System.Windows.Media.BrushConverter();
                    Background = (Brush)converter.ConvertFromString("#555");
                }
            }
        }
开发者ID:Alexz18z35z,项目名称:Gibbo2D,代码行数:33,代码来源:DragDropTreeViewItem.cs

示例3: DropInfo

    /// <summary>
    /// Initializes a new instance of the DropInfo class.
    /// </summary>
    /// <param name="sender">
    /// The sender of the drag event.
    /// </param>
    /// <param name="e">
    /// The drag event.
    /// </param>
    /// <param name="dragInfo">
    /// Information about the source of the drag, if the drag came from within the framework.
    /// </param>
    public DropInfo(object sender, DragEventArgs e, DragInfo dragInfo)
    {
      string dataFormat = DragDrop.DataFormat.Name;
      Data = (e.Data.GetDataPresent(dataFormat)) ? e.Data.GetData(dataFormat) : e.Data;
      DragInfo = dragInfo;

      VisualTarget = sender as UIElement;
      if (VisualTarget == null)
        return;

      DropPosition = e.GetPosition(VisualTarget);

      if (!(sender is ItemsControl))
        return;

      var itemsControl = (ItemsControl)sender;
      UIElement item = itemsControl.GetItemContainerAt(DropPosition);
      bool directlyOverItem = item != null;

      TargetGroup = FindGroup(itemsControl, DropPosition);
      VisualTargetOrientation = itemsControl.GetItemsPanelOrientation();

      if (item == null)
      {
        item = itemsControl.GetItemContainerAt(DropPosition, VisualTargetOrientation);
        directlyOverItem = false;
      }

      if (item == null)
      {
        TargetCollection = itemsControl.ItemsSource ?? itemsControl.Items;
        InsertIndex = itemsControl.Items.Count;
        return;
      }
      
      ItemsControl itemParent = ItemsControl.ItemsControlFromItemContainer(item);

      InsertIndex = itemParent.ItemContainerGenerator.IndexFromContainer(item);
      TargetCollection = itemParent.ItemsSource ?? itemParent.Items;

      if (directlyOverItem)
      {
        TargetItem = itemParent.ItemContainerGenerator.ItemFromContainer(item);
        VisualTargetItem = item;
      }

      if (VisualTargetOrientation == Orientation.Vertical)
      {
        if (e.GetPosition(item).Y > item.RenderSize.Height / 2)
          InsertIndex++;
      }
      else
      {
        if (e.GetPosition(item).X > item.RenderSize.Width / 2)
          InsertIndex++;
      }
    }
开发者ID:modulexcite,项目名称:LoreSoft.Shared,代码行数:69,代码来源:DropInfo.cs

示例4: DragScope_PreviewDragOver

 void DragScope_PreviewDragOver(object sender, DragEventArgs args)
 {
     if (this._adorner != null)
     {
         this._adorner.LeftOffset = args.GetPosition(this._dragScope).X;
         this._adorner.TopOffset = args.GetPosition(this._dragScope).Y;
         Debug.WriteLine("DragScope_PreviewDragOver:" + _adorner.LeftOffset + "," + _adorner.TopOffset);
     }
 }
开发者ID:SmartEncounter,项目名称:SmartLCT-V2.0,代码行数:9,代码来源:Window3.xaml.cs

示例5: DropUIElement

 public static void DropUIElement(object sender, DragEventArgs e)
 {
     var mainWin = DesignerMainWindow.GetInstance();
     var selectedObj = mainWin.GetSelectedCanvasElement();
     var uiElem = selectedObj as UIElement;
     InkCanvas.SetLeft(uiElem, e.GetPosition(mainWin.canMainCanvas).X - _elemPos.X);
     InkCanvas.SetTop(uiElem, e.GetPosition(mainWin.canMainCanvas).Y - _elemPos.Y);
     var selected = new List<UIElement> { uiElem };
     mainWin.canMainCanvas.Select(selected);
 }
开发者ID:undecimus,项目名称:komunikator,代码行数:10,代码来源:DragDropUIElement.cs

示例6: DropInfo

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="dragInfo"></param>
        /// <param name="dataFormat"></param>
        public DropInfo(object sender, DragEventArgs e, DragInfo dragInfo, string dataFormat)
        {
            Data = (e.Data.GetDataPresent(dataFormat)) ? e.Data.GetData(dataFormat) : e.Data;
            DragInfo = dragInfo;

            VisualTarget = sender as UIElement;

            if (sender is ItemsControl)
            {
                ItemsControl itemsControl = (ItemsControl)sender;
                Point p = e.GetPosition(itemsControl);
                UIElement item = itemsControl.GetItemContainerAt(p);
                if (item == null)
                {
                    // try again with margins
                    p.X -= 15;
                    p.Y -= 15;

                    item = itemsControl.GetItemContainerAt(p);
                }

                VisualTargetOrientation = itemsControl.GetItemsPanelOrientation();

                if (item != null)
                {
                    ItemsControl itemParent = ItemsControl.ItemsControlFromItemContainer(item);

                    InsertIndex = itemParent.ItemContainerGenerator.IndexFromContainer(item);
                    TargetCollection = itemParent.ItemsSource ?? itemParent.Items;
                    TargetItem = itemParent.ItemContainerGenerator.ItemFromContainer(item);
                    VisualTargetItem = item;

                    if (VisualTargetOrientation == Orientation.Vertical)
                    {
                        if (e.GetPosition(item).Y > item.RenderSize.Height / 2) InsertIndex++;
                    }
                    else
                    {
                        if (e.GetPosition(item).X > item.RenderSize.Width / 2) InsertIndex++;
                    }
                }
                else
                {
                    TargetCollection = itemsControl.ItemsSource ?? itemsControl.Items;
                    InsertIndex = itemsControl.Items.Count;
                }
            }

            this.IsNotHandled = false;
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:57,代码来源:DropInfo.cs

示例7: GameObjectsCanvas_Drop

        public void GameObjectsCanvas_Drop(object sender, DragEventArgs e)
        {
            Element element = e.Data.GetData(typeof(Element)) as Element;
            if (element != null)
            {
                System.Console.WriteLine("dropped " + element);
                GameObject pGo = App.ObjectBuilder.click(e.GetPosition(sender as Canvas)) as GameObject;
                Element newElement = new Element(element);
                if (pGo != null)
                {
                    pGo.Add(newElement);
                }
                else
                {
                    pGo = App.newGameObject();
                    if (pGo != null)
                    {
                        pGo.Position = e.GetPosition(sender as Canvas);
                        pGo.Add(newElement);
                    }
                }
            }
            ObjectBuilder ob = e.Data.GetData(typeof(ObjectBuilder)) as ObjectBuilder;
            if (ob != null && ob.IsMacro)
            {
                if (ob.IsRegistered || ob.IsLive)
                {
                    // TODO: Show Macro window
                    MacroCall macroCall = new MacroCall();
                    macroCall.Position = e.GetPosition(sender as Canvas);
                    macroCall.Macro = ob;
                    if (ob != App.ObjectBuilder)
                    {
                        App.ObjectBuilder.ScriptObjects.Add(macroCall);
                    }
                    else
                    {
                        MessageBox.Show("Cannot call Macro from within itself!", "Error");
                    }
                }
                else
                {
                    App.registerMacroInScript(ob);

                    (App.MainWindow as MainWindow).sortMacros();
                }
            }
        }
开发者ID:DelBero,项目名称:XnaScrapEdit,代码行数:48,代码来源:DragDropHandler.cs

示例8: Drop

 private static void Drop(object sender, DragEventArgs e)
 {
     var point = e.GetPosition((IInputElement)sender);
     var dropTarget = GetDropTarget((DependencyObject)sender);
     dropTarget.Drop(e.Data, point);
     e.Handled = true;
 }
开发者ID:shinyzid,项目名称:vixendisplayvisualizer,代码行数:7,代码来源:DropTargetBehaviour.cs

示例9: MainWindow_PreviewDragOver

 void MainWindow_PreviewDragOver(object sender, DragEventArgs e)
 {
     // Adjust the position of the draggedBlock as it's dragged
     if (draggedBlock == null) return;
     e.Effects = DragDropEffects.None;
     Point p = e.GetPosition(grdMain);
     draggedBlock.Margin = new Thickness(p.X - dragPos.X, p.Y - dragPos.Y, 100000, 100000);
 }
开发者ID:FreddyFlares,项目名称:SlidingBlock,代码行数:8,代码来源:MainWindow.xaml.cs

示例10: GraphDragEventArgs

        public GraphDragEventArgs(NodeGraphLayout canvas, DragEventArgs args)
        {
            Point canvasPoint = args.GetPosition(canvas);
            canvasPoint = new Point(canvasPoint.X - canvas.Translation.X, canvasPoint.Y - canvas.Translation.Y);
            Position = canvasPoint;

            DragArguments = args;
        }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:8,代码来源:GraphDragEventArgs.cs

示例11: Drawing_Area_Drop

 private void Drawing_Area_Drop(object sender, DragEventArgs e)
 {
     Label label = new Label();
     label.Content = e.Data.GetData(DataFormats.Text);
     Point labelCord = e.GetPosition(Drawing_Area);
     Canvas.SetLeft(label, labelCord.X);
     Canvas.SetTop(label, labelCord.Y);
     Drawing_Area.Children.Add(label);
 }
开发者ID:Narucross,项目名称:JFlores_Capstone_Fall_2013,代码行数:9,代码来源:MainWindow.xaml.cs

示例12: OnWidgetDrop

        private void OnWidgetDrop(object sender, DragEventArgs e)
        {
            WidgetDescriptor descriptor = (WidgetDescriptor)e.Data.GetData(WidgetDataFormat);
            Point mousePositionInCanvas = e.GetPosition(widgetContainer);

            descriptor.Position = mousePositionInCanvas;
            descriptor.ZIndex = 100;
            descriptor.IsActive = true;
        }
开发者ID:Kendry06,项目名称:Gymnastika,代码行数:9,代码来源:DefaultWidgetPanel.xaml.cs

示例13: GetPositionFromSender

 static Point GetPositionFromSender(object sender, DragEventArgs args)
 {
     IInputElement inputSender = sender as IInputElement;
     if (inputSender != null)
     {
         return args.GetPosition(inputSender);
     }
     return new Point();
 }
开发者ID:AnthonySteele,项目名称:openwrap,代码行数:9,代码来源:DropHelper.cs

示例14: IsMouseOnStartDot

        private bool IsMouseOnStartDot(DragEventArgs e)
        {
            HitTestResult result = VisualTreeHelper.HitTest(this, e.GetPosition(this));
            if (result != null && this.startDotGrid.IsAncestorOf(result.VisualHit))
            {
                return true;
            }

            return false;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:10,代码来源:ConnectorWithStartDot.xaml.cs

示例15: OnDragEnter

 protected override void OnDragEnter(DragEventArgs e)
 {
     Win32Point wp;
     e.Effects = DragDropEffects.Copy;
     Point p = e.GetPosition(this);
     wp.x = (int)p.X;
     wp.y = (int)p.Y;
     WindowInteropHelper wndHelper = new WindowInteropHelper(this);
     IDropTargetHelper dropHelper = (IDropTargetHelper)new DragDropHelper();
     dropHelper.DragEnter(wndHelper.Handle, (ComIDataObject)e.Data, ref wp, (int)e.Effects);
 }
开发者ID:renmin,项目名称:DesignHelper,代码行数:11,代码来源:MainWindow.xaml.cs


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