Example #1
0
 private static void OnMouseDown(object sender, MouseButtonEventArgs e)
 {
     PaintDotNet.UI.FrameworkElement visual = (PaintDotNet.UI.FrameworkElement)sender;
     if (!visual.IsMouseCaptured)
     {
         PresentationSource source = PresentationSource.FromVisual(visual);
         if ((source != null) && (source.PrimaryMouseDevice.Captured == null))
         {
             PointDouble position = e.GetPosition(visual);
             visual.CaptureMouse();
             visual.RaiseEvent(new MouseEventArgs(e.InputDevice, GestureBeginEvent, visual));
             if (visual.IsMouseCaptured)
             {
                 SetIsPressed(visual, true);
                 SetMouseCapturePoint(visual, position);
                 if (!GetAllowClick(visual))
                 {
                     SetIsDragging(visual, true);
                     visual.RaiseEvent(new MouseEventArgs(e.InputDevice, DragBeginEvent, visual));
                 }
             }
             else
             {
                 visual.RaiseEvent(new MouseEventArgs(e.InputDevice, GestureEndEvent, visual));
             }
             e.Handled = true;
         }
     }
 }
Example #2
0
 private static void OnMouseMove(object sender, MouseEventArgs e)
 {
     PaintDotNet.UI.FrameworkElement visual = (PaintDotNet.UI.FrameworkElement)sender;
     if (visual.IsMouseCaptured)
     {
         CompositionTarget compositionTarget = PresentationSource.FromVisual(visual).CompositionTarget;
         PointDouble       position          = e.GetPosition(visual);
         bool flag = visual.HitTestLocal(position);
         SetIsPressed(visual, flag);
         if (GetIsDragging(visual))
         {
             visual.RaiseEvent(new MouseEventArgs(e.InputDevice, DragMoveEvent, visual));
         }
         else if (GetAllowDrag(visual))
         {
             VectorDouble    num8;
             PointDouble     mouseCapturePoint = GetMouseCapturePoint(visual);
             PointDouble     pt             = e.GetPosition(visual);
             Matrix3x2Double matrixToDevice = compositionTarget.MatrixToDevice;
             PointDouble     num5           = matrixToDevice.Transform(mouseCapturePoint);
             VectorDouble    num7           = (VectorDouble)(matrixToDevice.Transform(pt) - num5);
             if (GetAllowClick(visual))
             {
                 num8 = new VectorDouble(PaintDotNet.UI.SystemParameters.MinimumHorizontalDragDistance, PaintDotNet.UI.SystemParameters.MinimumVerticalDragDistance);
             }
             else
             {
                 num8 = new VectorDouble(0.0, 0.0);
             }
             if ((Math.Abs(num7.X) >= num8.X) || (Math.Abs(num7.Y) >= num8.Y))
             {
                 SetIsDragging(visual, true);
                 visual.RaiseEvent(new MouseEventArgs(e.InputDevice, DragBeginEvent, visual));
             }
         }
         e.Handled = true;
     }
 }
Example #3
0
 private static void OnMouseUp(object sender, MouseButtonEventArgs e)
 {
     PaintDotNet.UI.FrameworkElement target = (PaintDotNet.UI.FrameworkElement)sender;
     if (target.IsMouseCaptured)
     {
         target.ReleaseMouseCapture();
         if (GetIsDragging(target))
         {
             target.RaiseEvent(new MouseEventArgs(e.InputDevice, DragEndEvent, target));
         }
         else if (GetAllowClick(target))
         {
             PointDouble position = e.GetPosition(target);
             if (target.HitTestLocal(position))
             {
                 target.RaiseEvent(new MouseEventArgs(e.InputDevice, ClickedEvent, target));
             }
         }
         SetIsDragging(target, false);
         SetIsPressed(target, false);
         target.RaiseEvent(new RoutedEventArgs(GestureEndEvent, target));
         e.Handled = true;
     }
 }
Example #4
0
 private static void IsPressedPropertyChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     PaintDotNet.UI.FrameworkElement source = (PaintDotNet.UI.FrameworkElement)sender;
     source.RaiseEvent(new RoutedEventArgs(IsPressedChangedEvent, source));
 }