diff --git a/HueUWP/APIHandler.cs b/HueUWP/APIHandler.cs index 0aacfb2..25ab39f 100755 --- a/HueUWP/APIHandler.cs +++ b/HueUWP/APIHandler.cs @@ -60,6 +60,7 @@ namespace HueUWP { l.Hue = rnd.Next(0, 65535); l.Brightness = rnd.Next(128, 254); + l.Saturation = 254; l.UpdateColorDisco(); }); //"transitiontime": 0 @@ -109,7 +110,6 @@ namespace HueUWP try { var json = await nwh.AllLights(); JObject o = JObject.Parse(json); - Debug.WriteLine(o.ToString()); foreach(var i in o) { var light = o["" + i.Key]; diff --git a/HueUWP/HueUWP.csproj b/HueUWP/HueUWP.csproj index aae2ed5..8f0923c 100644 --- a/HueUWP/HueUWP.csproj +++ b/HueUWP/HueUWP.csproj @@ -110,6 +110,9 @@ MainPage.xaml + + MultiEdit.xaml + @@ -150,6 +153,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/HueUWP/HueUWP.sln b/HueUWP/HueUWP.sln index 6e5e026..a304d8a 100644 --- a/HueUWP/HueUWP.sln +++ b/HueUWP/HueUWP.sln @@ -1,40 +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 + +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/MainPage.xaml b/HueUWP/MainPage.xaml index 69cc931..002e06a 100644 --- a/HueUWP/MainPage.xaml +++ b/HueUWP/MainPage.xaml @@ -33,10 +33,10 @@ - + - + @@ -61,7 +61,10 @@ + + + diff --git a/HueUWP/MainPage.xaml.cs b/HueUWP/MainPage.xaml.cs index cd5358a..ad6983e 100644 --- a/HueUWP/MainPage.xaml.cs +++ b/HueUWP/MainPage.xaml.cs @@ -1,3 +1,5 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -126,5 +128,52 @@ namespace HueUWP else api.DiscoMode(false); } + + private void GroupButton_Click(object sender, RoutedEventArgs e) + { + + if ((bool)GroupButton.IsChecked) + { + myListView.IsItemClickEnabled = false; + myListView.SelectionMode = ListViewSelectionMode.Multiple; + OnOffButton.Visibility = Visibility.Visible; + ValuesButton.Visibility = Visibility.Visible; + } + else + { + myListView.IsItemClickEnabled = true; + myListView.SelectionMode = ListViewSelectionMode.Single; + OnOffButton.Visibility = Visibility.Collapsed; + ValuesButton.Visibility = Visibility.Collapsed; + } + + } + + private void OnOffButton_Click(object sender, RoutedEventArgs e) + { + if ((bool)GroupButton.IsChecked) + { + foreach(var v in myListView.SelectedItems) + { + ((Light)v).UpdateState(!((Light)v).IsOn); + } + } + } + + public ListView GetListView() + { + return myListView; + } + + //hue.imegumii.space + private void ValuesButton_Click(object sender, RoutedEventArgs e) + { + if ((bool)GroupButton.IsChecked) + { + Frame rootframe = Window.Current.Content as Frame; + if (myListView.SelectedItems != null) + rootframe.Navigate(typeof(MultiEdit), this); + } + } } } diff --git a/HueUWP/MultiEdit.xaml b/HueUWP/MultiEdit.xaml new file mode 100755 index 0000000..dfc6641 --- /dev/null +++ b/HueUWP/MultiEdit.xaml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Off + On + + + + + + Hue + + + + + Saturation + + + + + Brightness + + + + + + diff --git a/HueUWP/MultiEdit.xaml.cs b/HueUWP/MultiEdit.xaml.cs new file mode 100755 index 0000000..6188d2e --- /dev/null +++ b/HueUWP/MultiEdit.xaml.cs @@ -0,0 +1,78 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Diagnostics; +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 MultiEdit : Page + { + IList lights = new List(); + MainPage main; + int hue = 65535; + int sat = 254; + int bri = 254; + + public MultiEdit() + { + this.InitializeComponent(); + } + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + main = e.Parameter as MainPage; + foreach(var v in main.GetListView().SelectedItems) + { + Light l = (Light)v; + lights.Add(l); + } + this.DataContext = this; + } + + + private void Slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) + { + //l.UpdateColor(); + } + + private void Slider_Released(object sender, PointerRoutedEventArgs e) + { + foreach(var l in lights) + { + l.Hue = HueSlider.Value; + l.Saturation = SaturationSlider.Value; + l.Brightness = BrightnessSlider.Value; + ColorRectangle.Fill = new SolidColorBrush(ColorUtil.getColor(l)); + l.UpdateColor(); + } + } + + private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e) + { + ToggleSwitch button = ((ToggleSwitch)sender); + foreach(var l in lights) + { + + l.UpdateState(button.IsOn); + } + + } + } +}