/// <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> /// Converts the specified ComboBoxStates value to a ButtonState value /// </summary> /// <param name="state">The ComboBoxStates value to be converted</param> /// <returns>A ButtonState value that represents the specified ComboBoxStates /// value</returns> private static ButtonState ConvertComboBoxStateToButtonState(I3ComboBoxStates state) { switch (state) { case I3ComboBoxStates.Pressed: { return(ButtonState.Pushed); } case I3ComboBoxStates.Disabled: { return(ButtonState.Inactive); } } return(ButtonState.Normal); }
/// <summary> /// Paints the Cells background /// </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; } if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell)) { I3ComboBoxStates state = this.GetDropDownRendererData(e.Cell).ButtonState; if (!e.Enabled) { state = I3ComboBoxStates.Disabled; } I3ThemeManager.DrawComboBoxButton(e.Graphics, this.CalcDropDownButtonBounds(), state); } }
/// <summary> /// Initializes a new instance of the DropDownRendererData class /// </summary> public I3DropDownRendererData() { this.buttonState = I3ComboBoxStates.Normal; this.clickX = -1; this.clickY = -1; }
/// <summary> /// Draws a combobox 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 ComboBoxStates value that specifies the /// state to draw the combobox button in</param> public static void DrawComboBoxButton(Graphics g, Rectangle buttonRect, Rectangle clipRect, I3ComboBoxStates state) { if (g == null || buttonRect.Width <= 0 || buttonRect.Height <= 0 || clipRect.Width <= 0 || clipRect.Height <= 0) { return; } if (I3ThemeManager.VisualStylesEnabled) { I3ThemeManager.DrawThemeBackground(g, I3ThemeClasses.ComboBox, (int)I3ComboBoxParts.DropDownButton, (int)state, buttonRect, clipRect); } else { ControlPaint.DrawComboButton(g, buttonRect, I3ThemeManager.ConvertComboBoxStateToButtonState(state)); } }
/// <summary> /// Draws a combobox 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 combobox button</param> /// <param name="state">A ComboBoxStates value that specifies the /// state to draw the combobox button in</param> public static void DrawComboBoxButton(Graphics g, Rectangle buttonRect, I3ComboBoxStates state) { I3ThemeManager.DrawComboBoxButton(g, buttonRect, buttonRect, state); }