protected void DrawText(Graphics g, Font font, string text, Brush brush, FlowChartPoint point) { StringFormat sf = new StringFormat(StringFormat.GenericDefault); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; g.DrawString(text, font, brush, point.X, point.Y, sf); }
protected void DrawPoint(Graphics g, FlowChartPoint p, Pen pen, float width, bool fill) { if (fill) { g.FillRectangle(Brushes.AliceBlue, p.X - width / 2, p.Y - width / 2, width, width); } g.DrawRectangle(pen, p.X - width / 2, p.Y - width / 2, width, width); }
internal PointF[] MakePointFArrayWith(FlowChartPoint endPoint) { return(new PointF[] { new PointF(X, Y), new PointF(endPoint.X, Y), new PointF(endPoint.X, endPoint.Y), new PointF(X, endPoint.Y) }); }
internal FlowChartPoint[] MakeFlowChartPointArrayWith(FlowChartPoint endPoint) { return(new FlowChartPoint[] { new FlowChartPoint(X, Y), new FlowChartPoint(endPoint.X, Y), new FlowChartPoint(endPoint.X, endPoint.Y), new FlowChartPoint(X, endPoint.Y) }); }
internal static float DistanceToLine(FlowChartPoint StartPoint, FlowChartPoint EndPoint, int x, int y) { float A = x - StartPoint.X; float B = y - StartPoint.Y; float C = EndPoint.X - StartPoint.X; float D = EndPoint.Y - StartPoint.Y; return (float)(Math.Abs(A * D - C * B) / Math.Sqrt(C * C + D * D)); }
internal static bool HasPoint(FlowChartPoint[] points, float testx, float testy) { int i, j; bool c = false; for (i = 0, j = points.Length - 1; i < points.Length; j = i++) { if (((points[i].Y > testy) != (points[j].Y > testy)) && (testx < (points[j].X - points[i].X) * (testy - points[i].Y) / (points[j].Y - points[i].Y) + points[i].X)) c = !c; } return c; }
protected void Draw4Arrows(Graphics g, FlowChartPoint p, float length) { /* ^ * <-|-> * v */ DrawArrow(g, p.CloneAndAdd(0, -length), p, Brushes.YellowGreen, Pens.Red, length); DrawArrow(g, p.CloneAndAdd(0, length), p, Brushes.YellowGreen, Pens.Red, length); DrawArrow(g, p.CloneAndAdd(-length, 0), p, Brushes.YellowGreen, Pens.Red, length); DrawArrow(g, p.CloneAndAdd(length, 0), p, Brushes.YellowGreen, Pens.Red, length); }
protected void DrawBoundingBox(Graphics g, FlowChartPoint p1, FlowChartPoint p2, FlowChartPoint p3, FlowChartPoint p4) { g.DrawPolygon( ViewFactory.BoundingBoxPen, new PointF[] { p1.MakePointF(), p2.MakePointF(), p3.MakePointF(), p4.MakePointF() }); }
void LinePointMovedTo(BaseLineComponent lineCmp, FlowChartPoint point) { if (lineCmp.StartPoint == point) { lineCmp.ConnectionStart = null; } else if (lineCmp.EndPoint == point) { lineCmp.ConnectionEnd = null; } foreach (BaseComponent drawableCmp in model.Items) { drawableCmp.Accept(new LinePointMovedVisitor(lineCmp, point)); } }
private PointF Bezier(FlowChartPoint a, FlowChartPoint b, FlowChartPoint c, FlowChartPoint d, float t) { FlowChartPoint ab = new FlowChartPoint(), bc = new FlowChartPoint(), cd = new FlowChartPoint(), abbc = new FlowChartPoint(), bccd = new FlowChartPoint(), dest = new FlowChartPoint(); Lerp( ab, a, b, t); // point between a and b (green) Lerp( bc, b, c, t); // point between b and c (green) Lerp( cd, c, d, t); // point between c and d (green) Lerp( abbc, ab, bc, t); // point between ab and bc (blue) Lerp( bccd, bc, cd, t); // point between bc and cd (blue) Lerp( dest, abbc, bccd, t); // point on the bezier-curve (black) return dest.MakePointF(); }
public FlowChartPoint CloneAndSubtract(FlowChartPoint another) { return new FlowChartPoint(X - another.X, Y - another.Y); }
protected void DrawArrow(Graphics g, FlowChartPoint dst, FlowChartPoint src, Brush b, Pen p, float length) { float angle = (float)Math.Atan2(dst.Y - src.Y, dst.X - src.X); float x1 = dst.X - (float)(0.5 * length * Math.Cos(angle + Math.PI / 6.0f)); float y1 = dst.Y - (float)(0.5 * length * Math.Sin(angle + Math.PI / 6.0f)); float x2 = dst.X - (float)(0.5 * length * Math.Cos(angle - Math.PI / 6.0f)); float y2 = dst.Y - (float)(0.5 * length * Math.Sin(angle - Math.PI / 6.0f)); g.FillPolygon(b, new PointF[] { new PointF(dst.X, dst.Y), new PointF(x1, y1), new PointF(x2, y2) }); g.DrawPolygon(p, new PointF[] { new PointF(dst.X, dst.Y), new PointF(x1, y1), new PointF(x2, y2) }); }
protected void DrawResizePoint(Graphics g, FlowChartPoint p, Pen pen, float width) { Draw4Arrows(g, p, 10); }
protected void DrawBoundingBox(Graphics g, FlowChartPoint startPoint, FlowChartPoint endPoint) { g.DrawPolygon(ViewFactory.BoundingBoxPen, startPoint.MakePointFArrayWith(endPoint)); }
internal PointF[] MakePointFArrayWith(FlowChartPoint endPoint) { return new PointF[] { new PointF(X, Y), new PointF(endPoint.X, Y), new PointF(endPoint.X, endPoint.Y), new PointF(X, endPoint.Y) }; }
protected void DrawPoint(Graphics g, FlowChartPoint p, Pen pen, float width) { DrawPoint(g, p, pen, width, false); }
public FlowChartPoint CloneAndSubtract(FlowChartPoint another) { return(new FlowChartPoint(X - another.X, Y - another.Y)); }
internal RectangleF MakeRectangleFTill(FlowChartPoint endPoint) { return new RectangleF(X, Y, endPoint.X - X, endPoint.Y - Y); }
internal Rectangle MakeRectangleTill(FlowChartPoint endPoint) { return(new Rectangle((int)X, (int)Y, (int)(endPoint.X - X), (int)(endPoint.Y - Y))); }
public FlowChartPoint Add(FlowChartPoint another) { this.X += another.X; this.Y += another.Y; return(this); }
internal static float Distance(FlowChartPoint p1, FlowChartPoint p2) { return Distance(p1, p2.X, p2.Y); }
internal static float Distance(FlowChartPoint p1, float x, float y) { return Distance(p1.X, p1.Y, x, y); }
public FlowChartPoint CloneAndAdd(FlowChartPoint another) { return new FlowChartPoint(X + another.X, Y + another.Y); }
public override void SetComponent(FlowChartComponent component) { ControlPoint1 = component.Points[2]; ControlPoint2 = component.Points[3]; base.SetComponent(component); }
public FlowChartPoint Subtract(FlowChartPoint another) { this.X -= another.X; this.Y -= another.Y; return this; }
void Lerp(FlowChartPoint dest, FlowChartPoint a, FlowChartPoint b, float t) { dest.X = a.X + (b.X - a.X) * t; dest.Y = a.Y + (b.Y - a.Y) * t; }
internal Rectangle MakeRectangleTill(FlowChartPoint endPoint) { return new Rectangle((int)X, (int)Y, (int)(endPoint.X - X), (int)(endPoint.Y - Y)); }
public FlowChartPoint Subtract(FlowChartPoint another) { this.X -= another.X; this.Y -= another.Y; return(this); }
internal FlowChartPoint[] MakeFlowChartPointArrayWith(FlowChartPoint endPoint) { return new FlowChartPoint[] { new FlowChartPoint(X, Y), new FlowChartPoint(endPoint.X, Y), new FlowChartPoint(endPoint.X, endPoint.Y), new FlowChartPoint(X, endPoint.Y) }; }
public FlowChartPoint CloneAndAdd(FlowChartPoint another) { return(new FlowChartPoint(X + another.X, Y + another.Y)); }
public FlowChartPoint Add(FlowChartPoint another) { this.X += another.X; this.Y += another.Y; return this; }
internal RectangleF MakeRectangleFTill(FlowChartPoint endPoint) { return(new RectangleF(X, Y, endPoint.X - X, endPoint.Y - Y)); }
public LinePointMovedVisitor(BaseLineComponent lineCmp, FlowChartPoint linePoint) { this.lineCmp = lineCmp; this.linePoint = linePoint; }