Example #1
0
 public override void _presenter_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (_startPoint != null)
     {
         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, _startPoint);
         double      scaling = dist1 / dist2;
         if (selectedStrokes.Count > 0)   //笔迹处理
         {
             foreach (MyStroke myStroke in selectedStrokes)
             {
                 ZoomCommand zc = new ZoomCommand(myStroke, scaling);
                 _inkCollector.CommandStack.Push(zc);
             }
         }
         if (selectedImages.Count > 0)    //图片处理
         {
             foreach (MyImage image in selectedImages)
             {
                 ImageZoomCommand izc = new ImageZoomCommand(image, scaling);
                 _inkCollector.CommandStack.Push(izc);
                 foreach (ImageConnector connector in image.ConnectorCollection)
                 {
                     connector.adjustConnector();
                 }
             }
         }
         if (selectedButtons.Count > 0)    //button处理
         {
             int i = 0;
             foreach (MyButton myButton in selectedButtons)
             {
                 ButtonZoomCommand bzc = new ButtonZoomCommand(myButton, scaling, _inkCollector, preMyButtonInkFrameList[i]);
                 _inkCollector.CommandStack.Push(bzc);
                 i++;
             }
         }
     }
     _inkCanvas.ReleaseMouseCapture();
     pressedMouseLeftButtonDown = false;
 }
Example #2
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;
     }
 }
        public override void _presenter_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (pressedMouseLeftButtonDown)
            {
                if (_startPoint != null)
                {
                    current = e.GetPosition(_inkCanvas);


                    switch (MoveOrZoom)
                    {
                    case "Move":
                        double offsetx = current.X - _startPoint.X;
                        double offsety = current.Y - _startPoint.Y;
                        _inkCollector.IsAutoMove = true;
                        foreach (MyButton myButton in _inkCollector.SelectButtons)
                        {
                            myButton.InkFrame._inkCanvas.ReleaseMouseCapture();
                            myButton.InkFrame._inkCanvas.Cursor = Cursors.Arrow;
                            myButton.TextBoxTime.Background     = null;
                            ButtonMoveCommand bmc = new ButtonMoveCommand(myButton, offsetx, offsety, _inkCollector);
                            _inkCollector.CommandStack.Push(bmc);
                        }
                        if (_inkCollector.SelectedImages.Count > 0)
                        {
                            foreach (MyImage image in _inkCollector.SelectedImages)
                            {
                                Command imc = new ImageMoveCommand(image, offsetx, offsety);
                                _inkCollector.CommandStack.Push(imc);
                                image.Bound.Visibility = Visibility.Collapsed;
                                _inkCanvas.Cursor      = Cursors.Arrow;
                                image.Image.ReleaseMouseCapture();

                                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);
                                _inkCollector.CommandStack.Push(mc);
                            }
                        }
                        //移动图形
                        if (SelectedMyGraphics.Count > 0)
                        {
                            foreach (MyGraphic myGraphic in SelectedMyGraphics)
                            {
                                MyGraphicMoveCommand mgmc = new MyGraphicMoveCommand(myGraphic, offsetx, offsety, _inkCollector);
                                _inkCollector.CommandStack.Push(mgmc);
                                mgmc.searchRelation();
                            }
                            //MyGraphicsMoveCommand mgsmc = new MyGraphicsMoveCommand(SelectedMyGraphics, offsetx, offsety, _inkCollector.Sketch.MyGraphics, _inkCollector);
                            //_inkCollector.CommandStack.Push(mgsmc);
                            List <int> ids = GraphicMathTool.getInstance().getGraphicStructure(_inkCollector.Sketch.MyGraphics[0], _inkCollector, new List <int>());
                            foreach (int id in ids)
                            {
                                _inkCollector._mainPage.message.Content += id.ToString() + ",";
                            }
                        }
                        //移动文本
                        foreach (MyRichTextBox myRichTextBox in _inkCollector.SelectedMyRichTextBoxs)
                        {
                            Command tmc = new TextMoveCommand(myRichTextBox, offsetx, offsety);
                            myRichTextBox.RichTextBox.BorderBrush = null;
                            _inkCollector.CommandStack.Push(tmc);
                        }
                        MoveOrZoom = "";
                        break;

                    case "Zoom":
                        _inkCollector.IsAutoMove = false;
                        StylusPoint curr = new StylusPoint(current.X, current.Y);
                        StylusPoint sta  = new StylusPoint(_startPoint.X, _startPoint.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), sta);
                            if (dist2 == 0)
                            {
                                dist2 = 1;
                            }
                            double scaling = dist1 / dist2;
                            _inkCanvas.Cursor = Cursors.Arrow;
                            myButton.TextBoxTime.Background = null;
                            ButtonZoomCommand bmc = new ButtonZoomCommand(myButton, scaling, _inkCollector, myButton.Angle);
                            _inkCollector.CommandStack.Push(bmc);
                        }
                        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), sta);
                            if (dist2 == 0)
                            {
                                dist2 = 1;
                            }
                            double scaling = dist1 / dist2;
                            _inkCanvas.Cursor      = Cursors.Arrow;
                            image.Bound.Visibility = Visibility.Collapsed;
                            ImageZoomCommand izc = new ImageZoomCommand(image, scaling);
                            _inkCollector.CommandStack.Push(izc);
                            foreach (ImageConnector connector in image.ConnectorCollection)
                            {
                                connector.adjustConnector();
                            }
                        }
                        MoveOrZoom = "";
                        break;
                    }



                    _inkCollector.SelectButtons.Clear();
                    _inkCollector.SelectedImages.Clear();
                    _inkCollector.SelectedStrokes.Clear();
                    _inkCollector.SelectedMyRichTextBoxs.Clear();
                    SelectedMyGraphics.Clear();
                }

                _inkCanvas.ReleaseMouseCapture();
                _inkCollector.IsAutoMove   = false;
                pressedMouseLeftButtonDown = false;
            }
        }
        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;
                }
            }
        }