1 // ================================================================================================
3 // Wikipedia翻訳支援ツール主画面クラスソース</summary>
5 // <copyright file="MainForm.cs" company="honeplusのメモ帳">
6 // Copyright (C) 2012 Honeplus. All rights reserved.</copyright>
9 // ================================================================================================
11 namespace Honememo.Wptscs
14 using System.Collections.Generic;
15 using System.ComponentModel;
18 using System.Threading;
19 using System.Windows.Forms;
20 using Honememo.Utilities;
21 using Honememo.Wptscs.Logics;
22 using Honememo.Wptscs.Models;
23 using Honememo.Wptscs.Properties;
24 using Honememo.Wptscs.Utilities;
25 using Honememo.Wptscs.Websites;
28 /// Wikipedia翻訳支援ツール主画面のクラスです。
30 public partial class MainForm : Form
35 /// 現在読み込んでいるアプリケーションの設定。
37 private Config config;
42 private Translator translator;
47 private int logLength;
52 private StatusManager<string> statusManager;
59 /// コンストラクタ。初期化メソッド呼び出しのみ。
63 // Windows フォーム デザイナで生成されたコード
64 this.InitializeComponent();
69 #region フォームの各イベントのメソッド
74 /// <param name="sender">イベント発生オブジェクト。</param>
75 /// <param name="e">発生したイベント。</param>
76 private void MainForm_Load(object sender, EventArgs e)
79 this.statusManager = new StatusManager<string>();
80 this.statusManager.Changed += new EventHandler(
81 delegate { this.toolStripStatusLabelStatus.Text = StringUtils.DefaultString(this.statusManager.Status); });
83 // 表示言語選択メニュー、設定選択メニューの初期設定
84 this.InitializeDropDownButtonLanguage();
85 this.InitializeDropDownButtonConfig();
87 // 設定ファイルの読み込みと関連項目の初期設定
88 this.InitializeByConfig();
91 this.textBoxSaveDirectory.Text = Settings.Default.SaveDirectory;
95 /// フォームクローズ時の処理。処理状態を保存。
97 /// <param name="sender">イベント発生オブジェクト。</param>
98 /// <param name="e">発生したイベント。</param>
99 private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
101 // 現在の出力先フォルダ、翻訳元/先言語、
102 // また更新されていれば表示言語や設定ファイルの選択を保存
104 Settings.Default.Save();
109 #region 翻訳元/先言語グループのイベントのメソッド
112 /// 翻訳元コンボボックス変更時の処理。
114 /// <param name="sender">イベント発生オブジェクト。</param>
115 /// <param name="e">発生したイベント。</param>
116 private void ComboBoxSource_SelectedIndexChanged(object sender, EventArgs e)
119 Website site = this.config.GetWebsite(this.comboBoxSource.Text);
120 this.SetLanguageNameLabel(this.labelSource, site);
123 this.linkLabelSourceURL.Text = "http://";
126 this.linkLabelSourceURL.Text = site.Location;
131 /// リンクラベルのリンククリック時の処理。
133 /// <param name="sender">イベント発生オブジェクト。</param>
134 /// <param name="e">発生したイベント。</param>
135 private void LinkLabelSourceURL_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
138 System.Diagnostics.Process.Start(((LinkLabel)sender).Text);
142 /// 翻訳先コンボボックス変更時の処理。
144 /// <param name="sender">イベント発生オブジェクト。</param>
145 /// <param name="e">発生したイベント。</param>
146 private void ComboBoxTarget_SelectedIndexChanged(object sender, EventArgs e)
149 this.SetLanguageNameLabel(this.labelTarget, this.config.GetWebsite(this.comboBoxTarget.Text));
155 /// <param name="sender">イベント発生オブジェクト。</param>
156 /// <param name="e">発生したイベント。</param>
157 private void ButtonConfig_Click(object sender, EventArgs e)
163 using (ConfigForm form = new ConfigForm(this.config))
168 // 戻ってきたら設定ファイルを再読み込みして表示を更新
169 // ※ キャンセル時もインスタンスは更新されてしまうので
170 this.InitializeByConfig();
173 #region イベント実装支援用メソッド
176 /// 翻訳元/先言語コンボボックスの初期化処理。
178 private void InitializeComboBox()
181 this.comboBoxSource.Items.Clear();
182 this.comboBoxTarget.Items.Clear();
184 // 設定ファイルに存在する全言語を選択肢として登録する
185 foreach (Website site in this.config.Websites)
187 this.comboBoxSource.Items.Add(site.Language.Code);
188 this.comboBoxTarget.Items.Add(site.Language.Code);
192 this.comboBoxSource.SelectedItem = Settings.Default.LastSelectedSource;
193 this.comboBoxTarget.SelectedItem = Settings.Default.LastSelectedTarget;
196 // ※ 項目が存在する場合は↑で自動的に呼ばれるが、無い場合は呼ばれないため
197 this.ComboBoxSource_SelectedIndexChanged(this.comboBoxSource, new EventArgs());
198 this.ComboBoxTarget_SelectedIndexChanged(this.comboBoxTarget, new EventArgs());
202 /// ウェブサイトの言語の表示名ラベルの表示を設定する。
204 /// <param name="label">言語の表示名用ラベル。</param>
205 /// <param name="site">選択されている言語のウェブサイト。</param>
206 private void SetLanguageNameLabel(Label label, Website site)
209 label.Text = string.Empty;
215 // ウェブサイトが空でない場合、その言語の、ユーザーが使用している言語での表示名を表示
216 // (日本語環境だったら日本語を、英語環境だったら英語を)
217 Language.LanguageName name;
218 if (site.Language.Names.TryGetValue(
219 Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName,
222 label.Text = name.Name;
230 #region フォルダの選択グループのイベントのメソッド
235 /// <param name="sender">イベント発生オブジェクト。</param>
236 /// <param name="e">発生したイベント。</param>
237 private void ButtonSaveDirectory_Click(object sender, EventArgs e)
239 // フォルダ名が入力されている場合、それを初期位置に設定
240 if (!string.IsNullOrEmpty(this.textBoxSaveDirectory.Text))
242 this.folderBrowserDialogSaveDirectory.SelectedPath = this.textBoxSaveDirectory.Text;
246 if (this.folderBrowserDialogSaveDirectory.ShowDialog() == System.Windows.Forms.DialogResult.OK)
248 // フォルダが選択された場合、フォルダ名に選択されたフォルダを設定
249 this.textBoxSaveDirectory.Text = this.folderBrowserDialogSaveDirectory.SelectedPath;
254 /// 出力先テキストボックスフォーカス喪失時の処理。
256 /// <param name="sender">イベント発生オブジェクト。</param>
257 /// <param name="e">発生したイベント。</param>
258 private void TextBoxSaveDirectory_Leave(object sender, EventArgs e)
261 this.textBoxSaveDirectory.Text = this.textBoxSaveDirectory.Text.Trim();
266 #region 記事を指定して実行グループのイベントのメソッド
271 /// <param name="sender">イベント発生オブジェクト。</param>
272 /// <param name="e">発生したイベント。</param>
273 private void ButtonRun_Click(object sender, EventArgs e)
276 if (string.IsNullOrWhiteSpace(this.comboBoxSource.Text))
278 FormUtils.WarningDialog(Resources.WarningMessageNotSelectedSource);
279 this.comboBoxSource.Focus();
282 else if (string.IsNullOrWhiteSpace(this.comboBoxTarget.Text))
284 FormUtils.WarningDialog(Resources.WarningMessageNotSelectedTarget);
285 this.comboBoxTarget.Focus();
288 else if (!string.IsNullOrWhiteSpace(this.comboBoxSource.Text)
289 && this.comboBoxSource.Text == this.comboBoxTarget.Text)
291 FormUtils.WarningDialog(Resources.WarningMessageEqualsSourceAndTarget);
292 this.comboBoxTarget.Focus();
295 else if (string.IsNullOrWhiteSpace(this.textBoxSaveDirectory.Text))
297 FormUtils.WarningDialog(Resources.WarningMessageEmptySaveDirectory);
298 this.textBoxSaveDirectory.Focus();
301 else if (!Directory.Exists(this.textBoxSaveDirectory.Text))
303 FormUtils.WarningDialog(Resources.WarningMessageIgnoreSaveDirectory);
304 this.textBoxSaveDirectory.Focus();
307 else if (string.IsNullOrWhiteSpace(this.textBoxArticle.Text))
309 FormUtils.WarningDialog(Resources.WarningMessageEmptyArticle);
310 this.textBoxArticle.Focus();
315 this.LockOperation();
317 // 表示領域を初期化、処理時間更新用にタイマーを起動
318 this.textBoxLog.Clear();
320 this.textBoxLog.AppendText(string.Format(Resources.LogMessageStart, FormUtils.ApplicationName(), DateTime.Now));
321 this.toolStripStatusLabelStopwatch.Text = string.Format(Resources.ElapsedTime, TimeSpan.Zero);
322 this.timerStatusStopwatch.Start();
325 this.backgroundWorkerRun.RunWorkerAsync();
331 /// <param name="sender">イベント発生オブジェクト。</param>
332 /// <param name="e">発生したイベント。</param>
333 private void ButtonStop_Click(object sender, EventArgs e)
336 this.buttonStop.Enabled = false;
337 if (this.backgroundWorkerRun.IsBusy)
339 // ※ CancelAsyncだけにしたいが、それをTranslatorに伝播させる方法
341 System.Diagnostics.Debug.WriteLine("MainForm.-Stop_Click > 処理中断");
342 this.backgroundWorkerRun.CancelAsync();
343 if (this.translator != null)
345 this.translator.CancellationPending = true;
351 /// 実行ボタン バックグラウンド処理(スレッド)。
353 /// <param name="sender">イベント発生オブジェクト。</param>
354 /// <param name="e">発生したイベント。</param>
355 private void BackgroundWorkerRun_DoWork(object sender, DoWorkEventArgs e)
360 // 別スレッドになるので表示言語を再度設定
361 Program.LoadSelectedCulture();
363 // フォーム要素から必要なパラメータ一式を取得
364 string source = null;
365 string target = null;
367 this.Invoke((MethodInvoker)delegate
369 source = this.comboBoxSource.Text;
370 target = this.comboBoxTarget.Text;
371 title = this.textBoxArticle.Text.Trim();
374 // 翻訳支援処理ロジックのオブジェクトを生成
375 this.translator = Translator.Create(this.config, source, target);
377 // ログ・処理状態更新通知を受け取るためのイベント登録
378 this.translator.LogUpdated += new EventHandler(
379 delegate { this.Invoke((MethodInvoker)delegate { this.UpdateLog(); }); });
380 this.translator.StatusUpdated += new EventHandler(
381 delegate { this.Invoke((MethodInvoker)delegate { this.statusManager.Status = this.translator.Status; }); });
386 this.translator.Run(title);
388 catch (ApplicationException)
390 // 中止要求で停止した場合、その旨イベントに格納する
391 e.Cancel = this.backgroundWorkerRun.CancellationPending;
395 // ここまで成功した場合のみ処理結果を成功とする
400 /// 実行ボタン バックグラウンド処理(終了時)。
402 /// <param name="sender">イベント発生オブジェクト。</param>
403 /// <param name="e">発生したイベント。</param>
404 private void BackgroundWorkerRun_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
406 // 中止ボタンをロック、処理時間更新用のタイマーを終了
407 this.buttonStop.Enabled = false;
408 this.timerStatusStopwatch.Stop();
412 // 処理中で想定外のエラーが発生していた場合ここで通知
413 if (e.Error is WebException)
415 // 想定外の通信エラー(↓とまとめてもよいが、こちらはサーバーの状況などで発生しやすいので)
416 WebException ex = (WebException)e.Error;
417 this.textBoxLog.AppendText(Environment.NewLine + string.Format(Resources.ErrorMessageConnectionFailed, ex.Message) + Environment.NewLine);
418 if (ex.Response != null)
420 // 出せるならエラーとなったURLも出力
421 this.textBoxLog.AppendText(Resources.RightArrow + " " + string.Format(Resources.LogMessageErrorURL, ex.Response.ResponseUri) + Environment.NewLine);
427 this.textBoxLog.AppendText(Environment.NewLine + string.Format(Resources.ErrorMessageDevelopmentError, e.Error.Message, e.Error.StackTrace) + Environment.NewLine);
432 // 実行結果から、ログと変換後テキストをファイル出力
433 this.WriteResult(!e.Cancelled && (bool)e.Result);
438 // ※ 微妙に時間がかかるので、ステータスバーに通知
439 using (var sm = this.statusManager.Switch(Resources.StatusCacheUpdating))
446 FormUtils.WarningDialog(Resources.WarningMessageCacheSaveFailed, ex.Message);
450 // 画面をロック中から戻す、トランスレータを解放
452 this.translator = null;
455 #region イベント実装支援用メソッド
460 private void LockOperation()
463 this.groupBoxTransfer.Enabled = false;
464 this.groupBoxSaveDirectory.Enabled = false;
465 this.textBoxArticle.Enabled = false;
466 this.buttonRun.Enabled = false;
467 this.toolStripDropDownButtonLanguage.Enabled = false;
468 this.toolStripDropDownButtonConfig.Enabled = false;
471 this.buttonStop.Enabled = true;
477 private void Release()
480 this.buttonStop.Enabled = false;
483 this.groupBoxTransfer.Enabled = true;
484 this.groupBoxSaveDirectory.Enabled = true;
485 this.textBoxArticle.Enabled = true;
486 this.buttonRun.Enabled = true;
487 this.toolStripDropDownButtonLanguage.Enabled = true;
488 this.toolStripDropDownButtonConfig.Enabled = true;
492 /// 翻訳支援処理のログ・変換後テキストをファイル出力。
494 /// <param name="success">翻訳支援処理が成功した場合<c>true</c>。</param>
495 private void WriteResult(bool success)
497 // 若干時間がかかるのでステータスバーに通知
498 using (var sm = this.statusManager.Switch(Resources.StatusFileWriting))
503 this.MakeFileName(out fileName, out logName, this.textBoxArticle.Text.Trim(), this.textBoxSaveDirectory.Text);
507 // 翻訳支援処理成功時は変換後テキストを出力
510 File.WriteAllText(Path.Combine(this.textBoxSaveDirectory.Text, fileName), this.translator.Text);
511 this.textBoxLog.AppendText(string.Format(Resources.LogMessageEnd, fileName, logName));
515 this.textBoxLog.AppendText(string.Format(Resources.LogMessageFileSaveFailed, Path.Combine(this.textBoxSaveDirectory.Text, fileName), ex.Message));
516 this.textBoxLog.AppendText(string.Format(Resources.LogMessageStop, logName));
521 this.textBoxLog.AppendText(string.Format(Resources.LogMessageStop, logName));
527 File.WriteAllText(Path.Combine(this.textBoxSaveDirectory.Text, logName), this.textBoxLog.Text);
531 this.textBoxLog.AppendText(string.Format(Resources.LogMessageFileSaveFailed, Path.Combine(this.textBoxSaveDirectory.Text, logName), ex.Message));
537 /// 渡された文字列から.txtと.logの重複していないファイル名を作成。
539 /// <param name="fileName">出力結果ファイル名。</param>
540 /// <param name="logName">出力ログファイル名。</param>
541 /// <param name="text">出力する結果テキスト。</param>
542 /// <param name="dir">出力先ディレクトリ。</param>
543 /// <returns>出力成功の場合<c>true</c>。</returns>
544 private bool MakeFileName(out string fileName, out string logName, string text, string dir)
546 // 出力先フォルダに存在しないファイル名(の拡張子より前)を作成
547 // ※渡されたWikipedia等の記事名にファイル名に使えない文字が含まれている場合、_ に置き換える
548 // また、ファイル名が重複している場合、xx[0].txtのように連番を付ける
549 string fileNameBase = FormUtils.ReplaceInvalidFileNameChars(text);
550 fileName = fileNameBase + ".txt";
551 logName = fileNameBase + ".log";
552 bool success = false;
553 for (int i = 0; i < 100000; i++)
555 // ※ 100000まで試して空きが見つからないことは無いはず、もし見つからなかったら最後のを上書き
556 if (!File.Exists(Path.Combine(dir, fileName))
557 && !File.Exists(Path.Combine(dir, logName)))
563 fileName = fileNameBase + "[" + i + "]" + ".txt";
564 logName = fileNameBase + "[" + i + "]" + ".log";
572 /// 翻訳支援処理クラスのログ更新反映。
574 private void UpdateLog()
576 // 前回以降に追加されたログをテキストボックスに出力
577 int length = this.translator.Log.Length;
578 if (length > this.logLength)
580 this.textBoxLog.AppendText(this.translator.Log.Substring(this.logLength, length - this.logLength));
583 this.logLength = length;
590 #region ステータスバーのイベントのメソッド
593 /// ステータスバー処理時間更新タイマー処理。
595 /// <param name="sender">イベント発生オブジェクト。</param>
596 /// <param name="e">発生したイベント。</param>
597 private void TimerStatusStopwatch_Tick(object sender, EventArgs e)
599 if (this.translator != null)
602 this.toolStripStatusLabelStopwatch.Text = string.Format(Resources.ElapsedTime, this.translator.Stopwatch.Elapsed);
607 /// 表示言語選択メニュー日本語クリック時の処理。
609 /// <param name="sender">イベント発生オブジェクト。</param>
610 /// <param name="e">発生したイベント。</param>
611 private void ToolStripMenuItemJapanese_Click(object sender, EventArgs e)
614 this.ChangeCultureAndRestart("ja-JP");
618 /// 表示言語選択メニュー英語(US)クリック時の処理。
620 /// <param name="sender">イベント発生オブジェクト。</param>
621 /// <param name="e">発生したイベント。</param>
622 private void ToolStripMenuItemEnglishUS_Click(object sender, EventArgs e)
624 // 表示言語を英語(US)に設定し再起動する
625 this.ChangeCultureAndRestart("en-US");
629 /// 表示言語選択メニュー英語(GB)クリック時の処理。
631 /// <param name="sender">イベント発生オブジェクト。</param>
632 /// <param name="e">発生したイベント。</param>
633 private void ToolStripMenuItemEnglishGB_Click(object sender, EventArgs e)
635 // 表示言語を英語(GB)に設定し再起動する
636 this.ChangeCultureAndRestart("en-GB");
640 /// 表示言語選択メニュー自動クリック時の処理。
642 /// <param name="sender">イベント発生オブジェクト。</param>
643 /// <param name="e">発生したイベント。</param>
644 private void ToolStripMenuItemAuto_Click(object sender, EventArgs e)
647 this.ChangeCultureAndRestart(string.Empty);
651 /// 設定選択メニュークリック時の処理。
653 /// <param name="sender">イベント発生オブジェクト。</param>
654 /// <param name="e">発生したイベント。</param>
655 private void ToolStripMenuItemConfig_Click(object sender, EventArgs e)
657 // メニュー項目を一旦全て未選択状態に更新
658 foreach (ToolStripMenuItem i in this.toolStripDropDownButtonConfig.DropDownItems)
664 // メニュー項目名から設定ファイル名を作成、再読み込みする
665 ToolStripMenuItem item = (ToolStripMenuItem)sender;
666 Settings.Default.LastSelectedConfiguration = item.Text;
668 this.InitializeByConfig();
672 /// 設定選択メニュー追加クリック時の処理。
674 /// <param name="sender">イベント発生オブジェクト。</param>
675 /// <param name="e">発生したイベント。</param>
676 private void ToolStripMenuItemNew_Click(object sender, EventArgs e)
678 // 重複チェック用の登録済みの設定一覧を用意
679 IList<string> configNames = new List<string>();
680 foreach (ToolStripMenuItem item in this.toolStripDropDownButtonConfig.DropDownItems)
682 if (item != this.toolStripMenuItemNew)
684 configNames.Add(item.Text);
688 // 設定追加用ダイアログで言語コードを入力
689 using (AddConfigDialog form = new AddConfigDialog(configNames))
691 if (form.ShowDialog() == DialogResult.OK)
693 // 設定選択メニューに新しい設定を追加。
694 // 設定ファイルが作成されているため、それを読み込みなおす。
695 this.ToolStripMenuItemConfig_Click(
696 this.AddToolStripDropDownButtonConfigItem(form.ConfigName),
702 #region イベント実装支援用メソッド
705 /// 表示言語選択メニューの初期化処理。
707 private void InitializeDropDownButtonLanguage()
710 ToolStripMenuItem item;
711 switch (Settings.Default.LastSelectedLanguage)
714 item = this.toolStripMenuItemEnglishUS;
717 item = this.toolStripMenuItemEnglishGB;
720 item = this.toolStripMenuItemJapanese;
723 item = this.toolStripMenuItemAuto;
727 // 選択中の項目をチェック状態&押下不能とする
729 item.Enabled = false;
730 if (item != this.toolStripMenuItemAuto)
732 // 自動以外の場合、ステータスバーの表示も更新
733 this.toolStripDropDownButtonLanguage.Text = item.Text;
738 /// 設定ファイル選択メニューの初期化処理。
740 private void InitializeDropDownButtonConfig()
742 // exeまたはユーザーフォルダにある設定ファイルをメニュー項目としてリストアップ
743 foreach (string file in FormUtils.GetFilesAtUserAppData(
744 "*" + Settings.Default.ConfigurationExtension,
745 Settings.Default.ConfigurationCompatible))
749 // 関係ないXMLファイルを除外するため、読み込めるフォーマットかをチェック
751 Config.GetInstance(file);
753 // 問題なければファイル名を見出しにメニューに追加
754 this.AddToolStripDropDownButtonConfigItem(Path.GetFileNameWithoutExtension(file));
758 System.Diagnostics.Debug.WriteLine(
759 "MainForm.InitializeDropDownButtonConfig : " + ex.Message);
765 /// 設定選択メニューに新しい設定を追加する。
767 /// <param name="name">設定名。</param>
768 /// <returns>追加したメニュー。</returns>
769 /// <remarks>追加メニューがあるのでその後ろに登録する。</remarks>
770 private ToolStripMenuItem AddToolStripDropDownButtonConfigItem(string name)
773 ToolStripMenuItem item = new ToolStripMenuItem();
775 item.Click += new EventHandler(this.ToolStripMenuItemConfig_Click);
776 this.toolStripDropDownButtonConfig.DropDownItems.Insert(
777 this.toolStripDropDownButtonConfig.DropDownItems.Count - 1,
783 /// アプリケーションの現在の表示言語を変更、再起動する。
785 /// <param name="name">変更先カルチャ名。</param>
786 /// <remarks>このメソッドを呼び出すとアプリケーションが一旦終了します。</remarks>
787 private void ChangeCultureAndRestart(string name)
789 // 現在の画面表示と表示言語設定を保存した後、アプリケーションを再起動
791 Settings.Default.LastSelectedLanguage = name;
792 Settings.Default.Save();
793 Application.Restart();
807 /// 読み込みに失敗した場合、空の設定を登録し、操作の大半をロックする
808 /// (設定変更メニューから正しい設定に変更されることを期待)。
810 private void InitializeByConfig()
814 if (this.config == null)
816 // 読み込みに失敗した場合、空の設定を作成(設定値には適当な値を設定)
817 // 設定選択メニューの表示を更新し、画面をほぼ操作不可に変更
818 this.config = new Config();
819 this.groupBoxTransfer.Enabled = false;
820 this.groupBoxSaveDirectory.Enabled = false;
821 this.groupBoxRun.Enabled = false;
822 this.toolStripDropDownButtonConfig.Text = Resources.DropDownConfigLoadConfigFailed;
826 // 設定選択メニューの表示を更新し、画面を操作可能な状態に戻す
827 this.groupBoxTransfer.Enabled = true;
828 this.groupBoxSaveDirectory.Enabled = true;
829 this.groupBoxRun.Enabled = true;
830 this.toolStripDropDownButtonConfig.Text = Path.GetFileNameWithoutExtension(this.config.File);
831 foreach (ToolStripMenuItem item in this.toolStripDropDownButtonConfig.DropDownItems)
833 // 読み込んだ設定を選択中(チェック状態&押下不能)に更新
834 if (item != this.toolStripMenuItemNew
835 && item.Text == this.toolStripDropDownButtonConfig.Text)
838 item.Enabled = false;
843 // コンボボックスを読み込んだ設定で初期化
844 this.InitializeComboBox();
850 private void LoadConfig()
853 string file = Settings.Default.LastSelectedConfiguration + Settings.Default.ConfigurationExtension;
856 // ※ 微妙に時間がかかるので、ステータスバーに通知
857 using (var sm = this.statusManager.Switch(Resources.StatusConfigReading))
859 this.config = Config.GetInstance(file);
862 catch (FileNotFoundException ex)
864 // 設定ファイルが見つからない場合、エラーメッセージを表示
865 System.Diagnostics.Debug.WriteLine(
866 "MainForm.LoadConfig > 設定ファイル読み込み失敗 : " + ex.Message);
867 FormUtils.ErrorDialog(Resources.ErrorMessageConfigNotFound, file);
871 // その他の例外(権限が無いとかファイルが壊れているとか)
872 System.Diagnostics.Debug.WriteLine(
873 "MainForm.LoadConfig > 設定ファイル読み込み時エラー : " + ex.ToString());
874 FormUtils.ErrorDialog(Resources.ErrorMessageConfigLordFailed, ex.Message);
879 /// 現在の出力先フォルダ、翻訳元/先言語をアプリケーション設定に反映。
881 /// <remarks>表示言語や設定ファイルの選択については必要な場合のみ別途実施。</remarks>
882 private void SetSettings()
884 Settings.Default.SaveDirectory = this.textBoxSaveDirectory.Text;
885 Settings.Default.LastSelectedSource = this.comboBoxSource.Text;
886 Settings.Default.LastSelectedTarget = this.comboBoxTarget.Text;