Skip to content

Commit

Permalink
Merge 4.1.7 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuubari committed Nov 19, 2015
2 parents 8f90e7f + 761ed85 commit baeffef
Show file tree
Hide file tree
Showing 14 changed files with 312 additions and 210 deletions.
Binary file added assemblies/mshtml.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions source/Grabacr07.KanColleViewer/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<setting name="KcvApiUrl" serializeAs="String">
<value>http://kcvapi.koumakan.jp/version/</value>
</setting>
<setting name="SallyAreaSource" serializeAs="String">
<value>http://shatteredskies.blob.core.windows.net/kancolle/sally.json</value>
</setting>
</Grabacr07.KanColleViewer.Properties.Settings>
</applicationSettings>
<runtime>
Expand Down
27 changes: 18 additions & 9 deletions source/Grabacr07.KanColleViewer/KanColleViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
<Reference Include="Livet.Extensions">
<HintPath>..\packages\LivetExtensions.1.1.0.0\lib\net45\Livet.Extensions.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Expression.Drawing, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\assemblies\Microsoft.Expression.Drawing.dll</HintPath>
Expand All @@ -77,10 +81,19 @@
<HintPath>..\packages\LivetCask.1.3.1.0\lib\net45\Microsoft.Expression.Interactions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="mshtml">
<HintPath>..\..\assemblies\mshtml.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Nekoxy, Version=1.5.1.19, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nekoxy.1.5.1.19\lib\net45\Nekoxy.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -114,6 +127,10 @@
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="TrotiNet, Version=0.8.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nekoxy.1.5.1.19\lib\net45\TrotiNet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Vannatech.CoreAudio">
<HintPath>..\..\assemblies\Vannatech.CoreAudio.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -141,6 +158,7 @@
<Compile Include="Models\ProxyBootstrapper.cs" />
<Compile Include="Models\Migration\_ProxySettings.cs" />
<Compile Include="Models\ResourceService.cs" />
<Compile Include="Models\SallyArea.cs" />
<Compile Include="Models\Settings\GeneralSettings.cs" />
<Compile Include="Models\Settings\KanColleSettings.cs" />
<Compile Include="Models\Settings\KanColleWindowSettings.cs" />
Expand Down Expand Up @@ -609,15 +627,6 @@
</None>
</ItemGroup>
<ItemGroup>
<COMReference Include="MSHTML">
<Guid>{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}</Guid>
<VersionMajor>4</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="SHDocVw">
<Guid>{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}</Guid>
<VersionMajor>1</VersionMajor>
Expand Down
93 changes: 45 additions & 48 deletions source/Grabacr07.KanColleViewer/Models/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using Grabacr07.KanColleViewer.Win32;
using Microsoft.Win32;
using Nekoxy;

namespace Grabacr07.KanColleViewer.Models
{
Expand Down Expand Up @@ -141,69 +145,62 @@ private static bool DeleteInternetCacheCore()
}


/// <summary>
/// 指定した文字列を暗号化します。
/// </summary>
/// <param name="source">暗号化する文字列。</param>
/// <param name="password">暗号化に使用するパスワード。</param>
/// <returns>暗号化された文字列。</returns>
public static string EncryptString(string source, string password)
{
using (var rijndael = new RijndaelManaged())
{
byte[] key, iv;
GenerateKeyFromPassword(password, rijndael.KeySize, out key, rijndael.BlockSize, out iv);
rijndael.Key = key;
rijndael.IV = iv;

using (var encryptor = rijndael.CreateEncryptor())
{
var strBytes = Encoding.UTF8.GetBytes(source);
var encBytes = encryptor.TransformFinalBlock(strBytes, 0, strBytes.Length);
return Convert.ToBase64String(encBytes);
}
}
}

/// <summary>
/// 指定された文字列を複合化します。
/// </summary>
/// <param name="source">暗号化された文字列。</param>
/// <param name="password">暗号化に使用したパスワード。</param>
/// <returns>復号化された文字列。</returns>
public static string DecryptString(string source, string password)
public static Color StringToColor(string colorCode)
{
try
{
using (var rijndael = new RijndaelManaged())
if (colorCode.StartsWith("#"))
{
byte[] key, iv;
GenerateKeyFromPassword(password, rijndael.KeySize, out key, rijndael.BlockSize, out iv);
rijndael.Key = key;
rijndael.IV = iv;

using (var decryptor = rijndael.CreateDecryptor())
if (colorCode.Length == 7)
{
// #rrggbb style
return Color.FromRgb(
Convert.ToByte(colorCode.Substring(1, 2), 16),
Convert.ToByte(colorCode.Substring(3, 2), 16),
Convert.ToByte(colorCode.Substring(5, 2), 16));
}
if (colorCode.Length == 9)
{
var strBytes = Convert.FromBase64String(source);
var decBytes = decryptor.TransformFinalBlock(strBytes, 0, strBytes.Length);
return Encoding.UTF8.GetString(decBytes);
// #aarrggbb style
return Color.FromArgb(
Convert.ToByte(colorCode.Substring(1, 2), 16),
Convert.ToByte(colorCode.Substring(3, 2), 16),
Convert.ToByte(colorCode.Substring(5, 2), 16),
Convert.ToByte(colorCode.Substring(7, 2), 16));
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex);
return null;
// 雑
System.Diagnostics.Debug.WriteLine(ex);
}

return Colors.Transparent;
}

private static void GenerateKeyFromPassword(string password, int keySize, out byte[] key, int blockSize, out byte[] iv)
public static HttpClientHandler GetProxyConfiguredHandler()
{
var salt = Encoding.UTF8.GetBytes("C98534F6-7286-4BED-83A6-10FD5052ABA6");
using (var deriveBytes = new Rfc2898DeriveBytes(password, salt) { IterationCount = 1000 })
switch (HttpProxy.UpstreamProxyConfig.Type)
{
key = deriveBytes.GetBytes(keySize / 8);
iv = deriveBytes.GetBytes(blockSize / 8);
case ProxyConfigType.DirectAccess:
return new HttpClientHandler
{
UseProxy = false,
};

case ProxyConfigType.SpecificProxy:
return new HttpClientHandler
{
UseProxy = true,
Proxy = new WebProxy($"{HttpProxy.UpstreamProxyConfig.SpecificProxyHost}:{HttpProxy.UpstreamProxyConfig.SpecificProxyPort}"),
};

case ProxyConfigType.SystemProxy:
return new HttpClientHandler();

default:
return new HttpClientHandler();
}
}
}
Expand Down
60 changes: 60 additions & 0 deletions source/Grabacr07.KanColleViewer/Models/SallyArea.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows.Media;
using Codeplex.Data;

namespace Grabacr07.KanColleViewer.Models
{
public class SallyArea
{
public int Area { get; private set; }

public string Name { get; private set; }

public Color Color { get; private set; } = Colors.Transparent;

private SallyArea() { }

public static SallyArea Default { get; } = new SallyArea();

public static async Task<SallyArea[]> GetAsync()
{
using (var client = new HttpClient(Helper.GetProxyConfiguredHandler()))
{
try
{
var uri = new Uri(Properties.Settings.Default.SallyAreaSource);
var response = await client.GetAsync(uri);
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
var json = DynamicJson.Parse(content);
var result = ((object[])json)
.Select(x => (dynamic)x)
.Select(x =>
new SallyArea
{
Area = (int)x.area,
Name = (string)x.name,
Color = Helper.StringToColor(x.color)
})
.ToArray();

return result;
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
StatusService.Current.Notify("出撃海域の取得に失敗しました: " + ex);
}
}

return new SallyArea[0];
}
}
}
2 changes: 1 addition & 1 deletion source/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.1.6.1")]
[assembly: AssemblyVersion("4.1.7.0")]

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

3 changes: 3 additions & 0 deletions source/Grabacr07.KanColleViewer/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
display:none!important;
}</Value>
</Setting>
<Setting Name="SallyAreaSource" Type="System.String" Scope="Application">
<Value Profile="(Default)">http://shatteredskies.blob.core.windows.net/kancolle/sally.json</Value>
</Setting>
<Setting Name="KcvApiUrl" Type="System.String" Scope="Application">
<Value Profile="(Default)">http://kcvapi.koumakan.jp/version/</Value>
</Setting>
Expand Down
Loading

0 comments on commit baeffef

Please sign in to comment.