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

            if (_hasDefNS)
            {
                item.MenuItems.Add(
                    new MenuItem(".//" +
                                 DisplayForm.GetElementName
                                     (_nsDefPrefix + ":",
                                     MatchRegex(_treeResult.SelectedNode.Text)),
                                 mnuSelectElements_Click));
            }
            else
            {
                item.MenuItems.Add(
                    new MenuItem(".//" + DisplayForm.GetElementName("", MatchRegex(_treeResult.SelectedNode.Text)),
                                 mnuSelectElements_Click));
            }
            _CtxAttrContextMenu.MenuItems.Add(item);
        }
Esempio n. 3
0
        private void mnuSelectAttributeValue_Click(object sender, EventArgs e)
        {
            var text = ((MenuItem)sender).Text;

            txtQuery.Text = DisplayForm.GetAllElementsName(_xPathExp) + "/@" + text;
        }
Esempio n. 4
0
 private void ctxAttr_Click(object sender, EventArgs e)
 {
     _xPathExp     = _xPathExp + "/" + DisplayForm.GetAttrName(((MenuItem)sender).Text);
     txtQuery.Text = _xPathExp;
 }