diff --git a/AnneProKeyboard/AboutPage.xaml b/AnneProKeyboard/AboutPage.xaml new file mode 100644 index 0000000..d5d2536 --- /dev/null +++ b/AnneProKeyboard/AboutPage.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/AnneProKeyboard/AboutPage.xaml.cs b/AnneProKeyboard/AboutPage.xaml.cs new file mode 100644 index 0000000..dd766e1 --- /dev/null +++ b/AnneProKeyboard/AboutPage.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 + +namespace AnneProKeyboard +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class AboutPage : Page + { + public AboutPage() + { + this.InitializeComponent(); + } + } +} diff --git a/AnneProKeyboard/AnneProKeyboard.csproj b/AnneProKeyboard/AnneProKeyboard.csproj index 9695768..b6e9601 100644 --- a/AnneProKeyboard/AnneProKeyboard.csproj +++ b/AnneProKeyboard/AnneProKeyboard.csproj @@ -97,15 +97,24 @@ + + AboutPage.xaml + App.xaml + + MainPage.xaml + + + LightingPage.xaml + - - MainPage.xaml + + LayoutPage.xaml @@ -116,7 +125,9 @@ + + @@ -131,7 +142,19 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + MSBuild:Compile Designer diff --git a/AnneProKeyboard/App.xaml.cs b/AnneProKeyboard/App.xaml.cs index 614b584..15ba4a4 100644 --- a/AnneProKeyboard/App.xaml.cs +++ b/AnneProKeyboard/App.xaml.cs @@ -5,8 +5,11 @@ using System.Runtime.InteropServices.WindowsRuntime; using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; +using Windows.ApplicationModel.Core; using Windows.Foundation; using Windows.Foundation.Collections; +using Windows.UI.Core; +using Windows.UI.ViewManagement; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; @@ -22,30 +25,19 @@ namespace AnneProKeyboard /// sealed partial class App : Application { - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// + public App() { this.InitializeComponent(); this.Suspending += OnSuspending; } - /// - /// Invoked when the application is launched normally by the end user. Other entry points - /// will be used such as when the application is launched to open a specific file. - /// - /// Details about the launch request and process. protected override void OnLaunched(LaunchActivatedEventArgs e) { -#if DEBUG - if (System.Diagnostics.Debugger.IsAttached) - { - this.DebugSettings.EnableFrameRateCounter = true; - } -#endif Frame rootFrame = Window.Current.Content as Frame; + ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize; + ApplicationView.PreferredLaunchViewSize = new Size(1074, 800); + ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(1024, 604)); // Do not repeat app initialization when the Window already has content, // just ensure that the window is active @@ -55,55 +47,68 @@ protected override void OnLaunched(LaunchActivatedEventArgs e) rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; + rootFrame.Navigated += OnNavigated; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { - //TODO: Load state from previously suspended application + // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; + + // Register a handler for BackRequested events and set the + // visibility of the Back button + SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; + + SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = + rootFrame.CanGoBack ? + AppViewBackButtonVisibility.Visible : + AppViewBackButtonVisibility.Collapsed; } - if (e.PrelaunchActivated == false) + if (rootFrame.Content == null) { - if (rootFrame.Content == null) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame.Navigate(typeof(MainPage), e.Arguments); - } - // Ensure the current window is active - Window.Current.Activate(); + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame.Navigate(typeof(MainPage), e.Arguments); } - this.DebugSettings.EnableFrameRateCounter = false; - this.DebugSettings.EnableRedrawRegions = false; + // Ensure the current window is active + Window.Current.Activate(); } - /// - /// Invoked when Navigation to a certain page fails - /// - /// The Frame which failed navigation - /// Details about the navigation failure void OnNavigationFailed(object sender, NavigationFailedEventArgs e) { throw new Exception("Failed to load Page " + e.SourcePageType.FullName); } - /// - /// Invoked when application execution is being suspended. Application state is saved - /// without knowing whether the application will be terminated or resumed with the contents - /// of memory still intact. - /// - /// The source of the suspend request. - /// Details about the suspend request. + private void OnNavigated(object sender, NavigationEventArgs e) + { + // Each time a navigation event occurs, update the Back button's visibility + SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = + ((Frame)sender).CanGoBack ? + AppViewBackButtonVisibility.Visible : + AppViewBackButtonVisibility.Collapsed; + } + private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); - //TODO: Save application state and stop any background activity + // TODO: Save application state and stop any background activity deferral.Complete(); } + + private void OnBackRequested(object sender, BackRequestedEventArgs e) + { + Frame rootFrame = Window.Current.Content as Frame; + + if (rootFrame.CanGoBack) + { + e.Handled = true; + rootFrame.GoBack(); + } + } } } diff --git a/AnneProKeyboard/Assets/README.html b/AnneProKeyboard/Assets/README.html new file mode 100644 index 0000000..e90f910 --- /dev/null +++ b/AnneProKeyboard/Assets/README.html @@ -0,0 +1,25 @@ + + +

Anne Keyboard Windows

+

A Universal Windows App for controlling the an Anne Pro keyboard over Bluetooth Low Energy.

+

Requirements

+

This app has been tested against Windows 10. Other version of Windows is not supported due to Universal Windows App (UWP) platform only supporting Windows 10. The keyboard has to be in L0 mode by: pressing Fn+B, Fn+0, ESC, Fn+B, +

+

Supported Features

+
    +
  • Automatic keyboard pairing (launch the app, and it should start scanning for the keyboard)
  • +
  • Create and manage profiles
  • +
  • Set keyboard backlight colours
  • +
+

Planned Features

+
    +
  • Support for changing keyboard layouts
  • +
  • Implement keyboard macros
  • +
  • Improve changing multiple button keyboard light colours
  • +
+

Known Bugs

+
    +
  • None so far. Please submit an issue to report any bugs.
  • +
+

License

+

The codebase and the project are released under the permissive MIT License. The images and icons are generated using the Font Awesome font released under the OFIL license, and the font can be found on Github.

+ \ No newline at end of file diff --git a/AnneProKeyboard/Assets/controls.png b/AnneProKeyboard/Assets/controls.png new file mode 100644 index 0000000..be24fa4 Binary files /dev/null and b/AnneProKeyboard/Assets/controls.png differ diff --git a/AnneProKeyboard/KeyboardProfileItem.cs b/AnneProKeyboard/KeyboardProfileItem.cs index 76f08f0..6b62ee3 100644 --- a/AnneProKeyboard/KeyboardProfileItem.cs +++ b/AnneProKeyboard/KeyboardProfileItem.cs @@ -43,7 +43,7 @@ public KeyboardProfileItem(int ID, string Label) { this.ID = ID; this.Label = Label; - + this.KeyboardColours = new List(); // We only need 70 values to represent the 61 keys (70 is needed for some reason by the keyboard..) @@ -176,7 +176,7 @@ public void SyncProfile(GattCharacteristic gatt) { this.SyncProfilePhase1(gatt); } - + // send the backlight first data, should cause a waterfall effect on syncing up the profile private void SyncProfilePhase1(GattCharacteristic gatt) { @@ -190,7 +190,7 @@ private void SyncProfilePhase1(GattCharacteristic gatt) KeyboardWriter keyboard_writer = new KeyboardWriter(gatt, lighting_meta_data, light_data); keyboard_writer.WriteToKeyboard(); - keyboard_writer.OnWriteFinished += (object_s, events) => { SyncProfilePhase2(gatt); NotifyStatus("Keyboard light has been synced"); }; // we need to do this because of async calls, threading is fun! + keyboard_writer.OnWriteFinished += (object_s, events) => { SyncProfilePhase2(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"); }; } @@ -224,5 +224,40 @@ private void NotifyStatus(string status) handler(status, EventArgs.Empty); } } + + public override Boolean Equals(object obj) + { + if (obj == null) + { + return false; + } + + if (obj.GetType() == typeof(KeyboardProfileItem)) + { + KeyboardProfileItem that = obj as KeyboardProfileItem; + return (this.ID == that.ID && this.Label == that.Label); + } + + return false; + } + + public static bool operator ==(KeyboardProfileItem a, KeyboardProfileItem b) + { + if (object.ReferenceEquals(a, null)) + { + return object.ReferenceEquals(b, null); + } + return a.Equals(b); + } + + public static bool operator !=(KeyboardProfileItem a, KeyboardProfileItem b) + { + return !(a == b); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } } } diff --git a/AnneProKeyboard/LayoutPage.xaml b/AnneProKeyboard/LayoutPage.xaml new file mode 100644 index 0000000..fef207c --- /dev/null +++ b/AnneProKeyboard/LayoutPage.xaml @@ -0,0 +1,293 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -