예제 #1
0
        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            if (paintParts.HasFlag(DataGridViewPaintParts.Background))
            {
                using (SolidBrush cellBackground =
                           new SolidBrush(cellStyle.BackColor))
                {
                    graphics.FillRectangle(cellBackground, cellBounds);
                }
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.Border))
            {
                PaintBorder(graphics, clipBounds, cellBounds, cellStyle,
                            advancedBorderStyle);
            }

            if (value != null)
            {
                CheckBoxRenderer.DrawCheckBox(
                    graphics,
                    new Point(cellBounds.X + 4, cellBounds.Y + 4),
                    new Rectangle(cellBounds.X + 24, cellBounds.Y + 4, cellBounds.Width - 24, cellBounds.Height - 4),
                    formattedValue.ToString(),
                    OwningColumn.InheritedStyle.Font,
                    TextFormatFlags.Left,
                    false,
                    CheckBoxState.CheckedNormal);
            }
        }
예제 #2
0
        /// <summary>
        /// Paints common elements behind the cell content.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="cellBounds"></param>
        /// <param name="cellState"></param>
        /// <param name="cellStyle"></param>
        /// <param name="paintParts"></param>
        protected void BeforePaintContent(Graphics graphics, Rectangle cellBounds, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts)
        {
            if (paintParts.HasFlag(DataGridViewPaintParts.Background))
            {
                using (Brush brush = new SolidBrush(cellStyle.BackColor)) {
                    graphics.FillRectangle(brush, cellBounds);
                }
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.SelectionBackground) && cellState.HasFlag(DataGridViewElementStates.Selected))
            {
                using (Brush brush = new SolidBrush(cellStyle.SelectionBackColor)) {
                    graphics.FillRectangle(brush, cellBounds);
                }
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.ContentBackground))
            {
                ComboBoxState state       = ComboBoxState.Normal;
                ButtonState   legacyState = ButtonState.Normal;

                if ((DataGridView.Site == null) || !DataGridView.Site.DesignMode)
                {
                    if (cellState.HasFlag(DataGridViewElementStates.ReadOnly))
                    {
                        state       = ComboBoxState.Disabled;
                        legacyState = ButtonState.Inactive;
                    }
                    else if (cellBounds.Contains(DataGridView.PointToClient(DataGridView.MousePosition)))
                    {
                        if (DataGridView.MouseButtons.HasFlag(MouseButtons.Left))
                        {
                            state       = ComboBoxState.Pressed;
                            legacyState = ButtonState.Pushed;
                        }
                        else
                        {
                            state = ComboBoxState.Hot;
                        }
                    }
                }

                Rectangle comboBounds = cellBounds;
                comboBounds.Width--;

                if (((DropDownColumnBase)OwningColumn).BufferedPaintingSupported)
                {
                    GroupedComboBox.DrawComboBox(graphics, comboBounds, state);
                }
                else
                {
                    DropDownControlBase.DrawLegacyComboBox(graphics, comboBounds, DropDownControlBase.GetComboButtonBounds(comboBounds), cellStyle.BackColor, legacyState);
                }
            }
        }
예제 #3
0
        protected override void Paint(
            Graphics graphics, Rectangle clipBounds, Rectangle cellBounds,
            int rowIndex, DataGridViewElementStates cellState,
            object value, object formattedValue, string errorText,
            DataGridViewCellStyle cellStyle,
            DataGridViewAdvancedBorderStyle advancedBorderStyle,
            DataGridViewPaintParts paintParts)
        {
            if (this.FilterEnabled && this.SortGlyphDirection != SortOrder.None)
            {
                this.SortGlyphDirection = SortOrder.None;
            }

            base.Paint(graphics, clipBounds, cellBounds, rowIndex,
                       cellState, value, formattedValue,
                       errorText, cellStyle, advancedBorderStyle, paintParts);

            if (this.FilterEnabled && paintParts.HasFlag(DataGridViewPaintParts.ContentBackground))
            {
                this.filterButtonOffsetBounds = GetFilterBounds(true);
                this.filterButtonImageBounds  = GetFilterBounds(false);
                Rectangle buttonBounds = this.filterButtonOffsetBounds;
                if (buttonBounds != null && clipBounds.IntersectsWith(buttonBounds))
                {
                    ControlPaint.DrawBorder(graphics, buttonBounds, Color.Gray, ButtonBorderStyle.Solid);
                    buttonBounds.Inflate(-1, -1);
                    using (Brush b = new SolidBrush(this.filterButtonOver ? Color.LightGray : Color.White))
                        graphics.FillRectangle(b, buttonBounds);
                    graphics.DrawImage(this.filterImage, buttonBounds);
                }
            }
        }
예제 #4
0
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            //base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            BeforePaintContent(graphics, cellBounds, cellState, cellStyle, paintParts);

            if (paintParts.HasFlag(DataGridViewPaintParts.ContentForeground))
            {
                ComboTreeBoxColumn column        = (ComboTreeBoxColumn)OwningColumn;
                Rectangle          contentBounds = cellBounds;
                contentBounds.Width -= 17;
                TextFormatFlags flags     = PipesBox.TEXT_FORMAT_FLAGS | TextFormatFlags.PreserveGraphicsClipping;
                Rectangle       txtBounds = new Rectangle(contentBounds.Left + 1, contentBounds.Top, contentBounds.Right - 4, contentBounds.Height);

                var sum   = 0m;
                var nodes = formattedValue as ComboTreeNodeCollection;
                if (nodes != null)
                {
                    foreach (var node in nodes)
                    {
                        if (node.Checked)
                        {
                            sum += ((Pipe)node.Tag).Volume;
                        }
                    }
                }

                TextRenderer.DrawText(graphics, String.Format("{0} m³", sum), cellStyle.Font, txtBounds, cellStyle.ForeColor, flags);
            }

            AfterPaintContent(graphics, clipBounds, cellBounds, rowIndex, cellStyle, advancedBorderStyle, paintParts);
        }
예제 #5
0
        /// <summary>
        /// Paints common elements in front of the cell content.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="cellBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="cellStyle"></param>
        /// <param name="advancedBorderStyle"></param>
        /// <param name="paintParts"></param>
        protected void AfterPaintContent(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            if (paintParts.HasFlag(DataGridViewPaintParts.ErrorIcon)) {
                base.PaintErrorIcon(graphics, clipBounds, cellBounds, GetErrorText(rowIndex));
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.Border)) {
                base.PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.Focus) && (DataGridView.CurrentCell == this)) {
                Rectangle focusBounds = cellBounds;
                focusBounds.Width--;
                focusBounds.Height--;
                ControlPaint.DrawFocusRectangle(graphics, focusBounds);
            }
        }
예제 #6
0
        /// <summary>
        /// Paints common elements behind the cell content.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="cellBounds"></param>
        /// <param name="cellState"></param>
        /// <param name="cellStyle"></param>
        /// <param name="paintParts"></param>
        protected void BeforePaintContent(Graphics graphics, Rectangle cellBounds, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle, DataGridViewPaintParts paintParts)
        {
            if (paintParts.HasFlag(DataGridViewPaintParts.Background)) {
                using (Brush brush = new SolidBrush(cellStyle.BackColor)) {
                    graphics.FillRectangle(brush, cellBounds);
                }
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.SelectionBackground) && cellState.HasFlag(DataGridViewElementStates.Selected)) {
                using (Brush brush = new SolidBrush(cellStyle.SelectionBackColor)) {
                    graphics.FillRectangle(brush, cellBounds);
                }
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.ContentBackground)) {
                ComboBoxState state = ComboBoxState.Normal;
                ButtonState legacyState = ButtonState.Normal;

                if ((DataGridView.Site == null) || !DataGridView.Site.DesignMode) {
                    if (cellState.HasFlag(DataGridViewElementStates.ReadOnly)) {
                        state = ComboBoxState.Disabled;
                        legacyState = ButtonState.Inactive;
                    }
                    else if (cellBounds.Contains(DataGridView.PointToClient(DataGridView.MousePosition))) {
                        if (DataGridView.MouseButtons.HasFlag(MouseButtons.Left)) {
                            state = ComboBoxState.Pressed;
                            legacyState = ButtonState.Pushed;
                        }
                        else {
                            state = ComboBoxState.Hot;
                        }
                    }
                }

                Rectangle comboBounds = cellBounds;
                comboBounds.Width--;

                if (((DropDownColumnBase)OwningColumn).BufferedPaintingSupported) {
                    GroupedComboBox.DrawComboBox(graphics, comboBounds, state);
                }
                else {
                    DropDownControlBase.DrawLegacyComboBox(graphics, comboBounds, DropDownControlBase.GetComboButtonBounds(comboBounds), cellStyle.BackColor, legacyState);
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Paints common elements in front of the cell content.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="cellBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="cellStyle"></param>
        /// <param name="advancedBorderStyle"></param>
        /// <param name="paintParts"></param>
        protected void AfterPaintContent(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            if (paintParts.HasFlag(DataGridViewPaintParts.ErrorIcon))
            {
                base.PaintErrorIcon(graphics, clipBounds, cellBounds, GetErrorText(rowIndex));
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.Border))
            {
                base.PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
            }

            if (paintParts.HasFlag(DataGridViewPaintParts.Focus) && (DataGridView.CurrentCell == this))
            {
                Rectangle focusBounds = cellBounds;
                focusBounds.Width--;
                focusBounds.Height--;
                ControlPaint.DrawFocusRectangle(graphics, focusBounds);
            }
        }
예제 #8
0
        /// <summary>
        /// Paints the cell.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="cellBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="cellState"></param>
        /// <param name="value"></param>
        /// <param name="formattedValue"></param>
        /// <param name="errorText"></param>
        /// <param name="cellStyle"></param>
        /// <param name="advancedBorderStyle"></param>
        /// <param name="paintParts"></param>
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            BeforePaintContent(graphics, cellBounds, cellState, cellStyle, paintParts);

            if (paintParts.HasFlag(DataGridViewPaintParts.ContentForeground))
            {
                Rectangle contentBounds = cellBounds;
                contentBounds.Width -= 17;
                TextFormatFlags flags = TextFormatFlags.NoPrefix | TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.PreserveGraphicsClipping;
                TextRenderer.DrawText(graphics, Convert.ToString(formattedValue), cellStyle.Font, contentBounds, cellStyle.ForeColor, flags);
            }

            AfterPaintContent(graphics, clipBounds, cellBounds, rowIndex, cellStyle, advancedBorderStyle, paintParts);
        }
        /// <summary>
        /// Paints the cell.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="cellBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="cellState"></param>
        /// <param name="value"></param>
        /// <param name="formattedValue"></param>
        /// <param name="errorText"></param>
        /// <param name="cellStyle"></param>
        /// <param name="advancedBorderStyle"></param>
        /// <param name="paintParts"></param>
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            BeforePaintContent(graphics, cellBounds, cellState, cellStyle, paintParts);

            if (paintParts.HasFlag(DataGridViewPaintParts.ContentForeground))
            {
                ComboTreeBoxColumn column = (ComboTreeBoxColumn)OwningColumn;
                ComboTreeNode      node   = Nodes.ParsePath(Convert.ToString(formattedValue), column.PathSeparator, column.UseNodeNamesForPath);
                string             displayValue;

                if (column.ShowPath)
                {
                    displayValue = Convert.ToString(formattedValue);
                }
                else
                {
                    displayValue = (node != null) ? node.Text : String.Empty;
                }

                Image img = ComboTreeBox.GetNodeImage(node, column.Images, column.ImageIndex, column.ImageKey, column.ExpandedImageIndex, column.ExpandedImageKey);

                Rectangle contentBounds = cellBounds;
                contentBounds.Width -= 17;
                TextFormatFlags flags = ComboTreeBox.TEXT_FORMAT_FLAGS | TextFormatFlags.PreserveGraphicsClipping;

                Rectangle imgBounds = (img == null)
                                        ? new Rectangle(Point.Add(contentBounds.Location, new Size(1, 0)), Size.Empty)
                                        : new Rectangle(contentBounds.Left + 4, contentBounds.Top + (contentBounds.Height / 2 - img.Height / 2), img.Width, img.Height);

                Rectangle txtBounds = new Rectangle(imgBounds.Right, contentBounds.Top, contentBounds.Right - imgBounds.Right - 3, contentBounds.Height);

                if (img != null)
                {
                    graphics.DrawImage(img, imgBounds);
                }

                TextRenderer.DrawText(graphics, displayValue, cellStyle.Font, txtBounds, cellStyle.ForeColor, flags);
            }

            AfterPaintContent(graphics, clipBounds, cellBounds, rowIndex, cellStyle, advancedBorderStyle, paintParts);
        }
예제 #10
0
        /// <summary>
        /// Pain method
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="cellBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="cellState"></param>
        /// <param name="value"></param>
        /// <param name="formattedValue"></param>
        /// <param name="errorText"></param>
        /// <param name="cellStyle"></param>
        /// <param name="advancedBorderStyle"></param>
        /// <param name="paintParts"></param>
        protected override void Paint(
            Graphics graphics,
            Rectangle clipBounds,
            Rectangle cellBounds,
            int rowIndex,
            DataGridViewElementStates cellState,
            object value,
            object formattedValue,
            string errorText,
            DataGridViewCellStyle cellStyle,
            DataGridViewAdvancedBorderStyle advancedBorderStyle,
            DataGridViewPaintParts paintParts)
        {
            if (SortGlyphDirection != SortOrder.None)
            {
                SortGlyphDirection = SortOrder.None;
            }

            base.Paint(graphics, clipBounds, cellBounds, rowIndex,
                       cellState, value, formattedValue,
                       errorText, cellStyle, advancedBorderStyle, paintParts);

            // Don't display a dropdown for Image columns
            if (this.OwningColumn.ValueType == typeof(System.Drawing.Bitmap))
            {
                return;
            }

            if (FilterAndSortEnabled && paintParts.HasFlag(DataGridViewPaintParts.ContentBackground))
            {
                _filterButtonOffsetBounds = GetFilterBounds(true);
                _filterButtonImageBounds  = GetFilterBounds(false);
                Rectangle buttonBounds = _filterButtonOffsetBounds;
                if (buttonBounds != null && clipBounds.IntersectsWith(buttonBounds))
                {
                    ControlPaint.DrawBorder(graphics, buttonBounds, Color.Gray, ButtonBorderStyle.Solid);
                    buttonBounds.Inflate(-1, -1);
                    using (Brush b = new SolidBrush(_filterButtonOver ? Color.WhiteSmoke : Color.White))
                        graphics.FillRectangle(b, buttonBounds);
                    graphics.DrawImage(_filterImage, buttonBounds);
                }
            }
        }
예제 #11
0
        protected override void Paint(
            Graphics graphics,
            Rectangle clipBounds,
            Rectangle cellBounds,
            int rowIndex,
            DataGridViewElementStates cellState,
            object value,
            object formattedValue,
            string errorText,
            DataGridViewCellStyle cellStyle,
            DataGridViewAdvancedBorderStyle advancedBorderStyle,
            DataGridViewPaintParts paintParts)
        {
            base.Paint(
                graphics,
                clipBounds,
                cellBounds,
                rowIndex,
                cellState,
                value,
                string.Empty,
                errorText,
                cellStyle,
                advancedBorderStyle,
                paintParts);

            if (paintParts.HasFlag(DataGridViewPaintParts.ContentBackground) && value is Color)
            {
                using (var cellBackground = new SolidBrush((Color)value))
                    using (var cellBackgroundBorder = new Pen(Color.DarkSlateGray, 1))
                    {
                        Rectangle rectangleWithMargin = CreateRectangleWithMargin(cellBounds, 3);
                        graphics.FillRectangle(cellBackground, rectangleWithMargin);
                        graphics.DrawRectangle(cellBackgroundBorder, rectangleWithMargin);
                    }
            }
        }
예제 #12
0
        /// <summary>
        /// Paints the cell.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="cellBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="cellState"></param>
        /// <param name="value"></param>
        /// <param name="formattedValue"></param>
        /// <param name="errorText"></param>
        /// <param name="cellStyle"></param>
        /// <param name="advancedBorderStyle"></param>
        /// <param name="paintParts"></param>
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            BeforePaintContent(graphics, cellBounds, cellState, cellStyle, paintParts);

            if (paintParts.HasFlag(DataGridViewPaintParts.ContentForeground)) {
                Rectangle contentBounds = cellBounds;
                contentBounds.Width -= 17;
                TextFormatFlags flags = TextFormatFlags.NoPrefix | TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.PreserveGraphicsClipping;
                TextRenderer.DrawText(graphics, Convert.ToString(formattedValue), cellStyle.Font, contentBounds, cellStyle.ForeColor, flags);
            }

            AfterPaintContent(graphics, clipBounds, cellBounds, rowIndex, cellStyle, advancedBorderStyle, paintParts);
        }
예제 #13
0
        protected override void Paint(
            Graphics graphics, Rectangle clipBounds, Rectangle cellBounds,
            int rowIndex, DataGridViewElementStates cellState,
            object value, object formattedValue, string errorText,
            DataGridViewCellStyle cellStyle,
            DataGridViewAdvancedBorderStyle advancedBorderStyle,
            DataGridViewPaintParts paintParts)
        {
            if (this.CellBehavior == ADGVColumnHeaderCellBehavior.SortingStandartGlyph)
            {
                switch (this.ActiveSortType)
                {
                case ADGVSortType.ASC:
                    this.SortGlyphDirection = SortOrder.Ascending;
                    break;

                case ADGVSortType.DESC:
                    this.SortGlyphDirection = SortOrder.Descending;
                    break;

                case ADGVSortType.None:
                    this.SortGlyphDirection = SortOrder.None;
                    break;
                }
            }
            else
            {
                this.SortGlyphDirection = SortOrder.None;
            }

            base.Paint(graphics, clipBounds, cellBounds, rowIndex,
                       cellState, value, formattedValue,
                       errorText, cellStyle, advancedBorderStyle, paintParts);

            if (this.CellBehavior != ADGVColumnHeaderCellBehavior.SortingStandartGlyph && this.CellBehavior != ADGVColumnHeaderCellBehavior.DisabledHidden && paintParts.HasFlag(DataGridViewPaintParts.ContentBackground))
            {
                Image filterImage = Properties.Resources.AddFilter;

                if (this.cellBehavior == ADGVColumnHeaderCellBehavior.Sorting || this.ActiveFilterType == ADGVFilterType.None)
                {
                    switch (this.ActiveSortType)
                    {
                    case ADGVSortType.ASC:
                        filterImage = Properties.Resources.ASC;
                        break;

                    case ADGVSortType.DESC:
                        filterImage = Properties.Resources.DESC;
                        break;

                    case ADGVSortType.None:
                        filterImage = Properties.Resources.AddFilter;
                        break;
                    }
                }
                else
                {
                    switch (this.ActiveSortType)
                    {
                    case ADGVSortType.ASC:
                        filterImage = Properties.Resources.FilterASC;
                        break;

                    case ADGVSortType.DESC:
                        filterImage = Properties.Resources.FilterDESC;
                        break;

                    case ADGVSortType.None:
                        filterImage = Properties.Resources.Filter;
                        break;
                    }
                }

                this.filterButtonOffsetBounds = this.GetFilterButtonBounds(true);
                this.filterButtonImageBounds  = this.GetFilterButtonBounds(false);
                Rectangle buttonBounds = this.filterButtonOffsetBounds;
                if (buttonBounds != null && clipBounds.IntersectsWith(buttonBounds))
                {
                    ControlPaint.DrawBorder(graphics, buttonBounds, Color.Gray, ButtonBorderStyle.Solid);
                    buttonBounds.Inflate(-1, -1);
                    using (Brush b = new SolidBrush((this.CellBehavior != ADGVColumnHeaderCellBehavior.Disabled && this.filterButtonOver) ? Color.LightGray : Color.White))
                        graphics.FillRectangle(b, buttonBounds);

                    graphics.DrawImage(filterImage, buttonBounds);
                }
            }
        }
예제 #14
0
        /// <summary>
        /// Paints the cell.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="clipBounds"></param>
        /// <param name="cellBounds"></param>
        /// <param name="rowIndex"></param>
        /// <param name="cellState"></param>
        /// <param name="value"></param>
        /// <param name="formattedValue"></param>
        /// <param name="errorText"></param>
        /// <param name="cellStyle"></param>
        /// <param name="advancedBorderStyle"></param>
        /// <param name="paintParts"></param>
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            BeforePaintContent(graphics, cellBounds, cellState, cellStyle, paintParts);

            if (paintParts.HasFlag(DataGridViewPaintParts.ContentForeground)) {
                ComboTreeBoxColumn column = (ComboTreeBoxColumn)OwningColumn;
                ComboTreeNode node = Nodes.ParsePath(Convert.ToString(formattedValue), column.PathSeparator, column.UseNodeNamesForPath);
                string displayValue;

                if (column.ShowPath)
                    displayValue = Convert.ToString(formattedValue);
                else
                    displayValue = (node != null) ? node.Text : String.Empty;

                Image img = ComboTreeBox.GetNodeImage(node, column.Images, column.ImageIndex, column.ImageKey, column.ExpandedImageIndex, column.ExpandedImageKey);

                Rectangle contentBounds = cellBounds;
                contentBounds.Width -= 17;
                TextFormatFlags flags = ComboTreeBox.TEXT_FORMAT_FLAGS | TextFormatFlags.PreserveGraphicsClipping;

                Rectangle imgBounds = (img == null)
                    ? new Rectangle(Point.Add(contentBounds.Location, new Size(1,0)), Size.Empty)
                    : new Rectangle(contentBounds.Left + 4, contentBounds.Top + (contentBounds.Height / 2 - img.Height / 2), img.Width, img.Height);

                Rectangle txtBounds = new Rectangle(imgBounds.Right, contentBounds.Top, contentBounds.Right - imgBounds.Right - 3, contentBounds.Height);

                if (img != null) graphics.DrawImage(img, imgBounds);

                TextRenderer.DrawText(graphics, displayValue, cellStyle.Font, txtBounds, cellStyle.ForeColor, flags);
            }

            AfterPaintContent(graphics, clipBounds, cellBounds, rowIndex, cellStyle, advancedBorderStyle, paintParts);
        }