Example #1
0
        /// <summary>
        /// Converts the specified CheckBoxStates value to a ButtonState value
        /// </summary>
        /// <param name="state">The CheckBoxStates value to be converted</param>
        /// <returns>A ButtonState value that represents the specified CheckBoxStates
        /// value</returns>
        private static ButtonState ConvertCheckBoxStateToButtonState(I3CheckBoxStates state)
        {
            switch (state)
            {
            case I3CheckBoxStates.UncheckedPressed:
            {
                return(ButtonState.Pushed);
            }

            case I3CheckBoxStates.UncheckedDisabled:
            {
                return(ButtonState.Inactive);
            }

            case I3CheckBoxStates.CheckedNormal:
            case I3CheckBoxStates.CheckedHot:
            {
                return(ButtonState.Checked);
            }

            case I3CheckBoxStates.CheckedPressed:
            {
                return(ButtonState.Checked | ButtonState.Pushed);
            }

            case I3CheckBoxStates.CheckedDisabled:
            {
                return(ButtonState.Checked | ButtonState.Inactive);
            }

            case I3CheckBoxStates.MixedNormal:
            case I3CheckBoxStates.MixedHot:
            {
                return(ButtonState.Checked);
            }

            case I3CheckBoxStates.MixedPressed:
            {
                return(ButtonState.Checked | ButtonState.Pushed);
            }

            case I3CheckBoxStates.MixedDisabled:
            {
                return(ButtonState.Checked | ButtonState.Inactive);
            }
            }

            return(ButtonState.Normal);
        }
Example #2
0
        /// <summary>
        /// Returns whether the specified CheckBoxStates value is in an
        /// indeterminate state
        /// </summary>
        /// <param name="state">The CheckBoxStates value to be checked</param>
        /// <returns>true if the specified CheckBoxStates value is in an
        /// indeterminate state, false otherwise</returns>
        private static bool IsMixed(I3CheckBoxStates state)
        {
            switch (state)
            {
            case I3CheckBoxStates.MixedNormal:
            case I3CheckBoxStates.MixedHot:
            case I3CheckBoxStates.MixedPressed:
            case I3CheckBoxStates.MixedDisabled:
            {
                return(true);
            }
            }

            return(false);
        }
Example #3
0
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaint(I3PaintCellEventArgs e)
        {
            base.OnPaint(e);

            // don't bother if the Cell is null
            if (e.Cell == null)
            {
                return;
            }

            Rectangle checkRect = this.CalcCheckBoxDisplayRect(this.LineAlignment, this.Alignment, e.Table.ColumnModel.Columns[e.Column] as I3CheckBoxColumn);

            I3CheckBoxStates state = this.GetCheckBoxRendererData(e.Cell).CheckState;

            if (!e.Enabled)
            {
                if (e.Cell.CheckState == CheckState.Checked)
                {
                    state = I3CheckBoxStates.CheckedDisabled;
                }
                else if (e.Cell.CheckState == CheckState.Indeterminate)
                {
                    state = I3CheckBoxStates.MixedDisabled;
                }
                else                 // if (e.Cell.CheckState == CheckState.Unchecked)
                {
                    state = I3CheckBoxStates.UncheckedDisabled;
                }
            }

            if (e.Table.ColumnModel.Columns[e.Column] is I3CheckBoxColumn)
            {
                I3CheckBoxColumn checkBoxColumn = e.Table.ColumnModel.Columns[e.Column] as I3CheckBoxColumn;
                switch (checkBoxColumn.CheckBoxColumnStyle)
                {
                case I3CheckBoxColumnStyle.RadioButton:
                    // remove any mixed states
                    switch (state)
                    {
                    case I3CheckBoxStates.MixedNormal:
                        state = I3CheckBoxStates.CheckedNormal;
                        break;

                    case I3CheckBoxStates.MixedHot:
                        state = I3CheckBoxStates.CheckedHot;
                        break;

                    case I3CheckBoxStates.MixedPressed:
                        state = I3CheckBoxStates.CheckedPressed;
                        break;

                    case I3CheckBoxStates.MixedDisabled:
                        state = I3CheckBoxStates.CheckedDisabled;
                        break;
                    }
                    I3ThemeManager.DrawRadioButton(e.Graphics, checkRect, (I3RadioButtonStates)state);
                    break;

                case I3CheckBoxColumnStyle.Image:
                    if (e.Cell.Checked)
                    {
                        Image image = this.CheckBoxImage(checkBoxColumn);
                        this.DrawImage(e.Graphics, image, checkRect, e.Cell.Enabled);
                    }
                    break;

                default:
                    I3ThemeManager.DrawCheck(e.Graphics, checkRect, state);
                    break;
                }
            }

            string text = "";

            if (this.DrawText)
            {
                //string text = e.Cell.Text;
                text = e.Table.ColumnModel.Columns[e.Column].DataToString(e.Cell.Data);

                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(text, this.Font, this.ForeBrush, textRect, this.StringFormat);
                    }
                    else
                    {
                        e.Graphics.DrawString(text, this.Font, this.GrayTextBrush, textRect, this.StringFormat);
                    }
                }
            }

            //cal needWidth needHeigth
            int maxWidth    = e.Table.ColumnModel.Columns[e.Column].CellTextAutoWarp ? e.Table.ColumnModel.Columns[e.Column].Width : 0;
            int buttonWidth = checkRect.Width;

            CalCellNeedSize(e.Graphics, e.Cell, text, this.Font, this.StringFormat, maxWidth, 6 + buttonWidth, 0);

            if (e.Focused && e.Enabled)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
            }
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the ButtonRendererData class with the
 /// specified CheckBox state
 /// </summary>
 /// <param name="checkState">The current state of the Cells CheckBox</param>
 public I3CheckBoxRendererData(I3CheckBoxStates checkState)
 {
     this.checkState = checkState;
 }
Example #5
0
        /// <summary>
        /// Draws a check box 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="checkRect">The Rectangle that represents the dimensions
        /// of the check box</param>
        /// <param name="clipRect">The Rectangle that represents the clipping area</param>
        /// <param name="state">A CheckBoxStates value that specifies the
        /// state to draw the check box in</param>
        public static void DrawCheck(Graphics g, Rectangle checkRect, Rectangle clipRect, I3CheckBoxStates state)
        {
            if (g == null || checkRect.Width <= 0 || checkRect.Height <= 0)
            {
                return;
            }

            if (I3ThemeManager.VisualStylesEnabled)
            {
                I3ThemeManager.DrawThemeBackground(g, I3ThemeClasses.Button, (int)I3ButtonParts.CheckBox, (int)state, checkRect, clipRect);
            }
            else
            {
                if (IsMixed(state))
                {
                    ControlPaint.DrawMixedCheckBox(g, checkRect, I3ThemeManager.ConvertCheckBoxStateToButtonState(state));
                }
                else
                {
                    ControlPaint.DrawCheckBox(g, checkRect, I3ThemeManager.ConvertCheckBoxStateToButtonState(state));
                }
            }
        }
Example #6
0
 /// <summary>
 /// Draws a check box 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="checkRect">The Rectangle that represents the dimensions
 /// of the check box</param>
 /// <param name="state">A CheckBoxStates value that specifies the
 /// state to draw the check box in</param>
 public static void DrawCheck(Graphics g, Rectangle checkRect, I3CheckBoxStates state)
 {
     I3ThemeManager.DrawCheck(g, checkRect, checkRect, state);
 }