Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
Modifed the refresher heartbeat to update the object and not replace …
Browse files Browse the repository at this point in the history
…it so the selected object stays selected
  • Loading branch information
Hyrules committed Jul 7, 2016
1 parent c750cbc commit 9723840
Show file tree
Hide file tree
Showing 16 changed files with 190 additions and 15 deletions.
6 changes: 5 additions & 1 deletion HueLib_base/Light/Light.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System.CodeDom;
using System.ComponentModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
Expand Down Expand Up @@ -66,5 +67,8 @@ public override string ToString()
{
return JsonConvert.SerializeObject(this, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, StringEscapeHandling = StringEscapeHandling.Default });
}



}
}
15 changes: 15 additions & 0 deletions WinHue3/Forms/Form_BulbsView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Window x:Class="WinHue3.Form_BulbsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WinHue3"
xmlns:resx="clr-namespace:WinHue3.Resources"
mc:Ignorable="d"
Title="{x:Static resx:GUI.Form_BulbsView_Title}" Height="492" Width="730.667" Icon="/WinHue3;component/Resources/BulbView.png" ResizeMode="CanResizeWithGrip">
<Grid>
<ToolBarTray Height="32" VerticalAlignment="Top"/>
<DataGrid x:Name="dataGrid" HorizontalAlignment="Left" Margin="0,32,0,-0.333" VerticalAlignment="Top" Height="431" Width="724" Background="White" HorizontalGridLinesBrush="#FFB2B2B2" VerticalGridLinesBrush="#FFB2B2B2" ItemsSource="{Binding BulbsDetails}"/>

</Grid>
</Window>
33 changes: 33 additions & 0 deletions WinHue3/Forms/Form_BulbsView.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using HueLib;

namespace WinHue3
{
/// <summary>
/// Interaction logic for Form_BulbsView.xaml
/// </summary>
public partial class Form_BulbsView : Window
{
private BulbsViewView _bvv;
private Bridge _br;
public Form_BulbsView(Bridge br)
{
InitializeComponent();
_br = br;
_bvv = new BulbsViewView(br);
DataContext = _bvv;
}
}
}
9 changes: 6 additions & 3 deletions WinHue3/Forms/Form_SceneMapping.xaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
<Window x:Class="WinHue3.Form_SceneMapping"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WinHue3"
xmlns:resources="clr-namespace:WinHue3.Resources"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid" x:Class="WinHue3.Form_SceneMapping"
mc:Ignorable="d"
Title="{x:Static resources:GUI.Form_SceneMapping_Title}" Height="653.956" Width="891.887" WindowStartupLocation="CenterOwner" Icon="/WinHue3;component/Resources/SceneMapping.png" ResizeMode="CanResizeWithGrip">
<Grid>
<DataGrid x:Name="dgSceneMap" CanUserResizeRows="False" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True" HorizontalGridLinesBrush="#FFB2B2B2" IsTabStop="True" VerticalGridLinesBrush="#FFB2B2B2" Margin="0,29,0.333,-0.333" HorizontalContentAlignment="Center" ItemsSource="{Binding SceneMapping}" AlternationCount="2" AlternatingRowBackground="#FFF0F0F0" Background="White"/>
<ToolBarTray Height="29" VerticalAlignment="Top" Margin="0,0,0.333,0">
<ToolBar x:Name="toolBar" HorizontalAlignment="Left" Margin="0,0,-212,-16.333" VerticalAlignment="Top" Height="29" Width="auto">
<Button Command="{Binding RefreshMappingCommand}" ToolTip="{x:Static resources:GUI.Form_SceneMapping_RefreshTooltip}">
<Image Source="/WinHue3;component/Resources/1409707765_reload.png" />
</Button>
<Separator/>
<xctk:WatermarkTextBox x:Name="tbFilter" Width="180" Text="{Binding Filter,UpdateSourceTrigger=PropertyChanged}" Margin="1" Watermark="Filter data here..." />
<xctk:WatermarkTextBox x:Name="tbFilter" Width="180" Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged}" Margin="1" Watermark="Filter data here..." />
</ToolBar>
</ToolBarTray>

<xcdg:DataGridControl Margin="0,29,0.333,-0.333" ItemsSource="{Binding SceneMapping}" IsCopyCommandEnabled="False" AlternationCount="2" ReadOnly="True" SelectionMode="Single" IsTextSearchEnabled="True"/>




Expand Down
1 change: 1 addition & 0 deletions WinHue3/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<RibbonTab Header="{x:Static resx:GUI.MainForm_Tab_View}" HorizontalAlignment="Stretch" VerticalAlignment="Top">
<RibbonGroup x:Name="rgViews" Header="" Width="auto">
<RibbonButton x:Name="btnScenesMapping" Label="{x:Static resx:GUI.MainForm_Tab_View_SceneMapping}" Command="{Binding ViewSceneMappingCommand}" LargeImageSource="Resources/SceneMapping.png"/>
<RibbonButton x:Name="btnBulbView" Label="{x:Static resx:GUI.MainForm_Tab_View_BulbsView}" Command="{Binding ViewBulbsCommand}" LargeImageSource="Resources/BulbView.png" />
</RibbonGroup>
</RibbonTab>
<RibbonTab Header="{x:Static resx:GUI.MainForm_Tab_Help}" HorizontalAlignment="Stretch" VerticalAlignment="Top">
Expand Down
10 changes: 10 additions & 0 deletions WinHue3/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions WinHue3/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,7 @@
<data name="SceneMapping" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SceneMapping.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="BulbView" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\BulbView.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added WinHue3/Resources/BulbView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions WinHue3/Resources/GUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions WinHue3/Resources/GUI.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -981,4 +981,10 @@
<data name="Form_SceneMapping_RefreshTooltip" xml:space="preserve">
<value>Actualiser</value>
</data>
<data name="MainForm_Tab_View_BulbsView" xml:space="preserve">
<value>Vue des ampoules</value>
</data>
<data name="Form_BulbsView_Title" xml:space="preserve">
<value>Vue des ampoules</value>
</data>
</root>
6 changes: 6 additions & 0 deletions WinHue3/Resources/GUI.resx
Original file line number Diff line number Diff line change
Expand Up @@ -981,4 +981,10 @@
<data name="Form_SceneMapping_RefreshTooltip" xml:space="preserve">
<value>Refresh</value>
</data>
<data name="MainForm_Tab_View_BulbsView" xml:space="preserve">
<value>Bulbs View</value>
</data>
<data name="Form_BulbsView_Title" xml:space="preserve">
<value>Bulbs View</value>
</data>
</root>
33 changes: 33 additions & 0 deletions WinHue3/Views/BulbsViewView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HueLib;
using HueLib_base;

namespace WinHue3
{
public class BulbsViewView : View
{
private Bridge _bridge;
private DataTable _dt;

public BulbsViewView(Bridge br)
{
_bridge = br;
BuildBulbsView();
}

public DataView BulbsDetails => _dt.DefaultView;

private void BuildBulbsView()
{
Dictionary<string, Light> llights = _bridge.GetLightList();


}

}
}
30 changes: 22 additions & 8 deletions WinHue3/Views/MainFormView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ private void _refreshStates_Tick(object sender, EventArgs e)
//log.Debug("Automatic refresh in progress");

List<HueObject> ll = _listBridgeObjects.Where(x => x.GetType() == typeof(Light)).ToList();

HueObject _selectedHueObject = SelectedObject;
foreach (HueObject obj in ll)
{

RefreshObject(obj);

}

SelectedObject = _selectedHueObject;
}

#endregion
Expand Down Expand Up @@ -802,6 +804,8 @@ private void RenameObject()
private void RefreshObject(HueObject obj, bool logging = false)
{
HueObject newobj;
int index = _listBridgeObjects.FindIndex(x => x.Id == obj.Id && x.GetType() == obj.GetType());
if (index == -1) return;

if (obj is Light)
{
Expand Down Expand Up @@ -833,14 +837,19 @@ private void RefreshObject(HueObject obj, bool logging = false)
}

if(logging) log.Debug("Refreshing Object : " + newobj.ToString());

if (newobj == null) return;
_listBridgeObjects[index].Image = newobj.Image;
PropertyInfo[] pi = newobj.GetType().GetProperties();
foreach (PropertyInfo p in pi)
{
if (_listBridgeObjects[index].HasProperty(p.Name))
p.SetValue(_listBridgeObjects[index], _listBridgeObjects[index].GetType().GetProperty(p.Name).GetValue(newobj));
}

int index = _listBridgeObjects.FindIndex(x => x.Id == obj.Id && x.GetType() == obj.GetType());
if (index == -1) return;
_listBridgeObjects[index] = newobj;
//SelectedObject = newobj;
OnPropertyChanged("ListBridgeObjects");
if(logging) log.Info($"Refreshed Object ID: {index}");
// OnPropertyChanged("ListBridgeObjects");
if (logging) log.Info($"Refreshed Object ID: {index}");
}

private void EditObject()
Expand Down Expand Up @@ -1218,6 +1227,11 @@ private void ViewSceneMapping()
_fsm.Show();
}

private void ViewBulbs()
{

}

#region PLUGINS
/// <summary>
/// Load all the plugins in the plugin folder.
Expand Down Expand Up @@ -1397,7 +1411,7 @@ private static void Pluginbutton_Click(object sender, RoutedEventArgs e)
//*************** View Commands ************************

public ICommand ViewSceneMappingCommand => new RelayCommand(param => ViewSceneMapping());

public ICommand ViewBulbsCommand => new RelayCommand(param => ViewBulbs());
#endregion
}
}
26 changes: 23 additions & 3 deletions WinHue3/Views/SceneMappingView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using HueLib;
using HueLib_base;
Expand All @@ -14,6 +16,7 @@ public class SceneMappingView : View
private Bridge _bridge;
private DataTable _dt;
private string _filter;
private object _selectedcell;

public SceneMappingView(Bridge br)
{
Expand Down Expand Up @@ -69,7 +72,7 @@ public void BuildSceneMapping()
Dictionary<string, Light> llights = _bridge.GetLightList();

DataTable dt = new DataTable();
dt.Columns.Add("Scenes");
dt.Columns.Add("Scenes",typeof(Button));

// Add all light columns
foreach (KeyValuePair<string, Light> kvp in llights)
Expand All @@ -86,11 +89,23 @@ public void BuildSceneMapping()
{

object[] data = new object[llights.Count + 4];
data[0] = svp.Value.name;
Button btn = new Button
{
Content = new TextBlock() {Text = svp.Value.name, TextWrapping = TextWrapping.Wrap,Height = Double.NaN, TextAlignment = TextAlignment.Center},

};

btn.Click += (o, e) =>
{
_bridge.ActivateScene(svp.Key);
};
data[0] = btn;

int i = 1;
foreach (KeyValuePair<string, Light> lvp in llights)
{
string value = svp.Value.lights.Contains(lvp.Key) ? "Assigned" : "";

data[i] = new string(value.ToCharArray());
i++;
}
Expand All @@ -112,7 +127,12 @@ public void RefreshSceneMapping()
FilterData();
}

public ICommand RefreshMappingCommand => new RelayCommand(param => RefreshSceneMapping());
public void ProcessDoubleClick(object val)
{

}

public ICommand RefreshMappingCommand => new RelayCommand(param => RefreshSceneMapping());
public ICommand DoubleClickObjectCommand => new RelayCommand(ProcessDoubleClick);
}
}
9 changes: 9 additions & 0 deletions WinHue3/WinHue3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@
<Compile Include="Forms\Form_AnimationCreator.xaml.cs">
<DependentUpon>Form_AnimationCreator.xaml</DependentUpon>
</Compile>
<Compile Include="Forms\Form_BulbsView.xaml.cs">
<DependentUpon>Form_BulbsView.xaml</DependentUpon>
</Compile>
<Compile Include="Forms\Form_SceneMapping.xaml.cs">
<DependentUpon>Form_SceneMapping.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -201,6 +204,7 @@
<Compile Include="Views\AnimatorView.cs" />
<Compile Include="Views\BridgeSettingsView.cs" />
<Compile Include="Views\BridgeDetectionPairingView.cs" />
<Compile Include="Views\BulbsViewView.cs" />
<Compile Include="Views\HotKeyCreatorView.cs" />
<Compile Include="Views\SceneMappingView.cs" />
<Compile Include="Views\WaitView.cs" />
Expand All @@ -224,6 +228,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Forms\Form_BulbsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Forms\Form_GroupCreator.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -519,6 +527,7 @@
<Content Include="lights\images\ZLL Light_unr.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="Resources\BulbView.png" />
<Resource Include="Resources\SceneMapping.png" />
<Resource Include="Resources\1465102684_preferences-desktop-keyboard-shortcuts.png" />
<Resource Include="Resources\close_delete.png" />
Expand Down
Binary file modified inno/Output/WinHue 3 BETA 16 Setup.exe
Binary file not shown.

0 comments on commit 9723840

Please sign in to comment.