mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Libraries updated + XmlSerializer replaced by JsonConvert
This commit is contained in:
@ -32,17 +32,18 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="EDIDParser, Version=1.1.6347.28506, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="EDIDParser, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\EDIDParser.1.1.6347.28506\lib\net45\EDIDParser.dll</HintPath>
|
<HintPath>..\packages\EDIDParser.1.2.0.1\lib\net45\EDIDParser.dll</HintPath>
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="IconLib, Version=0.73.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="IconLib, Version=0.73.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\IconLib.Unofficial.0.73.0\lib\net20\IconLib.dll</HintPath>
|
<HintPath>..\packages\IconLib.Unofficial.0.73.0\lib\net20\IconLib.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="NvAPIWrapper.Net, Version=0.5.6315.41439, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\NvAPIWrapper.Net.0.5.6315.41439\lib\net45\NvAPIWrapper.Net.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<Private>True</Private>
|
</Reference>
|
||||||
|
<Reference Include="NvAPIWrapper, Version=0.6.0.3, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NvAPIWrapper.Net.0.6.0.4\lib\net45\NvAPIWrapper.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@ -50,9 +51,8 @@
|
|||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="WindowsDisplayAPI, Version=1.0.6336.17084, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="WindowsDisplayAPI, Version=1.1.0.1, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\WindowsDisplayAPI.1.0.6336.17084\lib\net45\WindowsDisplayAPI.dll</HintPath>
|
<HintPath>..\packages\WindowsDisplayAPI.1.1.0.2\lib\net45\WindowsDisplayAPI.dll</HintPath>
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -10,9 +10,11 @@ using System.Xml.Linq;
|
|||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using WindowsDisplayAPI.DisplayConfig;
|
using WindowsDisplayAPI.DisplayConfig;
|
||||||
using HeliosDisplayManagement.Shared.Resources;
|
using HeliosDisplayManagement.Shared.Resources;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using NvAPIWrapper.GPU;
|
using NvAPIWrapper.GPU;
|
||||||
using NvAPIWrapper.Mosaic;
|
using NvAPIWrapper.Mosaic;
|
||||||
using NvAPIWrapper.Native.Mosaic;
|
using NvAPIWrapper.Native.Mosaic;
|
||||||
|
using Formatting = Newtonsoft.Json.Formatting;
|
||||||
using Path = HeliosDisplayManagement.Shared.Topology.Path;
|
using Path = HeliosDisplayManagement.Shared.Topology.Path;
|
||||||
|
|
||||||
namespace HeliosDisplayManagement.Shared
|
namespace HeliosDisplayManagement.Shared
|
||||||
@ -35,6 +37,7 @@ namespace HeliosDisplayManagement.Shared
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool IsActive
|
public bool IsActive
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -45,6 +48,7 @@ namespace HeliosDisplayManagement.Shared
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public bool IsPossible
|
public bool IsPossible
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -96,9 +100,10 @@ namespace HeliosDisplayManagement.Shared
|
|||||||
public Path[] Paths { get; set; } = new Path[0];
|
public Path[] Paths { get; set; } = new Path[0];
|
||||||
|
|
||||||
public static string ProfilesPath
|
public static string ProfilesPath
|
||||||
=>
|
{
|
||||||
System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
get => System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
Assembly.GetExecutingAssembly().GetName().Name, $"DisplayProfiles_{Version.ToString(2)}.xml");
|
Assembly.GetExecutingAssembly().GetName().Name, $"DisplayProfiles_{Version.ToString(2)}.json");
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool Equals(Profile other)
|
public bool Equals(Profile other)
|
||||||
@ -114,14 +119,10 @@ namespace HeliosDisplayManagement.Shared
|
|||||||
{
|
{
|
||||||
if (File.Exists(ProfilesPath))
|
if (File.Exists(ProfilesPath))
|
||||||
{
|
{
|
||||||
var xml = File.ReadAllText(ProfilesPath, Encoding.Unicode);
|
var json = File.ReadAllText(ProfilesPath, Encoding.Unicode);
|
||||||
if (!string.IsNullOrWhiteSpace(xml))
|
if (!string.IsNullOrWhiteSpace(json))
|
||||||
{
|
{
|
||||||
var serializer = XmlSerializer.FromTypes(new[] {typeof(Profile[])})[0];
|
return JsonConvert.DeserializeObject<Profile[]>(json);
|
||||||
using (var reader = XmlReader.Create(new StringReader(xml)))
|
|
||||||
{
|
|
||||||
return (Profile[]) serializer.Deserialize(reader);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,29 +162,14 @@ namespace HeliosDisplayManagement.Shared
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var serializer = XmlSerializer.FromTypes(new[] {typeof(Profile[])})[0];
|
var json = JsonConvert.SerializeObject(array.ToArray(), Formatting.Indented);
|
||||||
var sb = new StringBuilder();
|
if (!string.IsNullOrWhiteSpace(json))
|
||||||
using (var writer = XmlWriter.Create(sb))
|
|
||||||
{
|
|
||||||
serializer.Serialize(writer, array.ToArray());
|
|
||||||
}
|
|
||||||
var xml = sb.ToString();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var doc = XDocument.Parse(xml);
|
|
||||||
xml = doc.ToString();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrWhiteSpace(xml))
|
|
||||||
{
|
{
|
||||||
var dir = System.IO.Path.GetDirectoryName(ProfilesPath);
|
var dir = System.IO.Path.GetDirectoryName(ProfilesPath);
|
||||||
if (dir != null)
|
if (dir != null)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
File.WriteAllText(ProfilesPath, xml, Encoding.Unicode);
|
File.WriteAllText(ProfilesPath, json, Encoding.Unicode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,15 +250,14 @@ namespace HeliosDisplayManagement.Shared
|
|||||||
|
|
||||||
public Profile Clone()
|
public Profile Clone()
|
||||||
{
|
{
|
||||||
var serializer = XmlSerializer.FromTypes(new[] {typeof(Profile)})[0];
|
try
|
||||||
var sb = new StringBuilder();
|
|
||||||
using (var writer = XmlWriter.Create(sb))
|
|
||||||
{
|
{
|
||||||
serializer.Serialize(writer, this);
|
var serialized = JsonConvert.SerializeObject(this);
|
||||||
|
return JsonConvert.DeserializeObject<Profile>(serialized);
|
||||||
}
|
}
|
||||||
using (var reader = XmlReader.Create(new StringReader(sb.ToString())))
|
catch
|
||||||
{
|
{
|
||||||
return (Profile) serializer.Deserialize(reader);
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<packages>
|
<packages>
|
||||||
<package id="EDIDParser" version="1.2.0.1" targetFramework="net45" />
|
<package id="EDIDParser" version="1.2.0.1" targetFramework="net45" />
|
||||||
<package id="IconLib.Unofficial" version="0.73.0" targetFramework="net45" />
|
<package id="IconLib.Unofficial" version="0.73.0" targetFramework="net45" />
|
||||||
|
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net45" />
|
||||||
<package id="NvAPIWrapper.Net" version="0.6.0.4" targetFramework="net45" />
|
<package id="NvAPIWrapper.Net" version="0.6.0.4" targetFramework="net45" />
|
||||||
<package id="WindowsDisplayAPI" version="1.1.0.2" targetFramework="net45" />
|
<package id="WindowsDisplayAPI" version="1.1.0.2" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
@ -31,9 +31,11 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="SharpShell, Version=2.2.0.0, Culture=neutral, PublicKeyToken=f14dc899472fe6fb, processorArchitecture=MSIL">
|
<Reference Include="Apex.WinForms, Version=1.6.0.0, Culture=neutral, PublicKeyToken=98d06957926c086d, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\SharpShellTools.2.2.0.0\lib\SharpShell.dll</HintPath>
|
<HintPath>..\packages\SharpShellTools.2.2.1\lib\Apex.WinForms.dll</HintPath>
|
||||||
<Private>True</Private>
|
</Reference>
|
||||||
|
<Reference Include="SharpShell, Version=2.2.1.0, Culture=neutral, PublicKeyToken=f14dc899472fe6fb, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SharpShellTools.2.2.1\lib\SharpShell.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@ -57,9 +59,6 @@
|
|||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="packages.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
@ -77,6 +76,7 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
<None Include="Resources\Run_x16.png" />
|
<None Include="Resources\Run_x16.png" />
|
||||||
<None Include="Resources\Shortcut_x16.png" />
|
<None Include="Resources\Shortcut_x16.png" />
|
||||||
<None Include="Resources\Edit_x16.png" />
|
<None Include="Resources\Edit_x16.png" />
|
||||||
|
@ -54,26 +54,22 @@
|
|||||||
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
<ApplicationIcon>Icon.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="CircularProgressBar, Version=2.5.6403.13419, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="CircularProgressBar, Version=2.6.6823.24527, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\CircularProgressBar.2.5.6403.13419\lib\net35-client\CircularProgressBar.dll</HintPath>
|
<HintPath>..\packages\CircularProgressBar.2.6.6823.24527\lib\net35-client\CircularProgressBar.dll</HintPath>
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
|
<Reference Include="CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
|
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="HtmlAgilityPack, Version=1.5.1.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
|
<Reference Include="HtmlAgilityPack, Version=1.8.7.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\HtmlAgilityPack.1.5.1\lib\Net45\HtmlAgilityPack.dll</HintPath>
|
<HintPath>..\packages\HtmlAgilityPack.1.8.7\lib\Net45\HtmlAgilityPack.dll</HintPath>
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="IconLib, Version=0.73.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="IconLib, Version=0.73.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\IconLib.Unofficial.0.73.0\lib\net20\IconLib.dll</HintPath>
|
<HintPath>..\packages\IconLib.Unofficial.0.73.0\lib\net20\IconLib.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@ -83,9 +79,8 @@
|
|||||||
<Reference Include="System.XML" />
|
<Reference Include="System.XML" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Xml.Serialization" />
|
<Reference Include="System.Xml.Serialization" />
|
||||||
<Reference Include="WindowsDisplayAPI, Version=1.0.6336.17084, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="WindowsDisplayAPI, Version=1.1.0.1, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\WindowsDisplayAPI.1.0.6336.17084\lib\net45\WindowsDisplayAPI.dll</HintPath>
|
<HintPath>..\packages\WindowsDisplayAPI.1.1.0.2\lib\net45\WindowsDisplayAPI.dll</HintPath>
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="WinFormAnimation, Version=1.5.6298.3372, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="WinFormAnimation, Version=1.5.6298.3372, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\WinFormAnimation.1.5.6298.3372\lib\net35-client\WinFormAnimation.dll</HintPath>
|
<HintPath>..\packages\WinFormAnimation.1.5.6298.3372\lib\net35-client\WinFormAnimation.dll</HintPath>
|
||||||
|
@ -40,7 +40,7 @@ namespace HeliosDisplayManagement.Steam
|
|||||||
public static string GameIdsPath
|
public static string GameIdsPath
|
||||||
=>
|
=>
|
||||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
Assembly.GetExecutingAssembly().GetName().Name, @"SteamGames.xml");
|
Assembly.GetExecutingAssembly().GetName().Name, @"SteamGames.json");
|
||||||
|
|
||||||
public static string IconCache
|
public static string IconCache
|
||||||
=>
|
=>
|
||||||
@ -192,29 +192,14 @@ namespace HeliosDisplayManagement.Steam
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var serializer = new XmlSerializer(typeof(SteamAppIdNamePair[]));
|
var json = JsonConvert.SerializeObject(gameIds);
|
||||||
var sb = new StringBuilder();
|
if (!string.IsNullOrWhiteSpace(json))
|
||||||
using (var writer = XmlWriter.Create(sb))
|
|
||||||
{
|
|
||||||
serializer.Serialize(writer, gameIds.ToArray());
|
|
||||||
}
|
|
||||||
var xml = sb.ToString();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var doc = XDocument.Parse(xml);
|
|
||||||
xml = doc.ToString();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrWhiteSpace(xml))
|
|
||||||
{
|
{
|
||||||
var dir = Path.GetDirectoryName(GameIdsPath);
|
var dir = Path.GetDirectoryName(GameIdsPath);
|
||||||
if (dir != null)
|
if (dir != null)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
File.WriteAllText(GameIdsPath, xml, Encoding.Unicode);
|
File.WriteAllText(GameIdsPath, json, Encoding.Unicode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,14 +215,10 @@ namespace HeliosDisplayManagement.Steam
|
|||||||
{
|
{
|
||||||
if (File.Exists(GameIdsPath))
|
if (File.Exists(GameIdsPath))
|
||||||
{
|
{
|
||||||
var xml = File.ReadAllText(GameIdsPath, Encoding.Unicode);
|
var json = File.ReadAllText(GameIdsPath, Encoding.Unicode);
|
||||||
if (!string.IsNullOrWhiteSpace(xml))
|
if (!string.IsNullOrWhiteSpace(json))
|
||||||
{
|
{
|
||||||
var serializer = new XmlSerializer(typeof(SteamAppIdNamePair[]));
|
return JsonConvert.DeserializeObject<SteamAppIdNamePair[]>(json);
|
||||||
using (var reader = XmlReader.Create(new StringReader(xml)))
|
|
||||||
{
|
|
||||||
return (SteamAppIdNamePair[]) serializer.Deserialize(reader);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user