// 按下滑鼠 public void PressPointer(double x, double y) { _model.IsPressed = true; _resizing = WantToResize(x, y); _index = _model.GetSelectedShapeIndex(); if (_resizing) { _model.RemoveSelectedShapeFromTotalShapes(); _originalShape = _shapeFactory.CreateShape(_model.SelectedShape); } }
// 處理按下指標事件 public override void PressPointer(ShapeType shapeType, double left, double top) { if (left > 0 && top > 0) { _type = shapeType; _startPoint.Left = left; _startPoint.Top = top; _hint = _shapeFactory.CreateShape(_type); SetShapePoints(_hint, _startPoint, _startPoint); _isPressed = true; } }
// 畫預覽圖 public void DrawHint(double x1, double y1, double x2, double y2) { if (CurrentMode == -1) { _shapeHint = _shapeFactory.CreateShape(SelectedShape); SelectedShape = _shapeHint; } else { _shapeHint = _shapeFactory.CreateShape(CurrentMode); } _shapeHint.X1 = x1; _shapeHint.Y1 = y1; _shapeHint.X2 = x2; _shapeHint.Y2 = y2; }
//when pointer is released public void ReleasePointer(double x, double y) { const int FOUR = 4; _isPressed = false; double[] points = new double[FOUR] { _topLeftPointX, _topLeftPointY, x, y }; _shapeFactory.CreateShape(_paintMode, points, _commandManager, this); _hintShapes[_paintMode].TopLeftPointX = ZERO; _hintShapes[_paintMode].TopLeftPointY = ZERO; _hintShapes[_paintMode].BottomRightPointX = ZERO; _hintShapes[_paintMode].BottomRightPointY = ZERO; NotifyModelChanged(); }
public DrawState(Model model, Model.ShapeType type) { _model = model; _hint = _shapeFactory.CreateShape(type); }