OSDN Git Service

#28149 テンプレート名が空の不正なテンプレート呼び出しで処理が落ちていたのを修正,
[wptscs/wpts.git] / Wptscs / Program.cs
1 // ================================================================================================
2 // <summary>
3 //      アプリケーション起動用クラスソース</summary>
4 //
5 // <copyright file="Program.cs" company="honeplusのメモ帳">
6 //      Copyright (C) 2012 Honeplus. All rights reserved.</copyright>
7 // <author>
8 //      Honeplus</author>
9 // ================================================================================================
10
11 namespace Honememo.Wptscs
12 {
13     using System;
14     using System.Globalization;
15     using System.Threading;
16     using System.Windows.Forms;
17     using Honememo.Wptscs.Properties;
18
19     /// <summary>
20     /// アプリケーション起動時に最初に呼ばれるクラスです。
21     /// </summary>
22     internal static class Program
23     {
24         /// <summary>
25         /// 設定ファイルから表示言語の設定を読み込む。
26         /// </summary>
27         /// <remarks>特に表示言語が指定されていない場合は何もしない。</remarks>
28         public static void LoadSelectedCulture()
29         {
30             if (!String.IsNullOrWhiteSpace(Settings.Default.LastSelectedLanguage))
31             {
32                 try
33                 {
34                     Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(Settings.Default.LastSelectedLanguage);
35                     Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(Settings.Default.LastSelectedLanguage);
36                 }
37                 catch (Exception ex)
38                 {
39                     // 設定ファイルに手で不正な値が設定された場合など、万が一エラーになった場合デバッグログ
40                     System.Diagnostics.Debug.WriteLine("Program.LoadSelectedCulture : " + ex.ToString());
41                 }
42             }
43         }
44
45         /// <summary>
46         /// アプリケーションのメイン エントリ ポイントです。
47         /// </summary>
48         [STAThread]
49         private static void Main()
50         {
51             // 初回実行時は古いバージョンの設定があればバージョンアップ
52             if (!Settings.Default.IsUpgraded)
53             {
54                 // 現バージョンを上書きしてしまうため一度だけ実施
55                 Settings.Default.Upgrade();
56                 Settings.Default.IsUpgraded = true;
57             }
58
59             // 表示言語の設定が存在する場合、画面表示前にその設定を読み込み
60             Program.LoadSelectedCulture();
61
62             Application.EnableVisualStyles();
63             Application.SetCompatibleTextRenderingDefault(false);
64             Application.Run(new MainForm());
65         }
66     }
67 }