Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Grabacr07 committed Aug 11, 2015
2 parents ac7c19b + 9d80943 commit 59ecfde
Show file tree
Hide file tree
Showing 26 changed files with 576 additions and 314 deletions.
8 changes: 8 additions & 0 deletions source/Grabacr07.KanColleViewer/Composition/PluginHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ public void Initialize()
Exception = ex.ToString(),
});
}
catch (FileLoadException ex)
{
this.failedPlugins.Add(new LoadFailedPluginData
{
FilePath = filepath,
Exception = ex.ToString(),
});
}
}

this.container = new CompositionContainer(catalog);
Expand Down
5 changes: 2 additions & 3 deletions source/Grabacr07.KanColleViewer/KanColleViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
<DependentUpon>Tools.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Controls\MetroComboBox.cs" />
<Compile Include="Views\Converters\RangeToBooleanConverter.cs" />
<Compile Include="Views\InformationWindow.xaml.cs">
<DependentUpon>InformationWindow.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -625,9 +626,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Converters\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
5 changes: 3 additions & 2 deletions source/Grabacr07.KanColleViewer/Models/ProductInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public static class ProductInfo
private static readonly Lazy<IReadOnlyCollection<Library>> librariesLazy = new Lazy<IReadOnlyCollection<Library>>(() => new List<Library>
{
new Library("Reactive Extensions", new Uri("http://rx.codeplex.com/")),
new Library("Windows API Code Pack", new Uri("http://archive.msdn.microsoft.com/WindowsAPICodePack")),
new Library("Livet", new Uri("http://ugaya40.net/livet")),
new Library("Livet", new Uri("http://ugaya40.hateblo.jp/entry/Livet")),
new Library("StatefulModel", new Uri("http://ugaya40.hateblo.jp/entry/StatefulModel")),
new Library("DynamicJson", new Uri("http://dynamicjson.codeplex.com/")),
new Library("Nekoxy", new Uri("https://github.com/veigr/Nekoxy")),
new Library("Desktop Toast", new Uri("https://github.com/emoacht/DesktopToast")),
new Library(".NET Core Audio APIs", new Uri("https://netcoreaudio.codeplex.com/")),
});

Expand Down
10 changes: 5 additions & 5 deletions source/Grabacr07.KanColleViewer/Models/Settings/Providers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ namespace Grabacr07.KanColleViewer.Models.Settings
{
public static class Providers
{

private static readonly string roamingFilePath = Path.Combine(
public static string RoamingFilePath { get; } = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"grabacr.net", "KanColleViewer", "Settings.xaml");

private static readonly string localFilePath = Path.Combine(
public static string LocalFilePath { get; } = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"grabacr.net", "KanColleViewer", "Settings.xaml");

public static ISerializationProvider Roaming { get; } = new FileSettingsProvider(roamingFilePath);
public static ISerializationProvider Local { get; } = new FileSettingsProvider(localFilePath);
public static ISerializationProvider Roaming { get; } = new FileSettingsProvider(RoamingFilePath);

public static ISerializationProvider Local { get; } = new FileSettingsProvider(LocalFilePath);
}
}
191 changes: 123 additions & 68 deletions source/Grabacr07.KanColleViewer/Models/Settings/SettingsHost.cs
Original file line number Diff line number Diff line change
@@ -1,68 +1,123 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using MetroTrilithon.Serialization;

namespace Grabacr07.KanColleViewer.Models.Settings
{
public abstract class SettingsHost
{
private static readonly Dictionary<Type, SettingsHost> instances = new Dictionary<Type, SettingsHost>();
private readonly Dictionary<string, object> cachedProperties = new Dictionary<string, object>();

protected virtual string CategoryName => this.GetType().Name;

protected SettingsHost()
{
instances[this.GetType()] = this;
}

/// <summary>
/// 現在のインスタンスにキャッシュされている <see cref="SerializableProperty{T}"/>
/// を取得します。 キャッシュがない場合は <see cref="create"/> に従って生成します。
/// </summary>
/// <returns></returns>
protected SerializableProperty<T> Cache<T>(Func<string, SerializableProperty<T>> create, [CallerMemberName] string propertyName = "")
{
var key = this.CategoryName + "." + propertyName;

object obj;
if (this.cachedProperties.TryGetValue(key, out obj) && obj is SerializableProperty<T>) return (SerializableProperty<T>)obj;

var property = create(key);
this.cachedProperties[key] = property;

return property;
}


public static void Load()
{
#pragma warning disable 612
// 古い設定が存在する可能性があるので、読んでおく
// (ただし、1 度読んだら新しい方に移行するので保存はしない
Migration._Settings.Load();
#pragma warning restore 612

Providers.Local.Load();
Providers.Roaming.Load();
}

public static void Save()
{
Providers.Local.Save();
Providers.Roaming.Save();
}

/// <summary>
/// <typeparamref name="T"/> 型の設定オブジェクトの唯一のインスタンスを取得します。
/// </summary>
public static T Instance<T>() where T : SettingsHost, new()
{
SettingsHost host;
return instances.TryGetValue(typeof(T), out host) ? (T)host : new T();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
using MetroTrilithon.Serialization;

namespace Grabacr07.KanColleViewer.Models.Settings
{
public abstract class SettingsHost
{
private static readonly Dictionary<Type, SettingsHost> instances = new Dictionary<Type, SettingsHost>();
private readonly Dictionary<string, object> cachedProperties = new Dictionary<string, object>();

protected virtual string CategoryName => this.GetType().Name;

protected SettingsHost()
{
instances[this.GetType()] = this;
}

/// <summary>
/// 現在のインスタンスにキャッシュされている <see cref="SerializableProperty{T}"/>
/// を取得します。 キャッシュがない場合は <see cref="create"/> に従って生成します。
/// </summary>
/// <returns></returns>
protected SerializableProperty<T> Cache<T>(Func<string, SerializableProperty<T>> create, [CallerMemberName] string propertyName = "")
{
var key = this.CategoryName + "." + propertyName;

object obj;
if (this.cachedProperties.TryGetValue(key, out obj) && obj is SerializableProperty<T>) return (SerializableProperty<T>)obj;

var property = create(key);
this.cachedProperties[key] = property;

return property;
}


#region Load / Save

public static void Load()
{
#pragma warning disable 612
// 古い設定が存在する可能性があるので、読んでおく
// (ただし、1 度読んだら新しい方に移行するので保存はしない
Migration._Settings.Load();
#pragma warning restore 612

#region const message

const string message = @"設定ファイル ({0}) の読み込みに失敗しました。このファイルを削除することで解決する可能性があります。
エラーの詳細: {1}";

#endregion

try
{
Providers.Local.Load();
}
catch (Exception ex)
{
MessageBox.Show(string.Format(message, Providers.LocalFilePath, ex.Message), "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
throw;
}

try
{
Providers.Roaming.Load();
}
catch (Exception ex)
{
MessageBox.Show(string.Format(message, Providers.RoamingFilePath, ex.Message), "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
throw;
}
}

public static void Save()
{
#region const message

const string message = @"設定ファイル ({0}) の保存に失敗しました。
エラーの詳細: {1}";

#endregion

try
{
Providers.Local.Save();
}
catch (Exception ex)
{
MessageBox.Show(string.Format(message, Providers.LocalFilePath, ex.Message), "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
throw;
}

try
{
Providers.Roaming.Save();
}
catch (Exception ex)
{
MessageBox.Show(string.Format(message, Providers.RoamingFilePath, ex.Message), "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
throw;
}
}

#endregion

/// <summary>
/// <typeparamref name="T"/> 型の設定オブジェクトの唯一のインスタンスを取得します。
/// </summary>
public static T Instance<T>() where T : SettingsHost, new()
{
SettingsHost host;
return instances.TryGetValue(typeof(T), out host) ? (T)host : new T();
}
}
}
110 changes: 55 additions & 55 deletions source/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;

// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
// アセンブリに関連付けられている情報を変更するには、
// これらの属性値を変更してください。
[assembly: AssemblyTitle("提督業も忙しい!")]
[assembly: AssemblyDescription("提督業も忙しい!")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("grabacr.net")]
[assembly: AssemblyProduct("KanColleViewer")]
[assembly: AssemblyCopyright("Copyright © 2013 Grabacr07")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: Guid("101B49A6-7E7B-422D-95FF-500F9EF483A8")]

// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
// 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
// その型の ComVisible 属性を true に設定してください。
[assembly: ComVisible(false)]

//ローカライズ可能なアプリケーションのビルドを開始するには、
//.csproj ファイルの <UICulture>CultureYouAreCodingWith</UICulture> を
//<PropertyGroup> 内部で設定します。たとえば、
//ソース ファイルで英語を使用している場合、<UICulture> を en-US に設定します。次に、
//下の NeutralResourceLanguage 属性のコメントを解除します。下の行の "en-US" を
//プロジェクト ファイルの UICulture 設定と一致するよう更新します。

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
// テーマ固有のリソース ディクショナリが置かれている場所
// (リソースがページ、またはアプリケーション リソース ディクショナリに見つからない場合に使用されます)
ResourceDictionaryLocation.None,

// 汎用リソース ディクショナリが置かれている場所
// (リソースがページ、アプリケーション、またはいずれのテーマ固有のリソース ディクショナリにも見つからない場合に使用されます)
ResourceDictionaryLocation.SourceAssembly
)]


// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.0.0")]
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;

// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
// アセンブリに関連付けられている情報を変更するには、
// これらの属性値を変更してください。
[assembly: AssemblyTitle("提督業も忙しい!")]
[assembly: AssemblyDescription("提督業も忙しい!")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("grabacr.net")]
[assembly: AssemblyProduct("KanColleViewer")]
[assembly: AssemblyCopyright("Copyright © 2013 Grabacr07")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: Guid("101B49A6-7E7B-422D-95FF-500F9EF483A8")]

// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
// 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、
// その型の ComVisible 属性を true に設定してください。
[assembly: ComVisible(false)]

//ローカライズ可能なアプリケーションのビルドを開始するには、
//.csproj ファイルの <UICulture>CultureYouAreCodingWith</UICulture> を
//<PropertyGroup> 内部で設定します。たとえば、
//ソース ファイルで英語を使用している場合、<UICulture> を en-US に設定します。次に、
//下の NeutralResourceLanguage 属性のコメントを解除します。下の行の "en-US" を
//プロジェクト ファイルの UICulture 設定と一致するよう更新します。

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
// テーマ固有のリソース ディクショナリが置かれている場所
// (リソースがページ、またはアプリケーション リソース ディクショナリに見つからない場合に使用されます)
ResourceDictionaryLocation.None,

// 汎用リソース ディクショナリが置かれている場所
// (リソースがページ、アプリケーション、またはいずれのテーマ固有のリソース ディクショナリにも見つからない場合に使用されます)
ResourceDictionaryLocation.SourceAssembly
)]


// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.1.0.0")]
Loading

0 comments on commit 59ecfde

Please sign in to comment.