// return: // -1 error // 0 successed // -2 取消 private int InsertAttrWithDlg(AttrItem startAttr, out string strError) { strError = ""; ElementItem element = (ElementItem)(startAttr.parent); if (element == null) { strError = "InsertAttrWithDlg(),element不可能为null。"; return -1; } AttrNameDlg dlg = new AttrNameDlg (); dlg.SetInfo ("新同级属性", "给'" + startAttr.Name + "'增加新同级属性", element); dlg.ShowDialog (); if (dlg.DialogResult != DialogResult.OK ) return -2; AttrItem newAttr = null; int nRet = this.CreateAttrItemFromUI(dlg.textBox_strElementName.Text, dlg.textBox_URI.Text, out newAttr, out strError); if (nRet == -1) return -1; newAttr.SetValue(dlg.textBox_value.Text); return element.InsertAttr(startAttr, newAttr, out strError); }
// 追加属性,带对话框 // return: // -1 error // 0 successed // -2 取消 public int AppendAttrWithDlg(ElementItem item, out string strError) { strError = ""; AttrNameDlg dlg = new AttrNameDlg (); dlg.SetInfo("新属性", "给'" + item.Name + "'追加新属性", item); dlg.ShowDialog(); if (dlg.DialogResult != DialogResult.OK) return -2; AttrItem attr = null; int nRet = this.CreateAttrItemFromUI(dlg.textBox_strElementName.Text, dlg.textBox_URI.Text, out attr, out strError); if (nRet == -1) return -1; attr.SetValue(dlg.textBox_value.Text); return item.AppendAttr(attr, out strError); }