1using System.Globalization;
2using System.Windows.Input;
28 [CollectionName(
"ChatMessages")]
30 [Index(
"RemoteBareJid",
"Created")]
31 [Index(
"RemoteBareJid",
"RemoteObjectId")]
34 private string? objectId =
null;
36 private DateTime created = DateTime.MinValue;
37 private DateTime updated = DateTime.MinValue;
38 private string? remoteObjectId =
null;
40 private string plainText =
string.
Empty;
41 private string markdown =
string.
Empty;
42 private string html =
string.
Empty;
43 private object? parsedXaml =
null;
53 this.Updated = DateTime.MinValue;
55 this.XmppUriClicked =
new Command(async Parameter => await this.ExecuteUriClicked(Parameter,
UriScheme.Xmpp));
56 this.IotIdUriClicked =
new Command(async Parameter => await this.ExecuteUriClicked(Parameter,
UriScheme.IotId));
57 this.IotScUriClicked =
new Command(async Parameter => await this.ExecuteUriClicked(Parameter,
UriScheme.IotSc));
58 this.NeuroFeatureUriClicked =
new Command(async Parameter => await this.ExecuteUriClicked(Parameter,
UriScheme.NeuroFeature));
59 this.IotDiscoUriClicked =
new Command(async Parameter => await this.ExecuteUriClicked(Parameter,
UriScheme.IotDisco));
60 this.EDalerUriClicked =
new Command(async Parameter => await this.ExecuteUriClicked(Parameter,
UriScheme.EDaler));
61 this.HyperlinkClicked =
new Command(async Parameter => await ExecuteHyperlinkClicked(Parameter));
65 public string UniqueName => this.ObjectId ??
string.Empty;
74 set => this.objectId = value;
82 get => this.remoteBareJid;
83 set => this.remoteBareJid = value;
92 set => this.created = value;
98 [DefaultValueDateTimeMinValue]
102 set => this.updated = value;
110 get => this.remoteObjectId;
111 set => this.remoteObjectId = value;
119 get => this.messageType;
120 set => this.messageType = value;
128 get => this.plainText;
129 set => this.plainText = value;
137 get => this.markdown;
138 set => this.markdown = value;
150 this.parsedXaml =
null;
157 public string StyleId =>
"Message" + this.messageType.ToString();
165 this.chatView = View;
167 if (!
string.IsNullOrEmpty(this.markdown))
169 this.parsedXaml = await this.markdown.MarkdownToParsedXaml();
170 if (this.parsedXaml is VerticalStackLayout Layout)
175 VerticalStackLayout Layout =
new()
177 StyleId =
string.IsNullOrEmpty(this.html) &&
string.IsNullOrEmpty(this.plainText) ? string.Empty : this.StyleId
180 if (!
string.IsNullOrEmpty(this.html))
182 Layout.Children.Add(
new Label()
185 TextType = TextType.Html
188 else if (!
string.IsNullOrEmpty(this.plainText))
190 Layout.Children.Add(
new Label()
192 Text = this.plainText,
193 TextType = TextType.Text
196 this.parsedXaml = Layout;
240 private Task ExecuteUriClicked(
object Parameter,
UriScheme Scheme)
242 if (Parameter is
string Uri && this.chatView is not
null)
245 return Task.CompletedTask;
248 private static async Task ExecuteHyperlinkClicked(
object Parameter)
250 if (Parameter is not
string Url)
259 return this.created.ToString(CultureInfo.CurrentCulture);
The Application class, representing an instance of the Neuro-Access app.
static Task< bool > OpenUrlAsync(string Url)
Opens an URL in the application.
async Task GenerateXaml(IChatView View)
Parses the XAML in the message.
Command HyperlinkClicked
Command executed when a hyperlink in rendered markdown has been clicked.
object? ParsedXaml
Parsed XAML
ChatMessage()
Chat Messages
Command XmppUriClicked
Command executed when a multi-media-link with the xmpp URI scheme is clicked.
DateTime Created
When message was created
string Html
HTML of message
string? RemoteObjectId
Remote Objcet ID. If sent by the local user, value will be null or empty.
CaseInsensitiveString? RemoteBareJid
Remote Bare JID
Command IotDiscoUriClicked
Command executed when a multi-media-link with the iotdisco URI scheme is clicked.
Command IotIdUriClicked
Command executed when a multi-media-link with the iotid URI scheme is clicked.
string UniqueName
Unique name used to compare items.
string StyleId
Message Style ID
DateTime Updated
When message was created
Command IotScUriClicked
Command executed when a multi-media-link with the iotsc URI scheme is clicked.
string PlainText
Plain text of message
override string ToString()
string Markdown
Markdown of message
Command EDalerUriClicked
Command executed when a multi-media-link with the edaler URI scheme is clicked.
string? ObjectId
Object ID
Command NeuroFeatureUriClicked
Command executed when a multi-media-link with the nfeat URI scheme is clicked.
Represents a case-insensitive string.
static readonly CaseInsensitiveString Empty
Empty case-insensitive string
Interfaces for views displaying markdown
Task ExecuteUriClicked(string Uri, UriScheme Scheme)
Called when a special Multi-media URI link has been clicked.
TypeNameSerialization
How the type name should be serialized.