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

Commit

Permalink
Code Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyrules committed Mar 26, 2019
1 parent 5cc69e7 commit 60d6ce4
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 52 deletions.
2 changes: 1 addition & 1 deletion HueLib2Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.624.0")]
[assembly: AssemblyVersion("1.0.626.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
48 changes: 0 additions & 48 deletions WinHue3/Functions/HotKeys/HotKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
using System.Runtime.Serialization;
using System.Windows.Input;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using WinHue3.Philips_Hue.HueObjects.Common;
using WinHue3.Philips_Hue.HueObjects.LightObject;
using Action = WinHue3.Philips_Hue.HueObjects.GroupObject.Action;

namespace WinHue3.Functions.HotKeys
{
Expand Down Expand Up @@ -34,50 +31,5 @@ public class HotKey
public string ProgramPath { get;set; }
}

public class HotkeyConverter : JsonConverter
{
public override bool CanWrite { get { return false; } }

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
// NOT USED.

}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
HotKey hk = new HotKey();
JObject obj = serializer.Deserialize<JObject>(reader);
hk.Description = obj["Description"]?.Value<string>();
hk.Name = obj["Name"]?.Value<string>();
hk.Key = obj["Key"].ToObject<Key>();
hk.Modifier = obj["Modifier"].ToObject<ModifierKeys>();
hk.id = obj["id"]?.Value<string>();
hk.objecType = obj["objecType"]?.ToObject<Type>();
hk.ProgramPath = obj["ProgramPath"]?.Value<string>();

if (obj["properties"] == null) return hk;
switch (hk.objecType?.Name)
{
case "Light":
hk.properties = obj["properties"].ToObject<State>();
break;
case "Group":
hk.properties = obj["properties"].ToObject<Action>();
break;
case "Scene":
hk.properties = obj["properties"].ToObject<Action>();
break;
default:
break;

}
return hk;
}

public override bool CanConvert(Type objectType)
{
return objectType == typeof(HotKey);
}
}
}
56 changes: 56 additions & 0 deletions WinHue3/Functions/HotKeys/HotKeyConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Windows.Input;
using WinHue3.Philips_Hue.HueObjects.LightObject;
using Action = WinHue3.Philips_Hue.HueObjects.GroupObject.Action;

namespace WinHue3.Functions.HotKeys
{
public class HotkeyConverter : JsonConverter
{
public override bool CanWrite { get { return false; } }

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
// NOT USED.

}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
HotKey hk = new HotKey();
JObject obj = serializer.Deserialize<JObject>(reader);
hk.Description = obj["Description"]?.Value<string>();
hk.Name = obj["Name"]?.Value<string>();
hk.Key = obj["Key"].ToObject<Key>();
hk.Modifier = obj["Modifier"].ToObject<ModifierKeys>();
hk.id = obj["id"]?.Value<string>();
hk.objecType = obj["objecType"]?.ToObject<Type>();
hk.ProgramPath = obj["ProgramPath"]?.Value<string>();

if (obj["properties"] == null) return hk;
switch (hk.objecType?.Name)
{
case "Light":
hk.properties = obj["properties"].ToObject<State>();
break;
case "Group":
hk.properties = obj["properties"].ToObject<Action>();
break;
case "Scene":
hk.properties = obj["properties"].ToObject<Action>();
break;
default:
break;

}
return hk;
}

public override bool CanConvert(Type objectType)
{
return objectType == typeof(HotKey);
}
}
}
2 changes: 1 addition & 1 deletion WinHue3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.0.4290.0")]
[assembly: AssemblyVersion("3.0.4292.0")]
//[assembly: AssemblyFileVersion("3.0.*")]
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
3 changes: 2 additions & 1 deletion WinHue3/WinHue3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@
<Compile Include="Functions\Grouping\BridgeGroup.cs" />
<Compile Include="Functions\Grouping\BridgeSubGroup.cs" />
<Compile Include="Functions\Grouping\IGroup.cs" />
<Compile Include="Functions\HotKeys\HotKeyConverter.cs" />
<Compile Include="Functions\PowerSettings\Form_PowerCustomSettings.xaml.cs">
<DependentUpon>Form_PowerCustomSettings.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -1055,7 +1056,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_BuildVersioningStyle="None.None.Increment.None" BuildVersion_AssemblyInfoFilename="..\..\..\..\Documents\Visual Studio 2012\Projects\WinHue3_1\WinHue3\Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_StartDate="2000/1/1" />
<UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="..\..\..\..\Documents\Visual Studio 2012\Projects\WinHue3_1\WinHue3\Properties\AssemblyInfo.cs" BuildVersion_BuildVersioningStyle="None.None.Increment.None" />
</VisualStudio>
</ProjectExtensions>
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion whc/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.488.0")]
[assembly: AssemblyVersion("1.0.490.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit 60d6ce4

Please sign in to comment.