public void Draw(IDrawingContext dc) { var p0 = PointSnapper.SnapPoint(Points[0]); var p1 = PointSnapper.SnapPoint(Points[1]); dc.DrawLine(Pen, p0, p1); if (IsSelected) { selectionGeo1 = new RectangleGeometry(new Rect(PointSnapper.RoundValue(p0.X - 3), PointSnapper.RoundValue(p0.Y - 3), 6, 6)); selectionGeo2 = new RectangleGeometry(new Rect(PointSnapper.RoundValue(p1.X - 3), PointSnapper.RoundValue(p1.Y - 3), 6, 6)); dc.DrawGeometry(Pen.Brush, null, selectionGeo1); dc.DrawGeometry(Pen.Brush, null, selectionGeo2); } CreateRegion(); }
public void Draw(IDrawingContext dc) { if (iPoint != pointCount) { return; } var pts = new Point[pointCount]; for (int i = 0; i < pointCount; i++) { pts[i] = PointSnapper.SnapPoint(Points[i]); } dc.DrawLine(Pen, pts[0], pts[1]); var diffX = pts[1].X - pts[2].X; var diffY = pts[1].Y - pts[2].Y; Point pt00 = new Point(pts[0].X - diffX, pts[0].Y - diffY); dc.DrawLine(Pen, pt00, pts[2]); if (IsSelected) { selectionGeoList = new List <RectangleGeometry>(); for (int i = 0; i < PointCount; i++) { var selectionGeo = new RectangleGeometry(new Rect(PointSnapper.RoundValue(pts[i].X - 3), PointSnapper.RoundValue(pts[i].Y - 3), 6, 6)); dc.DrawGeometry(Pen.Brush, null, selectionGeo); selectionGeoList.Add(selectionGeo); } } CreateRegion(pts); }