diff --git a/HueUWP/HueUWP.csproj b/HueUWP/HueUWP.csproj
index b8c36ff..8d7e882 100644
--- a/HueUWP/HueUWP.csproj
+++ b/HueUWP/HueUWP.csproj
@@ -111,6 +111,7 @@
SettingsView.xaml
+
diff --git a/HueUWP/MainPage.xaml b/HueUWP/MainPage.xaml
index 8a4752e..e230437 100644
--- a/HueUWP/MainPage.xaml
+++ b/HueUWP/MainPage.xaml
@@ -23,7 +23,7 @@
Hue Lights
-
+
diff --git a/HueUWP/MainPage.xaml.cs b/HueUWP/MainPage.xaml.cs
index 6f6a8b6..5636988 100644
--- a/HueUWP/MainPage.xaml.cs
+++ b/HueUWP/MainPage.xaml.cs
@@ -32,7 +32,7 @@ namespace HueUWP
private ObservableCollection _lightsViewModel = LightDataSource.GetLights();
- private APIHandler api;
+ public APIHandler api;
public ObservableCollection LightsViewModel
{
@@ -42,8 +42,8 @@ namespace HueUWP
public MainPage()
{
this.InitializeComponent();
- LOCAL_SETTINGS.Values["ip"] = "localhost";
- LOCAL_SETTINGS.Values["port"] = 8000;
+ //LOCAL_SETTINGS.Values["ip"] = "localhost";
+ //LOCAL_SETTINGS.Values["port"] = 8000;
NetworkHandler nwh = new NetworkHandler();
api = new APIHandler(nwh);
_lightsViewModel.Clear();
@@ -75,10 +75,10 @@ namespace HueUWP
light.UpdateColor(0, 38, 255);
}
- private void RegisterButton_Click(object sender, RoutedEventArgs e)
+ private void SettingsButton_Click(object sender, RoutedEventArgs e)
{
- api.Register();
- Debug.WriteLine(LOCAL_SETTINGS.Values["id"]);
+ Frame rootframe = Window.Current.Content as Frame;
+ rootframe.Navigate(typeof(SettingsView), api);
}
private void RefreshButton_Click(object sender, RoutedEventArgs e)
diff --git a/HueUWP/SettingsView.xaml b/HueUWP/SettingsView.xaml
index ac4e124..0fef193 100644
--- a/HueUWP/SettingsView.xaml
+++ b/HueUWP/SettingsView.xaml
@@ -6,6 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
+
@@ -16,5 +17,25 @@
Settings
+
+
+
+ Server IP
+
+
+
+ Server Port
+
+
+
+ User ID
+
+
+
+
diff --git a/HueUWP/SettingsView.xaml.cs b/HueUWP/SettingsView.xaml.cs
index 5d0ae35..98bfff1 100644
--- a/HueUWP/SettingsView.xaml.cs
+++ b/HueUWP/SettingsView.xaml.cs
@@ -22,9 +22,25 @@ namespace HueUWP
///
public sealed partial class SettingsView : Page
{
+ public SettingsViewModel SettingsViewModel = new SettingsViewModel();
+
+ private APIHandler api;
+
public SettingsView()
- {
+ {
this.InitializeComponent();
+ //SettingsViewModel = new SettingsViewModel();
+ }
+
+ private void UpdateID_Click(object sender, RoutedEventArgs e)
+ {
+ api.Register();
+ SettingsViewModel.Update();
+ }
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ api = e.Parameter as APIHandler;
}
}
}
diff --git a/HueUWP/SettingsViewModel.cs b/HueUWP/SettingsViewModel.cs
new file mode 100644
index 0000000..9dc9d02
--- /dev/null
+++ b/HueUWP/SettingsViewModel.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Windows.Storage;
+
+namespace HueUWP
+{
+ public class SettingsViewModel : INotifyPropertyChanged
+ {
+ private static ApplicationDataContainer LOCAL_SETTINGS = ApplicationData.Current.LocalSettings;
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private void NotifyPropertyChanged(string propertyName)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ public string IP
+ {
+ get { Debug.WriteLine(LOCAL_SETTINGS.Values["ip"]); return LOCAL_SETTINGS.Values["ip"] as string; }
+ set { LOCAL_SETTINGS.Values["ip"] = value; NotifyPropertyChanged(nameof(IP)); }
+ }
+
+ public string PORT
+ {
+ get { Debug.WriteLine(LOCAL_SETTINGS.Values["port"]); return Convert.ToInt32(LOCAL_SETTINGS.Values["port"]).ToString(); }
+ set { LOCAL_SETTINGS.Values["port"] = int.Parse(value); NotifyPropertyChanged(nameof(PORT)); }
+ }
+
+ public string ID
+ {
+ get { Debug.WriteLine(LOCAL_SETTINGS.Values["id"]); return LOCAL_SETTINGS.Values["id"] as string; }
+ }
+
+ public void Update()
+ {
+ NotifyPropertyChanged(nameof(ID));
+ }
+ }
+}