Пример #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 static void DrawArrowEnd(Graphics g, PointF a1, PointF a2, Color clr, float arrowSize)
        {
            Brush b = GVGraphics.GetBrush(clr);

            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            double angle = -Math.Atan2(a2.Y - a1.Y, a2.X - a1.X);
            PointF p1    = new PointF(a2.X - (float)(Math.Cos(angle - Math.PI / 8.0) * arrowSize), a2.Y + (float)(Math.Sin(angle - Math.PI / 8.0) * arrowSize));
            PointF p2    = a2;
            PointF p3    = new PointF(a2.X - (float)(Math.Cos(angle + Math.PI / 8.0) * arrowSize), a2.Y + (float)(Math.Sin(angle + Math.PI / 8.0) * arrowSize));

            g.FillPolygon(b, new PointF[] { p1, p2, p3 });
        }
Пример #3
0
        public override void OnDraw(GVGraphViewContext context, RectangleF paintRect)
        {
            base.OnDraw(context, paintRect);

            context.Graphics.DrawImage(GetTrackerIcon(), paintRect);
            if (StatusHighlighted && !context.SelectedObject.PaintedRect.Contains(context.mouseMovePoint))
            {
                if (context.TrackedObject != null && context.TrackedObject.AcceptsTracker(this))
                {
                    GVGraphics.DrawRectangleLine(context.Graphics, Pens.Black, context.SelectedObject.PaintedRect,
                                                 context.TrackedObject.PaintedRect);
                }
                else
                {
                    GVGraphics.DrawRectangleLine(context.Graphics, Pens.Black,
                                                 context.SelectedObject.PaintedRect, context.mouseMovePoint);
                }
            }
        }
Пример #4
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);
        }
Пример #5
0
        public virtual Brush GetBackgroundBrush()
        {
            if (StatusHighlighted)
            {
                switch (ClickType)
                {
                case GVObjectTrackerType.Click:
                    return(GVGraphics.GetBrush(Color.CadetBlue));

                case GVObjectTrackerType.DragDrop:
                    return(GVGraphics.GetBrush(Color.MediumSeaGreen));

                case GVObjectTrackerType.Switch:
                    return(GVGraphics.GetBrush(Color.MediumVioletRed));

                default:
                    return(GVGraphics.GetBrush(Color.White));
                }
            }
            else
            {
                switch (ClickType)
                {
                case GVObjectTrackerType.Click:
                    return(GVGraphics.GetBrush(Color.Teal));

                case GVObjectTrackerType.DragDrop:
                    return(GVGraphics.GetBrush(Color.SeaGreen));

                case GVObjectTrackerType.Switch:
                    return(GVGraphics.GetBrush(Color.Purple));

                default:
                    return(GVGraphics.GetBrush(Color.Gray));
                }
            }
        }