public PaintStyleResult ResolvePaintStyle(PaintStyle ps, PaintStyleUse pst = PaintStyleUse.Background) { PaintStyle? psTemp = null; PaletteEntryBase pRef = null; // check for inherited data if (ps.StyleType == PaletteEntryType.Inherited) { psTemp = Atomic.FindPaintStyleByUsage(pst); } else { psTemp = ps; } if (psTemp.HasValue) { PaintStyle resolved = psTemp.Value; // resolve palette reference if needed if (resolved.StyleType == PaletteEntryType.PaletteReference) { pRef = Atomic.FindPaintStyleTarget(resolved); } return(BlockBase.PreparePaintStyleResults(ref resolved, pRef)); } else { return(new PaintStyleResult(PaintStyleResult.Result.NotFound, null)); } }
public PaletteEntryBase FindCascadedPaletteItem(int index) { PaletteEntryBase res = null; if (Palette != null) { res = Palette[index]; } if ((res == null) && (ParentBlock != null)) { return(ParentBlock.FindCascadedPaletteItem(index)); } if ((res == null) && (ParentBlock == null) && IsRoot && (Host.ParentFrame != null)) { return(Host.ParentFrame.FindCascadedPaletteItem(index)); } if ((res == null) && (ParentBlock == null) && (ParentNode != null) && (ParentNode.ApplicationPalette != null)) { res = ParentNode.ApplicationPalette[index]; } return(res); }
public PaintStyleResult ResolvePaintStyle(PaintStyle ps) { PaletteEntryBase pRef = null; // resolve palette reference if needed if (ps.StyleType == PaletteEntryType.PaletteReference) { pRef = FindPaintStyleTarget(ps); } return(PreparePaintStyleResults(ref ps, pRef)); }
public PaletteEntryBase FindPaintStyleTarget(PaintStyle ps) { PaletteEntryBase res = null; if ((ps.StyleType == PaletteEntryType.PaletteReference) && (ps.Data is int)) { int entryIndex = (int)ps.Data; do { res = FindCascadedPaletteItem(entryIndex) as PaletteEntryBase; }while ((res != null) && (res.EntryType == PaletteEntryType.PaletteReference)); } return(res); }
public static PaintStyleResult PreparePaintStyleResults(ref PaintStyle ps, PaletteEntryBase pRef) { PaintStyleResult.Result resType = PaintStyleResult.Result.NotFound; Brush br = null; switch (ps.StyleType) { case PaletteEntryType.DoNotPaint: resType = PaintStyleResult.Result.Transparent; br = new SolidColorBrush(Colors.Transparent); break; case PaletteEntryType.Colour: if (ps.Data is int) { resType = PaintStyleResult.Result.Colour; br = new SolidColorBrush(DataHelper.IntToColour((int)ps.Data)); break; } else { goto case PaletteEntryType.DoNotPaint; } case PaletteEntryType.PaletteReference: if ((pRef != null) && ((pRef.EntryType != PaletteEntryType.DoNotPaint) && (pRef.EntryType != PaletteEntryType.Inherited))) { switch (pRef.EntryType) { case PaletteEntryType.Colour: { ColourPaletteEntry cl = pRef as ColourPaletteEntry; if (cl != null) { resType = PaintStyleResult.Result.Colour; br = cl.ToBrush(); break; } goto default; } case PaletteEntryType.LinearGradient: { LinearGradientPaletteEntry lg = pRef as LinearGradientPaletteEntry; if (lg != null) { resType = PaintStyleResult.Result.LinearGradient; br = lg.ToBrush(); break; } goto default; } //IMPLEMENT: other palette entry types default: resType = PaintStyleResult.Result.Transparent; br = new SolidColorBrush(Colors.Transparent); break; } break; } else { goto case PaletteEntryType.DoNotPaint; } } return(new PaintStyleResult(resType, br)); }