示例#1
0
        private int _yOffset; //移動前後Y差值

        #endregion Fields

        #region Constructors

        //建構元
        public MoveShapeCommand(Model model, Shape shape,int xOffset,int yOffset)
        {
            this._model = model;
            this._targetShape = shape;
            this._xOffset = xOffset;
            this._yOffset = yOffset;
        }
示例#2
0
 //加入圖形
 public void AddShape(int mode, Point locationOfTopPoint)
 {
     Shape newShape = _shapeFactory.CreateShpae(mode, locationOfTopPoint);
     _shapes.Add(newShape);
     _focusShape = newShape;
     _focusShape.IsFocus = true;
 }
示例#3
0
 public void Initialize()
 {
     Point startPoint = new Point(10, 10);
     Point endPoint = new Point(20, 20);
     _rectangle = ShapeFactory.CreatShape(Mode.Rectangle, startPoint, endPoint);
     _moveShapeCommandTarget = new MoveShapeCommand_Accessor(_rectangle, new Point(10, 10));
 }
示例#4
0
 public ResizeShapeCommand(Shape shape, Point differentPoint, Point resize)
 {
     _resizeShape = shape;
     _startPoint = shape.StartPosition;
     _differentPoint = differentPoint;
     _resize = resize;
 }
示例#5
0
 // 按下滑鼠
 public override void PressMouse(Point point)
 {
     _startPosition = point;
     _mousePressed = true;
     _drawingShape = ShapeFactory.CreatShape(_shapeModel.SelectedMode, _startPosition, _startPosition);
     _drawingShape.IsSelect = true;
 }
        Point _oldPoint; //舊點

        #endregion Fields

        #region Constructors

        //建構元
        public ResizeShapeCommand(Model model, Shape shape, Shape.ChangePoint changePoint, Point newPoint,Point oldPoint)
        {
            _model = model;
            _targetShape = shape;
            _changePoint = changePoint;
            _newPoint = newPoint;
            _oldPoint = oldPoint;
        }
 public void Initialize()
 {
     Point startPoint = new Point(10, 10);
     Point endPoint = new Point(20, 20);
     _rectangle = ShapeFactory.CreatShape(Mode.Rectangle, startPoint, endPoint);
     _shapeModel = new ShapeModel();
     _deleteCommandTarget = new DeleteShapeCommand_Accessor(_rectangle, _shapeModel);
     _shapeModel.CursorChange += InvokeTest;
     _shapeModel.ScreenChange += InvokeTest;
     _shapeModel.StripChange += InvokeTest;
 }
示例#8
0
 //增加Shape命令
 public void AddShape(Shape targetShape,int shapeIndex)
 {
     if (!targetShape.IsAPoint) //可形成圖形 則新增命令
     {
         NewCommandExcute();
         _commands.Add(new AddShapeCommand(_model, targetShape, shapeIndex));
         targetShape.ResetLocationOfPaintPoint();
     }
     else //無法形成圖形 刪除點
     {
         _model.DeleteShape(shapeIndex);
     }
 }
示例#9
0
 //找尋被選取的圖形
 public void FindFocusShape(int mouseX, int mouseY)
 {
     if (_focusShape != null)
         DisposeFocusShape();
     for (int i = _shapes.Count() - 1; i >= 0; i--)
     {
         if (_shapes[i].ContainsInShape(mouseX, mouseY))
         {
             _focusShape = _shapes[i];
             _focusShape.IsFocus = true;
             break;
         }
     }
 }
示例#10
0
        // 放開滑鼠
        public override void ReleaseMouse(Point point)
        {
            if (_drawingShape != null)
            {
                Command command = new AddShapeCommand(_drawingShape, _shapeModel);
                if (_drawingShape.Width != 0 & _drawingShape.Height != 0)
                {
                    _shapeModel.DoCommand(command);
                }
                _drawingShape.IsSelect = false;
            }

            _drawingShape = null;
            _mousePressed = false;
        }
示例#11
0
 //按下滑鼠左鍵的事件
 public override void PressMouse(Point locationOfTopPoint)
 {
     if (_model.FocusShape != null && !_isPressing) //在案壓住並且有Shape被選中
     {
         _timer.Start(); //開始計數
         _FirstPressPoint = locationOfTopPoint;
         _isPressing = true;
         _focusShape = _model.FocusShape;
         if (IsPressOnControlPoint(locationOfTopPoint))
         {
             _isResizing = true;
         }
         else if (_focusShape.ContainsInShape(locationOfTopPoint.X, locationOfTopPoint.Y))
         {
             _isMoving = true;
         }
         else
         {
             _model.DisPoseFocusShape();
         }
     }
 }
示例#12
0
 //Resize命令
 public void ResizeShape(Shape targetShape, Point oldPoint, Point newPoint, Shape.ChangePoint changePoint)
 {
     NewCommandExcute();
     _commands.Add(new ResizeShapeCommand(_model, targetShape, changePoint, newPoint, oldPoint));
 }
示例#13
0
        private Model _model; // Model

        #endregion Fields

        #region Constructors

        //建構元
        public DeleteShapeCommand(Model model,Shape shape,int shapeIndex)
        {
            this._model = model;
            this._shapeIndex = shapeIndex;
            this._targetShape = shape;
        }
示例#14
0
 public AddShapeCommand(Shape shape, ShapeModel shapeModel)
 {
     _shape = shape;
     _shapeModel = shapeModel;
 }
示例#15
0
 //增加ReSize命令
 public void CommandResizeShape(Point oldPoint, Point newPoint, Shape.ChangePoint changePoint)
 {
     _commandManager.ResizeShape(FocusShape, oldPoint, newPoint, changePoint);
 }
示例#16
0
 public void Initialize()
 {
     _target = ShapeFactory.CreatShape(Mode.Line, new Point(10, 10), new Point(20, 20));
 }
示例#17
0
 public void Initialize()
 {
     Point start = new Point(10, 10);
     Point end= new Point(20, 20);
     _target = ShapeFactory.CreatShape(Mode.Rectangle, start, end);
 }
示例#18
0
 //取消選取狀態
 public void DisPoseFocusShape()
 {
     _shapes.DisposeFocusShape();
     _focusShape = null;
 }
示例#19
0
 public MoveShapeCommand(Shape shape, Point point)
 {
     _shape = shape;
     _point = point;
     _startPoint = _shape.StartPosition;
 }
示例#20
0
 //找尋目前鼠標所指的圖形
 public void FindFocusShape(int mouseX, int mouseY)
 {
     _shapes.FindFocusShape(mouseX, mouseY);
     if (_focusShape != _shapes.FocusShape)
         NotifyObserver();
     _focusShape = _shapes.FocusShape;
 }
示例#21
0
 //插入Shape
 public void InsertShape(Shape shape,int index)
 {
     _shapes.InsertShape(index, shape);
 }
示例#22
0
 public DeleteShapeCommand(Shape shape, ShapeModel shapeModel)
 {
     _shape = shape;
     _shapeModel = shapeModel;
 }
示例#23
0
 //增加圖形
 public void AddShape(Point locationOfTopPoint)
 {
     _shapes.AddShape((int)_shapeType, locationOfTopPoint);
     _focusShape = _shapes.FocusShape;
 }
示例#24
0
 //插入圖形
 public void InsertShape(int index, Shape shape)
 {
     _shapes.Insert(index, shape);
 }
示例#25
0
 //刪除圖形命令
 public void DeleteShape(Shape targetShape, int shapeIndex)
 {
     NewCommandExcute();
     _model.DeleteShape(shapeIndex);
     _model.DisPoseFocusShape();
     _commands.Add(new DeleteShapeCommand(_model,targetShape,shapeIndex));
 }
示例#26
0
 //取消選取
 public void DisposeFocusShape()
 {
     if (_focusShape != null)
         _focusShape.IsFocus = false;
     _focusShape = null;
 }
示例#27
0
 //移動圖形命令
 public void MoveShape(Shape targetShape,int xOffset,int yOffset)
 {
     NewCommandExcute();
     _commands.Add(new MoveShapeCommand(_model,targetShape,xOffset,yOffset));
 }
示例#28
0
 //找尋圖形Index
 public int FindShapeInedx(Shape targetShape)
 {
     for (int i = 0; i < _shapes.Count; i++)
     {
         if (_shapes[i] == targetShape)
             return i;
     }
     return -1; //not found
 }
示例#29
0
        private Model _model; //Model

        #endregion Fields

        #region Constructors

        //建構元
        public AddShapeCommand(Model model, Shape targetShape, int shapeIndex)
        {
            this._model = model;
            this._targetShape = targetShape;
            this._shapeIndex = shapeIndex;
        }