/// <summary> /// Download content (content node type only) /// </summary> private void ACTION_DownloadContent() { SaveFileDialog sd = new SaveFileDialog(); sd.Filter = "All files (*.*)|*.*"; sd.FilterIndex = 1; sd.RestoreDirectory = true; VXmlContent c = (VXmlContent)((CONTEXT_LIST_VIEW_ITEM == null) ? CONTEXT_XML_NODE : cont.GetNode(VSLib.ConvertStringToLong(CONTEXT_LIST_VIEW_ITEM.SubItems[0].Text))); string s = c.filename; sd.FileName = (s == "") ? "NewFileName" : s; if (sd.ShowDialog() == DialogResult.OK) { c.Download(sd.FileName); } }
/// <summary> /// Set Tree node name /// </summary> /// <param name="tn"></param> /// <param name="c"></param> private void ACTION_SetTreeNodeName(TreeNode tn, VXmlNode c) { string s = ""; string nodeid = c.ID; VXmlNode n = null; if (c.NodeTypeCode == DEFX.NODE_TYPE_REFERENCE) { n = ((VXmlReference)c).ReferenceNode; nodeid += "~" + n.ID; } else { n = c; } tn.Text = UTIL_PrepareName(c); s = "Id='" + nodeid + "'\r" + "\n" + "Type='" + n.NodeType + "'\r" + "\n" + "Name='" + n.Name + "'\r" + "\n" + "Value='" + n.Value + "'"; if (c.GUID != "") { s += "\r" + "\n" + "GUID=" + c.GUID; } if (c.NodeTypeCode == DEFX.NODE_TYPE_CONTENT) { VXmlContent ct = (VXmlContent)cont.GetNode(c.Id); s += "\r" + "\n" + "File name='" + ct.filename + "'" + "\r" + "\n" + "Size='" + ct.Length.ToString("#,0;(#,0)") + " bytes"; } tn.ToolTipText = s; }
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(); } } }