added multiselect

This commit is contained in:
Yorick Rommers
2015-12-04 14:49:24 +01:00
parent 482ebc828b
commit ad65c72747
7 changed files with 241 additions and 43 deletions
+1 -1
View File
@@ -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];
+7
View File
@@ -110,6 +110,9 @@
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="MultiEdit.xaml.cs">
<DependentUpon>MultiEdit.xaml</DependentUpon>
</Compile>
<Compile Include="NetworkHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingsView.xaml.cs">
@@ -150,6 +153,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MultiEdit.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
+40 -40
View File
@@ -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
+5 -2
View File
@@ -33,10 +33,10 @@
<RelativePanel Grid.Row="2" Margin="0,10,0,0" Name="LightListPanel">
<ScrollViewer RelativePanel.AlignBottomWithPanel="True" RelativePanel.AlignTopWithPanel="True">
<ListView x:Name="myListView" ItemsSource="{Binding}" IsItemClickEnabled="True" ItemClick="myListView_ItemClick" >
<ListView x:Name="myListView" ItemsSource="{Binding}" IsItemClickEnabled="True" ItemClick="myListView_ItemClick" SelectionMode="Extended">
<ListView.ItemTemplate>
<DataTemplate x:Name="dataTemplate">
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal" >
<Rectangle Width="30" Height="30" Fill="{Binding Color}" Margin="20,0,0,0" />
<StackPanel Orientation="Vertical" Width="140" Margin="10,0,0,0">
@@ -61,7 +61,10 @@
<Page.BottomAppBar>
<CommandBar>
<AppBarButton Icon="Edit" Label="Change values" Name="ValuesButton" Click="ValuesButton_Click" Visibility="Collapsed"/>
<AppBarButton Icon="Like" Label="On/Off" Name="OnOffButton" Click="OnOffButton_Click" Visibility="Collapsed"/>
<AppBarToggleButton Icon="Audio" Label="Disco" Name="DiscoButton" Click="DiscoButton_Click"/>
<AppBarToggleButton Icon="Save" Label="Group" Name="GroupButton" Click="GroupButton_Click"/>
<AppBarButton Icon="Setting" Label="Settings" Click="SettingsButton_Click"/>
<AppBarButton Icon="Refresh" Label="Refresh" Click="RefreshButton_Click"/>
<AppBarSeparator/>
+49
View File
@@ -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);
}
}
}
}
+61
View File
@@ -0,0 +1,61 @@
<Page
x:Class="HueUWP.MultiEdit"
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">
<Page.Resources>
<convert:NullableBooleanConverter x:Key="BoolConverter"/>
<convert:VisibilityConverter x:Key="VisibilityConverter"/>
</Page.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<RelativePanel Grid.Row="0">
<TextBlock RelativePanel.AlignLeftWithPanel="True" FontSize="24" Margin="20,10,0,0" Text="MultiEdit"/>
</RelativePanel>
<RelativePanel Grid.Row="1">
<TextBlock RelativePanel.AlignLeftWithPanel="True" FontSize="14" Margin="20,10,0,0" Text="Multiple Lamps"/>
</RelativePanel>
<RelativePanel Grid.Row="2">
<Rectangle Fill="{Binding color}" Name="ColorRectangle" RelativePanel.AlignLeftWithPanel="True" RelativePanel.AlignRightWithPanel="True" Height="20" Margin="0,10,0,10" />
</RelativePanel>
<StackPanel Grid.Row="3">
<ToggleSwitch Margin="20,10,0,10" Toggled="ToggleSwitch_Toggled" IsOn="False">
<ToggleSwitch.OffContent>Off</ToggleSwitch.OffContent>
<ToggleSwitch.OnContent>On</ToggleSwitch.OnContent>
</ToggleSwitch>
</StackPanel>
<StackPanel Grid.Row="4">
<StackPanel Margin="20,10,20,0" Visibility="Visible">
<TextBlock FontSize="18">Hue</TextBlock>
<Slider Maximum="65535" Name="HueSlider" Value="{Binding hue, Mode=TwoWay}" ValueChanged="Slider_ValueChanged" PointerCaptureLost="Slider_Released"/>
</StackPanel>
<StackPanel Margin="20,10,20,0" Visibility="Visible">
<TextBlock FontSize="18">Saturation</TextBlock>
<Slider Maximum="254" Name="SaturationSlider" Value="{Binding sat, Mode=TwoWay}" ValueChanged="Slider_ValueChanged" PointerCaptureLost="Slider_Released" />
</StackPanel>
<StackPanel Margin="20,10,20,0">
<TextBlock FontSize="18">Brightness</TextBlock>
<Slider Maximum="254" Name="BrightnessSlider" Value="{Binding bri, Mode=TwoWay}" ValueChanged="Slider_ValueChanged" PointerCaptureLost="Slider_Released"/>
</StackPanel>
</StackPanel>
</Grid>
</Page>
+78
View File
@@ -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
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MultiEdit : Page
{
IList<Light> lights = new List<Light>();
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);
}
}
}
}