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.Threading.Tasks;
3using Waher.Content;
9using Waher.Script;
11
13{
18 {
19 private string url;
20 private string contentType;
21
26 : base()
27 {
28 }
29
33 [Page(2, "Script", 100)]
34 [Header(77, "URL:")]
35 [ToolTip(78, "URL to media.")]
36 [Required]
37 public string Url
38 {
39 get => this.url;
40 set
41 {
42 if (!Uri.TryCreate(value, UriKind.Absolute, out Uri _))
43 throw new NotSupportedException("Invalid URL.");
44
45 this.url = value;
46 }
47 }
48
52 [Page(2, "Script", 100)]
53 [Header(63, "Content-Type:")]
54 [ToolTip(79, "Content-Type of media.")]
55 [Required]
56 public string ContentType
57 {
58 get => this.contentType;
59 set
60 {
61 if (!string.IsNullOrEmpty(value) && (
64 {
65 throw new NotSupportedException("Content-Type not supported.");
66 }
67
68 this.contentType = value;
69 }
70 }
71
75 [Page(2, "Script", 100)]
76 [Header(80, "Width:")]
77 [ToolTip(81, "Width of media.")]
78 public ushort? Width { get; set; }
79
83 [Page(2, "Script", 100)]
84 [Header(82, "Height:")]
85 [ToolTip(83, "Height of media.")]
86 public ushort? Height { get; set; }
87
93 public override Task<string> GetTypeNameAsync(Language Language)
94 {
95 return Language.GetStringAsync(typeof(ScriptNode), 84, "Media parameter");
96 }
97
104 public override Task PopulateForm(DataForm Parameters, Language Language, object Value)
105 {
106 Media Media = new Media(this.url, this.contentType, this.Width, this.Height);
107 MediaField Field = new MediaField(this.ParameterName, this.Label, Media);
108
109 Parameters.Add(Field);
110
111 Page Page = Parameters.GetPage(this.Page);
112 Page.Add(Field);
113
114 return Task.CompletedTask;
115 }
116
126 public override Task SetParameter(DataForm Parameters, Language Language, bool OnlySetChanged, Variables Values,
128 {
129 return Task.CompletedTask;
130 }
131
132 }
133}
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:26
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:17
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.
Definition: ImplTypes.g.cs:58