OSDN Git Service

#27621 言語間リンク解析の前処理の対象に<onlyinclude>タグを追加,
[wptscs/wpts.git] / Wptscs / AddLanguageDialog.cs
1 // ================================================================================================
2 // <summary>
3 //      Wikipedia翻訳支援ツールコード入力ダイアログクラスソース</summary>
4 //
5 // <copyright file="AddLanguageDialog.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.Windows.Forms;
15     using Honememo.Wptscs.Models;
16     using Honememo.Wptscs.Properties;
17     using Honememo.Wptscs.Utilities;
18
19     /// <summary>
20     /// Wikipedia翻訳支援ツールコード入力ダイアログのクラスです。
21     /// </summary>
22     public partial class AddLanguageDialog : Form
23     {
24         #region private変数
25
26         /// <summary>
27         /// 現在設定中のアプリケーションの設定。
28         /// </summary>
29         private Config config;
30
31         #endregion
32
33         #region コンストラクタ
34
35         /// <summary>
36         /// コンストラクタ。初期化メソッド呼び出しのみ。
37         /// </summary>
38         /// <param name="config">設定対象のConfig。</param>
39         /// <exception cref="ArgumentNullException"><paramref name="config"/>が<c>null</c>。</exception>
40         public AddLanguageDialog(Config config)
41         {
42             // Windows フォーム デザイナで生成されたコード
43             this.InitializeComponent();
44
45             // 設定対象のConfigを受け取る
46             this.config = Honememo.Utilities.Validate.NotNull(config, "config");
47         }
48
49         #endregion
50
51         #region プロパティ
52
53         /// <summary>
54         /// 言語コード(データやり取り用)。
55         /// </summary>
56         public string LanguageCode
57         {
58             get;
59             set;
60         }
61
62         #endregion
63
64         #region フォームの各イベントのメソッド
65
66         /// <summary>
67         /// OKボタン押下時の処理。データ保存。
68         /// </summary>
69         /// <param name="sender">イベント発生オブジェクト。</param>
70         /// <param name="e">発生したイベント。</param>
71         private void ButtonOk_Click(object sender, EventArgs e)
72         {
73             // 入力値チェック
74             this.LanguageCode = this.textBoxCode.Text.Trim();
75             if (String.IsNullOrEmpty(this.LanguageCode))
76             {
77                 FormUtils.WarningDialog(Resources.WarningMessageEmptyLanguageCode);
78                 this.textBoxCode.Focus();
79                 return;
80             }
81             else if (this.config.GetWebsite(this.LanguageCode) != null)
82             {
83                 FormUtils.WarningDialog(Resources.WarningMessageDuplicateLanguageCode);
84                 this.textBoxCode.Focus();
85                 return;
86             }
87
88             // テキストボックスの言語コードを保存して画面を閉じる
89             this.DialogResult = DialogResult.OK;
90         }
91
92         #endregion
93     }
94 }