Exemple #1
0
        private Rectangle PaintPrivate(Graphics graphics,
                                       Rectangle clipBounds,
                                       Rectangle cellBounds,
                                       int rowIndex,
                                       DataGridViewElementStates dataGridViewElementState,
                                       object formattedValue,
                                       string errorText,
                                       DataGridViewCellStyle cellStyle,
                                       DataGridViewAdvancedBorderStyle advancedBorderStyle,
                                       DataGridViewPaintParts paintParts,
                                       bool computeContentBounds,
                                       bool computeErrorIconBounds,
                                       bool paint)
        {
            // Parameter checking.
            // One bit and one bit only should be turned on
            Debug.Assert(paint || computeContentBounds || computeErrorIconBounds);
            Debug.Assert(!paint || !computeContentBounds || !computeErrorIconBounds);
            Debug.Assert(!computeContentBounds || !computeErrorIconBounds || !paint);
            Debug.Assert(!computeErrorIconBounds || !paint || !computeContentBounds);
            Debug.Assert(cellStyle != null);

            // If computeContentBounds == TRUE then resultBounds will be the contentBounds.
            // If computeErrorIconBounds == TRUE then resultBounds will be the error icon bounds.
            // Else resultBounds will be Rectangle.Empty;
            Rectangle resultBounds = Rectangle.Empty;

            if (paint && DataGridViewCell.PaintBorder(paintParts))
            {
                PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
            }

            Rectangle valBounds    = cellBounds;
            Rectangle borderWidths = BorderWidths(advancedBorderStyle);

            valBounds.Offset(borderWidths.X, borderWidths.Y);
            valBounds.Width  -= borderWidths.Right;
            valBounds.Height -= borderWidths.Bottom;
            Rectangle backgroundBounds = valBounds;

            bool cellSelected = (dataGridViewElementState & DataGridViewElementStates.Selected) != 0;

            if (DataGridView.ApplyVisualStylesToHeaderCells)
            {
                if (cellStyle.Padding != Padding.Empty)
                {
                    if (DataGridView.RightToLeftInternal)
                    {
                        valBounds.Offset(cellStyle.Padding.Right, cellStyle.Padding.Top);
                    }
                    else
                    {
                        valBounds.Offset(cellStyle.Padding.Left, cellStyle.Padding.Top);
                    }
                    valBounds.Width  -= cellStyle.Padding.Horizontal;
                    valBounds.Height -= cellStyle.Padding.Vertical;
                }

                if (backgroundBounds.Width > 0 && backgroundBounds.Height > 0)
                {
                    if (paint && DataGridViewCell.PaintBackground(paintParts))
                    {
                        // Theming
                        int state = (int)HeaderItemState.Normal;
                        if (DataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect ||
                            DataGridView.SelectionMode == DataGridViewSelectionMode.RowHeaderSelect)
                        {
                            if (ButtonState != ButtonState.Normal)
                            {
                                Debug.Assert(ButtonState == ButtonState.Pushed);
                                state = (int)HeaderItemState.Pressed;
                            }
                            else if (DataGridView.MouseEnteredCellAddress.Y == rowIndex &&
                                     DataGridView.MouseEnteredCellAddress.X == -1)
                            {
                                state = (int)HeaderItemState.Hot;
                            }
                            else if (cellSelected)
                            {
                                state = (int)HeaderItemState.Pressed;
                            }
                        }
                        // Flip the column header background
                        using (Bitmap bmFlipXPThemes = new Bitmap(backgroundBounds.Height, backgroundBounds.Width))
                        {
                            using (Graphics gFlip = Graphics.FromImage(bmFlipXPThemes))
                            {
                                DataGridViewRowHeaderCellRenderer.DrawHeader(gFlip, new Rectangle(0, 0, backgroundBounds.Height, backgroundBounds.Width), state);
                                bmFlipXPThemes.RotateFlip(DataGridView.RightToLeftInternal ? RotateFlipType.Rotate90FlipNone : RotateFlipType.Rotate270FlipY);

                                graphics.DrawImage(bmFlipXPThemes,
                                                   backgroundBounds,
                                                   new Rectangle(0, 0, backgroundBounds.Width, backgroundBounds.Height),
                                                   GraphicsUnit.Pixel);
                            }
                        }
                    }
                    // update the val bounds
                    Rectangle rectThemeMargins = GetThemeMargins(graphics);
                    if (DataGridView.RightToLeftInternal)
                    {
                        valBounds.X += rectThemeMargins.Height;
                    }
                    else
                    {
                        valBounds.X += rectThemeMargins.Y;
                    }
                    valBounds.Width  -= rectThemeMargins.Y + rectThemeMargins.Height;
                    valBounds.Height -= rectThemeMargins.X + rectThemeMargins.Width;
                    valBounds.Y      += rectThemeMargins.X;
                }
            }
            else
            {
                // No visual style applied
                if (valBounds.Width > 0 && valBounds.Height > 0)
                {
                    Color brushColor = PaintSelectionBackground(paintParts) && cellSelected
                        ? cellStyle.SelectionBackColor
                        : cellStyle.BackColor;

                    if (paint && PaintBackground(paintParts) && !brushColor.HasTransparency())
                    {
                        using var brush = brushColor.GetCachedSolidBrushScope();
                        graphics.FillRectangle(brush, valBounds);
                    }
                }

                if (cellStyle.Padding != Padding.Empty)
                {
                    if (DataGridView.RightToLeftInternal)
                    {
                        valBounds.Offset(cellStyle.Padding.Right, cellStyle.Padding.Top);
                    }
                    else
                    {
                        valBounds.Offset(cellStyle.Padding.Left, cellStyle.Padding.Top);
                    }
                    valBounds.Width  -= cellStyle.Padding.Horizontal;
                    valBounds.Height -= cellStyle.Padding.Vertical;
                }
            }

            Bitmap bmp = null;

            if (valBounds.Width > 0 && valBounds.Height > 0)
            {
                Rectangle errorBounds     = valBounds;
                string    formattedString = formattedValue as string;
                if (!string.IsNullOrEmpty(formattedString))
                {
                    // There is text to display
                    if (valBounds.Width >= s_iconsWidth +
                        2 * RowHeaderIconMarginWidth &&
                        valBounds.Height >= s_iconsHeight +
                        2 * RowHeaderIconMarginHeight)
                    {
                        if (paint && DataGridViewCell.PaintContentBackground(paintParts))
                        {
                            // There is enough room for the potential glyph which is the first priority
                            if (DataGridView.CurrentCellAddress.Y == rowIndex)
                            {
                                if (DataGridView.VirtualMode)
                                {
                                    if (DataGridView.IsCurrentRowDirty && DataGridView.ShowEditingIcon)
                                    {
                                        bmp = GetPencilBitmap(DataGridView.RightToLeftInternal);
                                    }
                                    else if (DataGridView.NewRowIndex == rowIndex)
                                    {
                                        bmp = GetArrowStarBitmap(DataGridView.RightToLeftInternal);
                                    }
                                    else
                                    {
                                        bmp = GetArrowBitmap(DataGridView.RightToLeftInternal);
                                    }
                                }
                                else
                                {
                                    if (DataGridView.IsCurrentCellDirty && DataGridView.ShowEditingIcon)
                                    {
                                        bmp = GetPencilBitmap(DataGridView.RightToLeftInternal);
                                    }
                                    else if (DataGridView.NewRowIndex == rowIndex)
                                    {
                                        bmp = GetArrowStarBitmap(DataGridView.RightToLeftInternal);
                                    }
                                    else
                                    {
                                        bmp = GetArrowBitmap(DataGridView.RightToLeftInternal);
                                    }
                                }
                            }
                            else if (DataGridView.NewRowIndex == rowIndex)
                            {
                                bmp = DataGridViewRowHeaderCell.StarBitmap;
                            }
                            if (bmp != null)
                            {
                                Color iconColor;
                                if (DataGridView.ApplyVisualStylesToHeaderCells)
                                {
                                    iconColor = DataGridViewRowHeaderCellRenderer.VisualStyleRenderer.GetColor(ColorProperty.TextColor);
                                }
                                else
                                {
                                    iconColor = cellSelected ? cellStyle.SelectionForeColor : cellStyle.ForeColor;
                                }
                                lock (bmp)
                                {
                                    PaintIcon(graphics, bmp, valBounds, iconColor);
                                }
                            }
                        }
                        if (!DataGridView.RightToLeftInternal)
                        {
                            valBounds.X += s_iconsWidth + 2 * RowHeaderIconMarginWidth;
                        }
                        valBounds.Width -= s_iconsWidth + 2 * RowHeaderIconMarginWidth;
                        Debug.Assert(valBounds.Width >= 0);
                        Debug.Assert(valBounds.Height >= 0);
                    }
                    // Second priority is text
                    // Font independent margins
                    valBounds.Offset(HorizontalTextMarginLeft + ContentMarginWidth, VerticalTextMargin);
                    valBounds.Width  -= HorizontalTextMarginLeft + 2 * ContentMarginWidth + HorizontalTextMarginRight;
                    valBounds.Height -= 2 * VerticalTextMargin;
                    if (valBounds.Width > 0 && valBounds.Height > 0)
                    {
                        TextFormatFlags flags = DataGridViewUtilities.ComputeTextFormatFlagsForCellStyleAlignment(DataGridView.RightToLeftInternal, cellStyle.Alignment, cellStyle.WrapMode);
                        if (DataGridView.ShowRowErrors && valBounds.Width > s_iconsWidth + 2 * RowHeaderIconMarginWidth)
                        {
                            // Check if the text fits if we remove the room required for the row error icon
                            Size maxBounds = new Size(valBounds.Width - s_iconsWidth - 2 * RowHeaderIconMarginWidth, valBounds.Height);
                            if (DataGridViewCell.TextFitsInBounds(graphics,
                                                                  formattedString,
                                                                  cellStyle.Font,
                                                                  maxBounds,
                                                                  flags))
                            {
                                // There is enough room for both the text and the row error icon, so use it all.
                                if (DataGridView.RightToLeftInternal)
                                {
                                    valBounds.X += s_iconsWidth + 2 * RowHeaderIconMarginWidth;
                                }
                                valBounds.Width -= s_iconsWidth + 2 * RowHeaderIconMarginWidth;
                            }
                        }

                        if (DataGridViewCell.PaintContentForeground(paintParts))
                        {
                            if (paint)
                            {
                                Color textColor;
                                if (DataGridView.ApplyVisualStylesToHeaderCells)
                                {
                                    textColor = DataGridViewRowHeaderCellRenderer.VisualStyleRenderer.GetColor(ColorProperty.TextColor);
                                }
                                else
                                {
                                    textColor = cellSelected ? cellStyle.SelectionForeColor : cellStyle.ForeColor;
                                }
                                if ((flags & TextFormatFlags.SingleLine) != 0)
                                {
                                    flags |= TextFormatFlags.EndEllipsis;
                                }
                                TextRenderer.DrawText(graphics,
                                                      formattedString,
                                                      cellStyle.Font,
                                                      valBounds,
                                                      textColor,
                                                      flags);
                            }
                            else if (computeContentBounds)
                            {
                                resultBounds = DataGridViewUtilities.GetTextBounds(valBounds, formattedString, flags, cellStyle);
                            }
                        }
                    }
                    // Third priority is the row error icon, which may be painted on top of text
                    if (errorBounds.Width >= 3 * RowHeaderIconMarginWidth +
                        2 * s_iconsWidth)
                    {
                        // There is enough horizontal room for the error icon and the glyph
                        if (paint && DataGridView.ShowRowErrors && DataGridViewCell.PaintErrorIcon(paintParts))
                        {
                            PaintErrorIcon(graphics, clipBounds, errorBounds, errorText);
                        }
                        else if (computeErrorIconBounds)
                        {
                            if (!string.IsNullOrEmpty(errorText))
                            {
                                resultBounds = ComputeErrorIconBounds(errorBounds);
                            }
                        }
                    }
                }
                else
                {
                    // There is no text to display
                    if (valBounds.Width >= s_iconsWidth + 2 * RowHeaderIconMarginWidth &&
                        valBounds.Height >= s_iconsHeight + 2 * RowHeaderIconMarginHeight)
                    {
                        if (paint && DataGridViewCell.PaintContentBackground(paintParts))
                        {
                            // There is enough room for the potential icon
                            if (DataGridView.CurrentCellAddress.Y == rowIndex)
                            {
                                if (DataGridView.VirtualMode)
                                {
                                    if (DataGridView.IsCurrentRowDirty && DataGridView.ShowEditingIcon)
                                    {
                                        bmp = GetPencilBitmap(DataGridView.RightToLeftInternal);
                                    }
                                    else if (DataGridView.NewRowIndex == rowIndex)
                                    {
                                        bmp = GetArrowStarBitmap(DataGridView.RightToLeftInternal);
                                    }
                                    else
                                    {
                                        bmp = GetArrowBitmap(DataGridView.RightToLeftInternal);
                                    }
                                }
                                else
                                {
                                    if (DataGridView.IsCurrentCellDirty && DataGridView.ShowEditingIcon)
                                    {
                                        bmp = GetPencilBitmap(DataGridView.RightToLeftInternal);
                                    }
                                    else if (DataGridView.NewRowIndex == rowIndex)
                                    {
                                        bmp = GetArrowStarBitmap(DataGridView.RightToLeftInternal);
                                    }
                                    else
                                    {
                                        bmp = GetArrowBitmap(DataGridView.RightToLeftInternal);
                                    }
                                }
                            }
                            else if (DataGridView.NewRowIndex == rowIndex)
                            {
                                bmp = DataGridViewRowHeaderCell.StarBitmap;
                            }
                            if (bmp != null)
                            {
                                lock (bmp)
                                {
                                    Color iconColor;
                                    if (DataGridView.ApplyVisualStylesToHeaderCells)
                                    {
                                        iconColor = DataGridViewRowHeaderCellRenderer.VisualStyleRenderer.GetColor(ColorProperty.TextColor);
                                    }
                                    else
                                    {
                                        iconColor = cellSelected ? cellStyle.SelectionForeColor : cellStyle.ForeColor;
                                    }
                                    PaintIcon(graphics, bmp, valBounds, iconColor);
                                }
                            }
                        }
                    }

                    if (errorBounds.Width >= 3 * RowHeaderIconMarginWidth +
                        2 * s_iconsWidth)
                    {
                        // There is enough horizontal room for the error icon
                        if (paint && DataGridView.ShowRowErrors && DataGridViewCell.PaintErrorIcon(paintParts))
                        {
                            PaintErrorIcon(graphics, cellStyle, rowIndex, cellBounds, errorBounds, errorText);
                        }
                        else if (computeErrorIconBounds)
                        {
                            if (!string.IsNullOrEmpty(errorText))
                            {
                                resultBounds = ComputeErrorIconBounds(errorBounds);
                            }
                        }
                    }
                }
            }
            // else no room for content or error icon, resultBounds = Rectangle.Empty

            return(resultBounds);
        }
Exemple #2
0
        private Rectangle PaintPrivate(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates dataGridViewElementState, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts, bool computeContentBounds, bool computeErrorIconBounds, bool paint)
        {
            Rectangle empty = Rectangle.Empty;

            if (paint && DataGridViewCell.PaintBorder(paintParts))
            {
                this.PaintBorder(graphics, clipBounds, cellBounds, cellStyle, advancedBorderStyle);
            }
            Rectangle rect       = cellBounds;
            Rectangle rectangle3 = this.BorderWidths(advancedBorderStyle);

            rect.Offset(rectangle3.X, rectangle3.Y);
            rect.Width  -= rectangle3.Right;
            rect.Height -= rectangle3.Bottom;
            Rectangle destRect = rect;
            bool      flag     = (dataGridViewElementState & DataGridViewElementStates.Selected) != DataGridViewElementStates.None;

            if (base.DataGridView.ApplyVisualStylesToHeaderCells)
            {
                if (cellStyle.Padding != Padding.Empty)
                {
                    if (base.DataGridView.RightToLeftInternal)
                    {
                        rect.Offset(cellStyle.Padding.Right, cellStyle.Padding.Top);
                    }
                    else
                    {
                        rect.Offset(cellStyle.Padding.Left, cellStyle.Padding.Top);
                    }
                    rect.Width  -= cellStyle.Padding.Horizontal;
                    rect.Height -= cellStyle.Padding.Vertical;
                }
                if ((destRect.Width > 0) && (destRect.Height > 0))
                {
                    if (paint && DataGridViewCell.PaintBackground(paintParts))
                    {
                        int headerState = 1;
                        if ((base.DataGridView.SelectionMode == DataGridViewSelectionMode.FullRowSelect) || (base.DataGridView.SelectionMode == DataGridViewSelectionMode.RowHeaderSelect))
                        {
                            if (base.ButtonState != ButtonState.Normal)
                            {
                                headerState = 3;
                            }
                            else if ((base.DataGridView.MouseEnteredCellAddress.Y == rowIndex) && (base.DataGridView.MouseEnteredCellAddress.X == -1))
                            {
                                headerState = 2;
                            }
                            else if (flag)
                            {
                                headerState = 3;
                            }
                        }
                        using (Bitmap bitmap = new Bitmap(destRect.Height, destRect.Width))
                        {
                            using (Graphics graphics2 = Graphics.FromImage(bitmap))
                            {
                                DataGridViewRowHeaderCellRenderer.DrawHeader(graphics2, new Rectangle(0, 0, destRect.Height, destRect.Width), headerState);
                                bitmap.RotateFlip(base.DataGridView.RightToLeftInternal ? RotateFlipType.Rotate90FlipNone : RotateFlipType.Rotate90FlipX);
                                graphics.DrawImage(bitmap, destRect, new Rectangle(0, 0, destRect.Width, destRect.Height), GraphicsUnit.Pixel);
                            }
                        }
                    }
                    Rectangle themeMargins = DataGridViewHeaderCell.GetThemeMargins(graphics);
                    if (base.DataGridView.RightToLeftInternal)
                    {
                        rect.X += themeMargins.Height;
                    }
                    else
                    {
                        rect.X += themeMargins.Y;
                    }
                    rect.Width  -= themeMargins.Y + themeMargins.Height;
                    rect.Height -= themeMargins.X + themeMargins.Width;
                    rect.Y      += themeMargins.X;
                }
            }
            else
            {
                if ((rect.Width > 0) && (rect.Height > 0))
                {
                    SolidBrush cachedBrush = base.DataGridView.GetCachedBrush((DataGridViewCell.PaintSelectionBackground(paintParts) && flag) ? cellStyle.SelectionBackColor : cellStyle.BackColor);
                    if ((paint && DataGridViewCell.PaintBackground(paintParts)) && (cachedBrush.Color.A == 0xff))
                    {
                        graphics.FillRectangle(cachedBrush, rect);
                    }
                }
                if (cellStyle.Padding != Padding.Empty)
                {
                    if (base.DataGridView.RightToLeftInternal)
                    {
                        rect.Offset(cellStyle.Padding.Right, cellStyle.Padding.Top);
                    }
                    else
                    {
                        rect.Offset(cellStyle.Padding.Left, cellStyle.Padding.Top);
                    }
                    rect.Width  -= cellStyle.Padding.Horizontal;
                    rect.Height -= cellStyle.Padding.Vertical;
                }
            }
            Bitmap bmp = null;

            if ((rect.Width > 0) && (rect.Height > 0))
            {
                Rectangle cellValueBounds = rect;
                string    str             = formattedValue as string;
                if (!string.IsNullOrEmpty(str))
                {
                    if ((rect.Width >= 0x12) && (rect.Height >= 15))
                    {
                        if (paint && DataGridViewCell.PaintContentBackground(paintParts))
                        {
                            if (base.DataGridView.CurrentCellAddress.Y == rowIndex)
                            {
                                if (base.DataGridView.VirtualMode)
                                {
                                    if (base.DataGridView.IsCurrentRowDirty && base.DataGridView.ShowEditingIcon)
                                    {
                                        bmp = GetPencilBitmap(base.DataGridView.RightToLeftInternal);
                                    }
                                    else if (base.DataGridView.NewRowIndex == rowIndex)
                                    {
                                        bmp = GetArrowStarBitmap(base.DataGridView.RightToLeftInternal);
                                    }
                                    else
                                    {
                                        bmp = GetArrowBitmap(base.DataGridView.RightToLeftInternal);
                                    }
                                }
                                else if (base.DataGridView.IsCurrentCellDirty && base.DataGridView.ShowEditingIcon)
                                {
                                    bmp = GetPencilBitmap(base.DataGridView.RightToLeftInternal);
                                }
                                else if (base.DataGridView.NewRowIndex == rowIndex)
                                {
                                    bmp = GetArrowStarBitmap(base.DataGridView.RightToLeftInternal);
                                }
                                else
                                {
                                    bmp = GetArrowBitmap(base.DataGridView.RightToLeftInternal);
                                }
                            }
                            else if (base.DataGridView.NewRowIndex == rowIndex)
                            {
                                bmp = StarBitmap;
                            }
                            if (bmp != null)
                            {
                                Color color;
                                if (base.DataGridView.ApplyVisualStylesToHeaderCells)
                                {
                                    color = DataGridViewRowHeaderCellRenderer.VisualStyleRenderer.GetColor(ColorProperty.TextColor);
                                }
                                else
                                {
                                    color = flag ? cellStyle.SelectionForeColor : cellStyle.ForeColor;
                                }
                                lock (bmp)
                                {
                                    this.PaintIcon(graphics, bmp, rect, color);
                                }
                            }
                        }
                        if (!base.DataGridView.RightToLeftInternal)
                        {
                            rect.X += 0x12;
                        }
                        rect.Width -= 0x12;
                    }
                    rect.Offset(4, 1);
                    rect.Width  -= 9;
                    rect.Height -= 2;
                    if ((rect.Width > 0) && (rect.Height > 0))
                    {
                        TextFormatFlags flags = DataGridViewUtilities.ComputeTextFormatFlagsForCellStyleAlignment(base.DataGridView.RightToLeftInternal, cellStyle.Alignment, cellStyle.WrapMode);
                        if (base.DataGridView.ShowRowErrors && (rect.Width > 0x12))
                        {
                            Size maxBounds = new Size((rect.Width - 12) - 6, rect.Height);
                            if (DataGridViewCell.TextFitsInBounds(graphics, str, cellStyle.Font, maxBounds, flags))
                            {
                                if (base.DataGridView.RightToLeftInternal)
                                {
                                    rect.X += 0x12;
                                }
                                rect.Width -= 0x12;
                            }
                        }
                        if (DataGridViewCell.PaintContentForeground(paintParts))
                        {
                            if (paint)
                            {
                                Color color2;
                                if (base.DataGridView.ApplyVisualStylesToHeaderCells)
                                {
                                    color2 = DataGridViewRowHeaderCellRenderer.VisualStyleRenderer.GetColor(ColorProperty.TextColor);
                                }
                                else
                                {
                                    color2 = flag ? cellStyle.SelectionForeColor : cellStyle.ForeColor;
                                }
                                if ((flags & TextFormatFlags.SingleLine) != TextFormatFlags.Default)
                                {
                                    flags |= TextFormatFlags.EndEllipsis;
                                }
                                TextRenderer.DrawText(graphics, str, cellStyle.Font, rect, color2, flags);
                            }
                            else if (computeContentBounds)
                            {
                                empty = DataGridViewUtilities.GetTextBounds(rect, str, flags, cellStyle);
                            }
                        }
                    }
                    if (cellValueBounds.Width >= 0x21)
                    {
                        if ((paint && base.DataGridView.ShowRowErrors) && DataGridViewCell.PaintErrorIcon(paintParts))
                        {
                            this.PaintErrorIcon(graphics, clipBounds, cellValueBounds, errorText);
                            return(empty);
                        }
                        if (computeErrorIconBounds && !string.IsNullOrEmpty(errorText))
                        {
                            empty = base.ComputeErrorIconBounds(cellValueBounds);
                        }
                    }
                    return(empty);
                }
                if (((rect.Width >= 0x12) && (rect.Height >= 15)) && (paint && DataGridViewCell.PaintContentBackground(paintParts)))
                {
                    if (base.DataGridView.CurrentCellAddress.Y == rowIndex)
                    {
                        if (base.DataGridView.VirtualMode)
                        {
                            if (base.DataGridView.IsCurrentRowDirty && base.DataGridView.ShowEditingIcon)
                            {
                                bmp = GetPencilBitmap(base.DataGridView.RightToLeftInternal);
                            }
                            else if (base.DataGridView.NewRowIndex == rowIndex)
                            {
                                bmp = GetArrowStarBitmap(base.DataGridView.RightToLeftInternal);
                            }
                            else
                            {
                                bmp = GetArrowBitmap(base.DataGridView.RightToLeftInternal);
                            }
                        }
                        else if (base.DataGridView.IsCurrentCellDirty && base.DataGridView.ShowEditingIcon)
                        {
                            bmp = GetPencilBitmap(base.DataGridView.RightToLeftInternal);
                        }
                        else if (base.DataGridView.NewRowIndex == rowIndex)
                        {
                            bmp = GetArrowStarBitmap(base.DataGridView.RightToLeftInternal);
                        }
                        else
                        {
                            bmp = GetArrowBitmap(base.DataGridView.RightToLeftInternal);
                        }
                    }
                    else if (base.DataGridView.NewRowIndex == rowIndex)
                    {
                        bmp = StarBitmap;
                    }
                    if (bmp != null)
                    {
                        lock (bmp)
                        {
                            Color color3;
                            if (base.DataGridView.ApplyVisualStylesToHeaderCells)
                            {
                                color3 = DataGridViewRowHeaderCellRenderer.VisualStyleRenderer.GetColor(ColorProperty.TextColor);
                            }
                            else
                            {
                                color3 = flag ? cellStyle.SelectionForeColor : cellStyle.ForeColor;
                            }
                            this.PaintIcon(graphics, bmp, rect, color3);
                        }
                    }
                }
                if (cellValueBounds.Width >= 0x21)
                {
                    if ((paint && base.DataGridView.ShowRowErrors) && DataGridViewCell.PaintErrorIcon(paintParts))
                    {
                        base.PaintErrorIcon(graphics, cellStyle, rowIndex, cellBounds, cellValueBounds, errorText);
                        return(empty);
                    }
                    if (computeErrorIconBounds && !string.IsNullOrEmpty(errorText))
                    {
                        empty = base.ComputeErrorIconBounds(cellValueBounds);
                    }
                }
            }
            return(empty);
        }