ComponentFactory.Krypton.Toolkit.RenderStandard.DrawGridSortGlyph C# (CSharp) Method

DrawGridSortGlyph() public method

Draw a grid sorting direction glyph.
public DrawGridSortGlyph ( RenderContext context, SortOrder sortOrder, Rectangle cellRect, IPaletteContent paletteContent, PaletteState state, bool rtl ) : Rectangle
context RenderContext Render context.
sortOrder SortOrder Sorting order of the glyph.
cellRect System.Drawing.Rectangle Available drawing rectangle space.
paletteContent IPaletteContent Palette to use for sourcing values.
state PaletteState State associated with rendering.
rtl bool Should be drawn from right to left.
return System.Drawing.Rectangle
        public override Rectangle DrawGridSortGlyph(RenderContext context,
                                                    SortOrder sortOrder,
                                                    Rectangle cellRect,
                                                    IPaletteContent paletteContent,
                                                    PaletteState state,
                                                    bool rtl)
        {
            Debug.Assert(context != null);
            Debug.Assert(paletteContent != null);

            // Get the appropriate each to draw
            Image sortImage = _gridSortOrder.Images[(sortOrder == SortOrder.Ascending ? 0 : 1)];

            // Is there enough room to draw the image?
            if ((sortImage.Width < cellRect.Width) && (sortImage.Height < cellRect.Height))
            {
                // Find the drawing location of the image
                int y = cellRect.Top + (cellRect.Height - sortImage.Height) / 2;
                int x = (rtl ? cellRect.X : cellRect.Right - sortImage.Width);

                // Grab the foreground color to use for the image
                Color imageColor = paletteContent.GetContentShortTextColor1(state);

                // Draw the image with remapping the image color to the foreground color
                using (ImageAttributes attribs = new ImageAttributes())
                {
                    ColorMap cm = new ColorMap();
                    cm.OldColor = Color.Black;
                    cm.NewColor = CommonHelper.MergeColors(imageColor, 0.75f, Color.Transparent, 0.25f);
                    attribs.SetRemapTable(new ColorMap[] { cm }, ColorAdjustType.Bitmap);

                    context.Graphics.DrawImage(sortImage,
                                               new Rectangle(x, y, sortImage.Width, sortImage.Height),
                                               0, 0, sortImage.Width, sortImage.Height,
                                               GraphicsUnit.Pixel, attribs);
                }

                // Reduce the cell rect by that used up
                cellRect.Width -= sortImage.Width;

                // With rtl we need to move across to the right
                if (rtl)
                    cellRect.X += sortImage.Width;
            }

            return cellRect;
        }
RenderStandard