Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SolidBackground.cs
1using SkiaSharp;
2using System.Threading.Tasks;
3using System.Xml;
5
7{
12 {
13 private ColorAttribute color;
14
21 : base(Document, Parent)
22 {
23 }
24
28 public override string LocalName => "SolidBackground";
29
34 {
35 get => this.color;
36 set => this.color = value;
37 }
38
43 public override Task FromXml(XmlElement Input)
44 {
45 this.color = new ColorAttribute(Input, "color", this.Document);
46 return base.FromXml(Input);
47 }
48
53 public override void ExportAttributes(XmlWriter Output)
54 {
55 base.ExportAttributes(Output);
56
57 this.color?.Export(Output);
58 }
59
66 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
67 {
68 return new SolidBackground(Document, Parent);
69 }
70
75 public override void CopyContents(ILayoutElement Destination)
76 {
77 base.CopyContents(Destination);
78
79 if (Destination is SolidBackground Dest)
80 Dest.color = this.color?.CopyIfNotPreset(Destination.Document);
81 }
82
88 public override async Task DoMeasureDimensions(DrawingState State)
89 {
90 await base.DoMeasureDimensions(State);
91
92 if (this.paint is null)
93 {
94 EvaluationResult<SKColor> Color = await this.color.TryEvaluate(State.Session);
95 if (Color.Ok)
96 {
97 this.paint = new SKPaint()
98 {
99 IsAntialias = true,
100 Style = SKPaintStyle.Fill,
101 Color = Color.Result
102 };
103
104 this.defined = true;
105 }
106 }
107 }
108
113 public override void ExportStateAttributes(XmlWriter Output)
114 {
115 base.ExportStateAttributes(Output);
116
117 this.color?.ExportState(Output);
118 }
119
120 }
121}
Contains a 2D layout document.
void Export(XmlWriter Output)
Exports the attribute.
Definition: Attribute.cs:187
void ExportState(XmlWriter Output)
Exports the state of the attribute.
Definition: Attribute.cs:199
static async Task< EvaluationResult< T > > TryEvaluate(Attribute< T > Attribute, Variables Session)
Tries to evaluate the attribute value.
Definition: Attribute.cs:256
ColorAttribute CopyIfNotPreset(Layout2DDocument ForDocument)
Copies the attribute object if undefined, or defined by an expression. Returns a reference to itself,...
Abstract base class for backgrounds.
Definition: Background.cs:10
override void ExportAttributes(XmlWriter Output)
Exports attributes to XML.
override Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
SolidBackground(Layout2DDocument Document, ILayoutElement Parent)
A solid background
override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
Creates a new instance of the layout element.
override string LocalName
Local name of type of element.
override async Task DoMeasureDimensions(DrawingState State)
Measures layout entities and defines unassigned properties, related to dimensions.
override void CopyContents(ILayoutElement Destination)
Copies contents (attributes and children) to the destination element.
override void ExportStateAttributes(XmlWriter Output)
Exports the local attributes of the current element.
Variables Session
Current session.
Definition: DrawingState.cs:89
Layout2DDocument Document
Layout document.
Base interface for all layout elements.
Layout2DDocument Document
Layout document.