Esempio n. 1
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            if (!DesignMode && !Visible)
            {
                return;
            }
            var g = pevent.Graphics;

            //g.SmoothingMode = SmoothingMode.AntiAlias;
            //g.TextRenderingHint = TextRenderingHint.AntiAlias;
            Share.GraphicSetup(g);
            var pen = new Pen(Share.BorderColor);
            var sb  = new SolidBrush(Share.FocusBackColor);

            if (Enabled)
            {
                if (!base.Checked)
                {
                    g.DrawPath(pen, rectPath);
                    g.DrawPath(pen, CheckPath);
                    pen.Dispose();
                    TextRenderer.DrawText(g, Text, Font, textRect, Color.Black,
                                          TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
                    //g.DrawString(base.Text, base.Font, Brushes.Black, new PointF(0, 0),StringFormatFlags.DirectionVertical);
                }
                else
                {
                    g.FillPath(sb, rectPath);
                    pen.Color = Share.FocusBackColor;
                    g.DrawPath(pen, rectPath);
                    sb.Color = Share.BackColor;
                    g.FillPath(sb, CheckPath);
                    sb.Dispose();
                    TextRenderer.DrawText(g, Text, Font, textRect, Color.White,
                                          TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
                }
            }
            else
            {
                sb.Color  = Share.DisabelBackColor;
                pen.Color = Share.DisableBorderColor;
                g.FillPath(sb, rectPath);
                g.DrawPath(pen, rectPath);
                g.FillPath(sb, CheckPath);
                g.DrawPath(pen, CheckPath);
                TextRenderer.DrawText(g, Text, Font, textRect, Share.DisabelFontColor,
                                      TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
                pen.Dispose();
                sb.Dispose();
            }
            rectPath.Dispose();
            CheckPath.Dispose();
        }
Esempio n. 2
0
        //Alpha alpha = Alpha.Normal;
        //Color bdcolor { get { return Color.FromArgb((int)Alpha.a180, bgColor.R, bgColor.G, bgColor.B); } }
        //Color color { get { return Color.FromArgb((int)alpha, bgColor.R, bgColor.G, bgColor.B); } }
        //Color bgColor = Share.BackColor;
        //public Color BgColor { get { return bgColor; } set { bgColor = value; this.Invalidate(); } }

        protected override void OnPaint(PaintEventArgs pevent)
        {
            if (!DesignMode && !Visible)
            {
                return;
            }
            var g = pevent.Graphics;

            //g.SmoothingMode = SmoothingMode.AntiAlias;
            //g.TextRenderingHint = TextRenderingHint.AntiAlias;
            Share.GraphicSetup(g);
            if (!Checked)
            {
                using (var sb = new SolidBrush(BgColor))
                {
                    g.FillPath(sb, radioPath);
                }
                using (var p = new Pen(borderColor, 1))
                {
                    g.DrawPath(p, radioPath);
                }
                //g.DrawPath(new Pen(Color.White, 1.8f), gp);
            }
            else
            {
                using (var sb = new SolidBrush(Share.FocusBackColor))
                {
                    g.FillPath(sb, radioPath);
                    var p = new Pen(Share.FocusBackColor, 1);
                    g.DrawPath(p, radioPath);
                    p.Dispose();
                }
                using (var p = new Pen(Share.BackColor, 1.55f))
                {
                    g.DrawPath(p, CheckPath);
                }
            }
            var TextRect = new Rectangle(radioRect.Width + 3, (int)(Height - g.MeasureString(Text, Font).Height) / 2,
                                         Width - radioRect.Width - 3, Height);

            //TextRenderer.DrawText(g, base.Text, base.Font, TextRect, base.ForeColor, TextFormatFlags.VerticalCenter |
            //                       TextFormatFlags.Left |
            //                       TextFormatFlags.SingleLine);
            if (Text != "")
            {
                DrawHelper.DrawCaptionText(g, TextRect, Text, Font, true, Color.White, 3, ForeColor);
            }

            radioPath.Dispose();
            CheckPath.Dispose();
        }