/// <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);
			}
		}
Пример #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 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 (!string.IsNullOrEmpty(e.Cell.Text))
            {
                if (e.Enabled)
                {
                    this.DrawString(e.Graphics, e.Cell.Text, this.Font, this.ForeBrush, textRect, e.Cell.WordWrap);
                }
                else
                {
                    this.DrawString(e.Graphics, e.Cell.Text, this.Font, this.GrayTextBrush, textRect, e.Cell.WordWrap);
                }

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

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

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

                ControlPaint.DrawFocusRectangle(e.Graphics, focusRect);
            }
        }
Пример #3
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;

            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);
            }
        }
Пример #4
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);
        }
		/// <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);
			}
		}
Пример #6
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);
            }
        }
Пример #7
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 textRect = this.CalcButtonBounds();
            textRect.Inflate(-4, -2);

            int imageWidth = 0;
            int textWidth = 0;

            if (e.Cell.Image != null)
            {
                Rectangle imageRect = this.CalcImageRect(e.Cell.Image, this.ImageAlignment);

                if (this.GetButtonRendererData(e.Cell).ButtonState == PushButtonState.Pressed && !ThemeManager.VisualStylesEnabled)
                {
                    imageRect.X += 1;
                    imageRect.Y += 1;
                }

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

            // draw the text
            if (e.Cell.Text != null && e.Cell.Text.Length != 0)
            {
                if (e.Enabled)
                {
                    if (!ThemeManager.VisualStylesEnabled && this.GetButtonRendererData(e.Cell).ButtonState == PushButtonState.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(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);
                    textWidth = (int)Math.Ceiling(size.Width);
                }
            }

            if (e.Cell.WidthNotSet)
            {
                e.Cell.ContentWidth = imageWidth + textWidth;
            }

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

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

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

                    ControlPaint.DrawFocusRectangle(e.Graphics, focusRect);
                }
            }
        }
		/// <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
			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 (ThemeManager.VisualStylesEnabled)
			{
				chunkRect.Inflate(-1, -1);
			}

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

			if (e.Enabled)
			{
				ThemeManager.DrawProgressBarChunks(e.Graphics, chunkRect);
			}
			else
			{
				using (Bitmap b = new Bitmap(chunkRect.Width, chunkRect.Height))
				{
					using (Graphics g = Graphics.FromImage(b))
					{
						ThemeManager.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 = ColumnAlignment.Center;
				this.LineAlignment = RowAlignment.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 (!ThemeManager.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);
				}
			}
			
			if (e.Focused && e.Enabled)
			{
				ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
			}
		}
		/// <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);
		}
Пример #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);

            // don't bother if the Cell is null or doesn't have an image
            if (e.Cell == null)
            {
                return;
            }

            if (e.Cell.Icon != null)
            {
                // work out the size and location of the image
                Rectangle imageRect = this.CalcImageRect(e.Cell.Image, e.Cell.ImageSizeMode, this.LineAlignment, this.Alignment);
                //imageRect.Y -= 1;
                imageRect.X += 1;
                imageRect.Width = 16;
                imageRect.Height = 16;

                e.Graphics.DrawIconUnstretched(e.Cell.Icon, imageRect);
            }
            //else if (e.Cell.Image!=null)
            //{
            //    // work out the size and location of the image
            //    Rectangle imageRect = this.CalcImageRect(e.Cell.Image, e.Cell.ImageSizeMode, this.LineAlignment, this.Alignment);
            //    //imageRect.Y -= 1;
            //    imageRect.X += 1;
            //    imageRect.Width = 16;
            //    imageRect.Height = 16;

            //    // draw the image
            //    bool scaled = false; // (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 += 18;//imageRect.Width;
                    textRect.Width -= 18; // imageRect.Width;
                    textRect.Y += 1;

                    // check that we will be able to see the text
                    if (textRect.Width > 0)
                    {
                        // draw the text
                        if (e.Enabled)
                        {
                            TextRenderer.DrawText(e.Graphics, e.Cell.Text, this.Font, textRect, this.ForeBrush.Color, TextFormatFlags.Left);
                        }
                        else
                        {
                            TextRenderer.DrawText(e.Graphics, e.Cell.Text, this.Font, textRect, SystemColors.GrayText, TextFormatFlags.Left);
                        }
                    }
                }
            }

            if (e.Focused && e.Enabled)
            {
                Rectangle rect = this.ClientRectangle;
                rect.X += 19;
                rect.Width -= 19;
                ControlPaint.DrawFocusRectangle(e.Graphics, rect);
            }
        }
Пример #11
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);
        }
Пример #12
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 r = this.ClientRectangle;
            CheckBoxStates state = this.GetCheckBoxRendererData(e.Cell).CheckState;
            Rectangle r2 = CalcCheckRectangle();
            ThemeManager.DrawCheck(e.Graphics, r2, state);

            int imageIndex = (int)e.Cell.Data;
            if (imageIndex >= 0)
            {
                imageList.Draw(e.Graphics, r.Left - 35, r.Top, imageIndex);
            }

            string text = e.Cell.Text;

            if (text != null && text.Length != 0)
            {
                // v1.1.1 fix - removed hardcoded alignment
                r.Y += 1;
                if (e.Enabled)
                {
                    TextRenderer.DrawText(e.Graphics, text, this.Font, r, this.ForeBrush.Color, TextFormatFlags.Left);
                }
                else
                {
                    TextRenderer.DrawText(e.Graphics, text, this.Font, r, SystemColors.GrayText, TextFormatFlags.Left);
                }
            }

            if (e.Focused && e.Enabled)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
            }
        }
Пример #13
0
		/// <summary>
		/// Raises the AfterPaintCell event
		/// </summary>
		/// <param name="e">A PaintCellEventArgs that contains the event data</param>
		protected virtual void OnAfterPaintCell(PaintCellEventArgs e)
		{
			if (AfterPaintCell != null)
			{
				AfterPaintCell(this, e);
			}
		}
Пример #14
0
		/// <summary>
		/// Raises the BeforePaintCell event
		/// </summary>
		/// <param name="e">A PaintCellEventArgs that contains the event data</param>
		protected virtual void OnBeforePaintCell(PaintCellEventArgs e)
		{
			if (BeforePaintCell != null)
			{
				BeforePaintCell(this, e);
			}
		}
Пример #15
0
		/// <summary>
		/// Paints the Cell at the specified row and column indexes
		/// </summary>
		/// <param name="e">A PaintEventArgs that contains the event data</param>
		/// <param name="row">The index of the row that contains the cell to be painted</param>
		/// <param name="column">The index of the column that contains the cell to be painted</param>
		/// <param name="cellRect">The bounding Rectangle of the Cell</param>
		protected void OnPaintCell(PaintEventArgs e, int row, int column, Rectangle cellRect)
		{
			if (row == 0 && column == 1)
			{
				column = 1;
			}
			
			// get the renderer for the cells column
			ICellRenderer renderer = this.ColumnModel.Columns[column].Renderer;
			if (renderer == null)
			{
				// get the default renderer for the column
				renderer = this.ColumnModel.GetCellRenderer(this.ColumnModel.Columns[column].GetDefaultRendererName());
			}

			// if the renderer is still null (which it shouldn't)
			// the get out of here
			if (renderer == null)
			{
				return;
			}

			PaintCellEventArgs pcea = new PaintCellEventArgs(e.Graphics, cellRect);
			pcea.Graphics.SetClip(Rectangle.Intersect(e.ClipRectangle, cellRect));

			if (column < this.TableModel.Rows[row].Cells.Count)
			{
				// is the cell selected
				bool selected = false;

				if (this.FullRowSelect)
				{
					selected = this.TableModel.Selections.IsRowSelected(row);
				}
				else
				{
					if (this.SelectionStyle == SelectionStyle.ListView)
					{
						if (this.TableModel.Selections.IsRowSelected(row) && this.ColumnModel.PreviousVisibleColumn(column) == -1)
						{
							selected = true;
						}
					}
					else if (this.SelectionStyle == SelectionStyle.Grid)
					{
						if (this.TableModel.Selections.IsCellSelected(row, column))
						{
							selected = true;
						}
					}
				}

				//
				bool editable = this.TableModel[row, column].Editable && this.TableModel.Rows[row].Editable && this.ColumnModel.Columns[column].Editable;
				bool enabled = this.TableModel[row, column].Enabled && this.TableModel.Rows[row].Enabled && this.ColumnModel.Columns[column].Enabled;

				// draw the cell
				pcea.SetCell(this.TableModel[row, column]);
				pcea.SetRow(row);
				pcea.SetColumn(column);
				pcea.SetTable(this);
				pcea.SetSelected(selected);
				pcea.SetFocused(this.Focused && this.FocusedCell.Row == row && this.FocusedCell.Column == column);
				pcea.SetSorted(column == this.lastSortedColumn);
				pcea.SetEditable(editable);
				pcea.SetEnabled(enabled);
				pcea.SetCellRect(cellRect);
			}
			else
			{
				// there isn't a cell for this column, so send a 
				// null value for the cell and the renderer will 
				// take care of the rest (it should draw an empty cell)

				pcea.SetCell(null);
				pcea.SetRow(row);
				pcea.SetColumn(column);
				pcea.SetTable(this);
				pcea.SetSelected(false);
				pcea.SetFocused(false);
				pcea.SetSorted(false);
				pcea.SetEditable(false);
				pcea.SetEnabled(false);
				pcea.SetCellRect(cellRect);
			}

			// let the user get the first crack at painting the cell
			this.OnBeforePaintCell(pcea);
			
			// only send to the renderer if the user hasn't 
			// set the handled property
			if (!pcea.Handled)
			{
				renderer.OnPaintCell(pcea);
			}

			// let the user have another go
			this.OnAfterPaintCell(pcea);
		}
Пример #16
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);
            }
        }
Пример #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
            if (e.Cell == null)
            {
                return;
            }

            Rectangle r = this.ClientRectangle;
            CheckBoxStates state = this.GetCheckBoxRendererData(e.Cell).CheckState;
            Rectangle r2 = CalcCheckRectangle();
            ThemeManager.DrawCheck(e.Graphics, r2, state);

            if (e.Cell.Icon != null)
            {
                // work out the size and location of the image
                Rectangle imageRect = this.CalcImageRect(e.Cell.Image, e.Cell.ImageSizeMode, this.LineAlignment, this.Alignment);
                //imageRect.Y -= 1;
                imageRect.X -=16;
                imageRect.Width = 16;
                imageRect.Height = 16;

                e.Graphics.DrawIconUnstretched(e.Cell.Icon, imageRect);
            }

            //int imageIndex = (int)e.Cell.Data;
            //if (imageIndex >= 0)
            //{
            //    imageList.Draw(e.Graphics, r.Left - 35, r.Top, imageIndex);
            //}

            string text = e.Cell.Text;

            if (text != null && text.Length != 0)
            {
                // v1.1.1 fix - removed hardcoded alignment
                r.Y += 1;
                if (e.Enabled)
                {
                    if (e.Cell.Checked)
                    {
                        TextRenderer.DrawText(e.Graphics, text, this.Font, r, Color.Blue, TextFormatFlags.Left);
                    }
                    else
                    {
                        TextRenderer.DrawText(e.Graphics, text, this.Font, r, this.ForeBrush.Color, TextFormatFlags.Left);
                    }
                }
                else
                {
                    TextRenderer.DrawText(e.Graphics, text, this.Font, r, SystemColors.GrayText, TextFormatFlags.Left);
                }
            }

            if (e.Focused && e.Enabled)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
            }
        }
Пример #18
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;

				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);
		}
Пример #19
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;
            }

            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)
            {
                textRect.Y += 1;
                textRect.X += 2;
                if (e.Enabled)
                {
                    TextRenderer.DrawText(e.Graphics, e.Cell.Text, this.Font, textRect, this.ForeBrush.Color, TextFormatFlags.Left);
                }
                else
                {
                    TextRenderer.DrawText(e.Graphics, e.Cell.Text, this.Font, textRect, SystemColors.GrayText, TextFormatFlags.Left);
                }
            }

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

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

                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(PaintCellEventArgs 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);
				}
			}
		}
Пример #21
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;
            }

            // image
            Rectangle imageRect = this.ClientRectangle;
            imageRect.X -= 16;
            if (e.Cell.Checked)
                e.Graphics.DrawImageUnscaled(Properties.Resources.Accept, imageRect);
            else
                e.Graphics.DrawImageUnscaled(Properties.Resources.Error, imageRect);

            if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell))
            {
                ComboBoxStates state = this.GetDropDownRendererData(e.Cell).ButtonState;

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

                Rectangle r = this.CalcDropDownButtonBounds();
                ThemeManager.DrawButton(e.Graphics, r, state);
                Font font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                e.Graphics.DrawString("...", font, new SolidBrush(Color.Black), r.X + 1, r.Y - 1);
            }
        }
Пример #22
0
		/// <summary>
		/// Raises the Paint event
		/// </summary>
		/// <param name="e">A PaintCellEventArgs that contains the event data</param>
		protected virtual void OnPaint(PaintCellEventArgs e)
		{
			
		}
Пример #23
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
                Rectangle rect = this.ClientRectangle;
                rect.Y += 1;

                if (e.Enabled)
                {
                    TextRenderer.DrawText(e.Graphics, text, this.Font, rect, this.ForeBrush.Color, TextFormatFlags.Left);
                }
                else
                {
                    TextRenderer.DrawText(e.Graphics, text, this.Font, rect, SystemColors.GrayText, TextFormatFlags.Left);
                }
            }

            if (e.Focused && e.Enabled)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, this.ClientRectangle);
            }
        }
Пример #24
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(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);
		}
		/// <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);
				}
			}
		}
		/// <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;

				// 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);
		}
Пример #27
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);
        }
		/// <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;
			}

			if (this.ShowUpDownButtons)
			{
				UpDownStates upButtonState = this.GetNumberRendererData(e.Cell).UpButtonState;
				UpDownStates downButtonState = this.GetNumberRendererData(e.Cell).DownButtonState;
				
				if (!e.Enabled)
				{
					upButtonState = UpDownStates.Disabled;
					downButtonState = UpDownStates.Disabled;
				}

				ThemeManager.DrawUpDownButtons(e.Graphics, this.GetUpButtonBounds(), upButtonState, this.GetDownButtonBounds(), downButtonState);
			}
		}
Пример #29
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);
            PushButtonState state = rendererData.ButtonState;

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

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

            // draw the button
            ThemeManager.DrawButton(e.Graphics, this.CalcButtonBounds(), state, flatStyle);
        }
		/// <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);
			}
		}