public override void ApplyFormattingAndLayout(SlotData slotData, SlotStyleData slotStyleData, TableLayoutItemInfo layout) { base.ApplyFormattingAndLayout(slotData, slotStyleData, layout); Brush background = null; Brush foreground = null; short fontID = -1; //IMPLEMENT: the rest of the properties in SlotData, SlotStyleData, and TableLayoutItemInfo if (layout != null) { // margins and paddings Margin = new Spacing(layout.LeftMargin, layout.TopMargin, layout.RightMargin, layout.BottomMargin); Padding = new Spacing(layout.LeftPadding, layout.TopPadding, layout.RightPadding, layout.BottomPadding); // cropping Crop = layout.CropStrategy; } if (slotData != null) { // background if (slotData.Background.HasValue) { PaintStyleResult bgRes = ResolvePaintStyle(slotData.Background.Value, PaintStyleUse.Background); if (bgRes.Brush != null) { background = bgRes.Brush; } } // foreground if (slotData.Foreground.HasValue) { PaintStyleResult fgRes = ResolvePaintStyle(slotData.Foreground.Value, PaintStyleUse.Foreground); if (fgRes.Brush != null) { foreground = fgRes.Brush; } } // get font fontID = slotData.Font ?? -1; } if (slotStyleData != null) { // cropping Crop = slotStyleData.Crop; // background if (slotStyleData.Background.HasValue) { PaintStyleResult bgRes = ResolvePaintStyle(slotStyleData.Background.Value, PaintStyleUse.Background); if (bgRes.Brush != null) { background = bgRes.Brush; } } // foreground if (slotStyleData.Foreground.HasValue) { PaintStyleResult fgRes = ResolvePaintStyle(slotStyleData.Foreground.Value, PaintStyleUse.Foreground); if (fgRes.Brush != null) { foreground = fgRes.Brush; } } // get font fontID = slotStyleData.Font; } // use parent foreground if needed if (foreground == null) { foreground = Atomic.Foreground; } // apply brushes Background = background; textControl.Foreground = foreground; // apply font if (fontID != -1) { FontReferencePaletteEntry fr = Atomic.FindCascadedPaletteItem(fontID) as FontReferencePaletteEntry; if (fr != null) { FontDefinition fd = fr.Resolve(Atomic.ParentNode.ApplicationID); if (fd != null) { fd.Apply(textControl); } } } // apply cropping, alignment, tick if ((Crop & CropStrategy.Wrap) == CropStrategy.Wrap) { textControl.TextWrapping = TextWrapping.Wrap; if ((Crop & CropStrategy.Tick) == CropStrategy.Tick) { textControl.TextTrimming = TextTrimming.WordEllipsis; } else { textControl.TextTrimming = TextTrimming.None; } } else if ((Crop & CropStrategy.Tick) == CropStrategy.Tick) { textControl.TextWrapping = TextWrapping.NoWrap; textControl.TextTrimming = TextTrimming.WordEllipsis; } else { textControl.TextWrapping = TextWrapping.NoWrap; textControl.TextTrimming = TextTrimming.None; } // set horizontal alignment (vertical one is done in layout) if ((Crop & CropStrategy.AlignLeft) == CropStrategy.AlignLeft) { textControl.TextAlignment = TextAlignment.Left; } else if ((Crop & CropStrategy.AlignHCenter) == CropStrategy.AlignHCenter) { textControl.TextAlignment = TextAlignment.Center; } else if ((Crop & CropStrategy.AlignRight) == CropStrategy.AlignRight) { textControl.TextAlignment = TextAlignment.Right; } }