Provides data for the PaintHeader event
Inheritance: PaintEventArgs
Esempio n. 1
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);
                    }
                }
            }
        }
Esempio n. 2
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)
            {
                ThemeManager.DrawColumnHeader(e.Graphics, e.HeaderRect, ColumnHeaderStates.Normal);
            }
            else
            {
                ThemeManager.DrawColumnHeader(e.Graphics, e.HeaderRect, (ColumnHeaderStates) e.Column.ColumnState);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Paints the Table's Column headers
        /// </summary>
        /// <param name="e">A PaintEventArgs that contains the event data</param>
        protected void OnPaintHeader(PaintEventArgs e)
        {
            // only bother if we actually get to paint something
            if (!this.HeaderRectangle.IntersectsWith(e.ClipRectangle))
            {
                return;
            }

            int xPos = this.DisplayRectangle.Left;
            bool needDummyHeader = true;

            //
            PaintHeaderEventArgs phea = new PaintHeaderEventArgs(e.Graphics, e.ClipRectangle);

            for (int i = 0; i < this.ColumnModel.Columns.Count; i++)
            {
                // check that the column isn't hidden
                if (this.ColumnModel.Columns[i].Visible)
                {
                    Rectangle colHeaderRect = new Rectangle(xPos, this.BorderWidth, this.ColumnModel.Columns[i].Width, this.HeaderHeight);

                    // check that the column intersects with the clipping rect
                    if (e.ClipRectangle.IntersectsWith(colHeaderRect))
                    {
                        // move and resize the headerRenderer
                        this.headerRenderer.Bounds = new Rectangle(xPos, this.BorderWidth, this.ColumnModel.Columns[i].Width, this.HeaderHeight);

                        // set the clipping area to the header renderers bounds
                        phea.Graphics.SetClip(Rectangle.Intersect(e.ClipRectangle, this.headerRenderer.Bounds));

                        // draw the column header
                        phea.SetColumn(this.ColumnModel.Columns[i]);
                        phea.SetColumnIndex(i);
                        phea.SetTable(this);
                        phea.SetHeaderStyle(this.HeaderStyle);
                        phea.SetHeaderRect(this.headerRenderer.Bounds);

                        // let the user get the first crack at painting the header
                        this.OnBeforePaintHeader(phea);

                        // only send to the renderer if the user hasn't
                        // set the handled property
                        if (!phea.Handled)
                        {
                            this.headerRenderer.OnPaintHeader(phea);
                        }

                        // let the user have another go
                        this.OnAfterPaintHeader(phea);
                    }

                    // set the next column start position
                    xPos += this.ColumnModel.Columns[i].Width;

                    // if the next start poition is past the right edge
                    // of the clipping rectangle then we don't need to
                    // draw anymore
                    if (xPos >= e.ClipRectangle.Right)
                    {
                        return;
                    }

                    // check is the next column position is past the
                    // right edge of the table.  if it is, get out of
                    // here as we don't need to draw anymore columns
                    if (xPos >= this.ClientRectangle.Width)
                    {
                        needDummyHeader = false;

                        break;
                    }
                }
            }

            if (needDummyHeader)
            {
                // move and resize the headerRenderer
                this.headerRenderer.Bounds = new Rectangle(xPos, this.BorderWidth, this.ClientRectangle.Width - xPos + 2, this.HeaderHeight);

                phea.Graphics.SetClip(Rectangle.Intersect(e.ClipRectangle, this.headerRenderer.Bounds));

                phea.SetColumn(null);
                phea.SetColumnIndex(-1);
                phea.SetTable(this);
                phea.SetHeaderStyle(this.HeaderStyle);
                phea.SetHeaderRect(this.headerRenderer.Bounds);

                // let the user get the first crack at painting the header
                this.OnBeforePaintHeader(phea);

                // only send to the renderer if the user hasn't
                // set the handled property
                if (!phea.Handled)
                {
                    this.headerRenderer.OnPaintHeader(phea);
                }

                // let the user have another go
                this.OnAfterPaintHeader(phea);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Raises the BeforePaintHeader event
 /// </summary>
 /// <param name="e">A PaintCellEventArgs that contains the event data</param>
 protected virtual void OnBeforePaintHeader(PaintHeaderEventArgs e)
 {
     if (BeforePaintHeader != null)
     {
         BeforePaintHeader(this, e);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Raises the AfterPaintHeader event
 /// </summary>
 /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
 protected virtual void OnAfterPaintHeader(PaintHeaderEventArgs e)
 {
     if (AfterPaintHeader != null)
     {
         AfterPaintHeader(this, e);
     }
 }
Esempio n. 6
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);
        }
Esempio n. 7
0
 /// <summary>
 /// Raises the PaintBackground event
 /// </summary>
 /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
 protected virtual void OnPaintBackground(PaintHeaderEventArgs e)
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Raises the Paint event
 /// </summary>
 /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
 protected virtual void OnPaint(PaintHeaderEventArgs e)
 {
 }
Esempio n. 9
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);
        }
Esempio n. 10
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);
                }
            }
        }