コード例 #1
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);
        }
コード例 #2
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(I3PaintCellEventArgs e)
        {
            if (e.Table.ColumnModel.Columns[e.Column] is I3NumberColumn)
            {
                I3NumberColumn column = (I3NumberColumn)e.Table.ColumnModel.Columns[e.Column];

                this.ShowUpDownButtons = column.ShowUpDownButtons;
                this.UpDownAlign       = column.UpDownAlign;
                //this.Maximum = Convert.ToDecimal(column.Maximum);
                //this.Minimum = Convert.ToDecimal(column.Minimum);

                // 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 I3NumberCellEditor)
                {
                    this.ShowUpDownButtons = true;
                }
            }
            else
            {
                this.ShowUpDownButtons = false;
                this.UpDownAlign       = LeftRightAlignment.Right;
                //this.Maximum = 100;
                //this.Minimum = 0;
            }

            base.OnPaintCell(e);
        }
コード例 #3
0
        /// <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);
            }
        }
コード例 #4
0
        /// <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(I3PaintCellEventArgs 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);
        }
コード例 #5
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;
            }

            string    text     = e.Table.ColumnModel.Columns[e.Column].DataToString(e.Cell.Data);
            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(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 = this.ShowUpDownButtons ? this.CalcButtonBounds().Width : 0;

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

            if (e.Focused && e.Enabled)
            {
                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);
            }
        }
コード例 #6
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 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
            string text = e.Table.ColumnModel.Columns[e.Column].DataToString(e.Cell.Data);

            if (text != null && text.Length != 0)
            {
                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 = this.ShowDropDownButton ? buttonRect.Width : 0;

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

            if (e.Focused && e.Enabled)
            {
                Rectangle focusRect = this.ClientRectangle;

                if (this.ShowDropDownButton)
                {
                    focusRect.Width -= buttonRect.Width;
                }

                ControlPaint.DrawFocusRectangle(e.Graphics, focusRect);
            }
        }
コード例 #7
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(I3PaintCellEventArgs e)
        {
            if (e.Table.ColumnModel.Columns[e.Column] is I3ButtonColumn)
            {
                this.ImageAlignment = ((I3ButtonColumn)e.Table.ColumnModel.Columns[e.Column]).ImageAlignment;
            }
            else
            {
                this.ImageAlignment = ContentAlignment.MiddleLeft;
            }

            base.OnPaintCell(e);
        }
コード例 #8
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(I3PaintCellEventArgs e)
        {
            if (e.Table.ColumnModel.Columns[e.Column] is I3ProgressBarColumn)
            {
                this.drawPercentageText = ((I3ProgressBarColumn)e.Table.ColumnModel.Columns[e.Column]).DrawPercentageText;
            }
            else
            {
                this.drawPercentageText = false;
            }

            base.OnPaintCell(e);
        }
コード例 #9
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(I3PaintCellEventArgs e)
        {
            if (e.Table.ColumnModel.Columns[e.Column] is I3DropDownColumn)
            {
                this.showButton = ((I3DropDownColumn)e.Table.ColumnModel.Columns[e.Column]).ShowDropDownButton;
            }
            else
            {
                this.showButton = true;
            }

            base.OnPaintCell(e);
        }
コード例 #10
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(I3PaintCellEventArgs e)
        {
            if (e.Table.ColumnModel.Columns[e.Column] is I3ImageColumn)
            {
                this.drawText = ((I3ImageColumn)e.Table.ColumnModel.Columns[e.Column]).DrawText;
            }
            else
            {
                this.drawText = true;
            }

            base.OnPaintCell(e);
        }
コード例 #11
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(I3PaintCellEventArgs e)
        {
            if (e.Table.ColumnModel.Columns[e.Column] is I3ColorColumn)
            {
                I3ColorColumn column = (I3ColorColumn)e.Table.ColumnModel.Columns[e.Column];

                this.ShowColor     = column.ShowColor;
                this.ShowColorName = column.ShowColorName;
            }
            else
            {
                this.ShowColor     = false;
                this.ShowColorName = true;
            }

            base.OnPaintCell(e);
        }
コード例 #12
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(I3PaintCellEventArgs e)
        {
            if (e.Table.ColumnModel.Columns[e.Column] is I3CheckBoxColumn)
            {
                I3CheckBoxColumn column = (I3CheckBoxColumn)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);
        }
コード例 #13
0
        /// <summary>
        /// Gets or sets the format of the date and time displayed in the Cell
        /// </summary>
        //public DateTimePickerFormat DateTimeFormat
        //{
        //    get
        //    {
        //        return this.dateFormat;
        //    }

        //    set
        //    {
        //        if (!Enum.IsDefined(typeof(DateTimePickerFormat), value))
        //        {
        //            throw new InvalidEnumArgumentException("value", (int) value, typeof(DateTimePickerFormat));
        //        }

        //        this.dateFormat = value;
        //    }
        //}

        #endregion


        #region Events

        #region Paint

        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(I3PaintCellEventArgs e)
        {
            //if (e.Table.ColumnModel.Columns[e.Column] is I3DateTimeColumn)
            //{
            //    I3DateTimeColumn column = (I3DateTimeColumn) e.Table.ColumnModel.Columns[e.Column];

            //    //this.DateTimeFormat = column.DateTimeFormat;
            //    this.Format = column.Format;
            //}
            //else
            //{
            //    //this.DateTimeFormat = DateTimePickerFormat.Long;
            //    this.Format = "";
            //}

            base.OnPaintCell(e);
        }
コード例 #14
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);
                }
            }
        }
コード例 #15
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public virtual void OnPaintCell(I3PaintCellEventArgs e)
        {
            this.Bounds = e.CellRect;

            if (e.Cell != null)
            {
                this.Padding = e.Cell.Padding;

                this.Alignment     = e.Table.ColumnModel.Columns[e.Column].CellAlignment;
                this.AutoWarp      = e.Table.ColumnModel.Columns[e.Column].CellTextAutoWarp;
                this.LineAlignment = e.Table.TableModel.Rows[e.Row].Alignment;

                //this.Format = e.Table.ColumnModel.Columns[e.Column].Format;

                this.Font = e.Cell.Font;
            }
            else
            {
                this.Padding = I3CellPadding.Empty;

                this.Alignment     = I3ColumnAlignment.Left;
                this.LineAlignment = I3RowAlignment.Center;

                //this.Format = "";

                this.Font = null;
            }

            // if the font is null, use the default font
            if (this.Font == null)
            {
                this.Font = Control.DefaultFont;
            }

            // paint the Cells background
            this.OnPaintBackground(e);

            // paint the Cells foreground
            this.OnPaint(e);
        }
コード例 #16
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);
            }
        }
コード例 #17
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 going any further if the Cell is null
            if (e.Cell == null)
            {
                return;
            }

            string text = e.Table.ColumnModel.Columns[e.Column].DataToString(e.Cell.Data);

            if (text != null && text.Length != 0)
            {
                Brush brush;
                if (e.Enabled)
                {
                    brush = this.ForeBrush;
                }
                else
                {
                    brush = this.GrayTextBrush;
                }

                e.Graphics.DrawString(text, this.Font, brush, this.ClientRectangle, this.StringFormat);
            }

            //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, text, this.Font, this.StringFormat, maxWidth, 6, 0);

            if (e.Focused && e.Enabled)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
            }
        }
コード例 #18
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);
            }
        }
コード例 #19
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
            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);

            Rectangle colorRect = Rectangle.Empty;

            if (this.ShowColor)
            {
                colorRect = this.CalcColorRect(e.Table.TableModel.Rows[e.Row].Alignment, e.Table.ColumnModel.Columns[e.Column].CellAlignment);

                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;
                }
            }

            string text = "";

            if (this.ShowColorName)
            {
                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);
                }
            }

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

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

            if (e.Focused && e.Enabled)
            {
                Rectangle focusRect = this.ClientRectangle;

                if (this.ShowDropDownButton)
                {
                    focusRect.Width -= buttonRect.Width;
                }

                ControlPaint.DrawFocusRectangle(e.Graphics, focusRect);
            }
        }
コード例 #20
0
 /// <summary>
 /// Raises the PaintBackground event
 /// </summary>
 /// <param name="e">A PaintCellEventArgs that contains the event data</param>
 protected virtual void OnPaintBackground(I3PaintCellEventArgs e)
 {
     this.OnPaintBackgroundNotVirtual(e);
 }
コード例 #21
0
        protected void OnPaintBackgroundNotVirtual(I3PaintCellEventArgs e)
        {
            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)
                    {
                        if (e.Row % 2 == 1)
                        {
                            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
                {
                    if (e.Row % 2 == 1)
                    {
                        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);
                //}
            }
        }
コード例 #22
0
 /// <summary>
 /// Raises the Paint event
 /// </summary>
 /// <param name="e">A PaintCellEventArgs that contains the event data</param>
 protected virtual void OnPaint(I3PaintCellEventArgs e)
 {
 }
コード例 #23
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);
            }
        }
コード例 #24
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);
            }
        }
コード例 #25
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 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 == I3PushButtonStates.Pressed && !I3ThemeManager.VisualStylesEnabled)
                {
                    imageRect.X += 1;
                    imageRect.Y += 1;
                }

                this.DrawImage(e.Graphics, e.Cell.Image, imageRect, e.Enabled);
            }

            // draw the text
            string text = e.Table.ColumnModel.Columns[e.Column].DataToString(e.Cell.Data);

            if (string.IsNullOrEmpty(text))
            {
                text = e.Table.ColumnModel.Columns[e.Column].Caption;
            }
            if (text != null && text.Length != 0)
            {
                if (e.Enabled)
                {
                    if (!I3ThemeManager.VisualStylesEnabled && this.GetButtonRendererData(e.Cell).ButtonState == I3PushButtonStates.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(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;

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

            // draw focus
            if (e.Focused && e.Enabled)
            {
                Rectangle focusRect = this.CalcButtonBounds();

                if (I3ThemeManager.VisualStylesEnabled)
                {
                    focusRect.Inflate(-3, -3);

                    if (this.GetButtonRendererData(e.Cell).ButtonState != I3PushButtonStates.Pressed)
                    {
                        ControlPaint.DrawFocusRectangle(e.Graphics, focusRect);
                    }
                }
                else
                {
                    focusRect.Inflate(-4, -4);

                    ControlPaint.DrawFocusRectangle(e.Graphics, focusRect);
                }
            }
        }
コード例 #26
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 or doesn't have an image
            if (e.Cell == null || e.Cell.Image == null)
            {
                return;
            }

            // work out the size and location of the image
            Rectangle imageRect = this.CalcImageRect(e.Cell.Image, e.Cell.ImageSizeMode, this.LineAlignment, this.Alignment);

            // draw the image
            bool scaled = (this.DrawText || e.Cell.ImageSizeMode != I3ImageSizeMode.Normal);

            this.DrawImage(e.Graphics, e.Cell.Image, imageRect, scaled, e.Table.Enabled);

            // check if we need to draw any text
            string text = "";

            if (this.DrawText)
            {
                text = e.Table.ColumnModel.Columns[e.Column].DataToString(e.Cell.Data);
                if (text != null && text.Length != 0)
                {
                    // rectangle the text will be drawn in
                    Rectangle textRect = this.ClientRectangle;

                    // take the imageRect into account so we don't
                    // draw over it
                    textRect.X     += imageRect.Width;
                    textRect.Width -= imageRect.Width;

                    // check that we will be able to see the text
                    if (textRect.Width > 0)
                    {
                        // draw the text
                        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
            if (this.DrawText || e.Cell.ImageSizeMode != I3ImageSizeMode.SizedToFit)
            {
                int maxWidth = e.Table.ColumnModel.Columns[e.Column].CellTextAutoWarp ? e.Table.ColumnModel.Columns[e.Column].Width : 0;
                int addWidth = string.IsNullOrEmpty(text) ? 0 : 6;
                CalCellNeedSize(e.Graphics, e.Cell, text, this.Font, this.StringFormat, maxWidth, addWidth + imageRect.Width, 0);
            }
            else
            {
                e.Cell.NeedWidth = e.Cell.Image == null ? 1 : e.Cell.Image.Width + e.Cell.Padding.Left + e.Cell.Padding.Right;
                if (e.Cell.NeedWidth > 200)
                {
                    e.Cell.NeedWidth = 200;
                }
            }
            e.Cell.NeedHeight = e.Cell.Image == null ? 1 : e.Cell.Image.Height + e.Cell.Padding.Top + e.Cell.Padding.Bottom;
            if (e.Cell.NeedHeight > 100)
            {
                e.Cell.NeedHeight = 100;
            }

            if (e.Focused && e.Enabled)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
            }
        }