public Contour(Color color, ArrayList elements) { shapeSegments = new ArrayList(); if (elements != null) { foreach (Element element in elements) { if (element is Line) { Line line = element as Line; shapeSegments.Add(new LineSegment(new PointF(line.x1 * 3.0F + 10.0F, line.y1 * 3.0F + 10.0F), new PointF(line.x2 * 3.0F + 10.0F, line.y2 * 3.0F + 10.0F))); } if (element is Bezier) { Bezier bezier = element as Bezier; BezierSegment bezierSegment = new BezierSegment(); bezierSegment.points[0] = new PointF(bezier.x1 * 3.0F + 10.0F, bezier.y1 * 3.0F + 10.0F); bezierSegment.points[1] = new PointF(bezier.x2 * 3.0F + 10.0F, bezier.y2 * 3.0F + 10.0F); bezierSegment.points[2] = new PointF(bezier.x3 * 3.0F + 10.0F, bezier.y3 * 3.0F + 10.0F); bezierSegment.points[3] = new PointF(bezier.x4 * 3.0F + 10.0F, bezier.y4 * 3.0F + 10.0F); shapeSegments.Add(BelongSegment); } } } }
private void menuItemInsertDecorBezierOnClick(object Sender, System.EventArgs e) { PointF pt0 = new PointF(saveNewPosX, saveNewPosY); PointF pt3 = new PointF(saveNewPosX + decorationWidth, saveNewPosY); BezierSegment newBezierSeg = new BezierSegment(); newBezierSeg.IsDecorationSegment = true; newBezierSeg.points[0] = pt0; newBezierSeg.points[1] = new PointF((pt0.X + pt3.X) / 3, (pt0.Y + pt3.Y) / 3); newBezierSeg.points[2] = new PointF((pt0.X + pt3.X) * 2 / 3, (pt0.Y + pt3.Y) * 2 / 3); newBezierSeg.points[3] = pt3; PolyLine newPolyline = new PolyLine(newBezierSeg); outLines.Add(newPolyline); newPolyline.Changed += new OutlineChangeEventHandler(onContourChanged); changeContour(Sender); }
private void CovertTo() { if (saveSegment is LineSegment) { BezierSegment newBezierSeg = new BezierSegment(); if ((saveSegment as LineSegment).IsDecorationSegment) { newBezierSeg.IsDecorationSegment = true; } shapeSegments.Remove(saveSegment); newBezierSeg.points[0] = saveStartPoint; newBezierSeg.points[1] = new PointF(((saveStartPoint.X) * 2 + saveEndPoint.X) / 3, ((saveStartPoint.Y) * 2 + saveEndPoint.Y) / 3); newBezierSeg.points[2] = new PointF(((saveStartPoint.X) / 2 + saveEndPoint.X) * 2 / 3, ((saveStartPoint.Y) / 2 + saveEndPoint.Y) * 2 / 3); newBezierSeg.points[3] = saveEndPoint; shapeSegments.Insert(saveIndex, newBezierSeg); } if (saveSegment is BezierSegment) { LineSegment newLineSegment = new LineSegment(saveStartPoint, saveEndPoint); if ((saveSegment as BezierSegment).IsDecorationSegment) { newLineSegment.IsDecorationSegment = true; } shapeSegments.Remove(saveSegment); shapeSegments.Insert(saveIndex, newLineSegment); } if (Changed != null) { Changed(this, new EventArgs()); } }
public Contour(Color color, ArrayList arr, PointF[] pStart, PointF[] point1, PointF[] point2, PointF[] pEnd) { Segment s = null; shapeSegments = new ArrayList(); if (arr != null) { for (int i = 0; i < arr.Count; ++i) { if (arr[i] is LineSegment) s = new LineSegment(pStart[i], pEnd[i]); if (arr[i] is BezierSegment) { s = new BezierSegment(); (s as BezierSegment).points[0] = pStart[i]; (s as BezierSegment).points[1] = point1[i]; (s as BezierSegment).points[2] = point2[i]; (s as BezierSegment).points[3] = pEnd[i]; } shapeSegments.Add(s); } } fillColor = color; }
internal void splitToBezier() { PointF pt0, pt3; pt0 = new PointF(saveNewPosX, saveNewPosY); pt3 = saveEndPoint; BezierSegment newBezierSegment = new BezierSegment(); LineSegment newLineSegment = new LineSegment(saveStartPoint, new PointF(saveNewPosX, saveNewPosY)); if (saveSegment is LineSegment && (saveSegment as LineSegment).IsDecorationSegment) { newBezierSegment.IsDecorationSegment = true; newLineSegment.IsDecorationSegment = true; } shapeSegments.Remove(saveSegment); shapeSegments.Insert(saveIndex, newLineSegment); newBezierSegment.points[0] = pt0; newBezierSegment.points[1] = new PointF(((pt0.X) * 2 + pt3.X) / 3, ((pt0.Y) * 2 + pt3.Y) / 3); newBezierSegment.points[2] = new PointF(((pt0.X) / 2 + pt3.X) * 2 / 3, ((pt0.Y) / 2 + pt3.Y) * 2 / 3); newBezierSegment.points[3] = pt3; shapeSegments.Insert(saveIndex + 1, newBezierSegment); if (Changed != null) Changed(this, new EventArgs()); }
private void CovertTo() { if (saveSegment is LineSegment) { BezierSegment newBezierSeg = new BezierSegment(); if ((saveSegment as LineSegment).IsDecorationSegment) newBezierSeg.IsDecorationSegment = true; shapeSegments.Remove(saveSegment); newBezierSeg.points[0] = saveStartPoint; newBezierSeg.points[1] = new PointF(((saveStartPoint.X) * 2 + saveEndPoint.X) / 3, ((saveStartPoint.Y) * 2 + saveEndPoint.Y) / 3); newBezierSeg.points[2] = new PointF(((saveStartPoint.X) / 2 + saveEndPoint.X) * 2 / 3, ((saveStartPoint.Y) / 2 + saveEndPoint.Y) * 2 / 3); newBezierSeg.points[3] = saveEndPoint; shapeSegments.Insert(saveIndex, newBezierSeg); } if (saveSegment is BezierSegment) { LineSegment newLineSegment = new LineSegment(saveStartPoint, saveEndPoint); if ((saveSegment as BezierSegment).IsDecorationSegment) newLineSegment.IsDecorationSegment = true; shapeSegments.Remove(saveSegment); shapeSegments.Insert(saveIndex, newLineSegment); } if (Changed != null) Changed(this, new EventArgs()); }