StephaneLenclud@225
|
1 |
using SharpLib.Ear;
|
StephaneLenclud@225
|
2 |
using System;
|
StephaneLenclud@225
|
3 |
using System.Collections.Generic;
|
StephaneLenclud@225
|
4 |
using System.Drawing;
|
StephaneLenclud@225
|
5 |
using System.Linq;
|
StephaneLenclud@225
|
6 |
using System.Runtime.Serialization;
|
StephaneLenclud@225
|
7 |
using System.Text;
|
StephaneLenclud@225
|
8 |
using System.Threading;
|
StephaneLenclud@225
|
9 |
using System.Threading.Tasks;
|
StephaneLenclud@225
|
10 |
|
StephaneLenclud@225
|
11 |
namespace SharpDisplayManager
|
StephaneLenclud@225
|
12 |
{
|
StephaneLenclud@225
|
13 |
|
StephaneLenclud@225
|
14 |
|
StephaneLenclud@225
|
15 |
[DataContract]
|
StephaneLenclud@231
|
16 |
[AttributeObject(Id = "Display.Message", Name = "Display Message", Description = "Shows a message on your internal display.")]
|
StephaneLenclud@225
|
17 |
class ActionDisplayMessage : SharpLib.Ear.Action
|
StephaneLenclud@225
|
18 |
{
|
StephaneLenclud@225
|
19 |
[DataMember]
|
StephaneLenclud@231
|
20 |
[AttributeObjectProperty(
|
StephaneLenclud@225
|
21 |
Id = "Display.Message.Duration",
|
StephaneLenclud@225
|
22 |
Name = "Duration (ms)",
|
StephaneLenclud@225
|
23 |
Description = "Specifies the number of milliseconds this message should be displayed.",
|
StephaneLenclud@225
|
24 |
Minimum = "1", //Otherwise time throws an exception
|
StephaneLenclud@225
|
25 |
Maximum = "30000",
|
StephaneLenclud@225
|
26 |
Increment = "1000"
|
StephaneLenclud@225
|
27 |
)]
|
StephaneLenclud@225
|
28 |
public int DurationInMilliseconds { get; set; } = 5000;
|
StephaneLenclud@225
|
29 |
|
StephaneLenclud@225
|
30 |
|
StephaneLenclud@225
|
31 |
[DataMember]
|
StephaneLenclud@231
|
32 |
[AttributeObjectProperty(
|
StephaneLenclud@225
|
33 |
Id = "Display.Message.PrimaryText",
|
StephaneLenclud@225
|
34 |
Name = "Primary Text",
|
StephaneLenclud@225
|
35 |
Description = "The primary text of this message."
|
StephaneLenclud@225
|
36 |
)]
|
StephaneLenclud@225
|
37 |
public string PrimaryText { get; set; } = "Your message";
|
StephaneLenclud@225
|
38 |
|
StephaneLenclud@225
|
39 |
[DataMember]
|
StephaneLenclud@231
|
40 |
[AttributeObjectProperty(
|
StephaneLenclud@225
|
41 |
Id = "Display.Message.SecondaryText",
|
StephaneLenclud@225
|
42 |
Name = "Secondary Text",
|
StephaneLenclud@225
|
43 |
Description = "The secondary text of this message."
|
StephaneLenclud@225
|
44 |
)]
|
StephaneLenclud@225
|
45 |
public string SecondaryText { get; set; } = "";
|
StephaneLenclud@225
|
46 |
|
StephaneLenclud@225
|
47 |
|
StephaneLenclud@225
|
48 |
/// <summary>
|
StephaneLenclud@225
|
49 |
///
|
StephaneLenclud@225
|
50 |
/// </summary>
|
StephaneLenclud@225
|
51 |
/// <returns></returns>
|
StephaneLenclud@225
|
52 |
public override string Brief()
|
StephaneLenclud@225
|
53 |
{
|
StephaneLenclud@225
|
54 |
string brief = Name + ": " + PrimaryText;
|
StephaneLenclud@225
|
55 |
if (!string.IsNullOrEmpty(SecondaryText))
|
StephaneLenclud@225
|
56 |
{
|
StephaneLenclud@225
|
57 |
brief += " - " + SecondaryText;
|
StephaneLenclud@225
|
58 |
}
|
StephaneLenclud@225
|
59 |
|
StephaneLenclud@225
|
60 |
brief += " ( " + DurationInMilliseconds.ToString() + " ms )";
|
StephaneLenclud@225
|
61 |
|
StephaneLenclud@225
|
62 |
return brief;
|
StephaneLenclud@225
|
63 |
}
|
StephaneLenclud@225
|
64 |
|
StephaneLenclud@225
|
65 |
/// <summary>
|
StephaneLenclud@225
|
66 |
///
|
StephaneLenclud@225
|
67 |
/// </summary>
|
StephaneLenclud@228
|
68 |
protected override void DoExecute()
|
StephaneLenclud@225
|
69 |
{
|
StephaneLenclud@225
|
70 |
StartMessageClient();
|
StephaneLenclud@225
|
71 |
}
|
StephaneLenclud@225
|
72 |
|
StephaneLenclud@225
|
73 |
/// <summary>
|
StephaneLenclud@225
|
74 |
/// Just launch our idle client.
|
StephaneLenclud@225
|
75 |
/// </summary>
|
StephaneLenclud@225
|
76 |
private void StartMessageClient()
|
StephaneLenclud@225
|
77 |
{
|
StephaneLenclud@225
|
78 |
Thread clientThread = new Thread(SharpDisplayClientMessage.Program.MainWithParams);
|
StephaneLenclud@225
|
79 |
SharpDisplayClientMessage.StartParams myParams =
|
StephaneLenclud@225
|
80 |
new SharpDisplayClientMessage.StartParams(PrimaryText, SecondaryText, DurationInMilliseconds);
|
StephaneLenclud@225
|
81 |
clientThread.Start(myParams);
|
StephaneLenclud@225
|
82 |
}
|
StephaneLenclud@225
|
83 |
|
StephaneLenclud@225
|
84 |
|
StephaneLenclud@225
|
85 |
}
|
StephaneLenclud@225
|
86 |
|
StephaneLenclud@225
|
87 |
}
|