/// <summary> /// Edit node value /// </summary> private void ACTION_EditNode() { string v = ""; if (CONTEXT_LIST_VIEW_ITEM != null) { v = CONTEXT_LIST_VIEW_ITEM.SubItems[2].Text; } else { v = CONTEXT_XML_NODE.Value; } string res = VSUILib.VSUICommonFunctions.InputBox("Edit node value", "Value", value: v, numeric: false); if (res == VSUILib.VSUICommonFunctions.CANCELLED) { return; } cont.Begin(); if (CONTEXT_LIST_VIEW_ITEM == null) { CONTEXT_XML_NODE.Value = res; ACTION_SetTreeNodeName(CONTEXT_TREE_NODE, CONTEXT_XML_NODE); } else { if (MENU_NODE_SELECTED_TYPE == DEFX.GET_NODETYPE(DEFX.NODE_TYPE_ATTRIBUTE)) { CONTEXT_XML_NODE.SetAttribute(MENU_NODE_SELECTED_NAME, res); } else if (MENU_NODE_SELECTED_TYPE == DEFX.GET_NODETYPE(DEFX.NODE_TYPE_COMMENT)) { VXmlComment cnode = CONTEXT_XML_NODE.GetCommentNode(MENU_NODE_SELECTED_NAME); cnode.Value = res; } else if (MENU_NODE_SELECTED_TYPE == DEFX.GET_NODETYPE(DEFX.NODE_TYPE_TEXT)) { VXmlText t = CONTEXT_XML_NODE.GetTextNode(MENU_NODE_SELECTED_NAME); t.Value = res; } else if (MENU_NODE_SELECTED_TYPE == DEFX.GET_NODETYPE(DEFX.NODE_TYPE_TAG)) { VXmlTag t = CONTEXT_XML_NODE.GetTagNode(MENU_NODE_SELECTED_NAME); string tv = t.Value; if (tv != res) { CONTEXT_XML_NODE.RemoveTag(tv); CONTEXT_XML_NODE.SetTag(res); } } SELECT_Node(true, CONTEXT_TREE_NODE); } cont.Commit(); }
private void btnCreate_Click(object sender, EventArgs e) { short node_type = 0; string V = ""; string N = ""; for (int i = 0; i < n_type.Length; i++) { if (n_type[i] == cbNodeType.Text) { node_type = n_type_code[i]; break; } } RC = 0; g.Read(); N = g.GetValue("name"); V = g.GetValue("value"); if ((N == "") & DEFX.BR_NODE_NEED_NAME(node_type)) { MessageBox.Show("Name field is not defined", "Error"); } else if ((node_type == DEFX.NODE_TYPE_CONTENT) & ((g.GetValue("file") == "") | (g.GetValue("title") == ""))) { MessageBox.Show("File name or Title not defined", "Error"); } else { VXmlNode node = CONT.GetNode(VSLib.ConvertStringToLong(TN.Name)); try { if (node_type == DEFX.NODE_TYPE_CONTENT) { VXmlContent c = node.CreateContent(g.GetValue("file")); } else if (node_type == DEFX.NODE_TYPE_CATALOG) { VXmlCatalog cat = (VXmlCatalog)CONT.GetNode(node.Id); VXmlCatalog newcat = cat.CreateCatalog(g.GetValue("name")); if (V != "") { newcat.Value = V; } } else if (node_type == DEFX.NODE_TYPE_DOCUMENT) { VXmlCatalog cat = (VXmlCatalog)CONT.GetNode(node.Id); VXmlDocument d = cat.CreateDocument(N); if (V != "") { d.Value = V; } } else if (node_type == DEFX.NODE_TYPE_ATTRIBUTE) { node.SetAttribute(N, V); } else if (node_type == DEFX.NODE_TYPE_COMMENT) { node.CreateComment(V); } else if (node_type == DEFX.NODE_TYPE_TEXT) { node.CreateTextNode(V); } else if (node_type == DEFX.NODE_TYPE_TAG) { node.SetTag(V.Trim()); } else if (node_type == DEFX.NODE_TYPE_ELEMENT) { VXmlElement el = node.CreateElement(N, V); } else { MessageBox.Show("Invalid node type '" + DEFX.GET_NODETYPE(node_type) + "'", "Error"); RC = 1; } } catch (VXmlException ex) { MessageBox.Show(ex.Message, "Error"); RC = 1; } if (RC == 0) { this.Close(); } } }