Exemple #1
0
 void Moving(object sender, System.Windows.Input.MouseEventArgs e)
 {
     if (isMove && Mouse.LeftButton == MouseButtonState.Released)//鼠标弹起
     {
         StopMove(sender, e);
         return;
     }
     if (SelectElement == null)
     {
         return;
     }
     if (isMove && SelectElement != null)
     {
         if (!DragPanel.GetCanDrag(SelectElement))
         {
             return;
         }
         double oldLeft  = Canvas.GetLeft(SelectElement);
         double oldTop   = Canvas.GetTop(SelectElement);
         double elementX = e.GetPosition(this).X - offsetX;
         double elementY = e.GetPosition(this).Y - offsetY;
         //LimitElement(ref elementX, ref elementY, SelectElement);
         Canvas.SetLeft(SelectElement, elementX);
         Canvas.SetTop(SelectElement, elementY);
         Canvas.SetLeft(rotationEllipse, SelectElement.ActualWidth / 2 - rotationEllipse.Width / 2 + elementX);
         Canvas.SetTop(rotationEllipse, SelectElement.ActualHeight / 2 - rotationEllipse.Height / 2 + elementY);
     }
 }
Exemple #2
0
 void elementAdd_Loaded(object sender, RoutedEventArgs e)
 {
     if (sender is FrameworkElement)
     {
         if (DragPanel.GetCanDelete((FrameworkElement)sender))
         {
             AddDeleteContextMenu((FrameworkElement)sender);
         }
     }
 }
Exemple #3
0
        void rotationEllipse_MouseMove(object sender, MouseEventArgs e)
        {
            if (!isRotation || SelectElement == null || !DragPanel.GetCanRotation(SelectElement))
            {
                return;
            }
            Point  newpoint = e.GetPosition(rotationEllipse);
            Point  rotationEllipseCenter = new Point(rotationEllipse.Width / 2, rotationEllipse.Height / 2);
            double angle = Vector.AngleBetween(newpoint - rotationEllipseCenter, oldpoint - rotationEllipseCenter);//返回角度单位为度,逆时针方向为正(按标准数学定义)

            rotationangle += angle;
            SelectElement.RenderTransform = new RotateTransform(-rotationangle, SelectElement.ActualWidth / 2, SelectElement.ActualHeight / 2);//旋转变换中顺时针为正
            oldpoint = newpoint;
        }