diff --git a/HueUWP/APIHandler.cs b/HueUWP/APIHandler.cs
index 0b628e5..ec8c71e 100755
--- a/HueUWP/APIHandler.cs
+++ b/HueUWP/APIHandler.cs
@@ -1,16 +1,17 @@
-using System;
+using Newtonsoft.Json.Linq;
+using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
-namespace HueUWP
+namespace BindingToCommandsUWP
{
class APIHandler
{
- public static ApplicationData APP_DATA = ApplicationData.Current;
- public static ApplicationDataContainer LOCAL_SETTINGS = APP_DATA.LocalSettings;
+
NetworkHandler nwh;
public APIHandler(NetworkHandler nwh)
@@ -18,10 +19,18 @@ namespace HueUWP
this.nwh = nwh;
}
- public void Register()
+ private JObject ObjectifyfJson(string json)
{
- string id = nwh.RegisterName("Hue", "Kenneth&Yorick").ToString();
- //write to file;
+ json = json.Replace("[", "").Replace("]", "");
+ return JObject.Parse(json);
+ }
+
+ public async void Register()
+ {
+ var json = await nwh.RegisterName("Hue", "Kenneth&Yorick");
+ JObject o = ObjectifyfJson(json);
+ string id= o["success"]["username"].ToString();
+ MainPage.LOCAL_SETTINGS.Values["id"] = id;
}
}
}
diff --git a/HueUWP/App.xaml b/HueUWP/App.xaml
index da19261..74c682e 100644
--- a/HueUWP/App.xaml
+++ b/HueUWP/App.xaml
@@ -1,8 +1,8 @@
diff --git a/HueUWP/App.xaml.cs b/HueUWP/App.xaml.cs
index f465a11..68bc255 100644
--- a/HueUWP/App.xaml.cs
+++ b/HueUWP/App.xaml.cs
@@ -15,7 +15,7 @@ using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
-namespace HueUWP
+namespace BindingToCommandsUWP
{
///
/// Provides application-specific behavior to supplement the default Application class.
@@ -43,7 +43,7 @@ namespace HueUWP
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
- this.DebugSettings.EnableFrameRateCounter = true;
+ this.DebugSettings.EnableFrameRateCounter = false;
}
#endif
diff --git a/HueUWP/HueUWP.csproj b/HueUWP/HueUWP.csproj
index 487059e..7e815c2 100644
--- a/HueUWP/HueUWP.csproj
+++ b/HueUWP/HueUWP.csproj
@@ -97,6 +97,7 @@
App.xaml
+
MainPage.xaml
diff --git a/HueUWP/HueUWP.sln b/HueUWP/HueUWP.sln
new file mode 100644
index 0000000..6e5e026
--- /dev/null
+++ b/HueUWP/HueUWP.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HueUWP", "HueUWP.csproj", "{88414ECD-0462-41DE-ABA9-462D2F154595}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM = Debug|ARM
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|ARM = Release|ARM
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Debug|ARM.ActiveCfg = Debug|ARM
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Debug|ARM.Build.0 = Debug|ARM
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Debug|ARM.Deploy.0 = Debug|ARM
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Debug|x64.ActiveCfg = Debug|x64
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Debug|x64.Build.0 = Debug|x64
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Debug|x64.Deploy.0 = Debug|x64
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Debug|x86.ActiveCfg = Debug|x86
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Debug|x86.Build.0 = Debug|x86
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Debug|x86.Deploy.0 = Debug|x86
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Release|ARM.ActiveCfg = Release|ARM
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Release|ARM.Build.0 = Release|ARM
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Release|ARM.Deploy.0 = Release|ARM
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Release|x64.ActiveCfg = Release|x64
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Release|x64.Build.0 = Release|x64
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Release|x64.Deploy.0 = Release|x64
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Release|x86.ActiveCfg = Release|x86
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Release|x86.Build.0 = Release|x86
+ {88414ECD-0462-41DE-ABA9-462D2F154595}.Release|x86.Deploy.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/HueUWP/Light.cs b/HueUWP/Light.cs
new file mode 100644
index 0000000..69436ff
--- /dev/null
+++ b/HueUWP/Light.cs
@@ -0,0 +1,77 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace BindingToCommandsUWP
+{
+ public class Light : INotifyPropertyChanged
+ {
+ public int ID { get; set; }
+ public string Make { get; set; }
+ public string Model { get; set; }
+
+ private string checkedInDateTime;
+
+ public string CheckedInDateTime
+ {
+ get { return checkedInDateTime; }
+ set
+ {
+ checkedInDateTime = value;
+ NotifyPropertyChanged(nameof(CheckedInDateTime));
+ }
+ }
+
+
+
+ public Light()
+ {
+
+ }
+
+ public void CheckInCar()
+ {
+ this.CheckedInDateTime = String.Format("{0:t}", DateTime.Now);
+ }
+
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ private void NotifyPropertyChanged(string propertyName)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ }
+
+ public class LightDataSource
+ {
+ private static ObservableCollection _cars
+ = new ObservableCollection();
+
+ public static ObservableCollection GetCars()
+ {
+ if (_cars.Count == 0)
+ {
+ _cars.Add(new Light() { ID = 1, Make = "Tesla", Model = "Model S" });
+ _cars.Add(new Light() { ID = 2, Make = "Tesla", Model = "Model 3" });
+ _cars.Add(new Light() { ID = 3, Make = "Tesla", Model = "Model X" });
+ }
+ return _cars;
+ }
+
+ //public static void CheckInCar(Car car)
+ //{
+ // _cars.FirstOrDefault(p => p.ID == car.ID).CheckedInDateTime = String.Format("{0:t}", DateTime.Now);
+ //}
+ }
+
+
+
+
+}
diff --git a/HueUWP/MainPage.xaml b/HueUWP/MainPage.xaml
index 538d50b..4d9e4d8 100644
--- a/HueUWP/MainPage.xaml
+++ b/HueUWP/MainPage.xaml
@@ -1,13 +1,41 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HueUWP/MainPage.xaml.cs b/HueUWP/MainPage.xaml.cs
index 5d3e6e3..92ba16a 100644
Binary files a/HueUWP/MainPage.xaml.cs and b/HueUWP/MainPage.xaml.cs differ
diff --git a/HueUWP/NetworkHandler.cs b/HueUWP/NetworkHandler.cs
index a6c3b56..785971d 100755
--- a/HueUWP/NetworkHandler.cs
+++ b/HueUWP/NetworkHandler.cs
@@ -7,11 +7,19 @@ using System.Threading.Tasks;
using Windows.UI.Popups;
using Windows.Web.Http;
-namespace HueUWP
+namespace BindingToCommandsUWP
{
class NetworkHandler
{
- private async Task Put(string ip, int port, string path, string json)
+ string ip;
+ int port;
+ public NetworkHandler()
+ {
+ this.ip = (string) MainPage.LOCAL_SETTINGS.Values["ip"];
+ this.port = (int)MainPage.LOCAL_SETTINGS.Values["port"];
+ }
+
+ private async Task Put(string path, string json)
{
var cts = new CancellationTokenSource();
cts.CancelAfter(5000);
@@ -31,7 +39,7 @@ namespace HueUWP
string jsonResponse = await response.Content.ReadAsStringAsync();
- System.Diagnostics.Debug.WriteLine(jsonResponse);
+ //System.Diagnostics.Debug.WriteLine(jsonResponse);
return jsonResponse;
}
@@ -43,7 +51,7 @@ namespace HueUWP
}
- private async Task Post(string ip, int port, string path, string json)
+ private async Task Post(string path, string json)
{
var cts = new CancellationTokenSource();
cts.CancelAfter(5000);
@@ -63,7 +71,7 @@ namespace HueUWP
string jsonResponse = await response.Content.ReadAsStringAsync();
- System.Diagnostics.Debug.WriteLine(jsonResponse);
+ //System.Diagnostics.Debug.WriteLine(jsonResponse);
return jsonResponse;
}
@@ -74,7 +82,7 @@ namespace HueUWP
}
}
- private async Task Get(string ip, int port, string path)
+ private async Task Get(string path)
{
var cts = new CancellationTokenSource();
cts.CancelAfter(5000);
@@ -94,7 +102,7 @@ namespace HueUWP
string jsonResponse = await response.Content.ReadAsStringAsync();
- System.Diagnostics.Debug.WriteLine(jsonResponse);
+ //System.Diagnostics.Debug.WriteLine(jsonResponse);
return jsonResponse;
}
@@ -106,18 +114,20 @@ namespace HueUWP
}
- public async Task RegisterName(string AppName, string UserName)
+ public async Task RegisterName(string AppName, string UserName)
{
- var response = await Post("localhost",8000,"",$"{{\"devicetype\":\"{AppName}#{UserName}\"}}");
+ var response = await Post("",$"{{\"devicetype\":\"{AppName}#{UserName}\"}}");
if (string.IsNullOrEmpty(response))
await new MessageDialog("Error while setting username. ….").ShowAsync();
+ return response;
}
- public async Task Test()
+ public async Task Test()
{
- var response = await Get("localhost", 8000, "/111bb033202ac68b5812245c22f77eb/lights");
+ var response = await Get( "/111bb033202ac68b5812245c22f77eb/lights");
if (string.IsNullOrEmpty(response))
await new MessageDialog("Error while setting username. ….").ShowAsync();
+ return response;
}
diff --git a/HueUWP/Package.appxmanifest b/HueUWP/Package.appxmanifest
index ec2d358..d3e1aaa 100644
--- a/HueUWP/Package.appxmanifest
+++ b/HueUWP/Package.appxmanifest
@@ -7,15 +7,15 @@
IgnorableNamespaces="uap mp">
-
+
- HueUWP
- kenny
+ CarCheckInUWP
+ Paul de Mast
Assets\StoreLogo.png
@@ -30,12 +30,12 @@
+ EntryPoint="CarCheckInUWP.App">