Adding non functional generic EAR HID event.
2 // Copyright (C) 2014-2016 Stéphane Lenclud.
4 // This file is part of SharpDisplayManager.
6 // SharpDisplayManager is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
11 // SharpDisplayManager is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with SharpDisplayManager. If not, see <http://www.gnu.org/licenses/>.
21 using System.Collections.Generic;
22 using System.ComponentModel;
27 using System.Threading.Tasks;
28 using System.Windows.Forms;
29 using System.Diagnostics;
30 using SharpLib.Display;
33 namespace SharpDisplayClientMessage
37 /// Sharp Display Client designed to act as an idle client.
38 /// It should take care of screen saving and other such concerns.
40 public partial class FormClientMessage : Form
42 public StartParams Params { get; set; }
45 ContentAlignment iAlignment;
46 TextField iPrimaryTextField;
47 TextField iSecondaryTextField;
50 public delegate void CloseDelegate();
51 public delegate void CloseConnectionDelegate();
54 public FormClientMessage()
56 InitializeComponent();
62 /// <param name="sender"></param>
63 /// <param name="e"></param>
64 private void FormClientMessage_Load(object sender, EventArgs e)
66 //Prevents showing in the Open Task view (Windows Key + Tab)
70 iClient = new Client();
71 iClient.CloseOrderEvent += OnCloseOrder;
73 iClient.SetName("Message");
74 iClient.SetPriority(Params.Priority);
78 iTimer.Interval = Params.DurationInMs;
86 /// <returns></returns>
87 public bool IsClientReady()
89 return (iClient != null && iClient.IsReady());
95 public void SetupDisplayClient()
99 //Set one column one line layout
102 iAlignment = ContentAlignment.MiddleCenter;
103 iPrimaryTextField = new TextField(Params.PrimaryText, iAlignment, 0, 0);
104 iSecondaryTextField = new TextField(Params.SecondaryText, iAlignment, 0, 1);
107 if (string.IsNullOrEmpty(Params.SecondaryText))
110 TableLayout layout = new TableLayout(1, 1);
111 iClient.SetLayout(layout);
113 iClient.CreateFields(new DataField[]
121 TableLayout layout = new TableLayout(1, 2);
122 iClient.SetLayout(layout);
124 iClient.CreateFields(new DataField[]
132 public void OnCloseOrder()
140 public void CloseThreadSafe()
142 if (this.InvokeRequired)
144 //Not in the proper thread, invoke ourselves
145 CloseDelegate d = new CloseDelegate(CloseThreadSafe);
146 this.Invoke(d, new object[] { });
150 //We are in the proper thread
158 public void CloseConnectionThreadSafe()
160 if (this.InvokeRequired)
162 //Not in the proper thread, invoke ourselves
163 CloseConnectionDelegate d = new CloseConnectionDelegate(CloseConnectionThreadSafe);
164 this.Invoke(d, new object[] { });
168 //We are in the proper thread
171 string sessionId = iClient.SessionId;
172 Trace.TraceInformation("Closing client: " + sessionId);
174 Trace.TraceInformation("Closed client: " + sessionId);
184 /// <param name="sender"></param>
185 /// <param name="e"></param>
186 private void FormClientMessage_FormClosing(object sender, FormClosingEventArgs e)
188 CloseConnectionThreadSafe();
195 /// <param name="sender"></param>
196 /// <param name="e"></param>
197 private void iTimer_Tick(object sender, EventArgs e)
206 /// <param name="sender"></param>
207 /// <param name="e"></param>
208 private void FormClientMessage_Shown(object sender, EventArgs e)