コード例 #1
0
 public override void _presenter_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 {
     if (pressedMouseLeftButtonDown)
     {
         Point       cur     = e.GetPosition(_inkCanvas);
         StylusPoint current = new StylusPoint(cur.X, cur.Y);
         double      dist1   = MathTool.getInstance().distanceP2P(center, current);
         double      dist2   = MathTool.getInstance().distanceP2P(center, _prepoint);
         if (dist2 == 0)
         {
             dist2 = 1;
         }
         double scaling = dist1 / dist2;
         if (selectedStrokes.Count > 0)   //笔迹处理
         {
             foreach (MyStroke myStroke in selectedStrokes)
             {
                 ZoomCommand zc = new ZoomCommand(myStroke, scaling);
                 zc.execute();
             }
         }
         if (selectedImages.Count > 0)    //图片处理
         {
             foreach (MyImage image in selectedImages)
             {
                 ImageZoomCommand izc = new ImageZoomCommand(image, scaling);
                 izc.execute();
                 image.adjustBound();
                 foreach (ImageConnector connector in image.ConnectorCollection)
                 {
                     connector.adjustConnector();
                 }
             }
         }
         if (selectedButtons.Count > 0)    //button处理
         {
             foreach (MyButton myButton in selectedButtons)
             {
                 ButtonZoomCommand bzc = new ButtonZoomCommand(myButton, scaling, _inkCollector, 1);
                 bzc.execute();
             }
         }
         //piemenu移动
         double dist3 = MathTool.getInstance().distanceP2P(center, current);
         double dist4 = MathTool.getInstance().distanceP2P(center, _startPoint);
         if (dist4 == 0)
         {
             dist4 = 1;
         }
         double scaling2 = dist3 / dist4;
         _inkCollector._mainPage.OperatePieMenu.Margin = new System.Windows.Thickness(_inkCollector.BoundSelect.Margin.Left + _inkCollector.BoundSelect.Width * scaling2, _inkCollector._mainPage.OperatePieMenu.Margin.Top, 0, 0);
         if (_inkCollector._mainPage.OperatePieMenu.Margin.Top < _inkCanvas.Margin.Top)       //上面
         {
             _inkCollector._mainPage.OperatePieMenu.Margin = new Thickness(_inkCollector._mainPage.OperatePieMenu.Margin.Left, 10, 0, 0);
         }
         //右边
         if (_inkCollector._mainPage.OperatePieMenu.Margin.Left > _inkCanvas.Margin.Left + _inkCanvas.ActualWidth - _inkCollector._mainPage.OperatePieMenu.ActualWidth)
         {
             _inkCollector._mainPage.OperatePieMenu.Margin = new Thickness(_inkCanvas.Margin.Left + _inkCanvas.ActualWidth - _inkCollector._mainPage.OperatePieMenu.ActualWidth, _inkCollector._mainPage.OperatePieMenu.Margin.Top, 0, 0);
         }
         _prepoint = current;
     }
 }
コード例 #2
0
        public override void _presenter_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (pressedMouseLeftButtonDown)
            {
                if (_startPoint != null)
                {
                    current = e.GetPosition(_inkCanvas);
                    switch (MoveOrZoom)
                    {
                    case "Move":
                        double offsetx = current.X - _prepoint.X;
                        double offsety = current.Y - _prepoint.Y;
                        _inkCollector.IsAutoMove = true;

                        //移动Mybutton
                        foreach (MyButton myButton in _inkCollector.SelectButtons)
                        {
                            myButton.InkFrame._inkCanvas.CaptureMouse();
                            ButtonMoveCommand bmc = new ButtonMoveCommand(myButton, offsetx, offsety, _inkCollector);
                            bmc.execute();
                        }

                        //移动MyImage
                        foreach (MyImage image in _inkCollector.SelectedImages)
                        {
                            ImageMoveCommand imc = new ImageMoveCommand(image, offsetx, offsety);
                            imc.execute();
                            image.adjustBound();
                            foreach (ImageConnector connector in image.ConnectorCollection)
                            {
                                connector.adjustConnector();
                            }
                        }

                        //移动笔迹
                        if (_inkCollector.SelectedStrokes.Count > 0)
                        {
                            foreach (MyStroke myStroke in _inkCollector.SelectedStrokes)
                            {
                                MoveCommand mc = new MoveCommand(myStroke, offsetx, offsety);
                                mc.execute();
                            }
                        }

                        //移动图形
                        if (SelectedMyGraphics.Count > 0)
                        {
                            MyGraphicsMoveCommand mgsmc = new MyGraphicsMoveCommand(SelectedMyGraphics, offsetx, offsety, _inkCollector);
                            mgsmc.execute();
                        }

                        //移动文本
                        foreach (MyRichTextBox myRichTextBox in _inkCollector.SelectedMyRichTextBoxs)
                        {
                            Command tmc = new TextMoveCommand(myRichTextBox, offsetx, offsety);
                            tmc.execute();
                        }
                        break;

                    case "Zoom":

                        _inkCollector.IsAutoMove = false;
                        StylusPoint curr = new StylusPoint(current.X, current.Y);
                        StylusPoint pre  = new StylusPoint(_prepoint.X, _prepoint.Y);

                        foreach (MyButton myButton in _inkCollector.SelectButtons)
                        {
                            double dist1 = MathTool.getInstance().distanceP2P(MathTool.getInstance().getMyButtonCenter(myButton), curr);
                            double dist2 = MathTool.getInstance().distanceP2P(MathTool.getInstance().getMyButtonCenter(myButton), pre);
                            if (dist2 == 0)
                            {
                                dist2 = 1;
                            }
                            double            scaling = dist1 / dist2;
                            ButtonZoomCommand bmc     = new ButtonZoomCommand(myButton, scaling, _inkCollector, myButton.Angle);
                            bmc.execute();
                        }
                        foreach (MyImage image in _inkCollector.SelectedImages)
                        {
                            double dist1 = MathTool.getInstance().distanceP2P(MathTool.getInstance().getImageCenter(image), curr);
                            double dist2 = MathTool.getInstance().distanceP2P(MathTool.getInstance().getImageCenter(image), pre);
                            if (dist2 == 0)
                            {
                                dist2 = 1;
                            }
                            double           scaling = dist1 / dist2;
                            ImageZoomCommand izc     = new ImageZoomCommand(image, scaling);
                            izc.execute();
                            image.adjustBound();
                            foreach (ImageConnector connector in image.ConnectorCollection)
                            {
                                connector.adjustConnector();
                            }
                        }
                        break;
                    }


                    _prepoint = current;
                }
            }
        }