From 6343d239a42cb90d53d49cd84b8c67f29b28f229 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Tue, 1 Dec 2015 23:14:37 +0100 Subject: [PATCH] Added themes, refined layout, bugfixes --- HueUWP/APIHandler.cs | 2 +- HueUWP/AboutView.xaml | 26 ++++++++++++++++++++ HueUWP/AboutView.xaml.cs | 30 +++++++++++++++++++++++ HueUWP/App.xaml | 11 ++++++++- HueUWP/DetailView.xaml | 46 +++++++++++++++++++++++++++++------ HueUWP/DetailView.xaml.cs | 9 ++++--- HueUWP/HueUWP.csproj | 17 +++++++++++++ HueUWP/Light.cs | 35 +++++++++++++++++++++++--- HueUWP/MainPage.xaml | 6 ++--- HueUWP/MainPage.xaml.cs | 6 +++++ HueUWP/SettingsView.xaml | 8 +++--- HueUWP/SettingsView.xaml.cs | 4 +-- HueUWP/Themes/DarkTheme.xaml | 9 +++++++ HueUWP/Themes/LightTheme.xaml | 5 ++++ 14 files changed, 189 insertions(+), 25 deletions(-) create mode 100644 HueUWP/AboutView.xaml create mode 100644 HueUWP/AboutView.xaml.cs create mode 100644 HueUWP/Themes/DarkTheme.xaml create mode 100644 HueUWP/Themes/LightTheme.xaml diff --git a/HueUWP/APIHandler.cs b/HueUWP/APIHandler.cs index 1d35662..8cb2a98 100755 --- a/HueUWP/APIHandler.cs +++ b/HueUWP/APIHandler.cs @@ -20,7 +20,7 @@ namespace HueUWP this.nwh = nwh; } - public async void Register() + public async Task Register() { try { var json = await nwh.RegisterName("Hue", "Kenneth&Yorick"); diff --git a/HueUWP/AboutView.xaml b/HueUWP/AboutView.xaml new file mode 100644 index 0000000..4cba0ac --- /dev/null +++ b/HueUWP/AboutView.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + About + + + + Made by Kenneth and Yorick. + + + + + diff --git a/HueUWP/AboutView.xaml.cs b/HueUWP/AboutView.xaml.cs new file mode 100644 index 0000000..3889eeb --- /dev/null +++ b/HueUWP/AboutView.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 HueUWP +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class AboutView : Page + { + public AboutView() + { + this.InitializeComponent(); + } + } +} diff --git a/HueUWP/App.xaml b/HueUWP/App.xaml index da19261..d7941d2 100644 --- a/HueUWP/App.xaml +++ b/HueUWP/App.xaml @@ -3,6 +3,15 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:HueUWP" - RequestedTheme="Light"> + RequestedTheme="Dark"> + + + + + + + + + diff --git a/HueUWP/DetailView.xaml b/HueUWP/DetailView.xaml index d8cb6ef..04f0b36 100644 --- a/HueUWP/DetailView.xaml +++ b/HueUWP/DetailView.xaml @@ -3,13 +3,21 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:HueUWP" + xmlns:convert="using:HueUWP.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:ctrl="using:Windows.UI.Xaml.Controls.Control" mc:Ignorable="d"> - - + + + + + + + + @@ -17,12 +25,36 @@ + + + + + + + + + + Off + On + + + + + + Hue + + + + + Saturation + + + + + Brightness + + - - - - - diff --git a/HueUWP/DetailView.xaml.cs b/HueUWP/DetailView.xaml.cs index 061a1d6..2134b8c 100644 --- a/HueUWP/DetailView.xaml.cs +++ b/HueUWP/DetailView.xaml.cs @@ -42,14 +42,17 @@ namespace HueUWP //l.UpdateColor(); } - private void Slider_DragLeave(object sender, DragEventArgs e) + private void Slider_Released(object sender, PointerRoutedEventArgs e) { l.UpdateColor(); } - private void Slider_PointerCaptureLost(object sender, PointerRoutedEventArgs e) + private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e) { - l.UpdateColor(); + ToggleSwitch button = ((ToggleSwitch)sender); + Light light = (Light)button.DataContext; + if (light != null) + light.UpdateState(button.IsOn); } } } diff --git a/HueUWP/HueUWP.csproj b/HueUWP/HueUWP.csproj index 8d7e882..a556db7 100644 --- a/HueUWP/HueUWP.csproj +++ b/HueUWP/HueUWP.csproj @@ -93,6 +93,9 @@ + + AboutView.xaml + App.xaml @@ -134,6 +137,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -146,6 +153,16 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + PreserveNewest + + + Designer + MSBuild:Compile + PreserveNewest + 14.0 diff --git a/HueUWP/Light.cs b/HueUWP/Light.cs index 0a17e2e..8f3f4bc 100644 --- a/HueUWP/Light.cs +++ b/HueUWP/Light.cs @@ -17,10 +17,37 @@ namespace HueUWP public string Name { get; set; } public string Type { get; set; } - public bool IsOn { get; set; } - public double Brightness{ get; set; } - public double Hue { get; set; } - public double Saturation { get; set; } + private bool _isOn; + + public bool IsOn + { + get { return _isOn; } + set { _isOn = value; NotifyPropertyChanged(nameof(IsOn)); } + } + + //Hue + private double _hue; + public double Hue + { + get { return _hue; } + set { _hue = value; NotifyPropertyChanged(nameof(Hue)); NotifyPropertyChanged(nameof(Color)); } + } + + //Brightness + private double _brightness; + public double Brightness + { + get { return _brightness; } + set { _brightness = value; NotifyPropertyChanged(nameof(Brightness)); NotifyPropertyChanged(nameof(Color)); } + } + + //Saturation + private double _saturation; + public double Saturation + { + get { return _saturation; } + set { _saturation = value; NotifyPropertyChanged(nameof(Saturation)); NotifyPropertyChanged(nameof(Color)); } + } public APIHandler api { get; set; } diff --git a/HueUWP/MainPage.xaml b/HueUWP/MainPage.xaml index 8a7dde0..342b7e7 100644 --- a/HueUWP/MainPage.xaml +++ b/HueUWP/MainPage.xaml @@ -24,12 +24,12 @@ Hue Lights - + - + @@ -58,7 +58,7 @@ - + diff --git a/HueUWP/MainPage.xaml.cs b/HueUWP/MainPage.xaml.cs index a519942..d991124 100644 --- a/HueUWP/MainPage.xaml.cs +++ b/HueUWP/MainPage.xaml.cs @@ -87,5 +87,11 @@ namespace HueUWP if (l != null) rootframe.Navigate(typeof(DetailView), l); } + + private void AboutButton_Click(object sender, RoutedEventArgs e) + { + Frame rootframe = Window.Current.Content as Frame; + rootframe.Navigate(typeof(AboutView)); + } } } diff --git a/HueUWP/SettingsView.xaml b/HueUWP/SettingsView.xaml index 0fef193..8016fe6 100644 --- a/HueUWP/SettingsView.xaml +++ b/HueUWP/SettingsView.xaml @@ -8,7 +8,7 @@ mc:Ignorable="d"> - + @@ -19,15 +19,15 @@ - + Server IP - + Server Port - + User ID