#region Using using System; using System.Collections.Generic; using System.Windows.Forms; using ORiN2.interop.CAO; #endregion Using namespace FL_netCaoTester { public partial class Form2 : Form { #region Fields private List listForm3; private List listForm4; #endregion Fields #region Constructor public Form2() { InitializeComponent(); } #endregion Constructor #region Load/Closed private void Form2_Load(object sender, EventArgs e) { listForm3 = new List(); listForm4 = new List(); } private void Form2_FormClosed(object sender, FormClosedEventArgs e) { foreach (Form3 f in listForm3) { try { f.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } foreach (Form4 f in listForm4) { try { f.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } private void button_Variables_Clear_Click(object sender, EventArgs e) { try { // Variables Clear Form2_VariablesClear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void Form2_VariablesClear() { foreach (Form3 f in listForm3) { try { f.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } #endregion Load/Closed #region AddVariable private void button_VariableAdd_Click(object sender, EventArgs e) { try { // AddVariable CaoVariable Val = ((Form1)this.Owner).caoCtrl.AddVariable(this.textBox_AddVarialeName.Text, this.comboBox_AddVariableOption.Text); // Valiable画面生成 Form3 f = new Form3(this.textBox_AddVarialeName.Text, Val); f.Owner = this; f.Show(); listForm3.Add(f); } catch (Exception ex) { MessageBox.Show(ex.Message); } } #endregion AddVariable #region ClearVariable private void button_VariableClear_Click(object sender, EventArgs e) { this.textBox_AddVarialeName.Text = string.Empty; this.comboBox_AddVariableOption.Text = string.Empty; } #endregion ClearVariable #region AddExtension private void button_ExtensionAdd_Click(object sender, EventArgs e) { try { // AddExtension CaoExtension Ext = ((Form1)this.Owner).caoCtrl.AddExtension(this.textBox_ExtensionName.Text, this.textBox_ExtensionOption.Text); // Extension画面生成 Form4 f = new Form4(this.textBox_ExtensionName.Text, Ext); f.Owner = this; f.Show(); listForm4.Add(f); } catch (Exception ex) { MessageBox.Show(ex.Message); } } #endregion AddExtension #region ClearExtension private void button_ExtensionClear_Click(object sender, EventArgs e) { this.textBox_ExtensionName.Text = string.Empty; this.textBox_ExtensionOption.Text = string.Empty; } #endregion ClearExtension private void button_VariableNames_Click(object sender, EventArgs e) { try { var Names = (object[])((Form1)this.Owner).caoCtrl.VariableNames; foreach (object name in Names) { this.listBox_VariableNames.Items.Add((String)name); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void listBox_VariableNames_SelectedIndexChanged(object sender, EventArgs e) { this.textBox_AddVarialeName.Text = this.listBox_VariableNames.SelectedItem.ToString(); } #region Execute private void button_Execute_Click(object sender, EventArgs e) { this.button_Execute.Enabled = false; try { this.textBox_Result.Text = ""; string[] strArry = this.textBox_Parameter.Text.Split(','); int iArryLen = strArry.Length; object objParam = new object(); switch (this.combo_Command.Text.ToString()) { case "ProviderCancel": case "ProviderClear": case "ClearLog": break; default: if (!this.checkBox_Array.Checked && (strArry.Length > 1)) { throw new System.ArgumentException("Arrayチェックなし複数要素指定"); } bool bChecked = this.checkBox_Array.Checked; int iSelectedIndex = this.comboBox_Type.SelectedIndex; Common cm = new Common(); objParam = cm.ConvertStringToObject(strArry, ref bChecked, ref iSelectedIndex); this.checkBox_Array.Checked = bChecked; this.comboBox_Type.SelectedIndex = iSelectedIndex; break; } // Executeコマンド実行 object objResult = ((Form1)this.Owner).caoCtrl.Execute(this.combo_Command.Text.ToString(), objParam); // 実行結果 if (objResult != null) { bool bChecked = this.checkBox_Array.Checked; int iSelectedIndex = this.comboBox_Type.SelectedIndex; Common cm = new Common(); this.textBox_Result.Text = cm.ConvertVariantToString(objResult, ref bChecked, ref iSelectedIndex); this.checkBox_Array.Checked = bChecked; this.comboBox_Type.SelectedIndex = iSelectedIndex; } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.button_Execute.Enabled = true; } #endregion Execute private void combo_Command_SelectedIndexChanged(object sender, EventArgs e) { } } }