static void Main() { // エラーハンドラ登録 System.Threading.Thread.GetDomain().UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e) { Exception ex = e.ExceptionObject as Exception; SaveExceptionLog(ex); }; try { // プラグインを検索する HeadlinePluginManager.FindPlugins(); // 設定を読み込む UserSettingAdapter.Load(); // ヘッドラインを読み込む HeadlineManager.Load(); Application.Run(new MainForm()); #region 番組取得のスレッドを終了する // ヘッドライン取得処理の中止 HeadlineManager.CancelFetchChannelsAsync(); // スレッドが中止されるまで待つ // 1秒待ってスレッドが中止されないようなら、スレッドの中止を待たずにここを抜ける for (int i = 0; HeadlineManager.IsExistBusyFetchChannelAsync() == true && i < 10; ++i) { System.Threading.Thread.Sleep(100); } #endregion // 番組取得のスレッドを終了する } catch (Exception ex) { SaveExceptionLog(ex); // 例外の再送 throw ex; } finally { // ヘッドラインを保存する HeadlineManager.Save(); // 設定を保存する UserSettingAdapter.Save(); } }
private void SettingForm_Closing(object sender, CancelEventArgs e) { #region 設定の書き込み UserSettingAdapter.Setting.MediaPlayerPath = mediaPlayerPathTextBox2.Text.Trim(); UserSettingAdapter.Setting.WebBrowserPath = webBrowserPathTextBox2.Text.Trim(); UserSettingAdapter.Setting.PlaylistSave = playlistSaveCheckBox.Checked; UserSettingAdapter.Setting.HeadlineAutomaticUpdatesInterval = (int)hedlineAutomaticUpdatesIntervalNumericUpDown.Value * 1000; switch (headlineListFontSizeDomainUpDown.SelectedIndex) { case 1: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size6pt; break; case 2: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size7pt; break; case 3: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size8pt; break; case 4: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size9pt; break; case 5: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size10pt; break; case 6: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size11pt; break; case 7: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size12pt; break; case 8: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size13pt; break; case 9: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size14pt; break; case 10: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size15pt; break; case 11: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size16pt; break; case 12: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size17pt; break; case 13: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size18pt; break; case 14: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size19pt; break; case 15: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.Size20pt; break; case 0: default: UserSettingAdapter.Setting.HeadlineListFontSize = UserSetting.HeadlineListFontSizes.DefaultSize; break; } if (proxyNoUseRadioButton.Checked == true) { UserSettingAdapter.Setting.ProxySetting.ProxyUse = WebProxySetting.ProxyConnects.NoUse; } else if (autoDetectProxySettingRadioButton.Checked == true) { UserSettingAdapter.Setting.ProxySetting.ProxyUse = WebProxySetting.ProxyConnects.AutoDetect; } else if (manualProxySettingRadioButton.Checked == true) { UserSettingAdapter.Setting.ProxySetting.ProxyUse = WebProxySetting.ProxyConnects.Manual; } else { // ここに到達することはあり得ない Trace.Assert(false, "想定外の動作のため、終了します"); } UserSettingAdapter.Setting.ProxySetting.ProxyServer = proxyServerTextBox.Text.Trim(); try { UserSettingAdapter.Setting.ProxySetting.ProxyPort = int.Parse(proxyPortTextBox.Text.Trim()); } catch (ArgumentException) {; } catch (FormatException) {; } catch (OverflowException) {; } try { UserSettingAdapter.Save(); } catch (IOException) { MessageBox.Show("設定ファイルが書き込めませんでした", "設定ファイル書き込みエラー"); } #endregion }