internal void combineSegments(float SaveCurrX, float SaveCurrY) { PointF pStart; PointF pEnd; if (shapeSegments.Count > MinNumLines) { for (int i = 0; i < shapeSegments.Count; ++i) { Segment s1 = (Segment)shapeSegments[i]; Segment s2 = (Segment)shapeSegments[(i + 1) % shapeSegments.Count]; if (s1.hitTest(new PointF(SaveCurrX, SaveCurrY)) && s2.hitTest(new PointF(SaveCurrX, SaveCurrY))) { saveIndex = i; pStart = s1.GetStartPoint(); pEnd = s2.GetEndPoint(); shapeSegments.Remove(s1); shapeSegments.Remove(s2); Segment sCombinedLine = new LineSegment(pStart, pEnd); shapeSegments.Insert(i, sCombinedLine); break; } } } }
internal override int getSegmentIndex(PointF p) { int Value = -1; for (int i = 0; i < shapeSegments.Count; ++i) { Segment s = (Segment)shapeSegments[i]; if (s.distanceToPoint(p) < distanceToLine) { saveSegment = s; saveStartPoint = s.GetStartPoint(); saveEndPoint = s.GetEndPoint(); saveIndex = i; Value = i; break; } } return(Value); }
private void DefineTextArea() { flagDefineTextArea = !flagDefineTextArea; menuItemDefineTextArea.Visible = false; menuItemClearTextArea.Visible = true; ArrayList arr = new ArrayList(); arr = ((Outline)outLines[0] as Contour).getSegments(); RectangleF rect = ((Outline)outLines[0] as Contour).getBoundingRect(); float middleCenterRectX = (Math.Abs(rect.Right - rect.Left)) / 2.0F + rect.Left; float middleCenterRectY = (Math.Abs(rect.Bottom - rect.Top)) / 2.0F + rect.Top; PointF[] pStart = new PointF[arr.Count]; PointF[] pEnd = new PointF[arr.Count]; PointF[] point1 = new PointF[arr.Count]; PointF[] point2 = new PointF[arr.Count]; for (int i = 0; i < arr.Count; ++i) { Segment s = (Segment)arr[i]; if (s is BezierSegment) { if ((s as BezierSegment).points[1].X < middleCenterRectX) { point1[i].X = (s as BezierSegment).points[1].X + distanceToTextArea; } if ((s as BezierSegment).points[1].X >= middleCenterRectX) { point1[i].X = (s as BezierSegment).points[1].X - distanceToTextArea; } if ((s as BezierSegment).points[1].Y < middleCenterRectY) { point1[i].Y = (s as BezierSegment).points[1].Y + distanceToTextArea; } if ((s as BezierSegment).points[1].Y >= middleCenterRectY) { point1[i].Y = (s as BezierSegment).points[1].Y - distanceToTextArea; } if ((s as BezierSegment).points[2].X < middleCenterRectX) { point2[i].X = (s as BezierSegment).points[2].X + distanceToTextArea; } if ((s as BezierSegment).points[2].X >= middleCenterRectX) { point2[i].X = (s as BezierSegment).points[2].X - distanceToTextArea; } if ((s as BezierSegment).points[2].Y < middleCenterRectY) { point2[i].Y = (s as BezierSegment).points[2].Y + distanceToTextArea; } if ((s as BezierSegment).points[2].Y >= middleCenterRectY) { point2[i].Y = (s as BezierSegment).points[2].Y - distanceToTextArea; } } PointF tempStart = s.GetStartPoint(); PointF tempEnd = s.GetEndPoint(); if (tempStart.X < middleCenterRectX) { pStart[i].X = tempStart.X + distanceToTextArea; } if (tempStart.X >= middleCenterRectX) { pStart[i].X = tempStart.X - distanceToTextArea; } if (tempEnd.X < middleCenterRectX) { pEnd[i].X = tempEnd.X + distanceToTextArea; } if (tempEnd.X >= middleCenterRectX) { pEnd[i].X = tempEnd.X - distanceToTextArea; } if (tempStart.Y < middleCenterRectY) { pStart[i].Y = tempStart.Y + distanceToTextArea; } if (tempStart.Y >= middleCenterRectY) { pStart[i].Y = tempStart.Y - distanceToTextArea; } if (tempEnd.Y < middleCenterRectY) { pEnd[i].Y = tempEnd.Y + distanceToTextArea; } if (tempEnd.Y >= middleCenterRectY) { pEnd[i].Y = tempEnd.Y - distanceToTextArea; } } Contour contour = new Contour(textAreaContourColor, arr, pStart, point1, point2, pEnd); outLines.Add(contour); contour.Changed += new OutlineChangeEventHandler(onContourChanged); }