Beispiel #1
0
        void Target_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (sender as FrameworkElement == null)
            {
                throw new ArgumentException("CoreMouseEvent.cs/CoreMouseEventProcessor/Target_PreviewMouseMove : Can't cover sender to FrameworkElement");
            }
            FrameworkElement Target = sender as FrameworkElement;

            if (Enable[MouseMove])
            {
                CoreMouseEventArgs info = new CoreMouseMoveEventArgs(CoreMouseEventProcessor.MouseMove, e.GetPosition(Target));
                OnMouseEvent(info, Target);
            }
            if (MouseLeftPressed)
            {
                if (Enable[MouseDragging])
                {
                    Point  NowPosition = e.GetPosition(Target);
                    double Distance    = Math.Pow(((MousePressedPoint.X - NowPosition.X) * (MousePressedPoint.X - NowPosition.X) + (MousePressedPoint.Y - NowPosition.Y) * (MousePressedPoint.Y - NowPosition.Y)), 0.5);
                    if (Distance > DragThreshold)
                    {
                        CoreMouseEventArgs info = new CoreMouseDraggingEventArgs(CoreMouseEventProcessor.MouseDragging, MousePressedPoint, CoreMouseDraggingEventArgs.LeftButton, NowPosition, Distance);
                        OnMouseEvent(info, Target);
                    }
                }
            }
            if (MouseRightPressed)
            {
                if (Enable[MouseDragging])
                {
                    Point  NowPosition = e.GetPosition(Target);
                    double Distance    = Math.Pow(((MousePressedPoint.X - NowPosition.X) * (MousePressedPoint.X - NowPosition.X) + (MousePressedPoint.Y - NowPosition.Y) * (MousePressedPoint.Y - NowPosition.Y)), 0.5);
                    if (Distance > DragThreshold)
                    {
                        CoreMouseEventArgs info = new CoreMouseDraggingEventArgs(CoreMouseEventProcessor.MouseDragging, MousePressedPoint, CoreMouseDraggingEventArgs.RightButton, NowPosition, Distance);
                        OnMouseEvent(info, Target);
                    }
                }
            }
        }
 void Target_PreviewMouseMove(object sender, MouseEventArgs e)
 {
     if (sender as FrameworkElement == null)
         throw new ArgumentException("CoreMouseEvent.cs/CoreMouseEventProcessor/Target_PreviewMouseMove : Can't cover sender to FrameworkElement");
     FrameworkElement Target = sender as FrameworkElement;
     if (Enable[MouseMove])
     {
         CoreMouseEventArgs info = new CoreMouseMoveEventArgs(CoreMouseEventProcessor.MouseMove, e.GetPosition(Target));
         OnMouseEvent(info, Target);
     }
     if (MouseLeftPressed)
     {
         if(Enable[MouseDragging])
         {
             Point NowPosition = e.GetPosition(Target);
             double Distance = Math.Pow(((MousePressedPoint.X - NowPosition.X) * (MousePressedPoint.X - NowPosition.X) + (MousePressedPoint.Y - NowPosition.Y) * (MousePressedPoint.Y - NowPosition.Y)), 0.5);
             if (Distance > DragThreshold)
             {
                 CoreMouseEventArgs info = new CoreMouseDraggingEventArgs(CoreMouseEventProcessor.MouseDragging, MousePressedPoint, CoreMouseDraggingEventArgs.LeftButton, NowPosition, Distance);
                 OnMouseEvent(info, Target);
             }
         }
     }
     if (MouseRightPressed)
     {
         if (Enable[MouseDragging])
         {
             Point NowPosition = e.GetPosition(Target);
             double Distance = Math.Pow(((MousePressedPoint.X - NowPosition.X) * (MousePressedPoint.X - NowPosition.X) + (MousePressedPoint.Y - NowPosition.Y) * (MousePressedPoint.Y - NowPosition.Y)), 0.5);
             if (Distance > DragThreshold)
             {
                 CoreMouseEventArgs info = new CoreMouseDraggingEventArgs(CoreMouseEventProcessor.MouseDragging, MousePressedPoint, CoreMouseDraggingEventArgs.RightButton, NowPosition, Distance);
                 OnMouseEvent(info, Target);
             }
         }
     }
 }