3using System.Collections.Generic;
19 private Dictionary<ILayoutElement, bool> relativeElements =
null;
21 private readonly SKPaint textRoot;
22 private readonly SKPaint defaultPen;
23 private SKCanvas canvas;
24 private SKPaint shapePen;
25 private SKPaint shapeFill;
28 private float? width_0;
29 private float? height_x;
30 private SKSize areaSize;
31 private SKSize viewportSize;
32 private readonly
float pixelsPerInch;
33 private bool logRelativeElements =
false;
44 this.session = Session;
46 this.areaSize = this.viewportSize =
new SKSize(Settings.
Width, Settings.
Height);
48 this.font =
new SKFont()
50 Edging = SKFontEdging.SubpixelAntialias,
51 Hinting = SKFontHinting.Full,
53 Size = (float)(Settings.
FontSize *
this.pixelsPerInch / 72),
54 Typeface = SKTypeface.FromFamilyName(Settings.
FontName, SKFontStyle.Normal)
57 this.text = this.textRoot =
new SKPaint()
59 FilterQuality = SKFilterQuality.High,
60 HintingLevel = SKPaintHinting.Full,
63 Style = SKPaintStyle.Fill,
65 Typeface = this.font.Typeface,
66 TextSize = this.font.Size
69 this.defaultPen =
new SKPaint()
71 FilterQuality = SKFilterQuality.High,
73 Style = SKPaintStyle.Stroke,
74 Color = Settings.PenColor
85 this.defaultPen?.Dispose();
104 internal set => this.canvas = value;
113 set => this.text = value;
122 set => this.font = value;
135 get => this.shapePen;
136 set => this.shapePen = value;
144 get => this.shapeFill;
145 set => this.shapeFill = value;
171 Size = L.Value * this.pixelsPerInch / 96;
176 Size = L.Value * this.pixelsPerInch / 72;
181 Size = L.Value * this.pixelsPerInch / 12;
186 Size = L.Value * this.pixelsPerInch / 2.54f;
191 Size = L.Value * this.pixelsPerInch;
196 Size = L.Value * this.pixelsPerInch / 25.4f;
201 float Size2 = L.Value * this.text.TextSize;
211 if (!this.height_x.HasValue)
213 SKRect Bounds =
new SKRect();
214 this.text.MeasureText(
"x", ref Bounds);
215 this.height_x = Bounds.Height;
218 Size2 = L.Value * this.height_x.Value;
228 if (!this.width_0.HasValue)
229 this.width_0 = this.text.MeasureText(
"0");
231 Size2 = L.Value * this.width_0.Value;
241 Size2 = L.Value * this.textRoot.TextSize;
251 Size2 = L.Value * this.viewportSize.Width / 100;
261 Size2 = L.Value * this.viewportSize.Height / 100;
271 if (this.viewportSize.Width <
this.viewportSize.Height)
272 Size2 = L.Value * this.viewportSize.Width / 100;
274 Size2 = L.Value * this.viewportSize.Height / 100;
285 if (this.viewportSize.Width >
this.viewportSize.Height)
286 Size2 = L.Value * this.viewportSize.Width / 100;
288 Size2 = L.Value * this.viewportSize.Height / 100;
300 Size2 = L.Value * this.areaSize.Width / 100;
302 Size2 = L.Value * this.areaSize.Height / 100;
324 SKSize Prev = this.areaSize;
325 this.areaSize = AreaSize;
374 this.MeasureRelative =
true;
375 if (this.logRelativeElements)
376 this.relativeElements[Element] =
true;
385 this.MeasureRelative =
false;
386 this.logRelativeElements = LogRelativeElements;
387 if (this.logRelativeElements)
389 if (this.relativeElements is
null)
390 this.relativeElements =
new Dictionary<ILayoutElement, bool>();
392 this.relativeElements.Clear();
402 string Best =
string.Empty;
403 int BestLen =
int.MaxValue;
407 string Item =
Map(Element);
408 int Len = Item.Length;
Contains information about an actionable area in a generated image.
SKPaint Text
Current text paint settings
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.
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
SKPaint Text
Measured Text
float? Width
Width of element
LengthUnit Unit
Unit of length.
float Value
Value of length
float PixelsPerInch
Pixels per inch (default=96 pixels/inch)
SKColor TextColor
Text color
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.