public virtual void RecomputePoints() { FlowChartPoint pt = GetWeightedPoint(); this.CenterPoint.X = pt.X; this.CenterPoint.Y = pt.Y; }
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); }
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); }
public override FlowChartPoint GetWeightedPoint() { FlowChartPoint pt = StartPoint.CloneAndAdd(EndPoint).CloneAndAdd(ControlPoint1).CloneAndAdd(ControlPoint2); pt.X = pt.X / 4; pt.Y = pt.Y / 4; return(pt); }
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))); }
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); }
public override void RecomputeEdgePoints() { float aradius = Math.Abs(TopLeftCorner.MakeRectangleFTill(BottomRightCorner).Width) / 2; float bradius = Math.Abs(TopLeftCorner.MakeRectangleFTill(BottomRightCorner).Height) / 2; FlowChartPoint centerPoint = TopLeftCorner.CloneAndAdd(BottomRightCorner); centerPoint.X /= 2; centerPoint.Y /= 2; float angle = -(float)Math.PI / 2.0f; this.EdgePoints.ForEach(x => { x.X = centerPoint.X + aradius * (float)Math.Cos(angle); x.Y = centerPoint.Y + bradius * (float)Math.Sin(angle); angle += (float)Math.PI / 4.0f; }); }
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)); } }
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() }); }
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()); }
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 DrawPoint(Graphics g, FlowChartPoint p, Pen pen, float width) { DrawPoint(g, p, pen, width, false); }
public override void SetComponent(FlowChartComponent component) { ControlPoint1 = component.Points[2]; ControlPoint2 = component.Points[3]; base.SetComponent(component); }
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; }
public LinePointMovedVisitor(BaseLineComponent lineCmp, FlowChartPoint linePoint) { this.lineCmp = lineCmp; this.linePoint = linePoint; }
internal static float Distance(FlowChartPoint p1, FlowChartPoint p2) { return(Distance(p1, p2.X, p2.Y)); }
protected void DrawBoundingBox(Graphics g, FlowChartPoint startPoint, FlowChartPoint endPoint) { g.DrawPolygon(ViewFactory.BoundingBoxPen, startPoint.MakePointFArrayWith(endPoint)); }
protected void DrawResizePoint(Graphics g, FlowChartPoint p, Pen pen, float width) { Draw4Arrows(g, p, 10); }
internal static float Distance(FlowChartPoint p1, float x, float y) { return(Distance(p1.X, p1.Y, x, y)); }