From 9e26f989798f5505eb16d17e5124be6e9751a4ab Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Fri, 27 Nov 2015 13:29:20 +0100 Subject: [PATCH] Added layout --- HueUWP/Light.cs | 65 +++++++++++++++++++++-------------------- HueUWP/MainPage.xaml | 22 +++++++------- HueUWP/MainPage.xaml.cs | 17 +++++++---- 3 files changed, 55 insertions(+), 49 deletions(-) diff --git a/HueUWP/Light.cs b/HueUWP/Light.cs index 69436ff..ea6a1e8 100644 --- a/HueUWP/Light.cs +++ b/HueUWP/Light.cs @@ -2,41 +2,49 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; -namespace BindingToCommandsUWP +namespace HueUWP { 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 int ID { get; private set; } + public string Name { get; private set; } + public string Type { get; private set; } + public bool On { get; private set; } + public int Brightness{ get; private set; } + public int Hue { get; private set; } + public int Saturation { get; private set; } public Light() { - + Debug.WriteLine("Get lamp data on creation or something"); + //temp + ID = 1; + Name = "Lamp 1"; + Type = "Extended color light"; + On = true; + Brightness = 10; + Hue = 14215; + Saturation = 425; } - public void CheckInCar() + public void UpdateState(bool on) { - this.CheckedInDateTime = String.Format("{0:t}", DateTime.Now); + NotifyPropertyChanged(nameof(UpdateState)); + Debug.WriteLine(on); + + } + + public void UpdateColor(int r, int g, int b) + { + NotifyPropertyChanged(nameof(UpdateColor)); + Debug.WriteLine(r + "-" + g + "-" + b); } @@ -51,24 +59,17 @@ namespace BindingToCommandsUWP public class LightDataSource { - private static ObservableCollection _cars + private static ObservableCollection _lights = new ObservableCollection(); - public static ObservableCollection GetCars() + public static ObservableCollection GetLights() { - if (_cars.Count == 0) + if (_lights.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" }); + _lights.Add(new Light()); } - return _cars; + return _lights; } - - //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 4d9e4d8..fbec180 100644 --- a/HueUWP/MainPage.xaml +++ b/HueUWP/MainPage.xaml @@ -5,7 +5,8 @@ xmlns:local="using:BindingToCommandsUWP" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - DataContext="{Binding CarsViewModel, RelativeSource={RelativeSource Self}}" + xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" + DataContext="{Binding LightsViewModel, RelativeSource={RelativeSource Self}}" mc:Ignorable="d"> @@ -14,21 +15,18 @@ + + - - + + -