Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
 //加入圖形
 public void AddShape(int mode, Point locationOfTopPoint)
 {
     Shape newShape = _shapeFactory.CreateShpae(mode, locationOfTopPoint);
     _shapes.Add(newShape);
     _focusShape = newShape;
     _focusShape.IsFocus = true;
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 4
0
 public ResizeShapeCommand(Shape shape, Point differentPoint, Point resize)
 {
     _resizeShape = shape;
     _startPoint = shape.StartPosition;
     _differentPoint = differentPoint;
     _resize = resize;
 }
Ejemplo n.º 5
0
 // 按下滑鼠
 public override void PressMouse(Point point)
 {
     _startPosition = point;
     _mousePressed = true;
     _drawingShape = ShapeFactory.CreatShape(_shapeModel.SelectedMode, _startPosition, _startPosition);
     _drawingShape.IsSelect = true;
 }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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;
         }
     }
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 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();
         }
     }
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 14
0
 public AddShapeCommand(Shape shape, ShapeModel shapeModel)
 {
     _shape = shape;
     _shapeModel = shapeModel;
 }
Ejemplo n.º 15
0
 //增加ReSize命令
 public void CommandResizeShape(Point oldPoint, Point newPoint, Shape.ChangePoint changePoint)
 {
     _commandManager.ResizeShape(FocusShape, oldPoint, newPoint, changePoint);
 }
Ejemplo n.º 16
0
 public void Initialize()
 {
     _target = ShapeFactory.CreatShape(Mode.Line, new Point(10, 10), new Point(20, 20));
 }
Ejemplo n.º 17
0
 public void Initialize()
 {
     Point start = new Point(10, 10);
     Point end= new Point(20, 20);
     _target = ShapeFactory.CreatShape(Mode.Rectangle, start, end);
 }
Ejemplo n.º 18
0
 //取消選取狀態
 public void DisPoseFocusShape()
 {
     _shapes.DisposeFocusShape();
     _focusShape = null;
 }
Ejemplo n.º 19
0
 public MoveShapeCommand(Shape shape, Point point)
 {
     _shape = shape;
     _point = point;
     _startPoint = _shape.StartPosition;
 }
Ejemplo n.º 20
0
 //找尋目前鼠標所指的圖形
 public void FindFocusShape(int mouseX, int mouseY)
 {
     _shapes.FindFocusShape(mouseX, mouseY);
     if (_focusShape != _shapes.FocusShape)
         NotifyObserver();
     _focusShape = _shapes.FocusShape;
 }
Ejemplo n.º 21
0
 //插入Shape
 public void InsertShape(Shape shape,int index)
 {
     _shapes.InsertShape(index, shape);
 }
Ejemplo n.º 22
0
 public DeleteShapeCommand(Shape shape, ShapeModel shapeModel)
 {
     _shape = shape;
     _shapeModel = shapeModel;
 }
Ejemplo n.º 23
0
 //增加圖形
 public void AddShape(Point locationOfTopPoint)
 {
     _shapes.AddShape((int)_shapeType, locationOfTopPoint);
     _focusShape = _shapes.FocusShape;
 }
Ejemplo n.º 24
0
 //插入圖形
 public void InsertShape(int index, Shape shape)
 {
     _shapes.Insert(index, shape);
 }
Ejemplo n.º 25
0
 //刪除圖形命令
 public void DeleteShape(Shape targetShape, int shapeIndex)
 {
     NewCommandExcute();
     _model.DeleteShape(shapeIndex);
     _model.DisPoseFocusShape();
     _commands.Add(new DeleteShapeCommand(_model,targetShape,shapeIndex));
 }
Ejemplo n.º 26
0
 //取消選取
 public void DisposeFocusShape()
 {
     if (_focusShape != null)
         _focusShape.IsFocus = false;
     _focusShape = null;
 }
Ejemplo n.º 27
0
 //移動圖形命令
 public void MoveShape(Shape targetShape,int xOffset,int yOffset)
 {
     NewCommandExcute();
     _commands.Add(new MoveShapeCommand(_model,targetShape,xOffset,yOffset));
 }
Ejemplo n.º 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
 }
Ejemplo n.º 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;
        }