/// <summary> /// 音声認識に対応する文言と操作の設定情報から取得した概要文字列を表示対象のラベルに設定する /// </summary> /// <param name="settingInfo">音声認識に対応する文言と操作の設定情報</param> private void SetSummaryText(SpeechRecognitionSettingInfo settingInfo = null) { // マッチングメッセージのチェックを行う if (!CheckMatchMessage(out string errorMessage)) { // マッチングメッセージがエラーの場合はエラーメッセージを設定して処理を終了する LbSummaryText.ForeColor = ErrorSummaryTextForeColor; LbSummaryText.Text = errorMessage; return; } // 処理内容のメッセージを生成する string summary = settingInfo?.SummaryText; if (settingInfo == null || settingInfo.SettingType.Equals(SpeechRecognitionSettingType.None)) { // 設定情報が存在しない または、タイプが「操作なし」の場合 // 「使用不可」を設定する summary = SpeechRecognitionSettingMessage.SummaryTextNotUse; } else if (string.IsNullOrEmpty(summary)) { // 概要文字列が存在しない場合は、「未設定」を設定する summary = SpeechRecognitionSettingMessage.SummaryTextNotSet; } // フォーマットに従って概要文字列を生成しラベルに設定す LbSummaryText.ForeColor = DefaultSummaryTextForeColor; LbSummaryText.Text = string.Format( CultureInfo.InvariantCulture, SpeechRecognitionSettingMessage.SummaryTextFormat, GetCheckedRadio()?.Text ?? SpeechRecognitionSettingMessage.SummaryTextNoneMatchPattern, summary); }
/// <summary> /// 各コントロールの初期化を行う /// </summary> /// <param name="settingInfo"> /// 音声認識に対するマッチングパターンと操作の設定情報 /// </param> public void Initialize(SpeechRecognitionSettingInfo settingInfo) { // 引数の音声認識に対するマッチングパターンと操作の設定情報を保持する // NULLが指定された場合は初期値を設定する CurrentSpeechRecognitionSettingInfo = settingInfo; SettingInfo = settingInfo ?? new SpeechRecognitionSettingInfo(); SpeechRecognitionSettingInfo info = SettingInfo.DeepCopy(); // マッチングメッセージのテキストボックスを設定 if (!string.IsNullOrEmpty(info.MatchMessage)) { TxtMatchMessage.Text = info.MatchMessage; IsSetMatchMessage = true; } else { // マッチングメッセージが存在しない場合はデフォルトの値を設定する TxtMatchMessage.Text = DefaultMatchMessage; IsSetMatchMessage = false; } // マッチングメッセージの文字色を初期化 SetMatchMessageForeColor(IsSetMatchMessage); // マッチングパターンのラジオボタン領域は非表示 PlMatchPattern.Visible = false; // 設定情報のマッジングパターンに紐づくラジオボタンコントロールを取得 RadioButton radio = GetRadio(info.MatchPattern); // ラジオボタンコントロールが取得できた場合はそのラジオボタンをチェックする if (radio != null) { radio.Checked = true; } else if ((radio = GetCheckedRadio()) != null) { // チェック対象のラジオボタンが存在しない場合は、 // チェックされているラジオボタンのチェックを外し、すべてが未チェック状態にする radio.Checked = false; } // 拡大縮小ボタンの初期化 IsSummary = true; SetBackgroundImageForBtMinMax(IsSummary); // 概要ラベルを設定 SetSummaryText(info); LbSummaryText.Visible = true; // 操作設定用のコントロールを設定 // (非表示にするためコントロールオブジェクトを解放する) if (SettingControl != null) { PlControl.Controls.Remove(SettingControl); SettingControl.Dispose(); SettingControl = null; } }
/// <summary> /// コンストラクタ /// 各コントロールの初期化を行う /// </summary> /// <param name="settingInfo"> /// 音声認識に対するマッチングパターンと操作の設定情報 /// </param> /// <exception cref="ArgumentNullException"> /// 引数の <paramref name="settingInfo"/> がNULLの場合に発生 /// </exception> public SpeechRecognitionSetting(SpeechRecognitionSettingInfo settingInfo) : this() { // NULLチェック if (settingInfo == null) { throw new ArgumentNullException(nameof(settingInfo)); } // 各コントロールの初期化を行う Initialize(settingInfo); }