Exemple #1
0
        /// <summary>
        /// Raises the PaintHeader event
        /// </summary>
        /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
        public virtual void OnPaintHeader(PaintHeaderEventArgs e)
        {
            // paint the Column header's background
            this.OnPaintBackground(e);

            // paint the Column headers foreground
            this.OnPaint(e);
        }
Exemple #2
0
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
        protected override void OnPaint(PaintHeaderEventArgs e)
        {
            base.OnPaint(e);

            if (e.Column == null)
            {
                return;
            }

            Rectangle textRect  = this.ClientRectangle;
            Rectangle imageRect = Rectangle.Empty;

            if (e.Column.Image != null)
            {
                imageRect = this.CalcImageRect();

                textRect.Width -= imageRect.Width;
                textRect.X     += imageRect.Width;

                if (e.Column.ImageOnRight)
                {
                    imageRect.X = this.ClientRectangle.Right - imageRect.Width;
                    textRect.X  = this.ClientRectangle.X;
                }

                this.DrawColumnHeaderImage(e.Graphics, e.Column.Image, imageRect, e.Column.Enabled);
            }

            if (e.Column.SortOrder != SortOrder.None)
            {
                Rectangle arrowRect = this.CalcSortArrowRect();

                arrowRect.X     = textRect.Right - arrowRect.Width;
                textRect.Width -= arrowRect.Width;

                this.DrawSortArrow(e.Graphics, arrowRect, e.Column.SortOrder, e.Column.Enabled);
            }

            if (e.Column.Text == null)
            {
                return;
            }

            if (e.Column.Text.Length > 0 && textRect.Width > 0)
            {
                if (e.Column.Enabled)
                {
                    e.Graphics.DrawString(e.Column.Text, this.Font, this.ForeBrush, textRect, this.StringFormat);
                }
                else
                {
                    using (SolidBrush brush = new SolidBrush(SystemPens.GrayText.Color))
                    {
                        e.Graphics.DrawString(e.Column.Text, this.Font, brush, textRect, this.StringFormat);
                    }
                }
            }
        }
        /// <summary>
        /// Raises the PaintBackground event
        /// </summary>
        /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
        protected override void OnPaintBackground(PaintHeaderEventArgs e)
        {
            base.OnPaintBackground(e);

            if (e.Column == null)
            {
                ThemeManager.DrawColumnHeader(e.Graphics, e.HeaderRect, ColumnHeaderStates.Normal);
            }
            else
            {
                ThemeManager.DrawColumnHeader(e.Graphics, e.HeaderRect, (ColumnHeaderStates)e.Column.ColumnState);
            }
        }
        /// <summary>
        /// Raises the PaintHeader event
        /// </summary>
        /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
        public virtual void OnPaintHeader(PaintHeaderEventArgs e)
        {
            // Apply the column alignment to the header
            if ((e.Column != null) && (e.Table != null) && (e.Table.HeaderAlignWithColumn))
            {
                this.Alignment = e.Column.Alignment;
            }

            // paint the Column header's background
            this.OnPaintBackground(e);

            // paint the Column headers foreground
            this.OnPaint(e);
        }
Exemple #5
0
        /// <summary>
        /// Raises the PaintBackground event
        /// </summary>
        /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
        protected override void OnPaintBackground(PaintHeaderEventArgs e)
        {
            base.OnPaintBackground(e);

            if (e.Column == null || e.Column.ColumnState != ColumnState.Pressed)
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(e.HeaderRect, this.StartColor, this.EndColor, LinearGradientMode.Vertical))
                {
                    e.Graphics.FillRectangle(brush, e.HeaderRect);
                }

                using (Pen pen = new Pen(this.EndColor))
                {
                    e.Graphics.DrawLine(pen, e.HeaderRect.Left, e.HeaderRect.Top, e.HeaderRect.Right - 2, e.HeaderRect.Top);
                    e.Graphics.DrawLine(pen, e.HeaderRect.Left, e.HeaderRect.Top, e.HeaderRect.Left, e.HeaderRect.Bottom - 1);
                }

                using (Pen pen = new Pen(this.StartColor))
                {
                    e.Graphics.DrawLine(pen, e.HeaderRect.Right - 1, e.HeaderRect.Top, e.HeaderRect.Right - 1, e.HeaderRect.Bottom - 1);
                    e.Graphics.DrawLine(pen, e.HeaderRect.Left + 1, e.HeaderRect.Bottom - 1, e.HeaderRect.Right - 1, e.HeaderRect.Bottom - 1);
                }
            }
            else
            {
                Color pressed = this.PressedColor;

                if (pressed == Color.Empty)
                {
                    pressed = ControlPaint.Light(this.startColor);
                }

                using (SolidBrush brush = new SolidBrush(pressed))
                {
                    e.Graphics.FillRectangle(brush, e.HeaderRect);
                }

                using (Pen pen = new Pen(this.StartColor))
                {
                    e.Graphics.DrawRectangle(pen, e.HeaderRect.X, e.HeaderRect.Y, e.HeaderRect.Width - 1, e.HeaderRect.Height - 1);
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
        protected override void OnPaint(PaintHeaderEventArgs e)
        {
            base.OnPaint(e);

            if (e.Column == null)
            {
                return;
            }

            Rectangle textRect  = this.ClientRectangle;
            Rectangle imageRect = Rectangle.Empty;

            int imageWidth = 0;
            int arrowWidth = 0;
            int textWidth  = 0;

            if (e.Column.Image != null)
            {
                imageRect = this.CalcImageRect();

                textRect.Width -= imageRect.Width;
                textRect.X     += imageRect.Width;

                if (e.Column.ImageOnRight)
                {
                    imageRect.X = this.ClientRectangle.Right - imageRect.Width;
                    textRect.X  = this.ClientRectangle.X;
                }

                this.DrawColumnHeaderImage(e.Graphics, e.Column.Image, imageRect, e.Column.Enabled);
                imageWidth = imageRect.Width;
            }

            if (e.Column.SortOrder != SortOrder.None)
            {
                Rectangle arrowRect = this.CalcSortArrowRect();

                if (this.Alignment == ColumnAlignment.Right)
                {
                    arrowRect.X     = textRect.Left;
                    textRect.Width -= arrowRect.Width;
                    textRect.X     += arrowRect.Width;
                }
                else
                {
                    arrowRect.X     = textRect.Right - arrowRect.Width;
                    textRect.Width -= arrowRect.Width;
                }

                this.DrawSortArrow(e.Graphics, arrowRect, e.Column.SortOrder, e.Column.Enabled);
                arrowWidth = arrowRect.Width;
            }

            if (e.Column.Text != null && e.Column.Text.Length > 0 && textRect.Width > 0)
            {
                if (e.Column.Enabled)
                {
                    e.Graphics.DrawString(e.Column.Text, this.Font, this.ForeBrush, textRect, this.StringFormat);
                }
                else
                {
                    using (SolidBrush brush = new SolidBrush(SystemPens.GrayText.Color))
                    {
                        e.Graphics.DrawString(e.Column.Text, this.Font, brush, textRect, this.StringFormat);
                    }
                }

                if (e.Column.WidthNotSet)
                {
                    SizeF size = e.Graphics.MeasureString(e.Column.Text, this.Font);
                    textWidth = (int)Math.Ceiling(size.Width);
                }

                // Also, determine whether we need a tooltip, if the text was truncated.
                if (e.Table.EnableToolTips)
                {
                    e.Column.IsTextTrimmed = this.IsTextTrimmed(e.Graphics, e.Column.Text);
                }
            }
            if (e.Column.WidthNotSet)
            {
                e.Column.ContentWidth = imageWidth + arrowWidth + textWidth;
            }
        }
Exemple #7
0
        /// <summary>
        /// Raises the PaintBackground event
        /// </summary>
        /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
        protected override void OnPaintBackground(PaintHeaderEventArgs e)
        {
            base.OnPaintBackground(e);

            e.Graphics.FillRectangle(this.BackBrush, this.Bounds);
        }
 /// <summary>
 /// Raises the Paint event
 /// </summary>
 /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
 protected virtual void OnPaint(PaintHeaderEventArgs e)
 {
 }
 /// <summary>
 /// Raises the PaintBackground event
 /// </summary>
 /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
 protected virtual void OnPaintBackground(PaintHeaderEventArgs e)
 {
 }