Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Layout2DDocument.cs
1using SkiaSharp;
2using System;
4using System.IO;
5using System.Reflection;
6using System.Text;
7using System.Threading.Tasks;
8using System.Xml;
10using Waher.Events;
18using Waher.Script;
19
21{
26 {
30 public const string LocalName = "Layout2D";
31
35 public const string Namespace = "http://waher.se/Schema/Layout2D.xsd";
36
40 public static readonly string SchemaResourceName = typeof(Layout2DDocument).Namespace + ".Schema.Layout2D.xsd";
41
42 private static Dictionary<string, ILayoutElement> elementTypes = new Dictionary<string, ILayoutElement>();
43 private static bool initialized = false;
44
45 private readonly Dictionary<string, ILayoutElement> elementsById = new Dictionary<string, ILayoutElement>();
46 private readonly Dictionary<string, object> attachments = new Dictionary<string, object>(StringComparer.CurrentCultureIgnoreCase);
47 private readonly Variables session;
48 private ILayoutElement root;
49
50 #region Construction
51
57 private Layout2DDocument(Variables Session, params KeyValuePair<string, object>[] Attachments)
58 {
59 this.session = Session;
60
61 if (!(Attachments is null))
62 {
63 foreach (KeyValuePair<string, object> P in Attachments)
64 this.attachments[P.Key] = P.Value;
65 }
66 }
67
68 internal async Task<ILayoutElement> CreateElement(XmlElement Xml, ILayoutElement Parent)
69 {
70 string Key = Xml.NamespaceURI + "#" + Xml.LocalName;
71
72 if (!elementTypes.TryGetValue(Key, out ILayoutElement E))
73 throw new LayoutSyntaxException("Layout element not recognized: " + Key);
74
75 ILayoutElement Result = E.Create(this, Parent);
76 await Result.FromXml(Xml);
77
78 EvaluationResult<string> Id = await Result.IdAttribute.TryEvaluate(this.session);
79 if (Id.Ok && !string.IsNullOrEmpty(Id.Result))
80 this.AddElementId(Id.Result, Result);
81
82 return Result;
83 }
84
90 public static Task<Layout2DDocument> FromFile(string FileName, params KeyValuePair<string, object>[] Attachments)
91 {
92 return FromFile(FileName, true, Attachments);
93 }
94
101 public static Task<Layout2DDocument> FromFile(string FileName, bool Preprocess, params KeyValuePair<string, object>[] Attachments)
102 {
103 return FromFile(FileName, Preprocess, new Variables(), Attachments);
104 }
105
113 public static async Task<Layout2DDocument> FromFile(string FileName, bool Preprocess, Variables Session, params KeyValuePair<string, object>[] Attachments)
114 {
115 string Xml = await Files.ReadAllTextAsync(FileName);
116 return await FromXml(Xml, Preprocess, Session, Attachments);
117 }
118
125 public static Task<Layout2DDocument> FromStream(Stream Input, Encoding DefaultEncoding, params KeyValuePair<string, object>[] Attachments)
126 {
127 return FromStream(Input, DefaultEncoding, true, Attachments);
128 }
129
137 public static Task<Layout2DDocument> FromStream(Stream Input, Encoding DefaultEncoding, bool Preprocess, params KeyValuePair<string, object>[] Attachments)
138 {
139 return FromStream(Input, DefaultEncoding, Preprocess, new Variables(), Attachments);
140 }
141
150 public static Task<Layout2DDocument> FromStream(Stream Input, Encoding DefaultEncoding, bool Preprocess, Variables Session, params KeyValuePair<string, object>[] Attachments)
151 {
152 long c = Input.Length - Input.Position;
153 if (c > int.MaxValue)
154 throw new OutOfMemoryException("Input too large");
155
156 int c2 = (int)c;
157 byte[] Bin = new byte[c2];
158 Input.ReadAll(Bin, 0, c2);
159
160 string Xml = Strings.GetString(Bin, DefaultEncoding);
161
162 return FromXml(Xml, Preprocess, Session, Attachments);
163 }
164
170 public static Task<Layout2DDocument> FromXml(string Xml, params KeyValuePair<string, object>[] Attachments)
171 {
172 return FromXml(Xml, true, Attachments);
173 }
174
181 public static Task<Layout2DDocument> FromXml(string Xml, bool Preprocess, params KeyValuePair<string, object>[] Attachments)
182 {
183 return FromXml(Xml, Preprocess, new Variables(), Attachments);
184 }
185
193 public static async Task<Layout2DDocument> FromXml(string Xml, bool Preprocess, Variables Session, params KeyValuePair<string, object>[] Attachments)
194 {
195 if (Preprocess)
196 Xml = await Expression.TransformAsync(Xml, "{{", "}}", Session);
197
198 XmlDocument Doc;
199
200 try
201 {
202 Doc = XML.ParseXml(Xml);
203 }
204 catch (XmlException ex)
205 {
206 throw XML.AnnotateException(ex, Xml);
207 }
208
209 return await FromXml(Doc, Session, Attachments);
210 }
211
217 public static Task<Layout2DDocument> FromXml(XmlDocument Xml, params KeyValuePair<string, object>[] Attachments)
218 {
219 return FromXml(Xml.DocumentElement, new Variables(), Attachments);
220 }
221
228 public static Task<Layout2DDocument> FromXml(XmlDocument Xml, Variables Session, params KeyValuePair<string, object>[] Attachments)
229 {
230 return FromXml(Xml.DocumentElement, Session, Attachments);
231 }
232
238 public static Task<Layout2DDocument> FromXml(XmlElement Xml, params KeyValuePair<string, object>[] Attachments)
239 {
240 return FromXml(Xml, new Variables(), Attachments);
241 }
242
249 public static async Task<Layout2DDocument> FromXml(XmlElement Xml, Variables Session, params KeyValuePair<string, object>[] Attachments)
250 {
251 if (!IsLayoutXml(Xml))
252 throw new ArgumentException("XML does not represent a 2D layout document.", nameof(Xml));
253
254 lock (elementTypes)
255 {
256 if (!initialized)
257 {
258 Type[] LayoutElementTypes = Types.GetTypesImplementingInterface(typeof(ILayoutElement));
259 Dictionary<string, ILayoutElement> TypesPerKey = new Dictionary<string, ILayoutElement>();
261
262 foreach (Type T in LayoutElementTypes)
263 {
264 TypeInfo TI = T.GetTypeInfo();
265 if (TI.IsAbstract || TI.IsInterface || TI.IsGenericTypeDefinition)
266 continue;
267
268 try
269 {
271 string Key = E.Namespace + "#" + E.LocalName;
272
273 if (TypesPerKey.ContainsKey(Key))
274 Log.Error("Layout element type already defined: " + Key);
275 else
276 TypesPerKey[Key] = E;
277 }
278 catch (Exception ex)
279 {
280 Log.Exception(ex);
281 }
282 }
283
284 elementTypes = TypesPerKey;
285 initialized = true;
286
287 Types.OnInvalidated += (Sender, e) => initialized = false;
288 }
289 }
290
291 Layout2DDocument Result = new Layout2DDocument(Session, Attachments);
292 Result.root = await Result.CreateElement(Xml, null);
293
294 return Result;
295 }
296
301 public static bool IsLayoutXml(XmlDocument Xml)
302 {
303 return IsLayoutXml(Xml.DocumentElement);
304 }
305
310 public static bool IsLayoutXml(XmlElement Xml)
311 {
312 return !(Xml is null) &&
313 Xml.LocalName == LocalName &&
314 Xml.NamespaceURI == Namespace;
315 }
316
320 [Obsolete("Use DisposeAsync() instead.")]
321 public void Dispose()
322 {
323 this.DisposeAsync().Wait();
324 }
325
329 public async Task DisposeAsync()
330 {
331 this.root?.Dispose();
332
333 foreach (object Attachment in this.attachments.Values)
334 {
335 if (Attachment is IDisposableAsync DisposableAsync)
336 await DisposableAsync.DisposeAsync();
337 else if (Attachment is IDisposable Disposable)
338 Disposable.Dispose();
339 }
340 }
341
342 #endregion
343
344 #region Rendering
345
351 public async Task<KeyValuePair<SKImage, Map[]>> Render(RenderSettings Settings)
352 {
353 Map[] Maps = null; // TODO: Generate maps.
354
355 int Width;
356 int Height;
357
358 switch (Settings.ImageSize)
359 {
360 case RenderedImageSize.ResizeImage:
361 Width = Height = 10;
362 break;
363
364 case RenderedImageSize.ScaleToFit:
365 default:
366 Width = Settings.Width;
367 Height = Settings.Height;
368 break;
369 }
370
371 SKSurface Surface = SKSurface.Create(new SKImageInfo(Width, Height, SKImageInfo.PlatformColorType, SKAlphaType.Premul));
372 DrawingState State = null;
373 try
374 {
375 SKCanvas Canvas = Surface.Canvas;
376 State = new DrawingState(Canvas, Settings, this.session);
377
378 if (Settings.BackgroundColor != SKColor.Empty)
379 Canvas.Clear(Settings.BackgroundColor);
380
381 int Limit = 100;
382
383 while (!(this.root is null))
384 {
385 State.ClearRelativeMeasurement(--Limit <= 0);
386 await this.root.MeasureDimensions(State);
387
388 this.RaiseMeasuringDimensions(State);
389
390 if (!State.MeasureRelative)
391 break;
392
393 if (Limit <= 0)
394 {
395 string ShortestBranch = State.GetShortestRelativeMeasurementStateXml();
396 throw new InvalidOperationException("Layout positions not well defined. Dimensions diverge:\r\n\r\n" + ShortestBranch);
397 }
398 }
399
400 this.root?.MeasurePositions(State);
401 this.RaiseMeasuringPositions(State);
402
403 switch (Settings.ImageSize)
404 {
405 case RenderedImageSize.ResizeImage:
406 Surface.Dispose();
407 Surface = null;
408
409 if (!(this.root is null))
410 {
411 Width = (int)this.root.Right - (int)this.root.Left + 1;
412 Height = (int)this.root.Bottom - (int)this.root.Top - 1;
413 }
414
415 Surface = SKSurface.Create(new SKImageInfo(Width, Height, SKImageInfo.PlatformColorType, SKAlphaType.Premul));
416 if (Surface is null)
417 throw new InvalidOperationException("Unable to render layout.");
418
419 Canvas = Surface.Canvas;
420 State.Canvas = Canvas;
421
422 if (Settings.BackgroundColor != SKColor.Empty)
423 Canvas.Clear(Settings.BackgroundColor);
424
425 if (!(this.root is null) && this.root.Left.HasValue && this.root.Top.HasValue)
426 State.Canvas.Translate(-this.root.Left.Value, -this.root.Top.Value);
427 break;
428
429 case RenderedImageSize.ScaleToFit:
430 if (!(this.root is null))
431 {
432 if (this.root.Width.HasValue && this.root.Height.HasValue)
433 {
434 float Width2 = this.root.Width.Value + 1;
435 float Height2 = this.root.Height.Value + 1;
436 float ScaleX = Width / Width2;
437 float ScaleY = Height / Height2;
438
439 if (ScaleX < ScaleY)
440 {
441 State.Canvas.Translate(0, (Height - Height2 * ScaleX) / 2);
442 State.Canvas.Scale(ScaleX);
443 }
444 else if (ScaleY < ScaleX)
445 {
446 State.Canvas.Translate((Width - Width2 * ScaleY) / 2, 0);
447 State.Canvas.Scale(ScaleY);
448 }
449 }
450
451 if (this.root.Left.HasValue && this.root.Top.HasValue)
452 State.Canvas.Translate(-this.root.Left.Value, -this.root.Top.Value);
453 }
454 break;
455 }
456
457 if (!(this.root is null))
458 await this.root.Draw(State);
459
460 return new KeyValuePair<SKImage, Map[]>(Surface.Snapshot(), Maps);
461 }
462 finally
463 {
464 State?.Dispose();
465 Surface?.Dispose();
466 }
467 }
468
473 public event EventHandler<DrawingEventArgs> OnMeasuringDimensions = null;
474
480 {
481 this.OnMeasuringDimensions?.Raise(this, new DrawingEventArgs(this, State));
482 }
483
487 public event EventHandler<DrawingEventArgs> OnMeasuringPositions = null;
488
494 {
495 this.OnMeasuringPositions?.Raise(this, new DrawingEventArgs(this, State));
496 }
497
498 #endregion
499
503 public event EventHandler<UpdatedEventArgs> OnUpdated = null;
504
508 public bool SupportsAsynchronnousUpdates => !(this.OnUpdated is null);
509
514 public void RaiseUpdated(ILayoutElement Element)
515 {
516 this.OnUpdated?.Raise(this, new UpdatedEventArgs(this, Element));
517 }
518
525 public bool TryGetContent(string ContentId, out object Content)
526 {
527 return this.attachments.TryGetValue(ContentId, out Content);
528 }
529
535 public async Task<bool> DisposeContent(string ContentId)
536 {
537 if (this.attachments.TryGetValue(ContentId, out object Obj))
538 {
539 this.attachments.Remove(ContentId);
540
541 if (Obj is IDisposableAsync DisposableAsync)
542 await DisposableAsync.DisposeAsync();
543 else if (Obj is IDisposable Disposable)
544 Disposable.Dispose();
545
546 return true;
547 }
548 else
549 return false;
550 }
551
557 public string AddContent(object Content)
558 {
559 string ContentId;
560
561 do
562 {
563 ContentId = Guid.NewGuid().ToString();
564 }
565 while (this.attachments.ContainsKey(ContentId));
566
567 this.attachments[ContentId] = Content;
568
569 return ContentId;
570 }
571
577 public async Task AddContent(string ContentId, object Content)
578 {
579 await this.DisposeContent(ContentId);
580 this.attachments[ContentId] = Content;
581 }
582
588 public void AddElementId(string Id, ILayoutElement Element)
589 {
590 this.elementsById[Id] = Element;
591 }
592
599 public bool TryGetElement(string Id, out ILayoutElement Element)
600 {
601 return this.elementsById.TryGetValue(Id, out Element);
602 }
603
607 public void ClearElementIds()
608 {
609 this.elementsById.Clear();
610 }
611
617 public async Task<RenderSettings> GetRenderSettings(Variables Session)
618 {
619 RenderSettings Result = new RenderSettings()
620 {
621 ImageSize = RenderedImageSize.ResizeImage // TODO: Theme colors, font, etc.
622 };
623
624 if (this.root is Model.Layout2D Layout2D)
625 {
627 {
628 DrawingState State = new DrawingState(null, Result, Session);
629
631 if (Width.Ok)
632 {
633 float w = Result.Width;
634 State.CalcDrawingSize(Width.Result, ref w, true, this.root);
635 Result.Width = (int)(w + 0.5f);
636 }
637
639 if (Height.Ok)
640 {
641 float h = Result.Height;
642 State.CalcDrawingSize(Height.Result, ref h, false, this.root);
643 Result.Height = (int)(h + 0.5f);
644 }
645 }
646
648 if (BackgroundId.Ok &&
649 this.TryGetElement(BackgroundId.Result, out ILayoutElement Element) &&
651 {
653 if (Color.Ok)
654 Result.BackgroundColor = Color.Result;
655 }
656 }
657
658 return Result;
659 }
660
667 {
668 KeyValuePair<string, object>[] Attachments = new KeyValuePair<string, object>[this.attachments.Count];
669 int i = 0;
670
671 foreach (KeyValuePair<string, object> P in this.attachments)
672 Attachments[i++] = P;
673
674 Layout2DDocument Result = new Layout2DDocument(Session, Attachments)
675 {
676 root = this.root.Copy(null),
677 Dynamic = this.Dynamic
678 };
679
680 Result.root.RegisterIDs(Session);
681
682 return Result;
683 }
684
688 public bool Dynamic
689 {
690 get;
691 internal set;
692 }
693
698 public string ExportState()
699 {
700 return this.ExportState(XML.WriterSettings(true, true));
701 }
702
708 public string ExportState(XmlWriterSettings Settings)
709 {
710 StringBuilder Output = new StringBuilder();
711 this.ExportState(Output, Settings);
712 return Output.ToString();
713 }
714
720 public void ExportState(StringBuilder Output, XmlWriterSettings Settings)
721 {
722 using (XmlWriter w = XmlWriter.Create(Output, Settings))
723 {
724 this.ExportState(w);
725 w.Flush();
726 }
727 }
728
733 public void ExportState(XmlWriter Output)
734 {
735 Output.WriteStartElement("Layout2DState", "http://waher.se/Schema/Layout2DState.xsd");
736 this.root?.ExportState(Output);
737 Output.WriteEndElement();
738 }
739
745 internal async Task<SKImage> RaiseGetInternalImage(string ContentId)
746 {
747 InteralImageEventArgs e = new InteralImageEventArgs(this, ContentId);
748 await this.OnGetInternalImage.Raise(this, e);
749 return e.Image;
750 }
751
756 public event EventHandlerAsync<InteralImageEventArgs> OnGetInternalImage = null;
757 }
758
759 /* TODO:
760 *
761 * Tree layout
762 * Radix/circular
763 * Directed graphs
764 * Smart Art/Graphs/Layout
765 * Mindmap (Example: https://bhavkaran.com/reconspider/mindmap.html)
766 *
767 * Blur when too small, and dont continue rendering
768 * Clip optimization
769 *
770 */
771
772}
Helps with common XML-related tasks.
Definition: XML.cs:21
static XmlException AnnotateException(XmlException ex)
Creates a new XML Exception object, with reference to the source XML file, for information.
Definition: XML.cs:1762
static XmlWriterSettings WriterSettings(bool Indent, bool OmitXmlDeclaration)
Gets an XML writer settings object.
Definition: XML.cs:1351
static XmlDocument ParseXml(string Xml)
Parses an XML Document from its string representation.
Definition: XML.cs:713
Static class managing the application event log. Applications and services log events on this static ...
Definition: Log.cs:14
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Definition: Log.cs:1657
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:692
Event raised when the layout model has been Drawing internally.
Event raised when the layout model has been updated internally.
Event raised when the layout model has been updated internally.
Contains a 2D layout document.
EventHandlerAsync< InteralImageEventArgs > OnGetInternalImage
Event raised when an internal image is requested, and one is not found in the document or variables.
async Task DisposeAsync()
IDisposableAsync.DisposeAsync
Layout2DDocument Copy(Variables Session)
Makes a copy of the layout document.
static Task< Layout2DDocument > FromStream(Stream Input, Encoding DefaultEncoding, params KeyValuePair< string, object >[] Attachments)
Loads a 2D layout document from a stream.
void ClearElementIds()
Clears registered elements with IDs.
bool Dynamic
If the layout is dynamic (i.e. contains script).
void RaiseUpdated(ILayoutElement Element)
Raises the OnUpdated event.
static Task< Layout2DDocument > FromStream(Stream Input, Encoding DefaultEncoding, bool Preprocess, Variables Session, params KeyValuePair< string, object >[] Attachments)
Loads a 2D layout document from a stream.
static Task< Layout2DDocument > FromFile(string FileName, bool Preprocess, params KeyValuePair< string, object >[] Attachments)
Loads a 2D layout document from a file.
void RaiseMeasuringDimensions(DrawingState State)
Raises the OnMeasuringDimensions event.
bool SupportsAsynchronnousUpdates
If asynchronous updates are supported.
void ExportState(StringBuilder Output, XmlWriterSettings Settings)
Exports the internal state of the layout.
void AddElementId(string Id, ILayoutElement Element)
Adds an element with an ID
string ExportState()
Exports the internal state of the layout.
void ExportState(XmlWriter Output)
Exports the internal state of the layout.
EventHandler< DrawingEventArgs > OnMeasuringDimensions
Event raised when the layout dimensions are being measured. Event can be raised multiple times during...
static Task< Layout2DDocument > FromXml(string Xml, bool Preprocess, params KeyValuePair< string, object >[] Attachments)
Parses a 2D layout document from its XML definition.
static Task< Layout2DDocument > FromXml(XmlDocument Xml, params KeyValuePair< string, object >[] Attachments)
Parses a 2D layout document from its XML definition.
static async Task< Layout2DDocument > FromXml(XmlElement Xml, Variables Session, params KeyValuePair< string, object >[] Attachments)
Parses a 2D layout document from its XML definition.
bool TryGetElement(string Id, out ILayoutElement Element)
Tries to get a layout element, given an ID reference
string AddContent(object Content)
Adds content to the layout.
EventHandler< UpdatedEventArgs > OnUpdated
Event raised when the internal state of the layout has been updated.
async Task< KeyValuePair< SKImage, Map[]> > Render(RenderSettings Settings)
Renders the layout to an image
static readonly string SchemaResourceName
Schema resource name.
static Task< Layout2DDocument > FromXml(XmlDocument Xml, Variables Session, params KeyValuePair< string, object >[] Attachments)
Parses a 2D layout document from its XML definition.
static bool IsLayoutXml(XmlDocument Xml)
Checks if an XML document contains a layout document.
static bool IsLayoutXml(XmlElement Xml)
Checks if an XML element contains a layout document.
async Task< bool > DisposeContent(string ContentId)
Disposes of attached content, given its ID.
EventHandler< DrawingEventArgs > OnMeasuringPositions
Event raised when the layout positions are being measured. Event is eaised once after dimensions have...
async Task AddContent(string ContentId, object Content)
Adds content to the layout.
const string Namespace
http://waher.se/Schema/Layout2D.xsd
static Task< Layout2DDocument > FromFile(string FileName, params KeyValuePair< string, object >[] Attachments)
Loads a 2D layout document from a file.
static Task< Layout2DDocument > FromXml(string Xml, params KeyValuePair< string, object >[] Attachments)
Parses a 2D layout document from its XML definition.
static async Task< Layout2DDocument > FromXml(string Xml, bool Preprocess, Variables Session, params KeyValuePair< string, object >[] Attachments)
Parses a 2D layout document from its XML definition.
bool TryGetContent(string ContentId, out object Content)
Tries to get content from attached content.
static Task< Layout2DDocument > FromStream(Stream Input, Encoding DefaultEncoding, bool Preprocess, params KeyValuePair< string, object >[] Attachments)
Loads a 2D layout document from a stream.
void RaiseMeasuringPositions(DrawingState State)
Raises the OnMeasuringPositions event.
string ExportState(XmlWriterSettings Settings)
Exports the internal state of the layout.
async Task< RenderSettings > GetRenderSettings(Variables Session)
Creates a render settings object.
static Task< Layout2DDocument > FromXml(XmlElement Xml, params KeyValuePair< string, object >[] Attachments)
Parses a 2D layout document from its XML definition.
static async Task< Layout2DDocument > FromFile(string FileName, bool Preprocess, Variables Session, params KeyValuePair< string, object >[] Attachments)
Loads a 2D layout document from a file.
Contains information about an actionable area in a generated image.
Definition: Map.cs:7
Manages an attribute value or expression.
Definition: Attribute.cs:14
bool Defined
If the attribute is defined.
Definition: Attribute.cs:144
static async Task< EvaluationResult< T > > TryEvaluate(Attribute< T > Attribute, Variables Session)
Tries to evaluate the attribute value.
Definition: Attribute.cs:256
SKCanvas Canvas
Current drawing canvas.
void Dispose()
IDisposable.Dispose
Definition: DrawingState.cs:77
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.
Root node for two-dimensional layouts
Definition: Layout2D.cs:15
StringAttribute BackgroundColorAttribute
Background Color
Definition: Layout2D.cs:76
LengthAttribute WidthAttribute
Width
Definition: LayoutArea.cs:51
LengthAttribute HeightAttribute
Height
Definition: LayoutArea.cs:60
SKColor BackgroundColor
Background color
RenderedImageSize ImageSize
Offset along X-axis.
Contains static methods
Definition: Files.cs:14
static async Task< string > ReadAllTextAsync(string FileName)
Reads a text file asynchronously.
Definition: Files.cs:84
Static class managing binary representations of strings.
Definition: Strings.cs:10
static string GetString(byte[] Data, int Offset, int Count, Encoding DefaultEncoding)
Gets a string from its binary representation, taking any Byte Order Mark (BOM) into account.
Definition: Strings.cs:148
Static class that dynamically manages types and interfaces available in the runtime environment.
Definition: Types.cs:15
static object Instantiate(Type Type, params object[] Arguments)
Returns an instance of the type Type . If one needs to be created, it is. If the constructor requires...
Definition: Types.cs:1454
static Type[] GetTypesImplementingInterface(string InterfaceFullName)
Gets all types implementing a given interface.
Definition: Types.cs:85
Class managing a script expression.
Definition: Expression.cs:41
static Task< string > TransformAsync(string s, string StartDelimiter, string StopDelimiter, Variables Variables)
Transforms a string by executing embedded script.
Definition: Expression.cs:4652
Collection of variables.
Definition: Variables.cs:25
Interface for asynchronously disposable objects.
Base interface for all layout elements.
float? Bottom
Bottom coordinate of bounding box, after measurement.
Task RegisterIDs(Variables Session)
Registers any IDs defined with the encapsulating document.
ILayoutElement Copy(ILayoutElement Parent)
Creates a copy of the layout element.
float? Right
Right coordinate of bounding box, after measurement.
Task Draw(DrawingState State)
Draws layout entities.
Task MeasureDimensions(DrawingState State)
Measures layout entities and defines unassigned properties, related to dimensions....
string LocalName
Local name of type of element.
Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
float? Left
Left coordinate of bounding box, after measurement.
ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
Creates a new instance of the layout element.
string ExportState()
Exports the internal state of the layout.
void MeasurePositions(DrawingState State)
Measures layout entities and defines unassigned properties, related to positions.
StringAttribute IdAttribute
ID Attribute
RenderedImageSize
Affects the size of the rendered image.