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

Commit

Permalink
Change scene Icon. Implemented an option for wrapping or not the obje…
Browse files Browse the repository at this point in the history
…cts on the mainview. Added the group zero item on the main window.
  • Loading branch information
Hyrules committed Feb 4, 2017
1 parent 42a6d83 commit 1a97c34
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 51 deletions.
3 changes: 1 addition & 2 deletions HueLib2/Objects/Resourcelinks/Resourcelink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public class Resourcelink : HueObject
/// <summary>
/// Name of the resource link
/// </summary>
[DataMember(EmitDefaultValue = false, IsRequired = false), Category("Resource Link"),
Description("Name of the resource link")]
[DataMember(EmitDefaultValue = false, IsRequired = false), Category("Resource Link"),Description("Name of the resource link")]
public string name
{
get
Expand Down
16 changes: 13 additions & 3 deletions WinHue3/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
xmlns:viewmodels="clr-namespace:WinHue3.ViewModels"
xmlns:converters="clr-namespace:WinHue3.Converters"
xmlns:controls="clr-namespace:WinHue3.Controls"
xmlns:tt="clr-namespace:WinHue3.Utils"
x:Class="WinHue3.MainWindow"
Title="WinHue 3" Height="768" Width="1024" WindowStartupLocation="CenterScreen" MinHeight="600" MinWidth="800" Icon="Resources/HueGroupOn-Large.png" Closing="Window_Closing" ResizeMode="CanResizeWithGrip" >
<Window.Resources>
Expand All @@ -18,6 +19,14 @@
<converters:IndexToSortConverter x:Key="IndexToSortConverter"/>
<converters:DoubleToUshortConverter x:Key="SliderToUshortConverter"/>
<converters:BoolToWrappingConverter x:Key="BoolToWrappingConverter"/>
<Style TargetType="{x:Type TextBlock}" x:Key="tbWrap">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=cbWrapButton, Path=IsChecked}" Value="True">
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="Width" Value="75"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>

<Window.DataContext>
Expand Down Expand Up @@ -120,6 +129,7 @@
<RibbonButton Label="{x:Static resx:GUI.MainForm_Tab_Help_Website}" x:Name="btnWebsite" LargeImageSource="Resources/1416184952_Gnome-Web-Browser-32.png" Command="{Binding OpenWinHueWebsiteCommand}" />
<RibbonButton Label="{x:Static resx:GUI.MainForm_Tab_Help_Forum}" x:Name="btnSupportForum" LargeImageSource="Resources/1416183787_Community Help.png" Command="{Binding OpenWinHueSupportCommand}"/>
<RibbonButton Label="{x:Static resx:GUI.MainForm_Tab_Help_About}" x:Name="btnAbout" LargeImageSource="Resources/unknown.png" Command="{Binding OpenAboutWindowCommand}" />
<RibbonButton Label="ProcDump" LargeImageSource="Resources/unknown.png" Command="{Binding StartProcDumpCommand}"/>
</RibbonGroup>
</RibbonTab>
</Ribbon>
Expand Down Expand Up @@ -192,10 +202,10 @@
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<WrapPanel Orientation="Vertical" Margin="5,5,5,5" Height="Auto" Width="Auto" SnapsToDevicePixels="True" VerticalAlignment="Top" HorizontalAlignment="Center">
<WrapPanel Orientation="Vertical" Margin="5,5,5,5" ItemHeight="Auto" ItemWidth="Auto" SnapsToDevicePixels="True" VerticalAlignment="Top" HorizontalAlignment="Center">
<Image Height="64" Width="64" Source="{Binding Image}" SnapsToDevicePixels="True" RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
<TextBlock x:Name="tblName" Text="{Binding name}" HorizontalAlignment="Center" TextWrapping="{Binding MainFormModel.WrapText}"/>
<TextBlock x:Name="tblShowId" Text="{Binding Id}" Visibility="{Binding IsChecked, Converter={StaticResource BoolToVisibilityConverter}, ElementName=cbShowID}" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type WrapPanel}}, Path=Width}" TextAlignment="Center" FontStyle="Italic" />
<TextBlock x:Name="tblName" Text="{Binding name}" Style="{StaticResource tbWrap}" HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center"/>
<TextBlock x:Name="tblShowId" Text="{Binding Id}" Style="{StaticResource tbWrap}" Visibility="{Binding IsChecked, Converter={StaticResource BoolToVisibilityConverter}, ElementName=cbShowID}" TextAlignment="Center" FontStyle="Italic" TextWrapping="Wrap" />
</WrapPanel>
</DataTemplate>
</ListView.ItemTemplate>
Expand Down
9 changes: 8 additions & 1 deletion WinHue3/Models/ResourceLinkCreatorModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ public class ResourceLinkCreatorModel : ValidatableBindableBase
private string _description;
private bool? _recycle;
private ushort _classId;
private bool _showId;

public ResourceLinkCreatorModel()
{
_name = string.Empty;
ListlinkObject = new ObservableCollection<HueObject>();
ClassId = 0;
ClassId = 1;
}

[StringLength(32,MinimumLength = 1,ErrorMessageResourceName = "ResourceLinks_NameNeeded", ErrorMessageResourceType = typeof(GlobalStrings))]
Expand Down Expand Up @@ -55,5 +56,11 @@ public ushort ClassId
get { return _classId; }
set { SetProperty(ref _classId,value); }
}

public bool ShowID
{
get { return _showId; }
set { SetProperty(ref _showId, value); }
}
}
}
8 changes: 4 additions & 4 deletions WinHue3/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="animation" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\animation.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down Expand Up @@ -155,6 +154,7 @@
<data name="effects" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\effects.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="flashlight_shine" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
Expand Down Expand Up @@ -306,9 +306,6 @@
<data name="rules" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\rules.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SceneLarge" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\scene.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<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>
Expand Down Expand Up @@ -388,4 +385,7 @@
<data name="_1416205084_Book_edit" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\1416205084_Book_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SceneLarge" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\1486263478_movie-01.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added WinHue3/Resources/1486263478_movie-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 49 additions & 5 deletions WinHue3/Utils/HueObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,25 @@ public static HelperResult GetBridgeGroups(Bridge bridge)
HelperResult hr = new HelperResult
{
Success = bresult.Success,
Hrobject =
bresult.Success
? ProcessGroups((Dictionary<string, Group>)bresult.resultobject)
: bresult.resultobject
};

if (hr.Success)
{
Dictionary<string, Group> gs = (Dictionary<string, Group>) bresult.resultobject;
Group zero = GetGroupZero(bridge);
if (zero != null)
{
gs.Add("0",zero);
}

hr.Hrobject = ProcessGroups(gs);
}
else
{
hr.Hrobject = bresult.resultobject;
}


log.Debug("List groups : " + Serializer.SerializeToJson(hr.Hrobject));
return hr;
}
Expand Down Expand Up @@ -476,13 +489,44 @@ public static HelperResult GetBridgeDataStore(Bridge bridge)
HelperResult hr = new HelperResult
{
Success = bresult.Success,
Hrobject = bresult.Success ? ProcessDataStore((DataStore)bresult.resultobject) : bresult.resultobject

};
if (hr.Success)
{
DataStore ds = (DataStore) bresult.resultobject;
Group zero = GetGroupZero(bridge);
if (zero != null)
{
ds.groups.Add("0",zero);
}

hr.Hrobject = ProcessDataStore(ds);
}
else
{
hr.Hrobject = bresult.resultobject;
}


log.Debug("Bridge data store : " + Serializer.SerializeToJson(hr.Hrobject));
return hr;
}

private static Group GetGroupZero(Bridge bridge)
{

CommandResult cr = bridge.GetObject<Group>("0");
if (cr.Success)
{
return (Group) cr.resultobject;
}
else
{
return null;
}
}


/// <summary>
/// Process the data from the bridge datastore.
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion WinHue3/ViewModels/AnimatorView.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Windows.Input;
using ICSharpCode.AvalonEdit;
using HueLib2;

namespace WinHue3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ private bool IsObjectSelected()
private bool IsEditable()
{
if (!IsObjectSelected()) return false;
if (IsGroupZero()) return false;
return !(SelectedObject is Light);
}

Expand Down Expand Up @@ -168,6 +169,23 @@ private bool CanClone()
return SelectedObject is Scene | SelectedObject is Group | SelectedObject is Rule | CanCloneSensor() | SelectedObject is Resourcelink;
}

private bool CanRename()
{
if (!IsObjectSelected()) return false;
return !IsGroupZero();
}

private bool CanDelete()
{
if (!IsObjectSelected()) return false;
return !IsGroupZero();
}

private bool IsGroupZero()
{
return SelectedObject is Group && SelectedObject.Id == "0";
}

//*************** MainMenu Commands ********************

public ICommand OpenSettingsWindowCommand => new RelayCommand(param => OpenSettingsWindow());
Expand Down Expand Up @@ -209,8 +227,8 @@ private bool CanClone()
public ICommand DoBridgePairingCommand => new RelayCommand(param => DoBridgePairing(ListBridges));

//*************** Context Menu Commands *************
public ICommand DeleteObjectCommand => new RelayCommand(param => DeleteObject(), (param) => IsObjectSelected());
public ICommand RenameObjectCommand => new RelayCommand(param => RenameObject(), (param) => IsObjectSelected());
public ICommand DeleteObjectCommand => new RelayCommand(param => DeleteObject(), (param) => CanDelete());
public ICommand RenameObjectCommand => new RelayCommand(param => RenameObject(), (param) => CanRename());
public ICommand EditObjectCommand => new RelayCommand(param => EditObject(), (param) => IsEditable());
public ICommand IdentifyLongCommand => new RelayCommand(param => Identify("lselect"), (param) => CanIdentify());
public ICommand IdentifyShortCommand => new RelayCommand(param => Identify("select"), (param) => CanIdentify());
Expand Down Expand Up @@ -246,7 +264,7 @@ private bool CanClone()

public ICommand OpenAboutWindowCommand => new RelayCommand(param => OpenAboutWindow());


public ICommand StartProcDumpCommand => new RelayCommand(param => StartProcDump());
// public ICommand RssFeedMonCommand => new RelayCommand(param => RunRssFeedMon(), (param) => EnableButtons());
//
// public ICommand RssFeedMonSettingsCommand => new RelayCommand(param => RssFeedMonSettings(), (param) => EnableButtons());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private void DoubleClickObject()
SelectedObject.Image = newimg;
int index = _listBridgeObjects.FindIndex(x => x.Id == SelectedObject.Id && x.GetType() == SelectedObject.GetType());
if (index == -1) return;
if (SelectedObject.HasProperty("state"))
if (SelectedObject is Light)
{
((Light)SelectedObject).state.on = !((Light)SelectedObject).state.on;
((Light)ListBridgeObjects[index]).state.on = !((Light)ListBridgeObjects[index]).state.on;
Expand Down Expand Up @@ -948,5 +948,15 @@ private void WrapText()
WinHueSettings.settings.WrapText = MainFormModel.WrapText;
WinHueSettings.Save();
}

private void StartProcDump()
{
ProcessStartInfo psi = new ProcessStartInfo($"{AppDomain.CurrentDomain.BaseDirectory}procdump.exe")
{
Arguments = $@"-e -w -ma WinHue3.exe {Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\WinHue3",
UseShellExecute = false
};
Process.Start(psi);
}
}
}
14 changes: 13 additions & 1 deletion WinHue3/Views/Form_ResourceLinksCreator.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
xmlns:local="clr-namespace:WinHue3"
xmlns:resx="clr-namespace:WinHue3.Resources"
xmlns:viewmodel="clr-namespace:WinHue3.ViewModels"
xmlns:CustomControls="clr-namespace:WinHue3.Controls" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" x:Class="WinHue3.Form_ResourceLinksCreator"
xmlns:CustomControls="clr-namespace:WinHue3.Controls" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" x:Name="Form_ResourceLink" x:Class="WinHue3.Form_ResourceLinksCreator"
xmlns:converter="clr-namespace:WinHue3.Converters"
mc:Ignorable="d"
Title="{x:Static resx:GUI.ResourceLinkCreatorForm_Title}" Height="352.861" Width="599.472" WindowStartupLocation="CenterOwner" Icon="/WinHue3;component/Resources/resource.png" ResizeMode="CanResizeWithGrip" MinHeight="600" MinWidth="800">
<Window.DataContext>
<viewmodel:ResourceLinkCreatorViewModel/>
</Window.DataContext>
<Window.Resources>
<converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
<converter:BoolToOppositeBoolConverter x:Key="BoolToOppositeBoolConverter"/>
<Style TargetType="{x:Type ListView}">
<Style.Triggers>
Expand Down Expand Up @@ -43,6 +44,16 @@
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type TextBlock}" x:Key="tblID">
<Style.Triggers>
<DataTrigger Binding="{Binding DataContext.LinkCreatorModel.ShowID, ElementName=Form_ResourceLink}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding DataContext.LinkCreatorModel.ShowID, ElementName=Form_ResourceLink}" Value="False">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Label x:Name="label" Content="{x:Static resx:GUI.ResourceLinkCreatorForm_Name}" HorizontalAlignment="Left" Margin="11,7,0,0" VerticalAlignment="Top"/>
Expand All @@ -60,6 +71,7 @@
<WrapPanel Orientation="Vertical" Margin="5,5,5,5" Height="Auto" Width="75" SnapsToDevicePixels="True" VerticalAlignment="Top">
<Image Height="64" Width="64" Source="{Binding Image}" SnapsToDevicePixels="True" RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
<TextBlock x:Name="tblName" Text="{Binding name}" HorizontalAlignment="Center" TextWrapping="Wrap"/>
<TextBlock x:Name="tblShowId" Text="{Binding Id}" Style="{StaticResource tblID}" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type WrapPanel}}, Path=Width}" TextAlignment="Center" FontStyle="Italic" />
</WrapPanel>
</DataTemplate>
</CustomControls:BindableListView.ItemTemplate>
Expand Down
Loading

0 comments on commit 1a97c34

Please sign in to comment.