/// <summary> /// 重绘背景 /// </summary> /// <param name="e">A PaintHeaderEventArgs that contains the event data</param> protected override void OnPaintBackground(I3PaintRowHeaderEventArgs e) { base.OnPaintBackground(e); if (e.Row != null && e.Row.IsSelected) { SolidBrush brush; if (this.SelectedColor == Color.Empty) { brush = new SolidBrush(Color.Orange); } else { brush = new SolidBrush(this.SelectedColor); } e.Graphics.FillRectangle(brush, this.Bounds); return; } if (e.Row == null) { I3ThemeManager.DrawRowHeader(e.Graphics, e.HeaderRect, I3RowHeaderStates.Normal); } else { I3ThemeManager.DrawRowHeader(e.Graphics, e.HeaderRect, (I3RowHeaderStates)e.Row.RowState); } }
/// <summary> /// 重绘行头 /// </summary> /// <param name="e">A PaintHeaderEventArgs that contains the event data</param> public virtual void OnPaintRowHeader(I3PaintRowHeaderEventArgs e) { // paint the Column header's background this.OnPaintBackground(e); // paint the Column headers foreground this.OnPaint(e); }
/// <summary> /// Raises the PaintBackground event /// </summary> /// <param name="e">A PaintHeaderEventArgs that contains the event data</param> protected override void OnPaintBackground(I3PaintRowHeaderEventArgs e) { base.OnPaintBackground(e); Color start = this.StartColor; Color end = this.EndColor; if (e.Row != null && e.Row.IsSelected) { start = this.SelectedColor; if (start == Color.Empty) { start = Color.Orange; } end = ControlPaint.Light(start); } if (e.Row == null || e.Row.RowState != I3RowState.Pressed) { using (LinearGradientBrush brush = new LinearGradientBrush(e.HeaderRect, start, end, LinearGradientMode.Horizontal)) { e.Graphics.FillRectangle(brush, e.HeaderRect); } using (Pen pen = new Pen(end)) { 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(start)) { 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(start); } 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); } } }
/// <summary> /// Raises the Paint event /// </summary> /// <param name="e">A PaintHeaderEventArgs that contains the event data</param> protected override void OnPaint(I3PaintRowHeaderEventArgs e) { base.OnPaint(e); if (e.Row == null || e.Table.RowHeaderDisplayMode != I3RowHeaderDisplayMode.Num) { return; } Rectangle textRect = this.ClientRectangle; //VisualStylesEnabled=true且列头按下时,文本显示区域向下、向右各移动1像素 if (!I3ThemeManager.VisualStylesEnabled && e.Row.RowState == I3RowState.Pressed) { textRect.X += 1; textRect.Y += 1; } //计算绘制文本的起始点 StringAlignment old = this.StringFormat.Alignment; this.StringFormat.Alignment = StringAlignment.Center; //this.StringFormat.Trimming=EllipsisCharacter,指定文本超出范围时的剪切方式为以....替代 string text = (e.RowIndex + 1).ToString(); if (e.Row.Enabled) { e.Graphics.DrawString(text, this.Font, this.ForeBrush, textRect, this.StringFormat); } else { using (SolidBrush brush = new SolidBrush(SystemPens.GrayText.Color)) { e.Graphics.DrawString(text, this.Font, brush, textRect, this.StringFormat); } } //cal needsize CalRowHeaderNeedHeight(e.Graphics, e.Row, text, this.Font, this.StringFormat); this.StringFormat.Alignment = old; }
/// <summary> /// Raises the PaintBackground event /// </summary> /// <param name="e">A PaintHeaderEventArgs that contains the event data</param> protected override void OnPaintBackground(I3PaintRowHeaderEventArgs e) { base.OnPaintBackground(e); SolidBrush brush = this.BackBrush; if (e.Row != null && e.Row.IsSelected) { if (this.SelectedColor == Color.Empty) { brush = new SolidBrush(Color.Orange); } else { brush = new SolidBrush(this.SelectedColor); } } e.Graphics.FillRectangle(brush, this.Bounds); }
/// <summary> /// 重绘行头 /// Raises the Paint event /// </summary> /// <param name="e">A PaintHeaderEventArgs that contains the event data</param> protected virtual void OnPaint(I3PaintRowHeaderEventArgs e) { }
/// <summary> /// 重绘背景,子函数实现 /// Raises the PaintBackground event /// </summary> /// <param name="e">A PaintHeaderEventArgs that contains the event data</param> protected virtual void OnPaintBackground(I3PaintRowHeaderEventArgs e) { }