Esempio n. 1
0
        private void SetTreeNodeImageAndToolTip(XMLEditorTreeNode nd, XmlNode xnd)
        {
            if (nd == null || xnd == null)
                return;
            if (xnd.Attributes == null)
            {
                nd.SelectedImageKey=nd.StateImageKey=nd.ImageKey = "DEFAULTTAG";
                return;
            }

            System.Xml.Schema.XmlSchemaSet schset = (System.Xml.Schema.XmlSchemaSet)                                     this.xmlNSSchemas[XMLEditor.XMLEditorMain.VXDDEFAULTXMLNS];
            object[] schmSetArray = new object[1];
            schset.GlobalElements.Values.CopyTo(schmSetArray, 0);
            XmlSchemaElement rootSchemaNode = (XmlSchemaElement)schmSetArray[0];

            nd.ToolTipText = xnd.Name + " " + this.GetAttributeList(xnd);
            nd.ContextMenuStrip = new ContextMenuStrip();
            nd.ContextMenuStrip.Items.Add("Delete " + nd.Name);
            nd.ContextMenuStrip.Items.Add("Copy " + nd.Name);
            ToolStripMenuItem paste = new ToolStripMenuItem();
            paste.Text = "Paste";
            paste.Enabled = false;
            nd.ContextMenuStrip.Items.Add(paste);
            nd.ContextMenuStrip.Items.Add(new ToolStripSeparator());

            CreateDropDownMenus(nd, xnd, rootSchemaNode);

            foreach (string attName in this.IMAGE_ATTRIBUTE_LIST)
            {
                string mainNameAtt = null;
                if (xnd.Attributes[attName] != null &&
                    xnd.Attributes[attName].Value != null)
                    mainNameAtt = xnd.Attributes[attName].Value;
                if (mainNameAtt == null)
                    continue;

                foreach (string prefix in this.IMAGE_ATTRIBUTE_VAL_PREFIX_LIST)
                    if (this.imgList.Images.ContainsKey(prefix + mainNameAtt))
                    {
                        string prefixedAttVal = prefix + mainNameAtt;
                        try
                        {
                            nd.SelectedImageKey=nd.StateImageKey=nd.ImageKey = prefixedAttVal;
                            return;
                        }
                        catch (Exception) { ;}

                    }
            }
        }
Esempio n. 2
0
        private void RefreshTreeEditor()
        {
            this.selectedEditor.leftTreeView.Nodes.Clear();
            XmlNode root = GetSelectedXMLDocumentElement();
            if (root == null)
                return;
            XMLEditorTreeNode[] children = this.PopulateTree(root);
            XMLEditorTreeNode[] attrroot = this.PopulateAttributes(root);
            XMLEditorTreeNode[] rootchildren = new XMLEditorTreeNode[children.Length + attrroot.Length];
            System.Array.Copy(attrroot, rootchildren, attrroot.Length);
            System.Array.Copy(children, 0, rootchildren, attrroot.Length, children.Length);
            XMLEditorTreeNode rootNode = new XMLEditorTreeNode("<" + root.Name + ">", rootchildren, root);
            this.BuildImageList(root);
            this.SetTreeNodeImageAndToolTip(rootNode, root);
            rootNode.SelectedImageKey = rootNode.StateImageKey =
                rootNode.ImageKey="DEFAULTVXD";
            this.selectedEditor.leftTreeView.Nodes.Add(rootNode);
            rootNode.Expand();
            this.selectedEditor.leftTreeView.Invalidate();

            this.selectedEditor.rightTreeView.Nodes.Clear();
            if (this.xmlValidated)
            {
                XmlNode rroot = GetSelectedXSDDocumentElement();
                XMLEditorTreeNode[] rchildren = this.PopulateTree(rroot);
                XMLEditorTreeNode[] rattrroot = this.PopulateAttributes(rroot);
                XMLEditorTreeNode[] rrootchildren = new XMLEditorTreeNode[rchildren.Length + rattrroot.Length];
                System.Array.Copy(rattrroot, rrootchildren, rattrroot.Length);
                System.Array.Copy(rchildren, 0, rrootchildren, rattrroot.Length, rchildren.Length);
                XMLEditorTreeNode rrootNode = new XMLEditorTreeNode("<" + rroot.Name + ">", rrootchildren, rroot);
                this.BuildImageList(rroot);
                this.SetTreeNodeImageAndToolTip(rrootNode, rroot);
                rrootNode.SelectedImageKey = rrootNode.StateImageKey =
                    rrootNode.ImageKey = "DEFAULTVXD";
                this.selectedEditor.rightTreeView.Nodes.Add(rrootNode);
                rrootNode.Expand();
                this.selectedEditor.rightTreeView.Invalidate();
            }

            this.selectedEditor.Invalidate();
        }
Esempio n. 3
0
        private static void CreateDropDownMenus(XMLEditorTreeNode nd, XmlNode xnd, XmlSchemaElement rootSchemaNode)
        {
            ToolStripDropDownButton elmnu = new ToolStripDropDownButton();
            elmnu.Text = "New Element";
            ToolStripDropDownButton attrmnu = new ToolStripDropDownButton();
            attrmnu.Text = "New Attribute";

            PopulateDropDownMenu(xnd, elmnu, attrmnu, rootSchemaNode);

            nd.ContextMenuStrip.Items.Add(attrmnu);
            nd.ContextMenuStrip.Items.Add(elmnu);
        }
Esempio n. 4
0
 private XMLEditorTreeNode[] PopulateAttributes(XmlNode parent)
 {
     if (parent == null || parent.Attributes == null)
         return new XMLEditorTreeNode[0];
     XMLEditorTreeNode treend = null;
     ArrayList arr = new ArrayList();
     foreach (XmlAttribute nd in parent.Attributes)
     {
         treend = new XMLEditorTreeNode(nd.Name + "=\"" + nd.Value + "\"", nd);
         treend.SelectedImageKey = treend.StateImageKey = treend.ImageKey = "DEFAULTATTR";
         treend.ToolTipText = nd.Name + "=\"" + nd.Value + "\"";
         arr.Add(treend);
     }
     int i = 0;
     XMLEditorTreeNode[] nds = new XMLEditorTreeNode[arr.Count];
     foreach (XMLEditorTreeNode t in arr)
     {
         nds[i] = t; ++i;
     }
     return nds;
 }
Esempio n. 5
0
 protected XMLEditorTreeNode[] PopulateTree(XmlNode parent)
 {
     if (parent == null || parent.ChildNodes == null)
         return new XMLEditorTreeNode[0];
     XMLEditorTreeNode treend = null;
     ArrayList arr = new ArrayList();
     foreach (XmlNode nd in parent.ChildNodes)
     {
         this.BuildImageList(nd);
         if (nd.HasChildNodes)
         {
             XMLEditorTreeNode[] attrroot = this.PopulateAttributes(nd);
             XMLEditorTreeNode[] children = this.PopulateTree(nd);
             XMLEditorTreeNode[] rootchildren = new XMLEditorTreeNode[children.Length + attrroot.Length];
             System.Array.Copy(attrroot, rootchildren, attrroot.Length);
             System.Array.Copy(children, 0, rootchildren, attrroot.Length, children.Length);
             string nameattr = string.Empty;
             if (nd.Attributes != null)
             {
                 XmlAttribute id = nd.Attributes["ID"];
                 if (id == null)
                     id = nd.Attributes["id"];
                 if (id != null && id.Value != null)
                     nameattr += " ID=\"" + id.Value.ToString() + "\" ";
                 foreach (string nmatt in new string[] { "Name", "NAME", "name" })
                 {
                     XmlAttribute nm = nd.Attributes[nmatt];
                     if (nm != null && nm.Value != null)
                     {
                         nameattr += " name=\"" + nm.Value.ToString() + "\"";
                         break;
                     }
                 }
             }
             treend = new XMLEditorTreeNode("<" + nd.Name + nameattr + ">", rootchildren, nd);
             this.SetTreeNodeImageAndToolTip(treend, nd);
             arr.Add(treend);
             treend.Expand();
         }
         else
         {
             XMLEditorTreeNode[] att = PopulateAttributes(nd);
             string nameattr = string.Empty;
             if (nd.Attributes != null)
             {
                 XmlAttribute id = nd.Attributes["ID"];
                 if (id == null)
                     id = nd.Attributes["id"];
                 if (id != null && id.Value != null)
                     nameattr += " ID=\"" + id.Value.ToString() + "\" ";
                 foreach (string nmatt in new string[] { "Name", "NAME", "name" })
                 {
                     XmlAttribute nm = nd.Attributes[nmatt];
                     if (nm != null && nm.Value != null)
                     {
                         nameattr += " name=\"" + nm.Value.ToString() + "\"";
                         break;
                     }
                 }
             }
             if (att == null)
                 treend = new XMLEditorTreeNode("<" + nd.Name + nameattr + ">", nd);
             else
                 treend = new XMLEditorTreeNode("<" + nd.Name + nameattr + ">", att, nd);
             this.SetTreeNodeImageAndToolTip(treend, nd);
             arr.Add(treend);
             treend.Collapse();
             if (treend.Parent != null)
                 treend.Parent.Collapse();
         }
     }
     int i = 0;
     XMLEditorTreeNode[] nds = new XMLEditorTreeNode[arr.Count];
     foreach (XMLEditorTreeNode t in arr)
     {
         nds[i] = t; ++i;
     }
     return nds;
 }