Skip to content
This repository has been archived by the owner on Nov 21, 2020. It is now read-only.

Redesigned UI and small code refactoring #24

Merged
merged 34 commits into from
Dec 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
be27e47
Redesigning UI. Includes refactoring pages.
Jul 12, 2017
527f3df
Added LightingPage, splitting it from the mainpage. Added navigation …
Jul 12, 2017
294d151
Massive UI changes. NavBar on left, colour changes, working navigatio…
Jul 14, 2017
df15059
Changed MainPage to template, made new LayoutPage for keyboard layout.
Jul 14, 2017
c51fc62
Mathc --> Match
Jul 14, 2017
23cd081
Enlarged Keyboard, moved profiles to top right (clean up view)
Jul 15, 2017
018d1b9
Added new keyboard to LightingPage.xaml, Fixed alignment and opening …
Jul 15, 2017
0fae879
Semi-working moving connection logic to mainpage and saving logic to …
Jul 16, 2017
160fc5d
Image
Jul 16, 2017
4de0e2c
Update README.md
ethanmsmith Jul 16, 2017
f7cd24b
Update README.md
ethanmsmith Jul 17, 2017
59bfefb
Connection logic moved to MainPage along with syncing logc. Views not…
Jul 17, 2017
c1e8ab1
Syncing working as before (syncs lighting and layout at once).
Jul 25, 2017
c919d1e
Merge branch 'master' of https://github.com/ethanmsmith/anne-keyboard…
Jul 25, 2017
94e4522
Profiles load (and save?) correctly
Jul 25, 2017
7d99dd1
Update README.md
ethanmsmith Jul 25, 2017
579c436
Changed to ColorPicker control for better clarity and more control ov…
Aug 1, 2017
dfd6c59
Added AboutPage
Aug 1, 2017
b607de8
Merge branch 'master' of https://github.com/ethanmsmith/anne-keyboard…
Aug 1, 2017
2fbe0d0
Update README.md
ethanmsmith Aug 1, 2017
2851c6c
Update README.md
ethanmsmith Aug 1, 2017
3ef25bc
Update README.md
ethanmsmith Aug 1, 2017
b2e386f
Profile comboboxes now load profiles correctly on load. May have shif…
Aug 1, 2017
11160bf
Merge branch 'master' of https://github.com/ethanmsmith/anne-keyboard…
Aug 1, 2017
7c2be87
Key combobox now shows up in the correct spot again
Aug 2, 2017
dfc8384
Update README.md
ethanmsmith Aug 3, 2017
5adc8b6
Fixed cyclical dependency, cleaned up positions
Aug 10, 2017
68ae2b5
Merge branch 'master' of https://github.com/ethanmsmith/anne-keyboard…
Aug 10, 2017
966afe8
Fixed bug when removing the only profile from the dropdown
Aug 10, 2017
69780a5
Equals, ==, !=, getHashCode to support correct profile loading when s…
Aug 10, 2017
64b2aef
Fixed bug with crashing regarding not handling UnauthorizedAccessExce…
Aug 10, 2017
f6d6d65
Update README.md
ethanmsmith Aug 10, 2017
808fafb
Fixed bug when comparing KeyboardProfileItems with == and first one i…
Aug 10, 2017
3076df1
Merge branch 'master' of https://github.com/ethanmsmith/anne-keyboard…
Aug 10, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions AnneProKeyboard/AboutPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Page
x:Class="AnneProKeyboard.AboutPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AnneProKeyboard"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" MinWidth="960" MinHeight="480">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<WebView Name="aboutGitHub" Grid.Row="0" x:FieldModifier="public" Source="ms-appx-web:///Assets/README.html" />
</Grid>
</Page>
30 changes: 30 additions & 0 deletions AnneProKeyboard/AboutPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class AboutPage : Page
{
public AboutPage()
{
this.InitializeComponent();
}
}
}
27 changes: 25 additions & 2 deletions AnneProKeyboard/AnneProKeyboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,24 @@
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="AboutPage.xaml.cs">
<DependentUpon>AboutPage.xaml</DependentUpon>
</Compile>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="LightingPage.xaml.cs">
<DependentUpon>LightingPage.xaml</DependentUpon>
</Compile>
<Compile Include="CRC16.cs" />
<Compile Include="KeyboardKey.cs" />
<Compile Include="KeyboardProfileItem.cs" />
<Compile Include="KeyboardWriter.cs" />
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
<Compile Include="LayoutPage.xaml.cs">
<DependentUpon>LayoutPage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand All @@ -116,7 +125,9 @@
<None Include="AnneProKeyboard_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\README.html" />
<Content Include="Assets\Square150x150Logo.scale-100.png" />
<Content Include="Assets\controls.png" />
<Content Include="Properties\Default.rd.xml" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\SplashScreen.scale-200.png" />
Expand All @@ -131,7 +142,19 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="AboutPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="LightingPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="LayoutPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
Expand Down
87 changes: 46 additions & 41 deletions AnneProKeyboard/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,30 +25,19 @@ namespace AnneProKeyboard
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// 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().
/// </summary>

public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}

/// <summary>
/// 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.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
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
Expand All @@ -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();
}

/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}

/// <summary>
/// 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.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
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();
}
}
}
}
25 changes: 25 additions & 0 deletions AnneProKeyboard/Assets/README.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

<body style="background:#36393e; color:whitesmoke;">
<h1 id="anne-keyboard-windows">Anne Keyboard Windows</h1>
<p>A Universal Windows App for controlling the an Anne Pro keyboard over Bluetooth Low Energy.</p>
<h2 id="requirements">Requirements</h2>
<p>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 <code>Fn+B, Fn+0, ESC, Fn+B, +</code></p>
<h2 id="supported-features">Supported Features</h2>
<ul>
<li>Automatic keyboard pairing (launch the app, and it should start scanning for the keyboard)</li>
<li>Create and manage profiles</li>
<li>Set keyboard backlight colours</li>
</ul>
<h2 id="planned-features">Planned Features</h2>
<ul>
<li>Support for changing keyboard layouts</li>
<li>Implement keyboard macros</li>
<li>Improve changing multiple button keyboard light colours</li>
</ul>
<h2 id="known-bugs">Known Bugs</h2>
<ul>
<li>None so far. Please submit an issue to report any bugs.</li>
</ul>
<h2 id="license">License</h2>
<p>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 <a href="http://scripts.sil.org/OFL">OFIL license</a>, and the font can be found on <a href="http://scripts.sil.org/OFL">Github</a>.</p>
</body>
Binary file added AnneProKeyboard/Assets/controls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 38 additions & 3 deletions AnneProKeyboard/KeyboardProfileItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public KeyboardProfileItem(int ID, string Label)
{
this.ID = ID;
this.Label = Label;

this.KeyboardColours = new List<int>();

// We only need 70 values to represent the 61 keys (70 is needed for some reason by the keyboard..)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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"); };
}

Expand Down Expand Up @@ -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();
}
}
}
Loading