// ================================================================================================ // // Wikipedia翻訳支援ツールコード入力ダイアログクラスソース // // // Copyright (C) 2012 Honeplus. All rights reserved. // // Honeplus // ================================================================================================ namespace Honememo.Wptscs { using System; using System.Windows.Forms; using Honememo.Wptscs.Models; using Honememo.Wptscs.Properties; using Honememo.Wptscs.Utilities; /// /// Wikipedia翻訳支援ツールコード入力ダイアログのクラスです。 /// public partial class AddLanguageDialog : Form { #region private変数 /// /// 現在設定中のアプリケーションの設定。 /// private Config config; #endregion #region コンストラクタ /// /// コンストラクタ。初期化メソッド呼び出しのみ。 /// /// 設定対象のConfig。 /// null public AddLanguageDialog(Config config) { // Windows フォーム デザイナで生成されたコード this.InitializeComponent(); // 設定対象のConfigを受け取る this.config = Honememo.Utilities.Validate.NotNull(config, "config"); } #endregion #region プロパティ /// /// 言語コード(データやり取り用)。 /// public string LanguageCode { get; set; } #endregion #region フォームの各イベントのメソッド /// /// OKボタン押下時の処理。データ保存。 /// /// イベント発生オブジェクト。 /// 発生したイベント。 private void ButtonOk_Click(object sender, EventArgs e) { // 入力値チェック this.LanguageCode = this.textBoxCode.Text.Trim(); if (string.IsNullOrEmpty(this.LanguageCode)) { FormUtils.WarningDialog(Resources.WarningMessageEmptyLanguageCode); this.textBoxCode.Focus(); return; } else if (this.config.GetWebsite(this.LanguageCode) != null) { FormUtils.WarningDialog(Resources.WarningMessageDuplicateLanguageCode); this.textBoxCode.Focus(); return; } // テキストボックスの言語コードを保存して画面を閉じる this.DialogResult = DialogResult.OK; } #endregion } }