Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ScriptMediaParameterNode.cs
1using System;
2using System.Text.RegularExpressions;
3using System.Threading.Tasks;
4using Waher.Content;
12using Waher.Script;
14
16{
21 {
22 private string url;
23 private string contentType;
24
29 : base()
30 {
31 }
32
36 [Page(2, "Script", 100)]
37 [Header(77, "URL:")]
38 [ToolTip(78, "URL to media.")]
39 [Required]
40 public string Url
41 {
42 get => this.url;
43 set
44 {
45 if (!Uri.TryCreate(value, UriKind.Absolute, out Uri _))
46 throw new NotSupportedException("Invalid URL.");
47
48 this.url = value;
49 }
50 }
51
55 [Page(2, "Script", 100)]
56 [Header(63, "Content-Type:")]
57 [ToolTip(79, "Content-Type of media.")]
58 [Required]
59 public string ContentType
60 {
61 get => this.contentType;
62 set
63 {
64 if (!string.IsNullOrEmpty(value) && (
67 {
68 throw new NotSupportedException("Content-Type not supported.");
69 }
70
71 this.contentType = value;
72 }
73 }
74
78 [Page(2, "Script", 100)]
79 [Header(80, "Width:")]
80 [ToolTip(81, "Width of media.")]
81 public ushort? Width { get; set; }
82
86 [Page(2, "Script", 100)]
87 [Header(82, "Height:")]
88 [ToolTip(83, "Height of media.")]
89 public ushort? Height { get; set; }
90
96 public override Task<string> GetTypeNameAsync(Language Language)
97 {
98 return Language.GetStringAsync(typeof(ScriptNode), 84, "Media parameter");
99 }
100
107 public override Task PopulateForm(DataForm Parameters, Language Language, object Value)
108 {
109 Media Media = new Media(this.url, this.contentType, this.Width, this.Height);
110 MediaField Field = new MediaField(this.ParameterName, this.Label, Media);
111
112 Parameters.Add(Field);
113
114 Page Page = Parameters.GetPage(this.Page);
115 Page.Add(Field);
116
117 return Task.CompletedTask;
118 }
119
129 public override Task SetParameter(DataForm Parameters, Language Language, bool OnlySetChanged, Variables Values,
131 {
132 return Task.CompletedTask;
133 }
134
135 }
136}
Static class managing encoding and decoding of internet content.
static string[] CanDecodeContentTypes
Internet content types that can be decoded.
static bool IsAccepted(string ContentType, params string[] AcceptedContentTypes)
Checks if a given content type is acceptable.
static string[] CanEncodeContentTypes
Internet content types that can be encoded.
Static class managing editable parameters in objects. Editable parameters are defined by using the at...
Definition: Parameters.cs:25
Implements support for data forms. Data Forms are defined in the following XEPs:
Definition: DataForm.cs:42
Base class for form fields
Definition: Field.cs:16
Class managing a page in a data form layout.
Definition: Page.cs:11
void Add(LayoutElement Element)
Adds a layout element.
Definition: Section.cs:135
Class containing information about media content in a data form.
Definition: Media.cs:18
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
Collection of variables.
Definition: Variables.cs:25
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
override Task SetParameter(DataForm Parameters, Language Language, bool OnlySetChanged, Variables Values, SetEditableFormResult Result)
Sets the parameters of the object, based on contents in the data form.
ScriptMediaParameterNode()
Represents a media-valued script parameter.
override Task PopulateForm(DataForm Parameters, Language Language, object Value)
Populates a data form with parameters for the object.
Node defined by script.
Definition: ScriptNode.cs:19
Represents a parameter on a command.
bool Required
If parameter is required.