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 System;
2using System.Threading.Tasks;
3using System.Xml;
6
8{
12 public abstract class EmbeddedText : LayoutElement, IFlowingText
13 {
14 private IFlowingText[] text;
15
22 : base(Document, Parent)
23 {
24 }
25
29 public override void Dispose()
30 {
31 base.Dispose();
32
33 if (!(this.text is null))
34 {
35 foreach (ILayoutElement E in this.text)
36 E.Dispose();
37 }
38 }
39
44 public override async Task FromXml(XmlElement Input)
45 {
46 await base.FromXml(Input);
47
49
50 foreach (XmlNode Node in Input.ChildNodes)
51 {
52 if (Node is XmlElement E)
53 {
54 ILayoutElement Child = await this.Document.CreateElement(E, this);
55
56 if (Child is IFlowingText Text)
57 Children.Add(Text);
58 else
59 throw new LayoutSyntaxException("Not flowing text: " + E.NamespaceURI + "#" + E.LocalName);
60 }
61 }
62
63 this.text = Children.ToArray();
64 }
65
70 public override void ExportChildren(XmlWriter Output)
71 {
72 base.ExportChildren(Output);
73
74 if (!(this.text is null))
75 {
76 foreach (ILayoutElement Child in this.text)
77 Child.ToXml(Output);
78 }
79 }
80
85 public override void CopyContents(ILayoutElement Destination)
86 {
87 base.CopyContents(Destination);
88
89 if (Destination is EmbeddedText Dest)
90 {
91 if (!(this.text is null))
92 {
93 int i, c = this.text.Length;
94
95 IFlowingText[] Children = new IFlowingText[c];
96
97 for (i = 0; i < c; i++)
98 Children[i] = this.text[i].Copy(Dest) as IFlowingText;
99
100 Dest.text = Children;
101 }
102 }
103 }
104
110 public virtual async Task MeasureSegments(ChunkedList<Segment> Segments, DrawingState State)
111 {
112 if (!(this.text is null))
113 {
114 foreach (IFlowingText Text in this.text)
115 {
116 await Text.MeasureDimensions(State);
117 if (Text.IsVisible)
118 await Text.MeasureSegments(Segments, State);
119 }
120 }
121 }
122
127 public override void ExportStateChildren(XmlWriter Output)
128 {
129 if (!(this.text is null))
130 {
131 foreach (ILayoutElement Child in this.text)
132 Child.ExportState(Output);
133 }
134 }
135
136 }
137}
Contains a 2D layout document.
Abstract base class of embedded text elements in flowing text.
Definition: EmbeddedText.cs:13
virtual async Task MeasureSegments(ChunkedList< Segment > Segments, DrawingState State)
Measures text segments to a list of segments.
EmbeddedText(Layout2DDocument Document, ILayoutElement Parent)
Abstract base class of embedded text elements in flowing text.
Definition: EmbeddedText.cs:21
override async Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
Definition: EmbeddedText.cs:44
override void ExportChildren(XmlWriter Output)
Exports child elements to XML.
Definition: EmbeddedText.cs:70
override void CopyContents(ILayoutElement Destination)
Copies contents (attributes and children) to the destination element.
Definition: EmbeddedText.cs:85
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(ChunkedList< Segment > Segments, DrawingState State)
Measures text segments to a list of segments.
Definition: Text.cs:90
Abstract base class for layout elements.
async Task MeasureDimensions(DrawingState State)
Measures layout entities and defines unassigned properties, related to dimensions....
ILayoutElement Copy(ILayoutElement Parent)
Creates a copy of the layout element.
Layout2DDocument Document
Layout document.
bool IsVisible
If the element is visible or not.
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
Base interface for all layout elements.
string ExportState()
Exports the internal state of the layout.
string ToXml()
Exports the element to XML.