diff --git a/AnneProKeyboard/KeyboardKey.cs b/AnneProKeyboard/KeyboardKey.cs index 4faf033..562d3ee 100644 --- a/AnneProKeyboard/KeyboardKey.cs +++ b/AnneProKeyboard/KeyboardKey.cs @@ -22,8 +22,8 @@ public class KeyboardKey static KeyboardKey() { // "Empty" key, also the unassigned value key - StringKeyboardKeys[""] = new KeyboardKey("", "None", 0); - IntKeyboardKeys[0] = StringKeyboardKeys[""]; + StringKeyboardKeys["None"] = new KeyboardKey("None", "None", 0); + IntKeyboardKeys[0] = StringKeyboardKeys["None"]; // "Anne" key StringKeyboardKeys["Anne"] = new KeyboardKey("Anne", "Anne", 250); diff --git a/AnneProKeyboard/KeyboardProfileItem.cs b/AnneProKeyboard/KeyboardProfileItem.cs index 497e14e..93a6153 100644 --- a/AnneProKeyboard/KeyboardProfileItem.cs +++ b/AnneProKeyboard/KeyboardProfileItem.cs @@ -11,6 +11,8 @@ namespace AnneProKeyboard [DataContract] public class KeyboardProfileItem : INotifyPropertyChanged { + public EventHandler SyncStatusNotify; + private int _ID; [DataMember] public int ID @@ -89,6 +91,7 @@ private bool SpecialKeyExists(List keys) if (key.KeyValue == 250) { anne_key = true; + int index = keys.IndexOf(key); } else if (key.KeyValue == 254) { @@ -187,7 +190,8 @@ private void SyncProfilePhase1(CoreDispatcher dispatcher, GattCharacteristic gat KeyboardWriter keyboard_writer = new KeyboardWriter(dispatcher, gatt, lighting_meta_data, light_data); keyboard_writer.WriteToKeyboard(); - keyboard_writer.OnWriteFinished += (object_s, events) => { SyncProfilePhase2(dispatcher, gatt); }; // we need to do this because of async calls, threading is fun! + keyboard_writer.OnWriteFinished += (object_s, events) => { SyncProfilePhase2(dispatcher, gatt); NotifyStatus("Keyboard light has been synced"); }; // we need to do this because of async calls, threading is fun! + keyboard_writer.OnWriteFailed += (object_s, events) => { NotifyStatus("Failed to sync profile (light): exception handled"); }; } // send the layout data @@ -207,6 +211,18 @@ private void SyncProfilePhase2(CoreDispatcher dispatcher, GattCharacteristic gat KeyboardWriter keyboard_writer = new KeyboardWriter(dispatcher, gatt, layout_meta_data, layout_data); keyboard_writer.WriteToKeyboard(); + + keyboard_writer.OnWriteFinished += (object_s, events) => { NotifyStatus("Layout data has been synced"); }; // we need to do this because of async calls, threading is fun! + keyboard_writer.OnWriteFailed += (object_s, events) => { NotifyStatus("Failed to sync profile (layout): exception handled"); }; + } + + private void NotifyStatus(string status) + { + EventHandler handler = this.SyncStatusNotify; + if (handler != null) + { + handler(status, EventArgs.Empty); + } } } } diff --git a/AnneProKeyboard/MainPage.xaml b/AnneProKeyboard/MainPage.xaml index 2e41f8b..0a44c47 100644 --- a/AnneProKeyboard/MainPage.xaml +++ b/AnneProKeyboard/MainPage.xaml @@ -51,7 +51,7 @@ - + @@ -67,88 +67,170 @@ - - - + + + + - + - - -