# HG changeset patch
# User StephaneLenclud
# Date 1471627134 -7200
# Node ID 2e4d2558bb21d0d8d66ce205a2cb12a847cde667
# Parent cc2251d065db413d4792614d059deb84ad9b006e
Adding non functional generic EAR HID event.
diff -r cc2251d065db -r 2e4d2558bb21 Server/Events/EventHid.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/Events/EventHid.cs Fri Aug 19 19:18:54 2016 +0200
@@ -0,0 +1,147 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.Serialization;
+using System.Windows.Forms;
+using Ear = SharpLib.Ear;
+using Hid = SharpLib.Hid;
+
+namespace SharpDisplayManager
+{
+ [DataContract]
+ [Ear.AttributeObject(Id = "Event.Hid", Name = "HID", Description = "Corresponding HID message received.")]
+ public class EventHid: Ear.Event
+ {
+ public EventHid()
+ {
+ }
+
+ [DataMember]
+ public ushort UsagePage { get; set; }
+
+ [DataMember]
+ public ushort UsageCollection { get; set; }
+
+ [DataMember]
+ public ushort Usage { get; set; }
+
+ [DataMember]
+ public Keys Key { get; set; }
+
+ [DataMember]
+ [Ear.AttributeObjectProperty
+ (
+ Id = "HID.Keyboard.IsKeyUp",
+ Name = "Key Up",
+ Description = "Key up if set, key down otherwise."
+ )]
+ public bool IsKeyUp { get; set; } = false;
+
+ [DataMember]
+ public bool IsMouse { get; set; }
+
+ [DataMember]
+ public bool IsKeyboard { get; set; }
+
+ [DataMember]
+ public bool IsGeneric { get; set; }
+
+ [DataMember]
+ public bool HasModifierShift { get; set; } = false;
+
+ [DataMember]
+ public bool HasModifierControl { get; set; } = false;
+
+ [DataMember]
+ public bool HasModifierAlt { get; set; } = false;
+
+ [DataMember]
+ public bool HasModifierWindows { get; set; } = false;
+
+
+ protected override void DoConstruct()
+ {
+ base.DoConstruct();
+ UpdateDynamicProperties();
+ }
+
+ private void UpdateDynamicProperties()
+ {
+
+ }
+
+
+ ///
+ /// Make sure we distinguish between various configuration of this event
+ ///
+ ///
+ public override string Brief()
+ {
+ string brief = Name + ": ";
+
+ if (IsKeyboard)
+ {
+ brief += Key.ToString();
+
+ if (HasModifierAlt)
+ {
+ brief += " + ALT";
+ }
+
+ if (HasModifierControl)
+ {
+ brief += " + CTRL";
+ }
+
+ if (HasModifierShift)
+ {
+ brief += " + SHIFT";
+ }
+
+ if (HasModifierWindows)
+ {
+ brief += " + WIN";
+ }
+ }
+ else if (IsGeneric)
+ {
+
+ }
+
+ if (IsKeyUp)
+ {
+ brief += " (UP)";
+ }
+ else
+ {
+ brief += " (DOWN)";
+ }
+
+ return brief;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public override bool Equals(object obj)
+ {
+ if (obj is EventHidKeyboard)
+ {
+ EventHidKeyboard e = (EventHidKeyboard)obj;
+ return e.Key == Key
+ && e.IsKeyUp == IsKeyUp
+ && e.HasModifierAlt == HasModifierAlt
+ && e.HasModifierControl == HasModifierControl
+ && e.HasModifierShift == HasModifierShift
+ && e.HasModifierWindows == HasModifierWindows;
+ }
+
+ return false;
+ }
+ }
+}
diff -r cc2251d065db -r 2e4d2558bb21 Server/FormEditObject.cs
--- a/Server/FormEditObject.cs Fri Aug 19 17:12:54 2016 +0200
+++ b/Server/FormEditObject.cs Fri Aug 19 19:18:54 2016 +0200
@@ -170,8 +170,10 @@
{
ComboBox ctrl = (ComboBox)aControl;
string currentItem = ctrl.SelectedItem.ToString();
- PropertyComboBox pcb = (PropertyComboBox)aInfo.GetValue(aObject);
- pcb.CurrentItem = currentItem;
+ PropertyComboBox value = (PropertyComboBox)aInfo.GetValue(aObject);
+ value.CurrentItem = currentItem;
+ //Not strictly needed but makes sure the set method is called
+ aInfo.SetValue(aObject, value);
}
//TODO: add support for other types here
diff -r cc2251d065db -r 2e4d2558bb21 Server/SharpDisplayManager.csproj
--- a/Server/SharpDisplayManager.csproj Fri Aug 19 17:12:54 2016 +0200
+++ b/Server/SharpDisplayManager.csproj Fri Aug 19 19:18:54 2016 +0200
@@ -179,6 +179,7 @@
+
diff -r cc2251d065db -r 2e4d2558bb21 SharpLibEar/Object.cs
--- a/SharpLibEar/Object.cs Fri Aug 19 17:12:54 2016 +0200
+++ b/SharpLibEar/Object.cs Fri Aug 19 19:18:54 2016 +0200
@@ -8,7 +8,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
-
+using System.ComponentModel;
namespace SharpLib.Ear
{
@@ -19,11 +19,11 @@
///
[DataContract]
[KnownType("DerivedTypes")]
- public abstract class Object: IComparable
+ public abstract class Object: IComparable, INotifyPropertyChanged
{
private bool iConstructed = false;
- public Object()
+ protected Object()
{
Construct();
}
@@ -106,5 +106,20 @@
return SharpLib.Utils.Reflection.GetDerivedTypes