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

PositionAlignContent() private static method

private static PositionAlignContent ( StandardContentMemento memento, IPaletteContent paletteContent, PaletteState state, RightToLeft rtl, PaletteRelativeAlign alignH, PaletteRelativeAlign alignV, int cellX, int cellY, int cellWidth, int cellHeight, int spacingGap ) : void
memento StandardContentMemento
paletteContent IPaletteContent
state PaletteState
rtl RightToLeft
alignH PaletteRelativeAlign
alignV PaletteRelativeAlign
cellX int
cellY int
cellWidth int
cellHeight int
spacingGap int
return void
        private static void PositionAlignContent(StandardContentMemento memento,
                                                 IPaletteContent paletteContent,
                                                 PaletteState state,
                                                 RightToLeft rtl,
                                                 PaletteRelativeAlign alignH,
                                                 PaletteRelativeAlign alignV,
                                                 int cellX,
                                                 int cellY,
                                                 int cellWidth,
                                                 int cellHeight,
                                                 int spacingGap)
        {
            // Create client rectangle covering cell size
            Rectangle cellRect = new Rectangle(cellX, cellY, cellWidth, cellHeight);

            PaletteRelativeAlign drawHImage = paletteContent.GetContentImageH(state);
            PaletteRelativeAlign drawVImage = paletteContent.GetContentImageV(state);
            PaletteRelativeAlign drawHShort = paletteContent.GetContentShortTextH(state);
            PaletteRelativeAlign drawVShort = paletteContent.GetContentShortTextV(state);
            PaletteRelativeAlign drawHLong = paletteContent.GetContentLongTextH(state);
            PaletteRelativeAlign drawVLong = paletteContent.GetContentLongTextV(state);

            PaletteRelativeAlign posHImage = drawHImage;
            PaletteRelativeAlign posHShort = drawHShort;
            PaletteRelativeAlign posHLong = drawHLong;

            // If positioning in the center, then need extra processing
            if (alignH == PaletteRelativeAlign.Center)
            {
                // Find number of content and width of those in this cell
                int totalWidth = 0;
                int totalItems = 0;

                if (memento.DrawImage && (drawHImage == alignH) && (drawVImage == alignV))
                {
                    totalWidth += memento.ImageRect.Width;
                    totalItems++;
                }

                if (memento.DrawShortText && (drawHShort == alignH) && (drawVShort == alignV))
                {
                    totalWidth += memento.ShortTextRect.Width;
                    totalItems++;
                }

                if (memento.DrawLongText && (drawHLong == alignH) && (drawVLong == alignV))
                {
                    totalWidth += memento.LongTextRect.Width;
                    totalItems++;
                }

                // If more than one item is to be positioned
                if (totalItems > 1)
                {
                    // Add on required number of spacing gaps
                    totalWidth += (totalItems - 1) * spacingGap;

                    // Then center the space for the content
                    int halfWidth = (cellRect.Width - totalWidth) / 2;
                    cellRect.Width -= (halfWidth * 2);
                    cellRect.X += halfWidth;

                    // Ensure all content are placed near, so they fit exactly
                    posHImage = posHShort = posHLong = PaletteRelativeAlign.Near;
                }
            }

            // Do we need to position the image?
            if (memento.DrawImage && (drawHImage == alignH) && (drawVImage == alignV))
                memento.ImageRect.Location = PositionCellContent(rtl, posHImage, drawVImage, memento.ImageRect.Size, spacingGap, ref cellRect);

            // Do we need to position the short text?
            if (memento.DrawShortText && (drawHShort == alignH) && (drawVShort == alignV))
                memento.ShortTextRect.Location = PositionCellContent(rtl, posHShort, drawVShort, memento.ShortTextRect.Size, spacingGap, ref cellRect);

            // Do we need to position the long text?
            if (memento.DrawLongText && (drawHLong == alignH) && (drawVLong == alignV))
                memento.LongTextRect.Location = PositionCellContent(rtl, posHLong, drawVLong, memento.LongTextRect.Size, spacingGap, ref cellRect);
        }
RenderStandard