private StGeneralInfo getLineInfo(int index) { StGeneralInfo retval = null; StackPanel sp = ((StackPanel)(mMW.amCanvas.Children[index])); String value = ""; switch (mLinetypes[index]) { case LINETYPE.COMBO: ComboBox cb = (ComboBox)sp.Children[1]; if (cb.SelectedIndex != -1) { value = (String)cb.Items[cb.SelectedIndex]; } break; case LINETYPE.TXTFIELD: TextBox tb = (TextBox)sp.Children[1]; value = tb.Text; break; case LINETYPE.RADIO: for (int i = 1; i < sp.Children.Count - 1; i++) { if (((RadioButton)sp.Children[i]).IsChecked == true) { value = (i - 1).ToString(); break; } } break; } if (String.IsNullOrEmpty(value) || String.IsNullOrWhiteSpace(value)) { System.Windows.Forms.MessageBox.Show( "请完整填写所有信息", "提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); retval = null; } else { retval = new StGeneralInfo(value, mVarNames[index]); } return(retval); }
public Dictionary <String, String> GetResult() { Dictionary <String, String> retval = new Dictionary <String, String>(); int upper = mMW.amCanvas.Children.Count; for (int i = 1; i < upper - 1; i++)//title and button exclueded { StGeneralInfo info = getLineInfo(i); if (info != null) { retval.Add(info.Name, info.Value); } else { retval = null; break; } } return(retval); }