public override void Draw(Canvas canvas) { Point thirdPoint = new Point(); PointCollection pointCollection = new PointCollection(); thirdPoint.X = firstPoint.X - (secondPoint.X - firstPoint.X); thirdPoint.Y = secondPoint.Y; height = (int)Math.Abs(firstPoint.Y - secondPoint.Y); width = (int)Math.Abs(secondPoint.X - thirdPoint.X) / 2; pointCollection.Clear(); pointCollection.Add(firstPoint); pointCollection.Add(secondPoint); pointCollection.Add(thirdPoint); System.Windows.Shapes.Polygon triangle = new System.Windows.Shapes.Polygon() { Points = pointCollection, Stroke = Brushes.Black, StrokeThickness = thickness, Fill = new SolidColorBrush(Colors.Wheat) }; hash = triangle.GetHashCode(); canvas.Children.Add(triangle); }
public override void Draw(Canvas canvas) { _points = new PointCollection(); if ((FirstPoint.X < SecondPoint.X) && (FirstPoint.Y < SecondPoint.Y)) { _up.X = FirstPoint.X; _up.Y = FirstPoint.Y; _left.X = FirstPoint.X; _left.Y = SecondPoint.Y; _right.X = SecondPoint.X; _right.Y = SecondPoint.Y; } else if ((FirstPoint.X < SecondPoint.X) && (FirstPoint.Y > SecondPoint.Y)) { _up.X = FirstPoint.X; _up.Y = SecondPoint.Y; _left.X = FirstPoint.X; _left.Y = FirstPoint.Y; _right.X = SecondPoint.X; _right.Y = FirstPoint.Y; } else if ((FirstPoint.X > SecondPoint.X) && (FirstPoint.Y < SecondPoint.Y)) { _up.X = SecondPoint.X; _up.Y = FirstPoint.Y; _left.X = SecondPoint.X; _left.Y = SecondPoint.Y; _right.X = FirstPoint.X; _right.Y = SecondPoint.Y; } else { _up.X = SecondPoint.X; _up.Y = SecondPoint.Y; _left.X = SecondPoint.X; _left.Y = FirstPoint.Y; _right.X = FirstPoint.X; _right.Y = FirstPoint.Y; } _points.Add(_up); _points.Add(_left); _points.Add(_right); var triangle = new System.Windows.Shapes.Polygon() { Points = _points, Stroke = Color, StrokeThickness = Thickness, Tag = Tag }; Tag = triangle.GetHashCode(); canvas.Children.Add(triangle); }