Beispiel #1
0
        private void ListViewDrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            string name       = (sender as ListView).Name.Replace("tabGroup", "");
            Color  colorBack  = Color.FromArgb(159, 175, 175);
            Color  colorDark  = Color.FromArgb(111, 131, 131);
            Color  colorLight = Color.FromArgb(211, 219, 219);

            if (new Rectangle(e.Bounds.X + (e.Header.DisplayIndex != 0 ? 8 : 0), e.Bounds.Y, e.Bounds.Width + (e.Header.DisplayIndex != 0 ?
                                                                                                               (e.Header.DisplayIndex + 1 == (sender as ListView).Columns.Count && (sender as ListView).Width <= e.Bounds.Right + 24 ? -3 : 0) : 8), e.Bounds.Height).Contains((sender as ListView).PointToClient(Control.MousePosition)))
            {
                colorBack  = Color.FromArgb(183, 195, 195);
                colorDark  = Color.FromArgb(131, 151, 151);
                colorLight = Color.FromArgb(239, 243, 243);
            }

            e.Graphics.FillRectangle(new SolidBrush(colorBack), new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Width - 2, e.Bounds.Height - 1));

            e.Graphics.DrawLine(new Pen(colorLight), new Point(e.Bounds.Left, e.Bounds.Top), new Point(e.Bounds.Right - 1, e.Bounds.Top));
            e.Graphics.DrawLine(new Pen(colorLight), new Point(e.Bounds.Left, e.Bounds.Top), new Point(e.Bounds.Left, e.Bounds.Bottom - 1));

            e.Graphics.DrawLine(new Pen(colorDark), new Point(e.Bounds.Right - 1, e.Bounds.Top), new Point(e.Bounds.Right - 1, e.Bounds.Bottom - 1));
            e.Graphics.DrawLine(new Pen(colorDark), new Point(e.Bounds.Left, e.Bounds.Bottom - 1), new Point(e.Bounds.Right - 1, e.Bounds.Bottom - 1));

            fontBold.DrawAligned(e.Graphics, new Rectangle(e.Bounds.Left + 8, e.Bounds.Top, e.Bounds.Width - 16, e.Bounds.Height), HorizontalAlignment.Left, e.Header.Text, Color.Black);

            e.DrawDefault = false;
        }
Beispiel #2
0
        //--------------------------------
        #endregion
        //============ EVENTS ============
        #region Events

        /** <summary> Paints the control. </summary> */
        protected override void OnPaint(PaintEventArgs e)
        {
            SpriteFont font = SpriteFont.FontBold;

            switch (this.fontType)
            {
            case FontType.Regular: font = SpriteFont.FontRegular; break;

            case FontType.Bold: font = SpriteFont.FontBold; break;

            case FontType.Small: font = SpriteFont.FontSmall; break;
            }
            font.DrawAligned(e.Graphics, new Rectangle(1, 1, ClientSize.Width - 8, ClientSize.Height - 8), textAlign, Text, ForeColor, outlineColor);
        }
Beispiel #3
0
        /** <summary> Paints the control. </summary> */
        protected override void OnPaint(PaintEventArgs e)
        {
            if (pressed || toggled)
            {
                e.Graphics.FillRectangle(new SolidBrush(colorBackgroundPressed), new Rectangle(0, 0, ClientSize.Width, ClientSize.Height));
                e.Graphics.DrawLine(new Pen(colorBorderDarkPressed), new Point(0, 0), new Point(ClientSize.Width - 1, 0));
                e.Graphics.DrawLine(new Pen(colorBorderDarkPressed), new Point(0, 0), new Point(0, ClientSize.Height - 1));
                e.Graphics.DrawLine(new Pen(colorBorderLightPressed), new Point(1, ClientSize.Height - 1), new Point(ClientSize.Width - 1, ClientSize.Height - 1));
                e.Graphics.DrawLine(new Pen(colorBorderLightPressed), new Point(ClientSize.Width - 1, 1), new Point(ClientSize.Width - 1, ClientSize.Height - 1));
            }
            else
            {
                e.Graphics.FillRectangle(new SolidBrush(colorBackgroundDepressed), new Rectangle(0, 0, ClientSize.Width, ClientSize.Height));

                if (hovering || !drawBorderOnlyOnHover || DesignMode)
                {
                    e.Graphics.DrawLine(new Pen(colorBorderLightDepressed), new Point(0, 0), new Point(ClientSize.Width - 2, 0));
                    e.Graphics.DrawLine(new Pen(colorBorderLightDepressed), new Point(0, 0), new Point(0, ClientSize.Height - 2));
                    e.Graphics.DrawLine(new Pen(colorBorderDarkDepressed), new Point(0, ClientSize.Height - 1), new Point(ClientSize.Width - 1, ClientSize.Height - 1));
                    e.Graphics.DrawLine(new Pen(colorBorderDarkDepressed), new Point(ClientSize.Width - 1, 0), new Point(ClientSize.Width - 1, ClientSize.Height - 1));
                }
            }

            if (image != null)
            {
                Point     point = Point.Empty;
                Size      size  = image.Size;
                Rectangle rect  = new Rectangle(2, 2, ClientSize.Width - 4, ClientSize.Height - 4);
                if (imageAlign == ContentAlignment.TopLeft || imageAlign == ContentAlignment.MiddleLeft || imageAlign == ContentAlignment.BottomLeft)
                {
                    point.X = 0;
                }
                else if (imageAlign == ContentAlignment.TopCenter || imageAlign == ContentAlignment.MiddleCenter || imageAlign == ContentAlignment.BottomCenter)
                {
                    point.X = (rect.Width - size.Width) / 2;
                }
                else if (imageAlign == ContentAlignment.TopRight || imageAlign == ContentAlignment.MiddleRight || imageAlign == ContentAlignment.BottomRight)
                {
                    point.X = rect.Width - size.Width;
                }

                if (imageAlign == ContentAlignment.TopLeft || imageAlign == ContentAlignment.TopCenter || imageAlign == ContentAlignment.TopRight)
                {
                    point.Y = 0;
                }
                else if (imageAlign == ContentAlignment.MiddleLeft || imageAlign == ContentAlignment.MiddleCenter || imageAlign == ContentAlignment.MiddleRight)
                {
                    point.Y = (rect.Height - size.Height) / 2;
                }
                else if (imageAlign == ContentAlignment.BottomLeft || imageAlign == ContentAlignment.BottomCenter || imageAlign == ContentAlignment.BottomRight)
                {
                    point.Y = rect.Height - size.Height;
                }
                e.Graphics.DrawImage(image, rect.X + point.X, rect.Y + point.Y);
            }

            SpriteFont font = SpriteFont.FontBold;

            switch (this.fontType)
            {
            case FontType.Regular: font = SpriteFont.FontRegular; break;

            case FontType.Bold: font = SpriteFont.FontBold; break;

            case FontType.Small: font = SpriteFont.FontSmall; break;
            }
            font.DrawAligned(e.Graphics, new Rectangle(2, 3, ClientSize.Width - 4, ClientSize.Height - 4), textAlign, Text, ForeColor, outlineColor);
        }