/// <summary> /// Raises the Paint event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaint(PaintCellEventArgs e) { base.OnPaint(e); // don't bother going any further if the Cell is null if (e.Cell == null) { return; } string text = e.Cell.Text; if (text != null && text.Length != 0) { if (e.Enabled) { e.Graphics.DrawString(text, this.Font, this.ForeBrush, this.ClientRectangle, this.StringFormat); } else { e.Graphics.DrawString(text, this.Font, this.GrayTextBrush, this.ClientRectangle, this.StringFormat); } } if ((e.Focused && e.Enabled) // only if we want to show selection rectangle && (e.Table.ShowSelectionRectangle)) { ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle); } }
/// <summary> /// Raises the PaintCell event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> public override void OnPaintCell(PaintCellEventArgs e) { if (e.Table.ColumnModel.Columns[e.Column] is ControlColumn) { ControlColumn column = (ControlColumn) e.Table.ColumnModel.Columns[e.Column]; this.controlSize = column.ControlSize; this.controlFactory = column.ControlFactory; } else { this.controlSize = new Size(13, 13); } base.OnPaintCell(e); }
/// <summary> /// Raises the Paint event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaint(PaintCellEventArgs e) { base.OnPaint(e); // don't bother going any further if the Cell is null if (e.Cell == null) { return; } Rectangle buttonRect = this.CalcDropDownButtonBounds(); Rectangle textRect = this.ClientRectangle; if (this.ShowDropDownButton) { textRect.Width -= buttonRect.Width - 1; } // draw the text if (e.Cell.Text != null && e.Cell.Text.Length != 0) { if (e.Enabled) { e.Graphics.DrawString(e.Cell.Text, this.Font, this.ForeBrush, textRect, this.StringFormat); } else { e.Graphics.DrawString(e.Cell.Text, this.Font, this.GrayTextBrush, textRect, this.StringFormat); } } if( (e.Focused && e.Enabled) // only if we want to show selection rectangle && ( e.Table.ShowSelectionRectangle ) ) { Rectangle focusRect = this.ClientRectangle; if (this.ShowDropDownButton) { focusRect.Width -= buttonRect.Width; } ControlPaint.DrawFocusRectangle(e.Graphics, focusRect); } }
/// <summary> /// Raises the Paint event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected virtual void OnPaint(PaintCellEventArgs e) { }
/// <summary> /// Raises the PaintCell event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> public override void OnPaintCell(PaintCellEventArgs e) { if (e.Table.ColumnModel.Columns[e.Column] is CheckBoxColumn) { CheckBoxColumn column = (CheckBoxColumn) e.Table.ColumnModel.Columns[e.Column]; this.checkSize = column.CheckSize; this.drawText = column.DrawText; } else { this.checkSize = new Size(13, 13); this.drawText = true; } base.OnPaintCell(e); }
/// <summary> /// Raises the Paint event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaint(PaintCellEventArgs e) { base.OnPaint(e); // don't bother if the Cell is null if (e.Cell == null) { return; } // get the Cells value int intVal = 0; if (e.Cell.Data != null && e.Cell.Data is int) { intVal = (int) e.Cell.Data; } if (intVal < 0) { intVal = 0; } else if (intVal > 100) { intVal = 100; } // adjust the chunk rect so we don't draw over the // progress bars borders Rectangle chunkRect = this.ClientRectangle; chunkRect.Inflate(-2, -2); // if xp themes are enabled, shrink the size of the // progress bar as otherwise the focus rect appears // to go awol if the cell has focus if (ThemeManager.VisualStylesEnabled) { chunkRect.Inflate(-1, -1); } chunkRect.Width = (int) ((((double) intVal) / 100d) * ((double) chunkRect.Width)); if (e.Enabled) { ThemeManager.DrawProgressBarChunks(e.Graphics, chunkRect); } else { using (Bitmap b = new Bitmap(chunkRect.Width, chunkRect.Height)) { using (Graphics g = Graphics.FromImage(b)) { ThemeManager.DrawProgressBarChunks(g, new Rectangle(0, 0, chunkRect.Width, chunkRect.Height)); } ControlPaint.DrawImageDisabled(e.Graphics, b, chunkRect.X, chunkRect.Y, this.BackBrush.Color); } } if (this.DrawPercentageText) { this.Alignment = ColumnAlignment.Center; this.LineAlignment = RowAlignment.Center; Font font = new Font(this.Font.FontFamily, this.Font.SizeInPoints, FontStyle.Bold); if (e.Enabled) { e.Graphics.DrawString("" + intVal + "%", font, SystemBrushes.ControlText, this.ClientRectangle, this.StringFormat); } else { e.Graphics.DrawString("" + intVal + "%", font, Brushes.White, this.ClientRectangle, this.StringFormat); } if (!ThemeManager.VisualStylesEnabled) { // remember the old clip area Region oldClip = e.Graphics.Clip; Rectangle clipRect = this.ClientRectangle; clipRect.Width = chunkRect.Width + 2; e.Graphics.SetClip(clipRect); if (e.Table.Enabled) { e.Graphics.DrawString("" + intVal + "%", font, SystemBrushes.HighlightText, this.ClientRectangle, this.StringFormat); } else { e.Graphics.DrawString("" + intVal + "%", font, Brushes.White, this.ClientRectangle, this.StringFormat); } // restore the old clip area e.Graphics.SetClip(oldClip, CombineMode.Replace); } } if( (e.Focused && e.Enabled) // only if we want to show selection rectangle && ( e.Table.ShowSelectionRectangle ) ) { ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle); } }
/// <summary> /// Raises the Paint event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaint(PaintCellEventArgs e) { base.OnPaint (e); // don't bother if the Cell is null if (e.Cell == null) { return; } // get the Cells value Color color = Color.Empty; if (e.Cell.Data != null && e.Cell.Data is Color) { color = (Color) e.Cell.Data; } Rectangle buttonRect = this.CalcDropDownButtonBounds(); Rectangle textRect = this.ClientRectangle; if (this.ShowDropDownButton) { textRect.Width -= buttonRect.Width - 1; } e.Graphics.SetClip(textRect); if (this.ShowColor) { Rectangle colorRect = this.CalcColorRect(e.Table.TableModel.Rows[e.Row].Alignment, e.Table.ColumnModel.Columns[e.Column].Alignment); if (color != Color.Empty) { using (SolidBrush brush = new SolidBrush(color)) { if (e.Enabled) { e.Graphics.FillRectangle(brush, colorRect); e.Graphics.DrawRectangle(SystemPens.ControlText, colorRect); } else { using (Bitmap b = new Bitmap(colorRect.Width, colorRect.Height)) { using (Graphics g = Graphics.FromImage(b)) { g.FillRectangle(brush, 0, 0, colorRect.Width, colorRect.Height); g.DrawRectangle(SystemPens.ControlText, 0, 0, colorRect.Width-1, colorRect.Height-1); } ControlPaint.DrawImageDisabled(e.Graphics, b, colorRect.X, colorRect.Y, this.BackColor); } } } textRect.X = colorRect.Right + 2; textRect.Width -= colorRect.Width + 4; } } if (this.ShowColorName) { string text = ""; if (color.IsEmpty) { text = "Empty"; } else if (color.IsNamedColor || color.IsSystemColor) { text = color.Name; } else { if (color.A != 255) { text += color.A + ", "; } text += color.R +", " + color.G + ", " + color.B; } if (e.Enabled) { e.Graphics.DrawString(text, this.Font, this.ForeBrush, textRect, this.StringFormat); } else { e.Graphics.DrawString(text, this.Font, this.GrayTextBrush, textRect, this.StringFormat); } } if( (e.Focused && e.Enabled) // only if we want to show selection rectangle && ( e.Table.ShowSelectionRectangle ) ) { Rectangle focusRect = this.ClientRectangle; if (this.ShowDropDownButton) { focusRect.Width -= buttonRect.Width; } ControlPaint.DrawFocusRectangle(e.Graphics, focusRect); } }
/// <summary> /// Raises the Paint event /// </summary> /// <param name="e"></param> protected override void OnPaint(PaintCellEventArgs e) { base.OnPaint (e); // don't bother if the Cell is null if (e.Cell == null) { return; } Rectangle checkRect = this.CalcCheckRect(this.LineAlignment, this.Alignment); if (!this.IsSubRow(e.Cell)) { GroupRendererData data = this.GetGroupRendererData(e.Cell); DrawBox(e.Graphics, this.LineColorPen, checkRect); if (data.Grouped) { DrawCross(e.Graphics, Pens.Gray, checkRect); } else { DrawMinus(e.Graphics, Pens.Gray, checkRect); DrawHalfLine2(e.Graphics, this.LineColorPen, checkRect); } } else { if (this.IsLastRow(e.Cell)) DrawEndLine2(e.Graphics, this.LineColorPen, checkRect); else DrawLine2(e.Graphics, this.LineColorPen, checkRect); } #region Draw text if (this.drawText) { string text = e.Cell.Text; if (text != null && text.Length != 0) { Rectangle textRect = this.ClientRectangle; textRect.X += checkRect.Width + 1; textRect.Width -= checkRect.Width + 1; if (e.Enabled) { e.Graphics.DrawString(e.Cell.Text, this.Font, this.ForeBrush, textRect, this.StringFormat); } else { e.Graphics.DrawString(e.Cell.Text, this.Font, this.GrayTextBrush, textRect, this.StringFormat); } } } #endregion }
/// <summary> /// Paints the Cells background /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaintBackground(PaintCellEventArgs e) { base.OnPaintBackground(e); // don't bother going any further if the Cell is null if (e.Cell == null) { return; } if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell)) { ComboBoxStates state = this.GetDropDownRendererData(e.Cell).ButtonState; if (!e.Enabled) { state = ComboBoxStates.Disabled; } ThemeManager.DrawComboBoxButton(e.Graphics, this.CalcDropDownButtonBounds(), state); } }
/// <summary> /// Raises the Paint event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaint(PaintCellEventArgs e) { base.OnPaint(e); // don't bother going any further if the Cell is null // or doesn't contain any data if (e.Cell == null || e.Cell.Data == null || !(e.Cell.Data is DateTime)) { return; } Rectangle buttonRect = this.CalcDropDownButtonBounds(); Rectangle textRect = this.ClientRectangle; if (this.ShowDropDownButton) { textRect.Width -= buttonRect.Width - 1; } // draw the text if (e.Enabled) { this.DrawText((DateTime) e.Cell.Data, e.Graphics, this.ForeBrush, textRect); } else { this.DrawText((DateTime) e.Cell.Data, e.Graphics, this.GrayTextBrush, textRect); } if( (e.Focused && e.Enabled) // only if we want to show selection rectangle && ( e.Table.ShowSelectionRectangle ) ) { Rectangle focusRect = this.ClientRectangle; if (this.ShowDropDownButton) { focusRect.Width -= buttonRect.Width; } ControlPaint.DrawFocusRectangle(e.Graphics, focusRect); } }
/// <summary> /// Raises the PaintCell event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> public override void OnPaintCell(PaintCellEventArgs e) { if (e.Table.ColumnModel.Columns[e.Column] is NumberColumn) { NumberColumn column = (NumberColumn) e.Table.ColumnModel.Columns[e.Column]; this.ShowUpDownButtons = column.ShowUpDownButtons; this.UpDownAlign = column.UpDownAlign; this.Maximum = column.Maximum; this.Minimum = column.Minimum; this.Formatter = column.Formatter; // if the table is editing this cell and the editor is a // NumberCellEditor then we should display the updown buttons if (e.Table.IsEditing && e.Table.EditingCell == e.CellPos && e.Table.EditingCellEditor is NumberCellEditor) { this.ShowUpDownButtons = true; } } else { this.ShowUpDownButtons = false; this.UpDownAlign = LeftRightAlignment.Right; this.Maximum = 100; this.Minimum = 0; } base.OnPaintCell(e); }
/// <summary> /// We don't want any background. /// </summary> /// <param name="e"></param> protected override void OnPaintBackground(PaintCellEventArgs e) { }
/// <summary> /// Raises the Paint event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaint(PaintCellEventArgs e) { base.OnPaint(e); // don't bother if the Cell is null if (e.Cell == null) { return; } Rectangle controlRect = this.CalcControlRect(this.LineAlignment, this.Alignment); ControlRendererData controlData = this.GetControlRendererData(e.Cell); if (controlData != null && controlData.Control != null) { controlData.Control.Size = controlRect.Size; controlData.Control.Location = controlRect.Location; controlData.Control.BringToFront(); } }
/// <summary> /// Raises the PaintBorder event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> /// <param name="pen">The pen used to draw the border</param> protected virtual void OnPaintBorder(PaintCellEventArgs e, Pen pen) { // bottom e.Graphics.DrawLine(pen, e.CellRect.Left, e.CellRect.Bottom, e.CellRect.Right, e.CellRect.Bottom); // right e.Graphics.DrawLine(pen, e.CellRect.Right, e.CellRect.Top, e.CellRect.Right, e.CellRect.Bottom); }
/// <summary> /// Raises the PaintBackground event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected virtual void OnPaintBackground(PaintCellEventArgs e) { // Mateusz [PEYN] Adamus ([email protected]) // we have to figure it out if row is in the alternate span or not // if position is odd it's alternate, even it's not (it's normal) // netus 2006-03-13 - new formula for calculating alternating background color bool isAlternateRow = (Math.Ceiling((double)(e.Row) / e.Table.AlternatingRowSpan) % 2) == 0; //Debug.WriteLine("row: " + e.Row.ToString() + ", isAlternateRow: " + isAlternateRow.ToString()); if (e.Selected && (!e.Table.HideSelection || (e.Table.HideSelection && (e.Table.Focused || e.Table.IsEditing)))) { if (e.Table.Focused || e.Table.IsEditing) { this.ForeColor = e.Table.SelectionForeColor; this.BackColor = e.Table.SelectionBackColor; } else { this.BackColor = e.Table.UnfocusedSelectionBackColor; this.ForeColor = e.Table.UnfocusedSelectionForeColor; } if (this.BackColor.A != 0) { e.Graphics.FillRectangle(this.BackBrush, e.CellRect); } } else { this.ForeColor = e.Cell != null ? e.Cell.ForeColor : Color.Black; if (!e.Sorted || (e.Sorted && e.Table.SortedColumnBackColor.A < 255)) { if (e.Cell != null) { if (e.Cell.BackColor.A < 255) { //netus 2006-03-13 - when there is alternate background color row if (isAlternateRow) { if (e.Table.AlternatingRowColor.A != 0) { this.BackColor = e.Table.AlternatingRowColor; e.Graphics.FillRectangle(this.BackBrush, e.CellRect); } } this.BackColor = e.Cell.BackColor; if (e.Cell.BackColor.A != 0) { e.Graphics.FillRectangle(this.BackBrush, e.CellRect); } } else { this.BackColor = e.Cell.BackColor; if (e.Cell.BackColor.A != 0) { e.Graphics.FillRectangle(this.BackBrush, e.CellRect); } } } else { //netus 2006-03-13 - when there is alternate background color row if (isAlternateRow) { if (e.Table.AlternatingRowColor.A != 0) { this.BackColor = e.Table.AlternatingRowColor; e.Graphics.FillRectangle(this.BackBrush, e.CellRect); } } } if (e.Sorted) { this.BackColor = e.Table.SortedColumnBackColor; if (e.Table.SortedColumnBackColor.A != 0) { e.Graphics.FillRectangle(this.BackBrush, e.CellRect); } } } else { this.BackColor = e.Table.SortedColumnBackColor; e.Graphics.FillRectangle(this.BackBrush, e.CellRect); } } }
/// <summary> /// Raises the PaintBackground event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaintBackground(PaintCellEventArgs e) { base.OnPaintBackground(e); // don't bother going any further if the Cell is null if (e.Cell == null) { return; } // get the button state ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); PushButtonStates state = rendererData.ButtonState; // if the cell has focus and is in its normal state, // make the button look like a default button if (state == PushButtonStates.Normal && e.Focused) { state = PushButtonStates.Default; } // if the table is not enabled, make sure the button is disabled if (!e.Enabled) { state = PushButtonStates.Disabled; } // draw the button ThemeManager.DrawButton(e.Graphics, this.CalcButtonBounds(), state); }
/// <summary> /// Raises the PaintCell event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> public override void OnPaintCell(PaintCellEventArgs e) { if (e.Table.ColumnModel.Columns[e.Column] is DateTimeColumn) { DateTimeColumn column = (DateTimeColumn) e.Table.ColumnModel.Columns[e.Column]; this.DateTimeFormat = column.DateTimeFormat; this.Format = column.CustomDateTimeFormat; } else { this.DateTimeFormat = DateTimePickerFormat.Long; this.Format = ""; } base.OnPaintCell(e); }
/// <summary> /// Raises the Paint event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaint(PaintCellEventArgs e) { base.OnPaint(e); // don't bother if the Cell is null if (e.Cell == null) { return; } // get the Cells value decimal decimalVal = decimal.MinValue; if (e.Cell.Data != null && (e.Cell.Data is int || e.Cell.Data is double || e.Cell.Data is float || e.Cell.Data is long || e.Cell.Data is ulong || e.Cell.Data is decimal)) { decimalVal = Convert.ToDecimal(e.Cell.Data); } // draw the value if (decimalVal != decimal.MinValue) { Rectangle textRect = this.ClientRectangle; if (this.ShowUpDownButtons) { textRect.Width -= this.CalcButtonBounds().Width - 1; if (this.UpDownAlign == LeftRightAlignment.Left) { textRect.X = this.ClientRectangle.Right - textRect.Width; } } if (e.Enabled) { e.Graphics.DrawString(this.Formatter.Format(decimalVal, this.Format), this.Font, this.ForeBrush, textRect, this.StringFormat); } else { e.Graphics.DrawString(this.Formatter.Format(decimalVal, this.Format), this.Font, this.GrayTextBrush, textRect, this.StringFormat); } } if( (e.Focused && e.Enabled) // only if we want to show selection rectangle && ( e.Table.ShowSelectionRectangle ) ) { Rectangle focusRect = this.ClientRectangle; if (this.ShowUpDownButtons) { focusRect.Width -= this.CalcButtonBounds().Width; if (this.UpDownAlign == LeftRightAlignment.Left) { focusRect.X = this.ClientRectangle.Right - focusRect.Width; } } ControlPaint.DrawFocusRectangle(e.Graphics, focusRect); } }
/// <summary> /// Raises the PaintCell event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> public override void OnPaintCell(PaintCellEventArgs e) { if (e.Table.ColumnModel.Columns[e.Column] is DropDownColumn) { this.showButton = ((DropDownColumn) e.Table.ColumnModel.Columns[e.Column]).ShowDropDownButton; } else { this.showButton = true; } base.OnPaintCell(e); }
/// <summary> /// Raises the PaintBackground event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaintBackground(PaintCellEventArgs e) { base.OnPaintBackground(e); // don't bother going any further if the Cell is null if (e.Cell == null) { return; } if (this.ShowUpDownButtons) { UpDownStates upButtonState = this.GetNumberRendererData(e.Cell).UpButtonState; UpDownStates downButtonState = this.GetNumberRendererData(e.Cell).DownButtonState; if (!e.Enabled) { upButtonState = UpDownStates.Disabled; downButtonState = UpDownStates.Disabled; } ThemeManager.DrawUpDownButtons(e.Graphics, this.GetUpButtonBounds(), upButtonState, this.GetDownButtonBounds(), downButtonState); } }
/// <summary> /// Raises the OnPaintCell event /// </summary> /// <param name="e"></param> public override void OnPaintCell(PaintCellEventArgs e) { if (e.Table.ColumnModel.Columns[e.Column] is GroupColumn) { GroupColumn column = (GroupColumn) e.Table.ColumnModel.Columns[e.Column]; this.drawText = column.DrawText; this.lineColor = column.LineColor; this.toggleOnSingleClick = column.ToggleOnSingleClick; } else { this.drawText = false; } base.OnPaintCell (e); }
/// <summary> /// Raises the AfterPaintCell event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected virtual void OnAfterPaintCell(PaintCellEventArgs e) { if (AfterPaintCell != null) { AfterPaintCell(this, e); } }
/// <summary> /// Raises the PaintCell event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> public override void OnPaintCell(PaintCellEventArgs e) { if (e.Table.ColumnModel.Columns[e.Column] is ColorColumn) { ColorColumn column = (ColorColumn) e.Table.ColumnModel.Columns[e.Column]; this.ShowColor = column.ShowColor; this.ShowColorName = column.ShowColorName; } else { this.ShowColor = false; this.ShowColorName = true; } base.OnPaintCell(e); }
/// <summary> /// Raises the BeforePaintCell event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected virtual void OnBeforePaintCell(PaintCellEventArgs e) { if (BeforePaintCell != null) { BeforePaintCell(this, e); } }
/// <summary> /// Raises the PaintCell event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> public override void OnPaintCell(PaintCellEventArgs e) { if (e.Table.ColumnModel.Columns[e.Column] is ProgressBarColumn) { this.drawPercentageText = ((ProgressBarColumn) e.Table.ColumnModel.Columns[e.Column]).DrawPercentageText; } else { this.drawPercentageText = false; } base.OnPaintCell(e); }
/// <summary> /// Paints the Cell at the specified row and column indexes /// </summary> /// <param name="e">A PaintEventArgs that contains the event data</param> /// <param name="row">The index of the row that contains the cell to be painted</param> /// <param name="column">The index of the column that contains the cell to be painted</param> /// <param name="cellRect">The bounding Rectangle of the Cell</param> protected void OnPaintCell(PaintEventArgs e, int row, int column, Rectangle cellRect) { if (row == 0 && column == 1) { column = 1; } // get the renderer for the cells column ICellRenderer renderer = this.ColumnModel.Columns[column].Renderer; if (renderer == null) { // get the default renderer for the column renderer = this.ColumnModel.GetCellRenderer(this.ColumnModel.Columns[column].GetDefaultRendererName()); } // if the renderer is still null (which it shouldn't) // the get out of here if (renderer == null) { return; } //////////// // Adjust the rectangle for this cell to include any cells that it colspans over Rectangle realRect = cellRect; Cell thisCell = this.TableModel[row, column]; if (thisCell != null && thisCell.ColSpan > 1) { int width = this.GetColumnWidth(column, thisCell); realRect = new Rectangle(cellRect.X, cellRect.Y, width, cellRect.Height); } //////////// PaintCellEventArgs pcea = new PaintCellEventArgs(e.Graphics, realRect); pcea.Graphics.SetClip(Rectangle.Intersect(e.ClipRectangle, realRect)); if (column < this.TableModel.Rows[row].Cells.Count) { // is the cell selected bool selected = false; if (this.FullRowSelect) { selected = this.TableModel.Selections.IsRowSelected(row); } else { if (this.SelectionStyle == SelectionStyle.ListView) { if (this.TableModel.Selections.IsRowSelected(row) && this.ColumnModel.PreviousVisibleColumn(column) == -1) { selected = true; } } else if (this.SelectionStyle == SelectionStyle.Grid) { if (this.TableModel.Selections.IsCellSelected(row, column)) { selected = true; } } } // bool editable = this.TableModel[row, column].Editable && this.TableModel.Rows[row].Editable && this.ColumnModel.Columns[column].Editable; bool enabled = this.TableModel[row, column].Enabled && this.TableModel.Rows[row].Enabled && this.ColumnModel.Columns[column].Enabled; // draw the cell pcea.SetCell(this.TableModel[row, column]); pcea.SetRow(row); pcea.SetColumn(column); pcea.SetTable(this); pcea.SetSelected(selected); pcea.SetFocused(this.Focused && this.FocusedCell.Row == row && this.FocusedCell.Column == column); pcea.SetSorted(column == this.lastSortedColumn); pcea.SetEditable(editable); pcea.SetEnabled(enabled); pcea.SetCellRect(realRect); } else { // there isn't a cell for this column, so send a // null value for the cell and the renderer will // take care of the rest (it should draw an empty cell) pcea.SetCell(null); pcea.SetRow(row); pcea.SetColumn(column); pcea.SetTable(this); pcea.SetSelected(false); pcea.SetFocused(false); pcea.SetSorted(false); pcea.SetEditable(false); pcea.SetEnabled(false); pcea.SetCellRect(realRect); } // let the user get the first crack at painting the cell this.OnBeforePaintCell(pcea); // only send to the renderer if the user hasn't // set the handled property if (!pcea.Handled) { renderer.OnPaintCell(pcea); } // let the user have another go this.OnAfterPaintCell(pcea); }
/// <summary> /// Raises the PaintBackground event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaintBackground(PaintCellEventArgs e) { base.OnPaintBackground(e); // don't bother if the Cell is null if (e.Cell == null) { return; } // fill the client area with the window color (this // will be the background color of the progress bar) e.Graphics.FillRectangle(SystemBrushes.Window, this.ClientRectangle); Rectangle progressRect = this.ClientRectangle; // draw the border if (e.Enabled) { // if xp themes are enabled, shrink the size of the // progress bar as otherwise the focus rect appears // to go awol if the cell has focus if (ThemeManager.VisualStylesEnabled) { progressRect.Inflate(-1, -1); } ThemeManager.DrawProgressBar(e.Graphics, progressRect); } else { using (Bitmap b = new Bitmap(progressRect.Width, progressRect.Height)) { using (Graphics g = Graphics.FromImage(b)) { ThemeManager.DrawProgressBar(g, new Rectangle(0, 0, progressRect.Width, progressRect.Height)); } ControlPaint.DrawImageDisabled(e.Graphics, b, progressRect.X, progressRect.Y, this.BackBrush.Color); } } }
/// <summary> /// Raises the PaintCell event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> public override void OnPaintCell(PaintCellEventArgs e) { if (e.Table.ColumnModel.Columns[e.Column] is ButtonColumn) { this.ImageAlignment = ((ButtonColumn) e.Table.ColumnModel.Columns[e.Column]).ImageAlignment; } else { this.ImageAlignment = ContentAlignment.MiddleLeft; } base.OnPaintCell(e); }
/// <summary> /// Raises the Paint event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaint(PaintCellEventArgs e) { base.OnPaint(e); // don't bother if the Cell is null if (e.Cell == null) { return; } Rectangle checkRect = this.CalcCheckRect(this.LineAlignment, this.Alignment); CheckBoxStates state = this.GetCheckBoxRendererData(e.Cell).CheckState; if (!e.Enabled) { if (e.Cell.CheckState == CheckState.Checked) { state = CheckBoxStates.CheckedDisabled; } else if (e.Cell.CheckState == CheckState.Indeterminate) { state = CheckBoxStates.MixedDisabled; } else // if (e.Cell.CheckState == CheckState.Unchecked) { state = CheckBoxStates.UncheckedDisabled; } } if (e.Table.ColumnModel.Columns[e.Column] is CheckBoxColumn && ((CheckBoxColumn) e.Table.ColumnModel.Columns[e.Column]).CheckStyle != CheckBoxColumnStyle.CheckBox) { // remove any mixed states switch (state) { case CheckBoxStates.MixedNormal: state = CheckBoxStates.CheckedNormal; break; case CheckBoxStates.MixedHot: state = CheckBoxStates.CheckedHot; break; case CheckBoxStates.MixedPressed: state = CheckBoxStates.CheckedPressed; break; case CheckBoxStates.MixedDisabled: state = CheckBoxStates.CheckedDisabled; break; } ThemeManager.DrawRadioButton(e.Graphics, checkRect, (RadioButtonStates) state); } else { ThemeManager.DrawCheck(e.Graphics, checkRect, state); } if (this.DrawText) { string text = e.Cell.Text; if (text != null && text.Length != 0) { Rectangle textRect = this.ClientRectangle; textRect.X += checkRect.Width + 1; textRect.Width -= checkRect.Width + 1; if (e.Enabled) { e.Graphics.DrawString(e.Cell.Text, this.Font, this.ForeBrush, textRect, this.StringFormat); } else { e.Graphics.DrawString(e.Cell.Text, this.Font, this.GrayTextBrush, textRect, this.StringFormat); } } } if( (e.Focused && e.Enabled) // only if we want to show selection rectangle && ( e.Table.ShowSelectionRectangle ) ) { ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle); } }
/// <summary> /// Raises the Paint event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaint(PaintCellEventArgs e) { base.OnPaint(e); // don't bother going any further if the Cell is null if (e.Cell == null) { return; } Rectangle textRect = this.CalcButtonBounds(); textRect.Inflate(-4, -2); if (e.Cell.Image != null) { Rectangle imageRect = this.CalcImageRect(e.Cell.Image, this.ImageAlignment); if (this.GetButtonRendererData(e.Cell).ButtonState == PushButtonStates.Pressed && !ThemeManager.VisualStylesEnabled) { imageRect.X += 1; imageRect.Y += 1; } this.DrawImage(e.Graphics, e.Cell.Image, imageRect, e.Enabled); } // draw the text if (e.Cell.Text != null && e.Cell.Text.Length != 0) { if (e.Enabled) { if (!ThemeManager.VisualStylesEnabled && this.GetButtonRendererData(e.Cell).ButtonState == PushButtonStates.Pressed) { textRect.X += 1; textRect.Y += 1; } // if the cell or the row it is in is selected // our forecolor will be the selection forecolor. // we'll ignore this and reset our forecolor to // that of the cell being rendered if (e.Selected) { this.ForeColor = e.Cell.ForeColor; } e.Graphics.DrawString(e.Cell.Text, this.Font, this.ForeBrush, textRect, this.StringFormat); } else { e.Graphics.DrawString(e.Cell.Text, this.Font, this.GrayTextBrush, textRect, this.StringFormat); } } // draw focus if( (e.Focused && e.Enabled) // only if we want to show selection rectangle && ( e.Table.ShowSelectionRectangle ) ) { Rectangle focusRect = this.CalcButtonBounds(); if (ThemeManager.VisualStylesEnabled) { focusRect.Inflate(-3, -3); if (this.GetButtonRendererData(e.Cell).ButtonState != PushButtonStates.Pressed) { ControlPaint.DrawFocusRectangle(e.Graphics, focusRect); } } else { focusRect.Inflate(-4, -4); ControlPaint.DrawFocusRectangle(e.Graphics, focusRect); } } }