Beispiel #1
0
        public void Init(VXmlCatalog dc, TreeNode tn)
        {
            g = new VSUIPanel(pnMain, "1");
            g.Load(Properties.Resources.CreateNode);

            CONT      = dc;
            TN        = tn;
            this.Text = "Create child node for " + tn.Text;
            cbNodeType.Items.Clear();

            PARENT      = CONT.GetNode(VSLib.ConvertStringToLong(tn.Name));
            n_type_code = DEFX.BR_CHILD_VALID_TYPE_CODES(PARENT.NodeTypeCode);
            n_type      = DEFX.BR_CREATE_VALID_TYPES(PARENT.NodeTypeCode);


            for (int i = 0; i < n_type.Length; i++)
            {
                if (n_type_code[i] != DEFX.NODE_TYPE_REFERENCE)
                {
                    cbNodeType.Items.Add(n_type[i]);
                }
            }

            g.AddControl("type", cbNodeType);
            g.AddControl("select", btnSelectFile);
            g.AddControl("ok", btnCreate);
            g.AddControl("cancel", btnCancel);

            g.Display();
        }
Beispiel #2
0
        /// <summary>
        /// Open existing storage
        /// </summary>
        private void ACTION_OpenStorage(string path = "")
        {
            ROOT = "";
            if (path == "")
            {
                ROOT = VSUILib.VSUICommonFunctions.SelectPath(DEFS.KEY_STORAGE_ROOT, "Select МXML storage path");
                if ((ROOT == VSUILib.VSUICommonFunctions.CANCELLED) | (ROOT == ""))
                {
                    ROOT = "";
                    return;
                }
            }
            else
            {
                ROOT = path;
            }

            try
            {
                cont = new VXmlCatalog(ROOT);
            }
            catch (VXmlException e)
            {
                MessageBox.Show(e.Message, "VXML Error", MessageBoxButtons.OK);
                cont.Close();
                return;
            }
            cont.Commit();
            SHOW_Childs();
            SELECT_Node();
            SHOW_Buttons();
            OPENED = true;
        }
Beispiel #3
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            g.Read();
            try
            {
                string s = g.GetValue("size").Trim();
                if (s != "")
                {
                    s_size = VSLib.ConvertStringToInt(s);
                }

                s = g.GetValue("ext").Trim();
                if (s != "")
                {
                    s_ext = VSLib.ConvertStringToInt(s);
                }

                s = g.GetValue("contsize").Trim();
                if (s != "")
                {
                    s_contsize = VSLib.ConvertStringToInt(s);
                }

                s = g.GetValue("context").Trim();
                if (s != "")
                {
                    s_contsize = VSLib.ConvertStringToInt(s);
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message, "Create VXML space - invalid parameter(s)", MessageBoxButtons.OK);
                return;
            }

            if (s_size <= 0)
            {
                MessageBox.Show("Size is not specified", "Create VXML space", MessageBoxButtons.OK);
                return;
            }

            VXmlCatalog c = new VXmlCatalog();

            c.Set(ROOT, "", s_size, s_ext, s_contsize, s_context);

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Beispiel #4
0
        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();
                }
            }
        }