/// <summary> /// 변수 추가 버튼 클릭 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { Form_AddVariable addvarform = new Form_AddVariable(m_Dictionary_EquationInformation, m_selectedEquation); // 다이얼로그에서 설정된 값을 토대로 변수 생성. if (addvarform.ShowDialog( ) == DialogResult.OK) { // 폼에서 출력 변수를 선택 했다. if (addvarform.IsEquationVariable) { // 출력변수 만들고 등록. EquationVariable vdata = MakeNewEquationVar(addvarform.VariableName, addvarform.Equation); vdata.Equation = addvarform.Equation; vdata.IsHiddenVariable = addvarform.IsHiddenValue; listBox2.Items.Add(vdata.Name); m_Dictionary_VariableData.Add(vdata.Name, vdata); } // 입력 변수를 선택했다. else { VariableData vdata = MakeNewVar(addvarform.VariableName); vdata.IsCorrespond = addvarform.isCorrespond; // 출력변수 대입인지 체크. if (vdata.IsCorrespond) { vdata.CorrespontVarName = addvarform.CorrespondVarPath; } // Option 체크 설정. vdata.m_checkOption = addvarform.Option; if (addvarform.Option == VariableData.CheckOption.None) { } else if (addvarform.Option == VariableData.CheckOption.MinMax) { vdata.OptionMinValue = addvarform.CheckMinValue; vdata.OptionMaxValue = addvarform.CheckMaxValue; } else { vdata.CustomOptionString = addvarform.CustomOptionString; } listBox1.Items.Add(vdata.Name); m_Dictionary_VariableData.Add(vdata.Name, vdata); } } }
private void listBox1_DoubleClick(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { string selectedItem = listBox1.SelectedItem.ToString(); var selectedVariable = m_Dictionary_VariableData[selectedItem]; Form_AddVariable addvarform = new Form_AddVariable(selectedVariable, m_Dictionary_EquationInformation, m_selectedEquation); if (addvarform.ShowDialog() == DialogResult.OK) { VariableData newVariable = new VariableData(addvarform.VariableName); newVariable.IsCorrespond = addvarform.isCorrespond; if (newVariable.IsCorrespond) { newVariable.CorrespontVarName = addvarform.CorrespondVarPath; } newVariable.m_checkOption = addvarform.Option; newVariable.OptionMinValue = addvarform.CheckMinValue; newVariable.OptionMaxValue = addvarform.CheckMaxValue; newVariable.m_Dictionary_SwitchInfo = addvarform.CaseInfo; newVariable.CustomOptionString = addvarform.CustomOptionString; try { int index = listBox1.SelectedIndex; m_Dictionary_VariableData.Remove(selectedItem); m_Dictionary_VariableData.Add(newVariable.Name, newVariable); listBox1.Items.Remove(listBox1.SelectedItem); listBox1.Items.Insert(index, newVariable.Name); } catch (System.Exception ex) { newVariable.Name = listBox1.SelectedItem.ToString(); m_Dictionary_VariableData.Add(listBox1.SelectedItem.ToString(), newVariable); MessageBox.Show(ex.Message); } } } }
/// <summary> /// listbox더블클릭시엔 해당 변수에 맞게 addvariable 창을 띄워줌 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listBox2_DoubleClick(object sender, EventArgs e) { if (listBox2.SelectedItem != null) { string selectedItem = listBox2.SelectedItem.ToString(); var selectedVariable = m_Dictionary_VariableData[selectedItem]; Form_AddVariable addvarform = new Form_AddVariable(selectedVariable, m_Dictionary_EquationInformation, m_selectedEquation); if (addvarform.ShowDialog() == DialogResult.OK) { EquationVariable newVariable = new EquationVariable(addvarform.VariableName); newVariable.Equation = addvarform.Equation; newVariable.IsHiddenVariable = addvarform.IsHiddenValue; try { m_Dictionary_VariableData.Remove(selectedItem); m_Dictionary_VariableData.Add(newVariable.Name, newVariable); int index = listBox2.SelectedIndex; listBox2.Items.Remove(listBox2.SelectedItem); listBox2.Items.Insert(index, newVariable.Name); } catch (System.Exception ex) { newVariable.Name = listBox2.SelectedItem.ToString(); m_Dictionary_VariableData.Add(listBox2.SelectedItem.ToString(), newVariable); MessageBox.Show(ex.Message); } } } }