public void OnDragEnter(DragEventArgs e)
 {
     if (this.owner.AllowItemReorder && e.Data.GetDataPresent(typeof(ToolStripItem)))
     {
         this.lastDropTarget = this.owner.ItemReorderDropTarget;
     }
     else
     {
         ToolStripItem item = this.FindItemAtPoint(e.X, e.Y);
         if ((item != null) && item.AllowDrop)
         {
             this.lastDropTarget = item;
         }
         else if (this.owner.AllowDrop)
         {
             this.lastDropTarget = this.owner;
         }
         else
         {
             this.lastDropTarget = null;
         }
     }
     if (this.lastDropTarget != null)
     {
         this.lastDropTarget.OnDragEnter(e);
     }
 }
 public void OnDragDrop(DragEventArgs e)
 {
     if (this.lastDropTarget != null)
     {
         this.lastDropTarget.OnDragDrop(e);
     }
     this.lastDropTarget = null;
 }
 public void EnsureUnRegistered(IDropTarget dropTarget)
 {
     for (int i = 0; i < this.owner.Items.Count; i++)
     {
         if (this.owner.Items[i].AllowDrop)
         {
             return;
         }
     }
     if (!this.owner.AllowDrop && !this.owner.AllowItemReorder)
     {
         this.SetAcceptDrops(false);
         this.owner.DropTargetManager = null;
     }
 }
    public static IDropTarget GetDropTargetAtPoint(
      UIElement draggedElement,
      UIElement dragContainer,
      MouseEventArgs e,
      out Nullable<Point> dropTargetPosition,
      out IDropTarget lastFoundDropTarget )
    {
      dropTargetPosition = null;
      lastFoundDropTarget = null;

      if( dragContainer == null )
        return null;

      IDropTarget dropTarget = null;

      Point pointToDragContainer = e.GetPosition( dragContainer );

      IInputElement hitTest = dragContainer.InputHitTest( pointToDragContainer );

      if( hitTest != null )
      {
        DependencyObject parent = hitTest as DependencyObject;

        while( parent != null )
        {
          dropTarget = parent as IDropTarget;
          if( dropTarget != null )
          {
            lastFoundDropTarget = dropTarget;

            if( dropTarget.CanDropElement( draggedElement ) )
            {
              dropTargetPosition = pointToDragContainer;
              break;
            }
          }
          dropTarget = null;
          parent = Xceed.Utils.Wpf.TreeHelper.GetParent( parent );
        }
      }

      return dropTarget;
    }
Beispiel #5
0
        public void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _LastDropTarget = null;

            Visual visual = e.OriginalSource as Visual;
            _TopWindow = DragController.FindAncestor(typeof(MainWindow), visual) as MainWindow;
            if (_TopWindow == null && !_TopWindow.IsActive)
                return;

            _DownPointInTopWindow = e.GetPosition(_TopWindow);
            _DownPointGapOfBlock = e.GetPosition(sender as IInputElement);
            _BlockBoard = _TopWindow.FindName("blocksBoard") as BlocksBoard;
            _DragCanvas = _TopWindow.FindName("dragCanvas") as Canvas;

            FrameworkElement fe = sender as FrameworkElement;
            if ( fe == null)
            {
                System.Diagnostics.Debug.WriteLine("create block datacontext null");
                System.Diagnostics.Debug.Assert(fe != null);
                return;
            }
            _DraggedData = sender;
            _bDragCreate = (fe.DataContext != null) ? true : false;
        }
    protected virtual IDropTarget GetDropTargetOnDrag( MouseEventArgs e, out Nullable<Point> dropTargetPosition, out IDropTarget lastFoundDropTarget )
    {
      IDropTarget dropTarget = DragDropHelper.GetDropTargetAtPoint( this.DraggedElement, this.DragContainer, e, out dropTargetPosition, out lastFoundDropTarget );

      // ColumnManagerRow was defined as IDropTarget only because Animated Column Reordering required it, ignore it in base class
      if( dropTarget is ColumnManagerRow )
      {
        dropTarget = null;
        dropTargetPosition = null;
      }

      return dropTarget;
    }
Beispiel #7
0
 public static extern int RegisterDragDrop(IntPtr hwnd, IDropTarget pDropTarget);
Beispiel #8
0
        public void OnPreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            _DraggedData = null;
            _bMouseCaptured = false;
            _LastDropTarget = null;

            if (_MoveBlock != null)
                _MoveBlock.ReleaseMouseCapture();

            _TopWindow = null;
        }
Beispiel #9
0
		public void UpdateMouseLocation(Point dragPosition)
		{
			var floatingWindowModel = _floatingWindow.Model as LayoutFloatingWindow;

			var newHost = _overlayWindowHosts.FirstOrDefault(oh => oh.HitTest(dragPosition));

			if (_currentHost != null || _currentHost != newHost)
			{
				//is mouse still inside current overlay window host?
				if ((_currentHost != null && !_currentHost.HitTest(dragPosition)) ||
					_currentHost != newHost)
				{
					//esit drop target
					if (_currentDropTarget != null)
						_currentWindow.DragLeave(_currentDropTarget);
					_currentDropTarget = null;

					//exit area
					_currentWindowAreas.ForEach(a =>
						_currentWindow.DragLeave(a));
					_currentWindowAreas.Clear();

					//hide current overlay window
					if (_currentWindow != null)
						_currentWindow.DragLeave(_floatingWindow);
					if (_currentHost != null)
						_currentHost.HideOverlayWindow();
					_currentHost = null;
				}

				if (_currentHost != newHost)
				{
					_currentHost = newHost;
					_currentWindow = _currentHost.ShowOverlayWindow(_floatingWindow);
					_currentWindow.DragEnter(_floatingWindow);
				}
			}

			if (_currentHost == null)
				return;

			if (_currentDropTarget != null &&
				!_currentDropTarget.HitTest(dragPosition))
			{
				_currentWindow.DragLeave(_currentDropTarget);
				_currentDropTarget = null;
			}

			List<IDropArea> areasToRemove = new List<IDropArea>();
			_currentWindowAreas.ForEach(a =>
			{
				//is mouse still inside this area?
				if (!a.DetectionRect.Contains(dragPosition))
				{
					_currentWindow.DragLeave(a);
					areasToRemove.Add(a);
				}
			});

			areasToRemove.ForEach(a =>
				_currentWindowAreas.Remove(a));


			var areasToAdd =
				_currentHost.GetDropAreas(_floatingWindow).Where(cw => !_currentWindowAreas.Contains(cw) && cw.DetectionRect.Contains(dragPosition)).ToList();

			_currentWindowAreas.AddRange(areasToAdd);

			areasToAdd.ForEach(a =>
				_currentWindow.DragEnter(a));

			if (_currentDropTarget == null)
			{
				_currentWindowAreas.ForEach(wa =>
					{
						if (_currentDropTarget != null)
							return;

						_currentDropTarget = _currentWindow.GetTargets().FirstOrDefault(dt => dt.HitTest(dragPosition));
						if (_currentDropTarget != null)
						{
							_currentWindow.DragEnter(_currentDropTarget);
							return;
						}
					});
			}

		}
 public DropTarget(IDropTarget owner) {
     Debug.WriteLineIf(CompModSwitches.DragDrop.TraceInfo, "DropTarget created");
     this.owner = owner;
 }
    protected override void ProcessDragOnCurrentDropTarget( IDropTarget dropTarget )
    {
      base.ProcessDragOnCurrentDropTarget( dropTarget );

      if( !this.IsAnimatedColumnReorderingEnabled )
        return;

      // We are reverting every animation before detaching from the manager
      // so do not update the ghost position
      if( m_ghostToTargetAndDetachAnimationClock != null )
        return;

      ColumnManagerCell cell = this.CurrentDropTarget as ColumnManagerCell;

      bool dragOverCell = ( cell != null );

      // We can drag over other type of IDropTarget than Cell
      if( dragOverCell && this.CurrentDropTargetToDragContainerPosition.HasValue )
      {
        this.ProcessDragOverColumnManagerCell();
      }
    }
Beispiel #12
0
		void IDocHostUIHandler.GetDropTarget(IDropTarget pDropTarget, out IDropTarget ppDropTarget)
		{
			ppDropTarget = null;
		}
 public static void SetDropTarget(DependencyObject d, IDropTarget value)
 {
     d.SetValue(DropTargetProperty, value);
 }
Beispiel #14
0
        void IDocHostUIHandler.GetDropTarget(IDropTarget pDropTarget, out IDropTarget ppDropTarget)
        {
            try
            {

                ppDropTarget = null;
            }
            catch(Exception ex)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: AppShare void IDocHostUIHandler.GetDropTarget(IDropTarget pDropTarget, out IDropTarget ppDropTarget)",ex,"",false);
                ppDropTarget = null;
            }
        }
 public void GetDropTarget(IDropTarget pDropTarget, out IDropTarget ppDropTarget)
 {
     ppDropTarget = null;
 }
Beispiel #16
0
 private bool lastDropTarget_Is(IDropTarget target)
 {
     return (_LastDropTarget == target) ? true : false;
 }
Beispiel #17
0
        public void _BlockBoard_OnMouseMove(object sender, MouseEventArgs e)
        {
            if (!_bDragging && e.LeftButton != MouseButtonState.Pressed)
                return;

            Point currentPoint = e.GetPosition(_TopWindow);
            _DeltaPoint = new Point(_DownPointInTopWindow.X - currentPoint.X, _DownPointInTopWindow.Y - currentPoint.Y);
            currentPoint.X -= _DownPointGapOfBlock.X;
            currentPoint.Y -= _DownPointGapOfBlock.Y;

            Canvas.SetLeft(_MoveBlock, currentPoint.X);
            Canvas.SetTop(_MoveBlock, currentPoint.Y);
            Canvas.SetRight(_MoveBlock, currentPoint.X + _MoveBlock.Width);
            Canvas.SetBottom(_MoveBlock, currentPoint.Y + _MoveBlock.Height);

            //Control block = _DraggedData as Control;
            //if (block != null)
            //{
            //	UIElement container = VisualTreeHelper.GetParent(block) as UIElement;
            //	Point relativeLocation = block.TranslatePoint(new Point(0, 0), container);

            //	System.Diagnostics.Debug.WriteLine(relativeLocation.ToString());
            //	System.Diagnostics.Debug.WriteLine(relativeLocation.ToString());
            //	Point p = e.GetPosition(_TopWindow.blocksBoard);
            //	//p.X -= _DownPointGapOfBlock.X;
            //	//p.Y -= _DownPointGapOfBlock.Y;
            //	System.Diagnostics.Debug.WriteLine(p.X + ", " + p.Y + " @");
            //}

            IDropTarget dropTarget = findDropTarget(_MoveBlock);
            if (dropTarget != null)
            {
                if (lastDropTarget_Is(dropTarget))
                {
                    dropTarget.OnDragOver(_MoveBlock, currentPoint);
                }
                else
                {
                    if (!lastDropTarget_Is(null))
                    {
                        _LastDropTarget.OnDragExit(_MoveBlock, currentPoint);
                    }
                    dropTarget.OnDragEnter(_MoveBlock, currentPoint);
                }
            }
            else
            {
                if (!lastDropTarget_Is(null))
                {
                    _LastDropTarget.OnDragExit(_MoveBlock, currentPoint);
                }
            }
            _LastDropTarget = dropTarget;
        }
    protected virtual void ProcessDragOnCurrentDropTarget( IDropTarget dropTarget )
    {
      if( dropTarget != this.CurrentDropTarget )
      {
        if( this.CurrentDropTarget != null )
        {
          this.CurrentDropTarget.DragLeave( this.DraggedElement );
          this.CurrentDropTarget = null;
        }

        if( dropTarget != null )
        {
          if( dropTarget.CanDropElement( this.DraggedElement ) )
          {
            this.CurrentDropTarget = dropTarget;
            this.CurrentDropTarget.DragEnter( this.DraggedElement );
          }
        }
      }

      if( this.CurrentDropTarget != null )
      {
        // Always use the Mouse Position relative to DraggedElement and not the DraggedContainer
        this.CurrentDropTarget.DragOver( this.DraggedElement, Mouse.GetPosition( this.CurrentDropTarget as IInputElement ) );
      }
    }
    protected override IDropTarget GetDropTargetOnDrag( MouseEventArgs e, out Nullable<Point> dropTargetPosition, out IDropTarget lastFoundDropTarget )
    {
      IDropTarget returnedDropTarget = base.GetDropTargetOnDrag( e, out dropTargetPosition, out lastFoundDropTarget );

      if( !this.IsAnimatedColumnReorderingEnabled )
        return returnedDropTarget;

      ColumnManagerCell cell = e.OriginalSource as ColumnManagerCell;

      if( cell == null )
        return returnedDropTarget;

      Row parentRow = cell.ParentRow;

      if( parentRow == null )
        return returnedDropTarget;

      // Rollback reordering only if dragging outside or if the base class found a DropTarget that is not a ColumnManagerCell or ColumnManagerRow at the current mouse position
      if( ( returnedDropTarget != null ) && !( returnedDropTarget is ColumnManagerCell ) && !( returnedDropTarget is ColumnManagerRow ) )
      {
        return returnedDropTarget;
      }

      // If there is no IDropTarget currently dragging over but one was found other than ColumnManagerRow or ColumnManagerCell this means this IDropTarget can't receive the drop
      if( ( lastFoundDropTarget != null ) && !( lastFoundDropTarget is ColumnManagerCell ) && !( lastFoundDropTarget is ColumnManagerRow ) )
      {
        return null;
      }

      UIElement dragContainer = this.DragContainer;
      Debug.Assert( dragContainer != null );

      Cell draggedCell = this.DraggedElement as Cell;
      Debug.Assert( draggedCell != null );

      Point parentRowToDragContainer = parentRow.TranslatePoint( ColumnReorderingDragSourceManager.EmptyPoint, dragContainer );

      Rect parentRowRect = new Rect( parentRowToDragContainer.X, parentRowToDragContainer.Y, parentRow.ActualWidth, parentRow.ActualHeight );

      Point draggedElementToMouse = e.GetPosition( draggedCell );
      draggedElementToMouse.X -= this.InitialMousePositionToDraggedElement.Value.X;

      Point draggedElementToDragContainer = draggedCell.TranslatePoint( draggedElementToMouse, dragContainer );

      double draggedElementWidth = draggedCell.RenderSize.Width;

      // Get the Rect for the DragContainer
      Rect dragContainerRect = new Rect( ColumnReorderingDragSourceManager.EmptyPoint, dragContainer.RenderSize );

      Point dragContainerToMouse = e.GetPosition( dragContainer );

      // If the mouse cursor is currently over the DragContainer
      if( dragContainerRect.Contains( dragContainerToMouse ) )
      {
        // Ensure the DraggedElement is not visible to HitTest
        draggedCell.IsHitTestVisible = false;

        // Correct the Y coordinate of the 
        double correctedY = parentRowRect.Y + ( draggedCell.ActualHeight / 2 );

        // Correct the Y part to ensure it is over the ParentRow
        Point correctedPoint = new Point( draggedElementToDragContainer.X, correctedY );

        if( m_horizontalMouseDragDirection == HorizontalMouseDragDirection.Left )
        {
          double rightEdge = draggedElementToDragContainer.X + draggedElementWidth;

          // When scrolling left, try to find the first IDropTarget from the left edge of the dragged element to the mouse cursor to the mouse cursor over the dragged element
          while( ( returnedDropTarget == null ) && ( correctedPoint.X < rightEdge ) )
          {
            returnedDropTarget = ColumnReorderingDragSourceManager.GetDropTargetAtPoint( dragContainer, draggedCell, correctedPoint );

            if( returnedDropTarget != null )
              break;

            correctedPoint.X += 1;
          }
        }
        else if( m_horizontalMouseDragDirection == HorizontalMouseDragDirection.Right )
        {
          // When scrolling right, try to find the first IDropTarget from the right edge of the dragged element to the mouse cursor over the dragged element
          double leftSide = draggedElementToDragContainer.X;

          correctedPoint.X += draggedCell.ParentColumn.ActualWidth;

          while( ( returnedDropTarget == null ) && ( correctedPoint.X > leftSide ) )
          {
            returnedDropTarget = ColumnReorderingDragSourceManager.GetDropTargetAtPoint( dragContainer, draggedCell, correctedPoint );

            if( returnedDropTarget != null )
              break;

            correctedPoint.X -= 1;
          }
        }
        else
        {
          returnedDropTarget = ColumnReorderingDragSourceManager.GetDropTargetAtPoint( dragContainer, draggedCell, correctedPoint );
        }

        dropTargetPosition = ( returnedDropTarget != null ) ? correctedPoint : ( Point? )null;

        draggedCell.ClearValue( UIElement.IsHitTestVisibleProperty );
      }
      else
      {
        dropTargetPosition = null;
      }

      //Flag used to reduce the number of column animations, to speed up the scrolling on ColumnManagerCell dragging.
      if( returnedDropTarget == null && this.CurrentDropTarget == null )
      {
        m_noColumnsReorderingNeeded = true;
        if( this.ParentWindowIsPopup )
        {
          m_popupDraggedElementAdorner.AdornedElementImage.Opacity = 0;
        }
      }
      else
      {
        m_noColumnsReorderingNeeded = false;
      }

      return returnedDropTarget;
    }
 private void UpdateDropTarget(IDropTarget newTarget, DragEventArgs e)
 {
     if (newTarget != this.lastDropTarget)
     {
         if (this.lastDropTarget != null)
         {
             this.OnDragLeave(new EventArgs());
         }
         this.lastDropTarget = newTarget;
         if (newTarget != null)
         {
             DragEventArgs args = new DragEventArgs(e.Data, e.KeyState, e.X, e.Y, e.AllowedEffect, e.Effect) {
                 Effect = DragDropEffects.None
             };
             this.OnDragEnter(args);
         }
     }
 }
 public DropTarget(IDropTarget owner)
 {
     this.owner = owner;
 }
 public void EnsureRegistered(IDropTarget dropTarget)
 {
     this.SetAcceptDrops(true);
 }
Beispiel #23
0
� � public static extern int RegisterDragDrop(IntPtr hWnd, IDropTarget IdropTgt);
 void IOverlayWindow.DragLeave(IDropTarget target)
 {
     _previewBox.Visibility = System.Windows.Visibility.Hidden;
 }
 public static void SetDropHandler(UIElement target, IDropTarget value)
 {
     target.SetValue(DropHandlerProperty, value);
 }
 public int AddToolbar3(VSTWT_LOCATION dwLoc, ref Guid pguid, uint dwId, IDropTarget pDropTarget, IOleCommandTarget pCommandTarget) {
     return VSConstants.S_OK;
 }
 void IOverlayWindow.DragEnter(IDropTarget target)
 {
     var previewBoxPath = target.GetPreviewPath(this, _floatingWindow.Model as LayoutFloatingWindow);
     if (previewBoxPath != null) {
         _previewBox.Data = previewBoxPath;
         _previewBox.Visibility = System.Windows.Visibility.Visible;
     }
 }
Beispiel #28
0
 public static extern int RegisterDragDrop(
     IntPtr hwnd,  //Handle to a window that can accept drops
     IDropTarget pDropTarget
     //Pointer to object that is to be target of drop
     );
 void IOverlayWindow.DragDrop(IDropTarget target)
 {
     target.Drop(_floatingWindow.Model as LayoutFloatingWindow);
 }
Beispiel #30
0
 public static extern uint RegisterDragDrop(IntPtr hWnd, IDropTarget dropTarget);