コード例 #1
0
        public virtual void RecomputePoints()
        {
            FlowChartPoint pt = GetWeightedPoint();

            this.CenterPoint.X = pt.X;
            this.CenterPoint.Y = pt.Y;
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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)));
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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;
            });
        }
コード例 #8
0
        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));
            }
        }
コード例 #9
0
 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()
     });
 }
コード例 #10
0
        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());
        }
コード例 #11
0
        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)
            });
        }
コード例 #12
0
 protected void DrawPoint(Graphics g, FlowChartPoint p, Pen pen, float width)
 {
     DrawPoint(g, p, pen, width, false);
 }
コード例 #13
0
 public override void SetComponent(FlowChartComponent component)
 {
     ControlPoint1 = component.Points[2];
     ControlPoint2 = component.Points[3];
     base.SetComponent(component);
 }
コード例 #14
0
 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;
 }
コード例 #15
0
 public LinePointMovedVisitor(BaseLineComponent lineCmp, FlowChartPoint linePoint)
 {
     this.lineCmp   = lineCmp;
     this.linePoint = linePoint;
 }
コード例 #16
0
 internal static float Distance(FlowChartPoint p1, FlowChartPoint p2)
 {
     return(Distance(p1, p2.X, p2.Y));
 }
コード例 #17
0
 protected void DrawBoundingBox(Graphics g,
                                FlowChartPoint startPoint,
                                FlowChartPoint endPoint)
 {
     g.DrawPolygon(ViewFactory.BoundingBoxPen, startPoint.MakePointFArrayWith(endPoint));
 }
コード例 #18
0
 protected void DrawResizePoint(Graphics g, FlowChartPoint p, Pen pen, float width)
 {
     Draw4Arrows(g, p, 10);
 }
コード例 #19
0
 internal static float Distance(FlowChartPoint p1, float x, float y)
 {
     return(Distance(p1.X, p1.Y, x, y));
 }