コード例 #1
0
ファイル: NumberCellRenderer.cs プロジェクト: unixcrh/Motion
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(PaintCellEventArgs e)
        {
            if (e.Table.ColumnModel.Columns[e.Column] is NumberColumn)
            {
                NumberColumn column = (NumberColumn)e.Table.ColumnModel.Columns[e.Column];

                this.ShowUpDownButtons = column.ShowUpDownButtons;
                this.UpDownAlign       = column.UpDownAlign;
                this.Maximum           = column.Maximum;
                this.Minimum           = column.Minimum;
                this.Formatter         = column.Formatter;

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

            base.OnPaintCell(e);
        }
コード例 #2
0
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaint(PaintCellEventArgs e)
        {
            base.OnPaint(e);

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

            // get the Cells value
            decimal decimalVal = decimal.MinValue;

            if (e.Cell.Data != null && (e.Cell.Data is int || e.Cell.Data is double || e.Cell.Data is float || e.Cell.Data is decimal))
            {
                decimalVal = Convert.ToDecimal(e.Cell.Data);
            }

            // draw the value
            if (decimalVal != decimal.MinValue)
            {
                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(decimalVal.ToString(this.Format), this.Font, this.ForeBrush, textRect, this.StringFormat);
                }
                else
                {
                    e.Graphics.DrawString(decimalVal.ToString(this.Format), this.Font, this.GrayTextBrush, textRect, this.StringFormat);
                }
            }

            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);
            }
        }
コード例 #3
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(PaintCellEventArgs e)
        {
            var doubleColumn = e.Table.ColumnModel.Columns[e.Column] as DoubleColumn;

            if (doubleColumn != null)
            {
                this.ShowUpDownButtons = doubleColumn.ShowUpDownButtons;
                this.UpDownAlign       = doubleColumn.UpDownAlign;
                this.Maximum           = doubleColumn.Maximum;
                this.Minimum           = doubleColumn.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 DoubleCellEditor)
                {
                    this.ShowUpDownButtons = true;
                }
            }
            else
            {
                this.ShowUpDownButtons = false;
                this.UpDownAlign       = LeftRightAlignment.Right;
                this.Maximum           = 100;
                this.Minimum           = 0;
            }

            base.OnPaintCell(e);
        }
コード例 #4
0
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaint(PaintCellEventArgs e)
        {
            base.OnPaint(e);

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

            string text = e.Cell.Text;

            if (text != null && text.Length != 0)
            {
                // v1.1.1 fix - removed hardcoded alignment

                if (e.Enabled)
                {
                    e.Graphics.DrawString(text, this.Font, this.ForeBrush, this.ClientRectangle, this.StringFormat);
                }
                else
                {
                    e.Graphics.DrawString(text, this.Font, this.GrayTextBrush, this.ClientRectangle, this.StringFormat);
                }
            }

            if (e.Focused && e.Enabled)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
            }
        }
コード例 #5
0
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaint(PaintCellEventArgs e)
        {
            base.OnPaint(e);

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

            Rectangle controlRect = this.CalcControlRect(this.LineAlignment, this.Alignment);

            ControlRendererData controlData = this.GetControlRendererData(e.Cell);

            if (controlData != null && controlData.Control != null)
            {
                controlData.Control.Size     = controlRect.Size;
                controlData.Control.Location = controlRect.Location;
                controlData.Control.BringToFront();

                if (e.Cell.WidthNotSet)
                {
                    e.Cell.ContentWidth = controlRect.Size.Width;
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaint(PaintCellEventArgs e)
        {
            base.OnPaint(e);

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

            string text = e.Cell.Text;

            if (text != null && text.Length != 0)
            {
                if (e.Enabled)
                {
                    e.Graphics.DrawString(text, this.Font, this.ForeBrush, this.ClientRectangle, this.StringFormat);
                }
                else
                {
                    e.Graphics.DrawString(text, this.Font, this.GrayTextBrush, this.ClientRectangle, this.StringFormat);
                }
            }

            if ((e.Focused && e.Enabled)
                // only if we want to show selection rectangle
                && (e.Table.ShowSelectionRectangle))
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
            }
        }
コード例 #7
0
        /// <summary>
        /// Raises the PaintBackground event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaintBackground(PaintCellEventArgs e)
        {
            base.OnPaintBackground(e);

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

            // get the button state
            ButtonRendererData rendererData = this.GetButtonRendererData(e.Cell);
            PushButtonStates   state        = rendererData.ButtonState;

            // if the cell has focus and is in its normal state,
            // make the button look like a default button
            if (state == PushButtonStates.Normal && e.Focused)
            {
                state = PushButtonStates.Default;
            }

            // if the table is not enabled, make sure the button is disabled
            if (!e.Enabled)
            {
                state = PushButtonStates.Disabled;
            }

            // draw the button
            ThemeManager.DrawButton(e.Graphics, this.CalcButtonBounds(), state);
        }
コード例 #8
0
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaint(PaintCellEventArgs 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
            if (e.Cell.Text != null && e.Cell.Text.Length != 0)
            {
                if (e.Enabled)
                {
                    e.Graphics.DrawString(e.Cell.Text, this.Font, this.ForeBrush, textRect, this.StringFormat);
                }
                else
                {
                    e.Graphics.DrawString(e.Cell.Text, this.Font, this.GrayTextBrush, textRect, this.StringFormat);
                }

                if (e.Cell.WidthNotSet)
                {
                    SizeF size = e.Graphics.MeasureString(e.Cell.Text, this.Font);
                    e.Cell.ContentWidth = (int)Math.Ceiling(size.Width) + (this.ShowDropDownButton ? buttonRect.Width : 0);
                }
            }
            else
            {
                if (e.Cell.WidthNotSet)
                {
                    e.Cell.ContentWidth = this.ShowDropDownButton ? buttonRect.Width : 0;
                }
            }

            if ((e.Focused && e.Enabled)
                // only if we want to show selection rectangle
                && (e.Table.ShowSelectionRectangle))
            {
                Rectangle focusRect = this.ClientRectangle;

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

                ControlPaint.DrawFocusRectangle(e.Graphics, focusRect);
            }
        }
コード例 #9
0
ファイル: CellRenderer.cs プロジェクト: 6555355/Scan_yan1
        /// <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(PaintCellEventArgs 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);
        }
コード例 #10
0
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaint(PaintCellEventArgs e)
        {
            base.OnPaint(e);

            if (e.Cell == null)
            {
                return;
            }

            var cellData = e.Cell.Data;

            if (cellData == null)
            {
                return;
            }

            var text = RenderText(cellData, this.Format, this.FormatProvider);

            // draw the value
            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.Cell.WidthNotSet)
            {
                SizeF size = e.Graphics.MeasureString(text, this.Font);
                e.Cell.ContentWidth = (int)Math.Ceiling(size.Width);
            }

            //Draw the formatted or raw value (striked out) if an error occured
            this.DrawString(e.Graphics, text, this.Font, e.Enabled ? this.ForeBrush : this.GrayTextBrush, textRect, e.Cell.WordWrap);

            if (e.Focused && e.Enabled && e.Table.ShowSelectionRectangle /*only if we want to show selection rectangle*/)
            {
                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);
            }
        }
コード例 #11
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public virtual void OnPaintCell(PaintCellEventArgs e)
        {
            this.Bounds = e.CellRect;

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

                // Cell settings supercede Column/Row settings

                bool alignmentSet     = false;
                bool lineAlignmentSet = false;
                if (e.Cell.CellStyle != null)
                {
                    CellStyle style = e.Cell.CellStyle;
                    if (style.IsAlignmentSet)
                    {
                        alignmentSet   = true;
                        this.Alignment = style.Alignment;
                    }
                    if (style.IsLineAlignmentSet)
                    {
                        lineAlignmentSet   = true;
                        this.LineAlignment = style.LineAlignment;
                    }
                }

                if (!alignmentSet)
                {
                    this.Alignment = e.Table.ColumnModel.Columns[e.Column].Alignment;
                }
                if (!lineAlignmentSet)
                {
                    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       = CellPadding.Empty;
                this.Alignment     = ColumnAlignment.Left;
                this.LineAlignment = RowAlignment.Center;
                this.Format        = string.Empty;
                this.Font          = null;
            }

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

            // paint the Cells foreground
            this.OnPaint(e);
        }
コード例 #12
0
ファイル: ImageCellRenderer.cs プロジェクト: unixcrh/Motion
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaint(PaintCellEventArgs 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 != ImageSizeMode.Normal);

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

            // check if we need to draw any text
            if (this.DrawText)
            {
                if (e.Cell.Text != null && e.Cell.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(e.Cell.Text, this.Font, this.ForeBrush, textRect, this.StringFormat);
                        }
                        else
                        {
                            e.Graphics.DrawString(e.Cell.Text, this.Font, this.GrayTextBrush, textRect, this.StringFormat);
                        }
                    }
                }
            }

            if ((e.Focused && e.Enabled)
                // only if we want to show selection rectangle
                && (e.Table.ShowSelectionRectangle))
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
            }
        }
コード例 #13
0
ファイル: ImageCellRenderer.cs プロジェクト: zeroyou/XPTable
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(PaintCellEventArgs e)
        {
            if (e.Table.ColumnModel.Columns[e.Column] is ImageColumn)
            {
                this.drawText = ((ImageColumn)e.Table.ColumnModel.Columns[e.Column]).DrawText;
            }
            else
            {
                this.drawText = true;
            }

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

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

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

            base.OnPaintCell(e);
        }
コード例 #17
0
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaint(PaintCellEventArgs e)
        {
            base.OnPaint(e);

            // don't bother going any further if the Cell is null
            // or doesn't contain any data
            if (e.Cell == null || e.Cell.Data == null || !(e.Cell.Data is DateTime))
            {
                return;
            }

            Rectangle buttonRect = this.CalcDropDownButtonBounds();
            Rectangle textRect   = this.ClientRectangle;

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

            string dateText = FormatDate((DateTime)e.Cell.Data);

            // draw the text
            if (e.Enabled)
            {
                DrawString(e.Graphics, dateText, this.Font, this.ForeBrush, textRect, e.Cell.WordWrap);
            }
            else
            {
                DrawString(e.Graphics, dateText, this.Font, this.GrayTextBrush, textRect, e.Cell.WordWrap);
            }

            if (e.Cell.WidthNotSet)
            {
                SizeF size = e.Graphics.MeasureString(dateText, this.Font);
                e.Cell.ContentWidth = (int)Math.Ceiling(size.Width) + (this.ShowDropDownButton ? buttonRect.Width : 0);
            }

            if ((e.Focused && e.Enabled)
                // only if we want to show selection rectangle
                && (e.Table.ShowSelectionRectangle))
            {
                Rectangle focusRect = this.ClientRectangle;

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

                ControlPaint.DrawFocusRectangle(e.Graphics, focusRect);
            }
        }
コード例 #18
0
ファイル: TextCellRenderer.cs プロジェクト: zeroyou/XPTable
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaint(PaintCellEventArgs e)
        {
            base.OnPaint(e);

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

            Cell c = e.Cell;

            //////////////////
            if (c.WidthNotSet)
            {
                int w = GetCellWidth(e.Graphics, c);
                c.ContentWidth = w;
            }
            //////////////////

            string text = c.Text;

            if (!string.IsNullOrEmpty(text))
            {
                if (e.Enabled)
                {
                    this.DrawString(e.Graphics, text, this.Font, this.ForeBrush, this.ClientRectangle, c.WordWrap);
                }
                else
                {
                    this.DrawString(e.Graphics, text, this.Font, this.GrayTextBrush, this.ClientRectangle, c.WordWrap);
                }

                // Also, determine whether we need a tooltip, if the text was truncated.
                if (c.WordWrap)
                {
                    c.InternalIsTextTrimmed = false;
                }
                else if (e.Table.EnableToolTips)
                {
                    c.InternalIsTextTrimmed = this.IsTextTrimmed(e.Graphics, c.Text);
                }
            }

            if ((e.Focused && e.Enabled)
                // only if we want to show selection rectangle
                && (e.Table.ShowSelectionRectangle))
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
            }
        }
コード例 #19
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public override void OnPaintCell(PaintCellEventArgs e)
        {
            if (e.Table.ColumnModel.Columns[e.Column] is ButtonColumn)
            {
                ButtonColumn buttonCol = ((ButtonColumn)e.Table.ColumnModel.Columns[e.Column]);
                this.ImageAlignment = buttonCol.ImageAlignment;
                this.FlatStyle      = buttonCol.FlatStyle;
            }
            else
            {
                this.ImageAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            }

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

                this.controlSize    = column.ControlSize;
                this.controlFactory = column.ControlFactory;
            }
            else
            {
                this.controlSize = new Size(13, 13);
            }

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

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

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

                this.drawText            = column.DrawText;
                this.lineColor           = column.LineColor;
                this.toggleOnSingleClick = column.ToggleOnSingleClick;
            }
            else
            {
                this.drawText = false;
            }

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

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

            base.OnPaintCell(e);
        }
コード例 #25
0
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaint(PaintCellEventArgs e)
        {
            base.OnPaint(e);

            // don't bother going any further if the Cell is null
            // or doesn't contain any data
            if (e.Cell == null || e.Cell.Data == null || !(e.Cell.Data is DateTime))
            {
                return;
            }

            Rectangle buttonRect = this.CalcDropDownButtonBounds();

            Rectangle textRect = this.ClientRectangle;

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

            // draw the text
            if (e.Enabled)
            {
                this.DrawText((DateTime)e.Cell.Data, e.Graphics, this.ForeBrush, textRect);
            }
            else
            {
                this.DrawText((DateTime)e.Cell.Data, e.Graphics, this.GrayTextBrush, textRect);
            }

            if ((e.Focused && e.Enabled)
                // only if we want to show selection rectangle
                && (e.Table.ShowSelectionRectangle))
            {
                Rectangle focusRect = this.ClientRectangle;

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

                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(PaintCellEventArgs 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
            if (e.Cell.Text != null && e.Cell.Text.Length != 0)
            {
                if (e.Enabled)
                {
                    e.Graphics.DrawString(e.Cell.Text, this.Font, this.ForeBrush, textRect, this.StringFormat);
                }
                else
                {
                    e.Graphics.DrawString(e.Cell.Text, this.Font, this.GrayTextBrush, textRect, this.StringFormat);
                }
            }

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

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

                ControlPaint.DrawFocusRectangle(e.Graphics, focusRect);
            }
        }
コード例 #27
0
        /// <summary>
        /// Raises the PaintBackground event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaintBackground(PaintCellEventArgs 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 (ThemeManager.VisualStylesEnabled)
                {
                    progressRect.Inflate(-1, -1);
                }

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

                    ControlPaint.DrawImageDisabled(e.Graphics, b, progressRect.X, progressRect.Y, this.BackBrush.Color);
                }
            }
        }
コード例 #28
0
        /// <summary>
        /// Paints the Cells background
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        protected override void OnPaintBackground(PaintCellEventArgs 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))
            {
                ComboBoxStates state = this.GetDropDownRendererData(e.Cell).ButtonState;

                if (!e.Enabled)
                {
                    state = ComboBoxStates.Disabled;
                }

                ThemeManager.DrawComboBoxButton(e.Graphics, this.CalcDropDownButtonBounds(), state);
            }
        }
コード例 #29
0
ファイル: CellRenderer.cs プロジェクト: 6555355/Scan_yan1
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public virtual void OnPaintCell(PaintCellEventArgs e)
        {
            this.Bounds = e.CellRect;

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

                this.Alignment     = e.Table.ColumnModel.Columns[e.Column].Alignment;
                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 = CellPadding.Empty;

                this.Alignment     = ColumnAlignment.Left;
                this.LineAlignment = RowAlignment.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);
        }
コード例 #30
0
        protected override void OnPaint(PaintCellEventArgs e)
        {
            base.OnPaint(e);

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

            // make sure we have some Text to draw
            if (e.Cell.Text != null && e.Cell.Text.Length != 0)
            {
                // check whether the cell is enabled
                if (e.Enabled)
                {
                    TextRenderer.DrawText(e.Graphics, e.Cell.Text, base.Font, base.ClientRectangle, base.ForeColor, formatFlags);
                }
                else
                {
                    Color GrayColor = Color.Gray;
                    try
                    {
                        GrayColor = (base.GrayTextBrush as SolidBrush).Color;
                    }
                    catch { }

                    TextRenderer.DrawText(e.Graphics, e.Cell.Text, base.Font, base.ClientRectangle, GrayColor, formatFlags);
                }
            }

            // draw a focus rect around the cell if it is
            // enabled and has focus
            if (e.Focused && e.Enabled)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics,
                                                base.ClientRectangle);
            }
        }