/// <summary> /// Gets the vertical relative alignment of the image. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentImageV(PaletteState state) { if (_apply) { PaletteRelativeAlign ret = _primary.GetContentImageV(_override ? _state : state); if (ret == PaletteRelativeAlign.Inherit) { ret = _backup.GetContentImageV(state); } return(ret); } else { return(_backup.GetContentImageV(state)); } }
/// <summary> /// Gets the vertical relative alignment of the image. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public virtual PaletteRelativeAlign GetContentImageV(PaletteState state) { if (Apply) { PaletteRelativeAlign ret = _primaryContent.GetContentImageV(Override ? OverrideState : state); if (ret == PaletteRelativeAlign.Inherit) { ret = _backupContent.GetContentImageV(state); } return(ret); } else { return(_backupContent.GetContentImageV(state)); } }
/// <summary> /// Gets the actual content image vertical alignment value. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public PaletteRelativeAlign GetContentImageV(PaletteState state) { if (_image.ImageV != PaletteRelativeAlign.Inherit) { return(_image.ImageV); } else { return(_inherit.GetContentImageV(state)); } }
/// <summary> /// Gets the vertical relative alignment of the image. /// </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 GetContentImageV(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); if (inherit != null) { return(inherit.GetContentImageV(state)); } else { return(Target.GetContentImageV(style, state)); } }
/// <summary> /// Gets the vertical relative alignment of the image. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentImageV(PaletteState state) { return(_inherit.GetContentImageV(state)); }
/// <summary> /// Gets the vertical relative alignment of the image. /// </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 GetContentImageV(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentImageV(state) ?? Target.GetContentImageV(style, state)); }
/// <summary> /// Gets the vertical relative alignment of the image. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public override PaletteRelativeAlign GetContentImageV(PaletteState state) => _inherit.GetContentImageV(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 AllocateImageSpace(StandardContentMemento memento, IPaletteContent paletteContent, IContentValues contentValues, PaletteState state, Rectangle displayRect, RightToLeft rtl, ref Size[,] allocation) { // By default, we cannot draw the image memento.DrawImage = false; // Get the image details memento.Image = contentValues.GetImage(state); memento.ImageTransparentColor = contentValues.GetImageTransparentColor(state); // Is there any image to be drawn? if (memento.Image != null) { try { // Cache the size of the image memento.ImageRect.Size = memento.Image.Size; // Check for enough space to show all of the image if ((displayRect.Width >= memento.ImageRect.Width) && (displayRect.Height >= memento.ImageRect.Height)) { // Convert from alignment enums to integers int alignHIndex = RightToLeftIndex(rtl, paletteContent.GetContentImageH(state)); int alignVIndex = (int)paletteContent.GetContentImageV(state); // Bump the allocated space in the destination grid cell allocation[alignHIndex, alignVIndex].Width += memento.ImageRect.Width; allocation[alignHIndex, alignVIndex].Height += memento.ImageRect.Height; // Yes, we do want to draw the image/icon memento.DrawImage = true; } } catch { // Image is not valid, so do not use it! memento.Image = null; memento.DrawImage = false; } } }
/// <summary> /// Gets the vertical relative alignment of the image. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>RelativeAlignment value.</returns> public PaletteRelativeAlign GetContentImageV(PaletteState state) { return(_content.GetContentImageV(state)); }