Exemplo n.º 1
0
 public void undo()
 {
     foreach (MyGraphic mg in _myGraphicsMove)
     {
         MyGraphicMoveCommand mgmc = new MyGraphicMoveCommand(mg, -offset_x, -offset_y, _inkCollector);
         mgmc.execute();
     }
 }
Exemplo n.º 2
0
        public void execute()
        {
            //移动需要移动的graphic
            foreach (MyGraphic mg in _myGraphicsMove)
            {
                MyGraphicMoveCommand mgmc = new MyGraphicMoveCommand(mg, offset_x, offset_y, _inkCollector);
                mgmc.execute();
            }
            //找出要移动的graphic中不是箭头的graphic
            List <MyGraphic> MyGraphicsNoArrow = new List <MyGraphic>();
            StrokeCollection strokesMove       = new StrokeCollection();

            foreach (MyGraphic mg in _myGraphicsMove)
            {
                if (mg.ShapeType != "arrow" && mg.ShapeType != "loopArc" && mg.ShapeType != "polylineArrow" && mg.ShapeType != "loopArcSelf")
                {
                    strokesMove.Add(mg.Strokes);
                    MyGraphicsNoArrow.Add(mg);
                }
            }
            Rect boundMove = strokesMove.GetBounds(); //获取需要移动的graphic的矩形边框
            //检查其他不需要移动的graphic与移动的graphic之间的距离是否小到了最小阈值
            Rect boundOther;                          //不需要移动的graphic的矩形边框

            foreach (MyGraphic mg in MyGraphics)
            {
                if (_myGraphicsMove.IndexOf(mg) == -1)
                {
                    boundOther = mg.Strokes.GetBounds();
                    if (MathTool.getInstance().distanceR2R(boundOther, boundMove) <= GlobalValues.MyGraphic_SpacingDistance)
                    {
                        //MessageBox.Show("嘿,太近了");
                        List <MyGraphic> MyGraphicsOther = new List <MyGraphic>();
                        MyGraphicsOther.Add(mg);
                        MyGraphicsMoveCommand mgmc = new MyGraphicsMoveCommand(MyGraphicsOther, offset_x, offset_y, _inkCollector);
                        mgmc.execute();
                    }
                }
            }
        }