Пример #1
0
        private RectangleF GetRectangleForSize(SizeF sz)
        {
            if (Source == null || Target == null)
            {
                return(RectangleF.Empty);
            }
            PointF p1 = GVGraphics.GetCenterPoint(Source.PaintedRect);
            PointF p2 = GVGraphics.GetCenterPoint(Target.PaintedRect);

            return(new RectangleF((p1.X + p2.X - sz.Width) / 2, (p1.Y + p2.Y - sz.Height) / 2,
                                  sz.Width, sz.Height));
        }
Пример #2
0
        public virtual void Paint(GVGraphViewContext context)
        {
            RectangleF rectA = Source.PaintedRect;
            RectangleF rectB = Target.PaintedRect;
            RectSide   rsa, rsb;
            PointF     border1 = GVGraphics.GetConnectorPoint(rectA, GVGraphics.GetCenterPoint(rectB), out rsa);
            PointF     border2 = GVGraphics.GetConnectorPoint(rectB, GVGraphics.GetCenterPoint(rectA), out rsb);

            context.Graphics.DrawLine(LinePen, border1, border2);
            if (ArrowSize > 0)
            {
                GVGraphics.DrawArrowEnd(context.Graphics, border1, border2, LinePen.Color, ArrowSize);
            }


            TitleRectangle = GetRectangleForSize(context.Graphics.MeasureString(Title, SystemFonts.MenuFont),
                                                 GVGraphics.GetCenterPoint(border1, border2));
            context.Graphics.FillRectangle(SystemBrushes.Control, TitleRectangle.X, TitleRectangle.Y,
                                           TitleRectangle.Width, TitleRectangle.Height);
            context.Graphics.DrawString(Title, SystemFonts.MenuFont, Brushes.Black, TitleRectangle.Location);
        }