19 private Dictionary<ILayoutElement, bool> relativeElements =
null;
21 private readonly SKPaint textPenRoot;
22 private readonly SKFont fontRoot;
23 private readonly SKPaint defaultPen;
24 private SKCanvas canvas;
25 private SKPaint shapePen;
26 private SKPaint shapeFill;
28 private SKPaint textPen;
29 private float? width_0;
30 private float? height_x;
31 private SKSize areaSize;
32 private SKSize viewportSize;
33 private readonly
float pixelsPerInch;
34 private bool logRelativeElements =
false;
45 this.session = Session;
47 this.areaSize = this.viewportSize =
new SKSize(Settings.
Width, Settings.
Height);
49 this.font = this.fontRoot =
new SKFont()
51 Edging = SKFontEdging.SubpixelAntialias,
52 Hinting = SKFontHinting.Full,
54 Size = (float)(Settings.
FontSize *
this.pixelsPerInch / 72),
55 Typeface = SKTypeface.FromFamilyName(Settings.
FontName, SKFontStyle.Normal)
59 this.textPen = this.textPenRoot =
new SKPaint()
62 Style = SKPaintStyle.Fill,
63 Color = Settings.TextColor
66 this.defaultPen =
new SKPaint()
69 Style = SKPaintStyle.Stroke,
70 Color = Settings.PenColor
79 this.textPen?.Dispose();
80 this.textPenRoot?.Dispose();
82 this.fontRoot?.Dispose();
83 this.defaultPen?.Dispose();
102 internal set => this.canvas = value;
111 set => this.textPen = value;
120 set => this.font = value;
133 get => this.shapePen;
134 set => this.shapePen = value;
142 get => this.shapeFill;
143 set => this.shapeFill = value;
169 Size = L.Value * this.pixelsPerInch / 96;
174 Size = L.Value * this.pixelsPerInch / 72;
179 Size = L.Value * this.pixelsPerInch / 12;
184 Size = L.Value * this.pixelsPerInch / 2.54f;
189 Size = L.Value * this.pixelsPerInch;
194 Size = L.Value * this.pixelsPerInch / 25.4f;
199 float Size2 = L.Value * this.font.Size;
209 if (!this.height_x.HasValue)
211 this.font.MeasureText(
"x", out SKRect Bounds, this.textPen);
212 this.height_x = Bounds.Height;
215 Size2 = L.Value * this.height_x.Value;
225 if (!this.width_0.HasValue)
226 this.width_0 = this.font.MeasureText(
"0", this.textPen);
228 Size2 = L.Value * this.width_0.Value;
238 Size2 = L.Value * this.fontRoot.Size;
248 Size2 = L.Value * this.viewportSize.Width / 100;
258 Size2 = L.Value * this.viewportSize.Height / 100;
268 if (this.viewportSize.Width <
this.viewportSize.Height)
269 Size2 = L.Value * this.viewportSize.Width / 100;
271 Size2 = L.Value * this.viewportSize.Height / 100;
282 if (this.viewportSize.Width >
this.viewportSize.Height)
283 Size2 = L.Value * this.viewportSize.Width / 100;
285 Size2 = L.Value * this.viewportSize.Height / 100;
297 Size2 = L.Value * this.areaSize.Width / 100;
299 Size2 = L.Value * this.areaSize.Height / 100;
321 SKSize Prev = this.areaSize;
322 this.areaSize = AreaSize;
371 this.MeasureRelative =
true;
372 if (this.logRelativeElements)
373 this.relativeElements[Element] =
true;
382 this.MeasureRelative =
false;
383 this.logRelativeElements = LogRelativeElements;
384 if (this.logRelativeElements)
386 if (this.relativeElements is
null)
387 this.relativeElements =
new Dictionary<ILayoutElement, bool>();
389 this.relativeElements.Clear();
399 string Best =
string.Empty;
400 int BestLen =
int.MaxValue;
404 string Item =
Map(Element);
405 int Len = Item.Length;
Contains information about an actionable area in a generated image.
SKCanvas Canvas
Current drawing canvas.
float PixelsPerInch
Pixels per inch
void Restore(FontState FontState)
Restores font settings, from a previous call to Push
float AreaWidth
Width of current area
FontState Push(Font Font)
Pushes new font settings.
float AreaHeight
Height of current area
SKSize SetAreaSize(SKSize AreaSize)
Sets the current area size.
string GetShortestRelativeMeasurement(ElementToString Map)
Gets the shortest relative measurements element, given an element to string mapping.
Variables Session
Current session.
string GetShortestRelativeMeasurementXml()
Gets the shortest subtree XML of an element with relative measurements.
IEnumerable< ILayoutElement > RelativeElements
Relative elements.
SKPaint ShapeFill
Fill to use for shape, if no other is specified in the shape.
SKPaint TextPen
Current text paint settings
void Dispose()
IDisposable.Dispose
DrawingState(SKCanvas Canvas, RenderSettings Settings, Variables Session)
Current drawing state.
SKPaint ShapePen
Pen to use for shape, if no other is specified in the shape.
void ReportMeasureRelative(ILayoutElement Element)
Reports an element as having relative measurements.
SKPaint DefaultPen
Default pen
void CalcDrawingSize(Length L, ref float Size, bool Horizontal, ILayoutElement Element)
Converts a defined length to drawing size.
string GetShortestRelativeMeasurementStateXml()
Gets the shortest subtree State XML of an element with relative measurements.
void ClearRelativeMeasurement(bool LogRelativeElements)
Clears information about first relative measurement.
bool MeasureRelative
If layout contains relative sizes and dimensions should be recalculated.
Abstract base class for fonts.
SKFont FontDef
Measured Font
float? Width
Width of element
LengthUnit Unit
Unit of length.
float Value
Value of length
float PixelsPerInch
Pixels per inch (default=96 pixels/inch)
float FontSize
Font size, in points
int Height
Height of image
Base interface for all layout elements.
delegate string ElementToString(ILayoutElement Element)
Delegate to methods that return a string from a layout element.