/// <summary> /// Gets the vertical relative alignment of the long text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentLongTextV(PaletteState state) { if (Apply) { PaletteRelativeAlign ret = _primary.GetContentLongTextV(Override ? OverrideState : state); if (ret == PaletteRelativeAlign.Inherit) { ret = _backup.GetContentLongTextV(state); } return(ret); } else { return(_backup.GetContentLongTextV(state)); } }
/// <summary> /// Gets the vertical relative alignment of the long text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public virtual PaletteRelativeAlign GetContentLongTextV(PaletteState state) { if (_apply) { PaletteRelativeAlign ret = _primaryContent.GetContentLongTextV(_override ? _state : state); if (ret == PaletteRelativeAlign.Inherit) { ret = _backupContent.GetContentLongTextV(state); } return(ret); } else { return(_backupContent.GetContentLongTextV(state)); } }
/// <summary> /// Gets the actual content long text vertical alignment value. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public PaletteRelativeAlign GetContentLongTextV(PaletteState state) { if (_longText.TextV != PaletteRelativeAlign.Inherit) { return(_longText.TextV); } else { return(_inherit.GetContentLongTextV(state)); } }
/// <summary> /// Gets the vertical relative alignment of the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentLongTextV(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); if (inherit != null) { return(inherit.GetContentLongTextV(state)); } else { return(Target.GetContentLongTextV(style, state)); } }
/// <summary> /// Gets the vertical relative alignment of the long text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentLongTextV(PaletteState state) { switch (_cellStyle.Alignment) { case DataGridViewContentAlignment.TopLeft: case DataGridViewContentAlignment.MiddleLeft: case DataGridViewContentAlignment.BottomLeft: return(PaletteRelativeAlign.Near); case DataGridViewContentAlignment.TopCenter: case DataGridViewContentAlignment.MiddleCenter: case DataGridViewContentAlignment.BottomCenter: return(PaletteRelativeAlign.Center); case DataGridViewContentAlignment.TopRight: case DataGridViewContentAlignment.MiddleRight: case DataGridViewContentAlignment.BottomRight: return(PaletteRelativeAlign.Far); case DataGridViewContentAlignment.NotSet: default: return(_inherit.GetContentLongTextV(state)); } }
/// <summary> /// Gets the vertical relative alignment of the long text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentLongTextV(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentLongTextV(state) ?? Target.GetContentLongTextV(style, state)); }
/// <summary> /// Gets the vertical relative alignment of the long text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentLongTextV(PaletteState state) { return(_inherit.GetContentLongTextV(state)); }
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); }
private static void AllocateLongTextSpace(ViewLayoutContext context, Graphics g, StandardContentMemento memento, IPaletteContent paletteContent, IContentValues contentValues, PaletteState state, Rectangle displayRect, RightToLeft rtl, int spacingGap, ref Size[,] allocation, bool composition, bool glowing) { // By default, we cannot draw the text memento.DrawLongText = false; // Get the defined text for display string longText = contentValues.GetLongText(); // Is there any text to be drawn? if ((longText != null) && (longText.Length > 0)) { // If the text is not allowed to span multiple lines if (paletteContent.GetContentLongTextMultiLine(state) == InheritBool.False) { // Replace any carriage returns and newlines with just spaces longText = longText.Replace("\r\n", " "); longText = longText.Replace("\n", " "); longText = longText.Replace("\r", " "); } // Convert from alignment enums to integers int alignHIndex = RightToLeftIndex(rtl, paletteContent.GetContentLongTextH(state)); int alignVIndex = (int)paletteContent.GetContentLongTextV(state); // Cache the rendering hint used memento.LongTextHint = CommonHelper.PaletteTextHintToRenderingHint(paletteContent.GetContentLongTextHint(state)); memento.LongTextTrimming = paletteContent.GetContentLongTextTrim(state); bool fontChanged = false; Font textFont = paletteContent.GetContentLongTextFont(state); // Get the appropriate font to use in the caption area if (paletteContent.GetContentStyle() == PaletteContentStyle.HeaderForm) { Font captionFont = ContentFontForButtonForm(context, textFont); fontChanged = (captionFont != textFont); textFont = captionFont; } // Get a pixel accurate measure of text drawing space needed memento.LongTextMemento = AccurateText.MeasureString(g, rtl, longText, textFont, memento.LongTextTrimming, paletteContent.GetContentLongTextMultiLineH(state), paletteContent.GetContentLongTextPrefix(state), memento.LongTextHint, composition, glowing, fontChanged); // Space required for long text starts with the text width itself Size requiredSpace = memento.LongTextMemento.Size; // Find the space available given our required alignment if (AllocateAlignmentSpace(alignHIndex, alignVIndex, allocation, displayRect, spacingGap, memento.LongTextTrimming, ref requiredSpace)) { // Cache the actual draw size of the text memento.LongTextRect.Size = requiredSpace; // Mark the memento to draw the long text memento.DrawLongText = true; } } }
/// <summary> /// Gets the vertical relative alignment of the long text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public PaletteRelativeAlign GetContentLongTextV(PaletteState state) { return(_content.GetContentLongTextV(state)); }