Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ImageInternal.cs
1using System.Threading.Tasks;
2using System.Xml;
3using SkiaSharp;
5
7{
11 public class ImageInternal : Image
12 {
13 private StringAttribute cid;
14
21 : base(Document, Parent)
22 {
23 }
24
28 public override string LocalName => "ImageInternal";
29
34 {
35 get => this.cid;
36 set => this.cid = value;
37 }
38
43 public override Task FromXml(XmlElement Input)
44 {
45 this.cid = new StringAttribute(Input, "cid", this.Document);
46 return base.FromXml(Input);
47 }
48
53 public override void ExportAttributes(XmlWriter Output)
54 {
55 base.ExportAttributes(Output);
56
57 this.cid?.Export(Output);
58 }
59
66 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
67 {
68 return new ImageInternal(Document, Parent);
69 }
70
75 public override void CopyContents(ILayoutElement Destination)
76 {
77 base.CopyContents(Destination);
78
79 if (Destination is ImageInternal Dest)
80 Dest.cid = this.cid?.CopyIfNotPreset(Destination.Document);
81 }
82
89 protected override async Task<SKImage> LoadImage(DrawingState State)
90 {
91 string ContentId = await this.cid.Evaluate(State.Session, string.Empty);
92 if (!string.IsNullOrEmpty(ContentId) &&
93 this.Document.TryGetContent(ContentId, out object Content) &&
94 Content is SKImage Image)
95 {
96 return Image;
97 }
98 else
99 return null;
100 }
101
106 public override void ExportStateAttributes(XmlWriter Output)
107 {
108 base.ExportStateAttributes(Output);
109
110 this.cid?.ExportState(Output);
111 }
112 }
113}
Contains a 2D layout document.
bool TryGetContent(string ContentId, out object Content)
Tries to get content from attached content.
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
StringAttribute CopyIfNotPreset(Layout2DDocument ForDocument)
Copies the attribute object if undefined, or defined by an expression. Returns a reference to itself,...
Variables Session
Current session.
Definition: DrawingState.cs:91
Abstract base class for images.
Definition: Image.cs:12
An image provided by the caller, identified by a content id.
override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
Creates a new instance of the layout element.
override void ExportAttributes(XmlWriter Output)
Exports attributes to XML.
ImageInternal(Layout2DDocument Document, ILayoutElement Parent)
An image provided by the caller, identified by a content id.
override Task FromXml(XmlElement Input)
Populates the element (including children) with information from its XML definition.
override void ExportStateAttributes(XmlWriter Output)
Exports the local attributes of the current element.
override async Task< SKImage > LoadImage(DrawingState State)
Loads the image defined by the element.
override string LocalName
Local name of type of element.
override void CopyContents(ILayoutElement Destination)
Copies contents (attributes and children) to the destination element.
Layout2DDocument Document
Layout document.
Base interface for all layout elements.
Layout2DDocument Document
Layout document.