Esempio n. 1
0
 private void ClickAction()
 {
     if (!this.isContextNode)
     {
         TreeNode selectedNode = this._treeResult.SelectedNode;
         if (selectedNode != null)
         {
             this._xPathExp = "";
             while (selectedNode.Parent != null)
             {
                 if (selectedNode.Text.StartsWith("<") && selectedNode.Text.EndsWith(">"))
                 {
                     this._level = this.GetNodeLevel(selectedNode);
                     string prefix      = "";
                     string elementName = this.MatchRegex(selectedNode.Text);
                     if (this._hasDefNS && (elementName.IndexOf(":", 0, elementName.Length) == -1))
                     {
                         prefix = this._nsDefPrefix + ":";
                     }
                     if (this._hasSiblings)
                     {
                         this._xPathExp = DisplayForm.GetElementName(prefix, elementName) + "[" + DisplayForm.GetPositionName(this._level) + "]/" + this._xPathExp;
                     }
                     else
                     {
                         this._xPathExp = DisplayForm.GetElementName(prefix, elementName) + "/" + this._xPathExp;
                     }
                 }
                 else
                 {
                     this._xPathExp = this._xPathExp + DisplayForm.GetTextName();
                 }
                 selectedNode = selectedNode.Parent;
             }
             this._xPathExp = "/" + this._xPathExp;
             if (this._xPathExp.EndsWith("/"))
             {
                 this._xPathExp = this._xPathExp.Remove(this._xPathExp.Length - 1, 1);
             }
             this._attributes   = this.GetAttributes(this._treeResult.SelectedNode.Text);
             this.txtQuery.Text = this._xPathExp;
         }
     }
 }
Esempio n. 2
0
        private void AddAllElementsMenu()
        {
            this._CtxAttrContextMenu.MenuItems.Add(new MenuItem("-"));
            MenuItem item = new MenuItem("Select All <" + this.MatchRegex(this._treeResult.SelectedNode.Text) + "> elements");

            if (this._hasDefNS)
            {
                item.MenuItems.Add(
                    new MenuItem(".//" +
                                 DisplayForm.GetElementName
                                     (this._nsDefPrefix + ":",
                                     this.MatchRegex(this._treeResult.SelectedNode.Text)),
                                 new EventHandler(this.mnuSelectElements_Click)));
            }
            else
            {
                item.MenuItems.Add(new MenuItem(".//" + DisplayForm.GetElementName("", this.MatchRegex(this._treeResult.SelectedNode.Text)), new EventHandler(this.mnuSelectElements_Click)));
            }
            this._CtxAttrContextMenu.MenuItems.Add(item);
        }