Beispiel #1
0
        /// <summary>
        /// Draws the dark blue border of the XpButton object.
        /// </summary>
        /// <param name="g">The System.Drawing.Graphics object to be used to paint the border.</param>
        private void DrawBorder(Graphics g)
        {
            Pen penBorder = new Pen(clrBorder);

            MyControlPaint.DrawRoundedRectangle(g, penBorder, this.BorderRectangle,
                                                sizeBorderPixelIndent);
            penBorder.Dispose();
        }
Beispiel #2
0
        /// <summary>
        /// Draws the disabled state of the XpButton.
        /// </summary>
        /// <param name="g">The System.Drawing.Graphics object to be used to paint the XpButton.</param>
        private void OnDrawDisabled(Graphics g)
        {
            Rectangle rcBorder = this.BorderRectangle;

            //
            // Background
            //
            Rectangle rcBackground = new Rectangle(
                rcBorder.X + 1, rcBorder.Y + 1, rcBorder.Width - 1, rcBorder.Height - 1);
            SolidBrush brushBackground = new SolidBrush(Color.FromArgb(245, 244, 234));

            g.FillRectangle(brushBackground, rcBackground);
            brushBackground.Dispose();

            //
            // Border
            //
            Pen penBorder = new Pen(Color.FromArgb(201, 199, 186));

            MyControlPaint.DrawRoundedRectangle(g, penBorder, rcBorder,
                                                sizeBorderPixelIndent);
            penBorder.Dispose();
        }
Beispiel #3
0
        /// <summary>
        /// Draws the text of the XpButton.
        /// </summary>
        /// <param name="g">The System.Drawing.Graphics object to be used to paint the XpButton.</param>
        private void OnDrawTextAndImage(Graphics g)
        {
            SolidBrush brushText;

            if (Enabled)
            {
                brushText = new SolidBrush(ForeColor);
            }
            else
            {
                brushText = new SolidBrush(MyControlPaint.DisabledForeColor);
            }

            StringFormat sf = MyControlPaint.GetStringFormat(this.TextAlign);

            sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;

            if (this.Image != null)
            {
                Rectangle rc         = new Rectangle();
                Point     ImagePoint = new Point(6, 4);
                switch (this.ImageAlign)
                {
                case ContentAlignment.MiddleRight:
                {
                    rc.Width     = this.ClientRectangle.Width - this.Image.Width - 8;
                    rc.Height    = this.ClientRectangle.Height;
                    rc.X         = 0;
                    rc.Y         = 0;
                    ImagePoint.X = rc.Width;
                    ImagePoint.Y = this.ClientRectangle.Height / 2 - Image.Height / 2;
                    break;
                }

                case ContentAlignment.TopCenter:
                {
                    ImagePoint.Y = 2;
                    ImagePoint.X = (this.ClientRectangle.Width - this.Image.Width) / 2;
                    rc.Width     = this.ClientRectangle.Width;
                    rc.Height    = this.ClientRectangle.Height - this.Image.Height - 4;
                    rc.X         = this.ClientRectangle.X;
                    rc.Y         = this.Image.Height;
                    break;
                }

                case ContentAlignment.MiddleCenter:
                {         // no text in this alignment
                    ImagePoint.X = (this.ClientRectangle.Width - this.Image.Width) / 2;
                    ImagePoint.Y = (this.ClientRectangle.Height - this.Image.Height) / 2;
                    rc.Width     = 0;
                    rc.Height    = 0;
                    rc.X         = this.ClientRectangle.Width;
                    rc.Y         = this.ClientRectangle.Height;
                    break;
                }

                default:
                {
                    ImagePoint.X = 6;
                    ImagePoint.Y = this.ClientRectangle.Height / 2 - Image.Height / 2;
                    rc.Width     = this.ClientRectangle.Width - this.Image.Width;
                    rc.Height    = this.ClientRectangle.Height;
                    rc.X         = this.Image.Width;
                    rc.Y         = 0;
                    break;
                }
                }
                ImagePoint.X += locPoint.X;
                ImagePoint.Y += locPoint.Y;
                if (this.Enabled)
                {
                    g.DrawImage(this.Image, ImagePoint);
                }
                else
                {
                    System.Windows.Forms.ControlPaint.DrawImageDisabled(g, this.Image, locPoint.X, locPoint.Y, this.BackColor);
                }
                if (ContentAlignment.MiddleCenter != this.ImageAlign)
                {
                    g.DrawString(
                        this.Text,
                        this.Font,
                        brushText,
                        rc,
                        sf);
                }
            }
            else
            {
                g.DrawString(
                    this.Text,
                    this.Font,
                    brushText,
                    this.ClientRectangle,
                    sf);
            }

            brushText.Dispose();
            sf.Dispose();
        }