Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
EmbeddedText.cs
1using SkiaSharp;
2using System;
3using System.Collections.Generic;
4using System.Threading.Tasks;
5using System.Xml;
7
9{
13 public abstract class EmbeddedText : LayoutElement, IFlowingText
14 {
15 private IFlowingText[] text;
16
23 : base(Document, Parent)
24 {
25 }
26
30 public override void Dispose()
31 {
32 base.Dispose();
33
34 if (!(this.text is null))
35 {
36 foreach (ILayoutElement E in this.text)
37 E.Dispose();
38 }
39 }
40
45 public override async Task FromXml(XmlElement Input)
46 {
47 await base.FromXml(Input);
48
49 List<IFlowingText> Children = new List<IFlowingText>();
50
51 foreach (XmlNode Node in Input.ChildNodes)
52 {
53 if (Node is XmlElement E)
54 {
55 ILayoutElement Child = await this.Document.CreateElement(E, this);
56
57 if (Child is IFlowingText Text)
58 Children.Add(Text);
59 else
60 throw new LayoutSyntaxException("Not flowing text: " + E.NamespaceURI + "#" + E.LocalName);
61 }
62 }
63
64 this.text = Children.ToArray();
65 }
66
71 public override void ExportChildren(XmlWriter Output)
72 {
73 base.ExportChildren(Output);
74
75 if (!(this.text is null))
76 {
77 foreach (ILayoutElement Child in this.text)
78 Child.ToXml(Output);
79 }
80 }
81
86 public override void CopyContents(ILayoutElement Destination)
87 {
88 base.CopyContents(Destination);
89
90 if (Destination is EmbeddedText Dest)
91 {
92 if (!(this.text is null))
93 {
94 int i, c = this.text.Length;
95
96 IFlowingText[] Children = new IFlowingText[c];
97
98 for (i = 0; i < c; i++)
99 Children[i] = this.text[i].Copy(Dest) as IFlowingText;
100
101 Dest.text = Children;
102 }
103 }
104 }
105
111 public virtual async Task MeasureSegments(List<Segment> Segments, DrawingState State)
112 {
113 if (!(this.text is null))
114 {
115 foreach (IFlowingText Text in this.text)
116 await Text.MeasureSegments(Segments, State);
117 }
118 }
119
124 public override void ExportStateChildren(XmlWriter Output)
125 {
126 if (!(this.text is null))
127 {
128 foreach (ILayoutElement Child in this.text)
129 Child.ExportState(Output);
130 }
131 }
132
133 }
134}
Contains a 2D layout document.
Abstract base class of embedded text elements in flowing text.
Definition: EmbeddedText.cs:14
EmbeddedText(Layout2DDocument Document, ILayoutElement Parent)
Abstract base class of embedded text elements in flowing text.
Definition: EmbeddedText.cs:22
override async Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
Definition: EmbeddedText.cs:45
override void ExportChildren(XmlWriter Output)
Exports child elements to XML.
Definition: EmbeddedText.cs:71
virtual async Task MeasureSegments(List< Segment > Segments, DrawingState State)
Measures text segments to a list of segments.
override void CopyContents(ILayoutElement Destination)
Copies contents (attributes and children) to the destination element.
Definition: EmbeddedText.cs:86
override void ExportStateChildren(XmlWriter Output)
Exports the current state of child nodes of the current element.
Represents a segment of text in flowing text.
Definition: Text.cs:14
async Task MeasureSegments(List< Segment > Segments, DrawingState State)
Measures text segments to a list of segments.
Definition: Text.cs:90
Abstract base class for layout elements.
ILayoutElement Copy(ILayoutElement Parent)
Creates a copy of the layout element.
Layout2DDocument Document
Layout document.
Base interface for all layout elements.
string ExportState()
Exports the internal state of the layout.
string ToXml()
Exports the element to XML.