private void Canvas_MouseDown(object sender, MouseButtonEventArgs e) { _currentState |= State.LEFTMOUSE_DOWN; if (_currentState.HasFlag(State.DRAWING)) { _lastDownedPoint = GetDot(e.GetPosition(shapeCanvas).ToVector()); _movingPoint = GDot.FromCoord(e.GetPosition(shapeCanvas).ToVector()); if (_drawingShape == null) { if (_currentState.HasFlag(State.CIRCLE)) { _drawingShape = GCircle.FromTwoDots(_lastDownedPoint, _movingPoint); } else if (_currentState.HasFlag(State.LINE)) { _drawingShape = GLine.FromTwoDots(_lastDownedPoint, _movingPoint); } else if (_currentState.HasFlag(State.DOT)) { _drawingShape = _lastDownedPoint; } _drawingShape.Control.Stroke = Brushes.Blue; shapeCanvas.Children.Add(_drawingShape.Control); } } }
private void AddShape(GShape shape) { _shapes.Add(shape); if (!shapeCanvas.Children.Contains(shape.Control)) { shapeCanvas.Children.Add(shape.Control); } foreach (var c in shape.Childs) { if (!_shapes.Contains(c)) { AddShape(c); } } }
public override void IntersectWith(GShape gShape) { IntersectionResult res; if (gShape is GLine) { res = Intersection.ParabolaLine(this, (GLine)gShape); if (res.IntersectionPoints.Count == 0) { return; } IntersectionResults.Add(res); } else if (gShape is GParabola) { res = Intersection.ParabolaParabola(this, (GParabola)gShape); if (res.IntersectionPoints.Count == 0) { return; } IntersectionResults.Add(res); } else if (gShape is GCircle) { res = Intersection.ParabolaCircle(this, (GCircle)gShape); if (res.IntersectionPoints.Count == 0) { return; } IntersectionResults.Add(res); } }
private void Canvas_MouseUp(object sender, MouseButtonEventArgs e) { _currentState &= ~State.LEFTMOUSE_DOWN; AddShape(_drawingShape); _drawingShape = null; // 요거 없으면 새로 생성안함 }