Exemplo n.º 1
0
        static void DropTarget_PreviewDragLeave(object sender, DragEventArgs e)
        {
            try
            {
                if (UpdateEffects(sender, e) == false)
                {
                    return;
                }

                DropTargetBase advisor    = GetDropTarget(sender as DependencyObject);
                Point          mousePoint = MouseUtilities.GetMousePosition(advisor.TargetUI);

                //Console.WriteLine("Inside DropTarget_PreviewDragLeave1" + mousePoint.X.ToString() + "|" + mousePoint.Y.ToString());
                //giving a tolerance of 2 so that the adorner is removed when the mouse is moved fast.
                //this might still be small...in that case increase the tolerance
                if ((mousePoint.X < 2) || (mousePoint.Y < 2) ||
                    (mousePoint.X > ((FrameworkElement)(advisor.TargetUI)).ActualWidth - 2) ||
                    (mousePoint.Y > ((FrameworkElement)(advisor.TargetUI)).ActualHeight - 2))
                {
                    RemovePreviewAdorner();
                }
                e.Handled = true;
            }
            catch (Exception ex)
            {
                VMuktiHelper.ExceptionHandler(ex, "DropTarget_PreviewDragLeave()", "Controls\\VMuktiGrid\\DragDropManager\\DragDropManager.cs");
            }
        }
Exemplo n.º 2
0
        static void DropTarget_PreviewDragEnter(object sender, DragEventArgs e)
        {
            try
            {
                if (UpdateEffects(sender, e) == false)
                {
                    return;
                }

                // Setup the preview Adorner
                UIElement feedbackUI = GetDropTarget(sender as DependencyObject).GetVisualFeedback(e.Data);
                _offsetPoint = GetOffsetPoint(e.Data);

                DropTargetBase advisor = GetDropTarget(sender as DependencyObject);

                Point mousePoint = MouseUtilities.GetMousePosition(advisor.TargetUI);

                // Console.WriteLine("Inside DropTarget_PreviewDragEnter" + mousePoint.X.ToString() + "|" + mousePoint.Y.ToString());

                //giving a tolerance of 2 so that the adorner is created when the mouse is moved fast.
                //this might still be small...in that case increase the tolerance
                if ((mousePoint.X < 2) || (mousePoint.Y < 2) ||
                    (mousePoint.X > ((FrameworkElement)(advisor.TargetUI)).ActualWidth - 2) ||
                    (mousePoint.Y > ((FrameworkElement)(advisor.TargetUI)).ActualHeight - 2) ||
                    (_overlayElt == null))
                {
                    CreatePreviewAdorner(sender as UIElement, feedbackUI);
                }

                e.Handled = true;
            }
            catch (Exception ex)
            {
                VMuktiHelper.ExceptionHandler(ex, "DropTarget_PreviewDragEnter()", "Controls\\VMuktiGrid\\DragDropManager\\DragDropManager.cs");
            }
        }