StephaneLenclud@236: using Ear = SharpLib.Ear;
StephaneLenclud@236: using SharpLib.Ear;
StephaneLenclud@225: using System;
StephaneLenclud@225: using System.Collections.Generic;
StephaneLenclud@225: using System.Drawing;
StephaneLenclud@225: using System.Linq;
StephaneLenclud@225: using System.Runtime.Serialization;
StephaneLenclud@225: using System.Text;
StephaneLenclud@225: using System.Threading;
StephaneLenclud@225: using System.Threading.Tasks;
StephaneLenclud@225:
StephaneLenclud@225: namespace SharpDisplayManager
StephaneLenclud@225: {
StephaneLenclud@225:
StephaneLenclud@225:
StephaneLenclud@225: [DataContract]
StephaneLenclud@231: [AttributeObject(Id = "Display.Message", Name = "Display Message", Description = "Shows a message on your internal display.")]
StephaneLenclud@236: class ActionDisplayMessage : Ear.Action
StephaneLenclud@225: {
StephaneLenclud@225: [DataMember]
StephaneLenclud@231: [AttributeObjectProperty(
StephaneLenclud@225: Id = "Display.Message.Duration",
StephaneLenclud@225: Name = "Duration (ms)",
StephaneLenclud@225: Description = "Specifies the number of milliseconds this message should be displayed.",
StephaneLenclud@225: Minimum = "1", //Otherwise time throws an exception
StephaneLenclud@225: Maximum = "30000",
StephaneLenclud@225: Increment = "1000"
StephaneLenclud@225: )]
StephaneLenclud@225: public int DurationInMilliseconds { get; set; } = 5000;
StephaneLenclud@225:
StephaneLenclud@225:
StephaneLenclud@225: [DataMember]
StephaneLenclud@231: [AttributeObjectProperty(
StephaneLenclud@225: Id = "Display.Message.PrimaryText",
StephaneLenclud@225: Name = "Primary Text",
StephaneLenclud@225: Description = "The primary text of this message."
StephaneLenclud@225: )]
StephaneLenclud@225: public string PrimaryText { get; set; } = "Your message";
StephaneLenclud@225:
StephaneLenclud@225: [DataMember]
StephaneLenclud@231: [AttributeObjectProperty(
StephaneLenclud@225: Id = "Display.Message.SecondaryText",
StephaneLenclud@225: Name = "Secondary Text",
StephaneLenclud@225: Description = "The secondary text of this message."
StephaneLenclud@225: )]
StephaneLenclud@225: public string SecondaryText { get; set; } = "";
StephaneLenclud@225:
StephaneLenclud@225:
StephaneLenclud@225: ///
StephaneLenclud@225: ///
StephaneLenclud@225: ///
StephaneLenclud@225: ///
StephaneLenclud@225: public override string Brief()
StephaneLenclud@225: {
StephaneLenclud@225: string brief = Name + ": " + PrimaryText;
StephaneLenclud@225: if (!string.IsNullOrEmpty(SecondaryText))
StephaneLenclud@225: {
StephaneLenclud@225: brief += " - " + SecondaryText;
StephaneLenclud@225: }
StephaneLenclud@225:
StephaneLenclud@225: brief += " ( " + DurationInMilliseconds.ToString() + " ms )";
StephaneLenclud@225:
StephaneLenclud@225: return brief;
StephaneLenclud@225: }
StephaneLenclud@225:
StephaneLenclud@225: ///
StephaneLenclud@225: ///
StephaneLenclud@225: ///
StephaneLenclud@228: protected override void DoExecute()
StephaneLenclud@225: {
StephaneLenclud@225: StartMessageClient();
StephaneLenclud@225: }
StephaneLenclud@225:
StephaneLenclud@225: ///
StephaneLenclud@225: /// Just launch our idle client.
StephaneLenclud@225: ///
StephaneLenclud@225: private void StartMessageClient()
StephaneLenclud@225: {
StephaneLenclud@225: Thread clientThread = new Thread(SharpDisplayClientMessage.Program.MainWithParams);
StephaneLenclud@225: SharpDisplayClientMessage.StartParams myParams =
StephaneLenclud@225: new SharpDisplayClientMessage.StartParams(PrimaryText, SecondaryText, DurationInMilliseconds);
StephaneLenclud@225: clientThread.Start(myParams);
StephaneLenclud@225: }
StephaneLenclud@225:
StephaneLenclud@225:
StephaneLenclud@225: }
StephaneLenclud@225:
StephaneLenclud@225: }