Beispiel #1
0
        public override void Draw(Graphics g)
        {
            base.Draw(g);
            PointF[] ps = ToPoints();
            if (ShadowWidth > 0)
            {
                PointF[] pss = (PointF[])ps.Clone();
                OffsetPoint(pss, ShadowWidth, ShadowWidth);
                g.FillPolygon(new SolidBrush(Color.FromArgb(64, Color.Black)), pss);
            }

            if (BackBrush.Color != Color.Empty)
            {
                g.FillPolygon(BackBrush.GetBrush(GetMaxRect()), ps);
            }

            if (LinePen.Color != Color.Empty)
            {
                g.DrawLines(LinePen.GetPen(), ps);
            }

            TextRenderingHint trh = g.TextRenderingHint;

            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            LabelFont.DrawString(NewText, g, Rect);
            g.TextRenderingHint = trh;
        }
Beispiel #2
0
        public override void Draw(Graphics g)
        {
            base.Draw(g);
            PointF     P    = ToPointF(ControlPoints[0]);
            SizeF      sf   = g.MeasureString(Text, TextFont, 1000, format);
            RectangleF Rect = new RectangleF(P.X, P.Y, sf.Width + 4, sf.Height + 4);
            ArrayList  al   = new ArrayList();

            al.Add(new PointF(Rect.Left, Rect.Top + RoundWidth));
            al.Add(new PointF(Rect.Left + RoundWidth, Rect.Top));

            al.Add(new PointF(Rect.Right - RoundWidth, Rect.Top));
            al.Add(new PointF(Rect.Right, Rect.Top + RoundWidth));

            al.Add(new PointF(Rect.Right, Rect.Bottom - RoundWidth));
            al.Add(new PointF(Rect.Right - RoundWidth, Rect.Bottom));

            al.Add(new PointF(Rect.Left + RoundWidth, Rect.Bottom));
            al.Add(new PointF(Rect.Left, Rect.Bottom - RoundWidth));
            al.Add(al[0]);

            if (StickHeight > 0)
            {
                float OffsetX = 0;
                float OffsetY = 0;
                int   Index   = 1;
                switch (StickAlignment)
                {
                case StickAlignment.LeftTop:
                    OffsetX = StickHeight;
                    OffsetY = StickHeight;
                    break;

                case StickAlignment.LeftCenter:
                    break;

                case StickAlignment.LeftBottom:
                    OffsetX = StickHeight;
                    OffsetY = -Rect.Height - StickHeight;
                    Index   = 7;
                    break;

                case StickAlignment.CenterTop:
                    break;

                case StickAlignment.CenterCenter:
                    break;

                case StickAlignment.CenterBottom:
                    break;

                case StickAlignment.RightTop:
                    OffsetX = -Rect.Width - StickHeight;
                    OffsetY = StickHeight;
                    Index   = 3;
                    break;

                case StickAlignment.RightCenter:
                    break;

                case StickAlignment.RightBottom:
                    OffsetX = -Rect.Width - StickHeight;
                    OffsetY = -Rect.Height - StickHeight;
                    Index   = 5;
                    break;
                }
                al = OffsetPoint(al, OffsetX, OffsetY);
                al.Insert(Index, P);
                Rect.Offset(OffsetX, OffsetY);
            }

            PointF[] ps = (PointF[])al.ToArray(typeof(PointF));
            if (ShadowWidth > 0)
            {
                PointF[] pss = (PointF[])ps.Clone();
                OffsetPoint(pss, ShadowWidth, ShadowWidth);
                g.FillPolygon(new SolidBrush(Color.FromArgb(64, Color.Black)), pss);
            }

            if (BackBrush.Color != Color.Empty)
            {
                g.FillPolygon(BackBrush.GetBrush(GetMaxRect()), ps);
            }

            if (LinePen.Color != Color.Empty)
            {
                g.DrawLines(LinePen.GetPen(), ps);
            }

            TextRenderingHint trh = g.TextRenderingHint;

            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            g.DrawString(Text, TextFont, TextBrush.GetBrush(), Rect, format);
            g.TextRenderingHint = trh;
        }