/// <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);
            }
        }
Example #2
0
        /// <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);
        }
Example #3
0
        /// <summary>
        /// 重绘背景
        /// </summary>
        /// <param name="e">A PaintHeaderEventArgs that contains the event data</param>
        protected override void OnPaintBackground(I3PaintColumnHeaderEventArgs e)
        {
            base.OnPaintBackground(e);

            if (e.Column != null && e.Column.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.Column == null)
            {
                I3ThemeManager.DrawColumnHeader(e.Graphics, e.HeaderRect, I3ColumnHeaderStates.Normal);
            }
            else
            {
                I3ThemeManager.DrawColumnHeader(e.Graphics, e.HeaderRect, (I3ColumnHeaderStates)e.Column.ColumnState);
            }
        }
Example #4
0
        /// <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 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 (I3ThemeManager.VisualStylesEnabled)
                {
                    progressRect.Inflate(-1, -1);
                }

                I3ThemeManager.DrawProgressBar(e.Graphics, progressRect);
            }
            else
            {
                using (Bitmap b = new Bitmap(progressRect.Width, progressRect.Height))
                {
                    using (Graphics g = Graphics.FromImage(b))
                    {
                        I3ThemeManager.DrawProgressBar(g, new Rectangle(0, 0, progressRect.Width, progressRect.Height));
                    }

                    ControlPaint.DrawImageDisabled(e.Graphics, b, progressRect.X, progressRect.Y, this.BackBrush.Color);
                }
            }
        }
Example #5
0
        /// <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);
            }
        }
Example #6
0
        /// <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;
            }

            if (this.ShowUpDownButtons)
            {
                I3UpDownStates upButtonState   = this.GetNumberRendererData(e.Cell).UpButtonState;
                I3UpDownStates downButtonState = this.GetNumberRendererData(e.Cell).DownButtonState;

                if (!e.Enabled)
                {
                    upButtonState   = I3UpDownStates.Disabled;
                    downButtonState = I3UpDownStates.Disabled;
                }

                I3ThemeManager.DrawUpDownButtons(e.Graphics, this.GetUpButtonBounds(), upButtonState, this.GetDownButtonBounds(), downButtonState);
            }
        }
Example #7
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;
            }

            // 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 (I3ThemeManager.VisualStylesEnabled)
            {
                chunkRect.Inflate(-1, -1);
            }

            chunkRect.Width = (int)((((double)intVal) / 100d) * ((double)chunkRect.Width));

            if (e.Enabled)
            {
                I3ThemeManager.DrawProgressBarChunks(e.Graphics, chunkRect);
            }
            else
            {
                using (Bitmap b = new Bitmap(chunkRect.Width, chunkRect.Height))
                {
                    using (Graphics g = Graphics.FromImage(b))
                    {
                        I3ThemeManager.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     = I3ColumnAlignment.Center;
                this.LineAlignment = I3RowAlignment.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 (!I3ThemeManager.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);
                }

                //cal needWidth needHeigth
                int maxWidth = e.Table.ColumnModel.Columns[e.Column].CellTextAutoWarp ? e.Table.ColumnModel.Columns[e.Column].Width : 0;
                CalCellNeedSize(e.Graphics, e.Cell, "" + intVal + "%%", this.Font, this.StringFormat, maxWidth, 0, 0);
            }

            if (e.Focused && e.Enabled)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
            }
        }
Example #8
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);
            }
        }