sliders working
This commit is contained in:
@@ -44,7 +44,8 @@ namespace HueUWP
|
||||
{
|
||||
if(l.IsOn)
|
||||
{
|
||||
var json = await nwh.SetLightInfo(l.ID, $"{{\"bri\": {l.Brightness-1},\"hue\": {(l.Hue/360)*65535},\"sat\": {l.Saturation*254}}}");
|
||||
Debug.WriteLine(l.Hue);
|
||||
var json = await nwh.SetLightInfo(l.ID, $"{{\"bri\": {l.Brightness},\"hue\": {(l.Hue)},\"sat\": {l.Saturation}}}");
|
||||
Debug.WriteLine(json);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
</RelativePanel>
|
||||
|
||||
<StackPanel Grid.Row="1">
|
||||
<Slider Maximum="65535" Value="{Binding Hue}" />
|
||||
<Slider Maximum="254" Value="{Binding Saturation}" />
|
||||
<Slider Maximum="254" Value="{Binding Brightness}" />
|
||||
<Slider Maximum="65535" Value="{Binding Hue, Mode=TwoWay}" ValueChanged="Slider_ValueChanged" PointerCaptureLost="Slider_PointerCaptureLost"/>
|
||||
<Slider Maximum="254" Value="{Binding Saturation, Mode=TwoWay}" ValueChanged="Slider_ValueChanged" PointerCaptureLost="Slider_PointerCaptureLost" />
|
||||
<Slider Maximum="254" Value="{Binding Brightness, Mode=TwoWay}" ValueChanged="Slider_ValueChanged" PointerCaptureLost="Slider_PointerCaptureLost"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
@@ -34,5 +35,21 @@ namespace HueUWP
|
||||
l = e.Parameter as Light;
|
||||
this.DataContext = l;
|
||||
}
|
||||
|
||||
|
||||
private void Slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
|
||||
{
|
||||
//l.UpdateColor();
|
||||
}
|
||||
|
||||
private void Slider_DragLeave(object sender, DragEventArgs e)
|
||||
{
|
||||
l.UpdateColor();
|
||||
}
|
||||
|
||||
private void Slider_PointerCaptureLost(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
l.UpdateColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-8
@@ -41,16 +41,17 @@ namespace HueUWP
|
||||
|
||||
}
|
||||
|
||||
public void UpdateColor(int r, int g, int b)
|
||||
public void UpdateColor()
|
||||
{
|
||||
NotifyPropertyChanged(nameof(UpdateColor));
|
||||
double h; double s; double v;
|
||||
ColorUtil.RGBtoHSV(r,g,b, out h,out s,out v);
|
||||
this.Hue = h; this.Saturation = s; this.Brightness = v;
|
||||
api.SetLightValues(this);
|
||||
Debug.WriteLine(r + "-" + g + "-" + b);
|
||||
Debug.WriteLine(h + "-" + s + "-" + v);
|
||||
NotifyPropertyChanged(nameof(UpdateColor));
|
||||
}
|
||||
|
||||
public void UpdateColor(int h, int s, int b)
|
||||
{
|
||||
//double h; double s; double v;
|
||||
//ColorUtil.RGBtoHSV(r,g,b, out h,out s,out v);
|
||||
this.Hue = h; this.Saturation = s; this.Brightness = b;
|
||||
api.SetLightValues(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,8 +54,6 @@ namespace HueUWP
|
||||
{
|
||||
Button button = ((Button)sender);
|
||||
Light light = (Light)button.DataContext;
|
||||
|
||||
light.UpdateColor(10, 10, 10);
|
||||
}
|
||||
|
||||
public void ToggleSwitch_Tapped(object sender, TappedRoutedEventArgs e)
|
||||
@@ -72,7 +70,6 @@ namespace HueUWP
|
||||
ToggleSwitch button = ((ToggleSwitch)sender);
|
||||
Light light = (Light)button.DataContext;
|
||||
light.UpdateState(button.IsOn);
|
||||
light.UpdateColor(0, 38, 255);
|
||||
}
|
||||
|
||||
private void RegisterButton_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user