/// <summary> /// Paints the Cells background /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaintBackground(I3PaintCellEventArgs e) { this.OnPaintBackgroundNotVirtual(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)) { I3ComboBoxStates comboBoxState = this.GetDropDownRendererData(e.Cell).ButtonState; I3PushButtonStates state = (I3PushButtonStates)comboBoxState; if (!e.Enabled) { state = I3PushButtonStates.Disabled; } //ThemeManager.DrawComboBoxButton(e.Graphics, this.CalcDropDownButtonBounds(), state); Rectangle rect = this.CalcDropDownButtonBounds(); I3ThemeManager.DrawButton(e.Graphics, rect, state); if (state == I3PushButtonStates.Pressed) { rect.X += 1; rect.Y += 1; rect.Width -= 1; rect.Height -= 1; } e.Graphics.DrawString(I3ExtendCellRenderer.ButtonText, this.buttonFont, this.buttonBrush, rect, this.buttonStringFormat); } }
/// <summary> /// Raises the PaintBackground event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaintBackground(I3PaintCellEventArgs e) { base.OnPaintBackground(e); // don't bother going any further if the Cell is null if (e.Cell == null) { return; } // get the button state I3ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell); I3PushButtonStates state = rendererData.ButtonState; // if the cell has focus and is in its normal state, // make the button look like a default button if (state == I3PushButtonStates.Normal && e.Focused) { state = I3PushButtonStates.Default; } // if the table is not enabled, make sure the button is disabled if (!e.Enabled) { state = I3PushButtonStates.Disabled; } // draw the button I3ThemeManager.DrawButton(e.Graphics, this.CalcButtonBounds(), state); }
/// <summary> /// Converts the specified PushButtonStates value to a ButtonState value /// </summary> /// <param name="state">The PushButtonStates value to be converted</param> /// <returns>A ButtonState value that represents the specified PushButtonStates /// value</returns> private static ButtonState ConvertPushButtonStateToButtonState(I3PushButtonStates state) { switch (state) { case I3PushButtonStates.Pressed: { return(ButtonState.Pushed); } case I3PushButtonStates.Disabled: { return(ButtonState.Inactive); } } return(ButtonState.Normal); }
/// <summary> /// Initializes a new instance of the ButtonRendererData class /// </summary> public I3ButtonRendererData() { this.buttonState = I3PushButtonStates.Normal; this.clickX = -1; this.clickY = -1; }
/// <summary> /// Draws a push button in the specified state, on the specified graphics /// surface, and within the specified bounds /// </summary> /// <param name="g">The Graphics to draw on</param> /// <param name="buttonRect">The Rectangle that represents the dimensions /// of the button</param> /// <param name="clipRect">The Rectangle that represents the clipping area</param> /// <param name="state">A PushButtonStates value that specifies the /// state to draw the button in</param> public static void DrawButton(Graphics g, Rectangle buttonRect, Rectangle clipRect, I3PushButtonStates state) { if (g == null || buttonRect.Width <= 0 || buttonRect.Height <= 0 || clipRect.Width <= 0 || clipRect.Height <= 0) { return; } if (I3ThemeManager.VisualStylesEnabled) { I3ThemeManager.DrawThemeBackground(g, I3ThemeClasses.Button, (int)I3ButtonParts.PushButton, (int)state, buttonRect, clipRect); } else { ControlPaint.DrawButton(g, buttonRect, I3ThemeManager.ConvertPushButtonStateToButtonState(state)); } }
/// <summary> /// Draws a push button in the specified state, on the specified graphics /// surface, and within the specified bounds /// </summary> /// <param name="g">The Graphics to draw on</param> /// <param name="buttonRect">The Rectangle that represents the dimensions /// of the button</param> /// <param name="state">A PushButtonStates value that specifies the /// state to draw the button in</param> public static void DrawButton(Graphics g, Rectangle buttonRect, I3PushButtonStates state) { I3ThemeManager.DrawButton(g, buttonRect, buttonRect, state); }