Exemplo n.º 1
0
        private void HandleNodeDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            string fn = MethodBase.GetCurrentMethod().Name;

            try
            {
                if (!EnableMultiSelection)
                {
                    TreeNode             node = e.Node;
                    XmlDataSelectionInfo xdsi = node.Tag as XmlDataSelectionInfo;
                    this.SelectedItems = new List <XmlDataSelectionInfo>();
                    this.SelectedItem  = xdsi;
                }
                else
                {
                    this.SelectedItem  = null;
                    this.SelectedItems = new List <XmlDataSelectionInfo>();
                    getSelectedXmlNodeInfo(this.SelectedItems, null);
                }
                if (null != DoubleClickItemEvent)
                {
                    DoubleClickItemEvent(this, new EventArgs());
                }
            }
            catch (Exception exc)
            {
                Util.HandleExc(this, fn, exc);
                return;
            }
        }
Exemplo n.º 2
0
        private bool getSelectedXmlNodeInfo(List <XmlDataSelectionInfo> oList, TreeNode oRootNode = null)
        {
            TreeNodeCollection tnc = null;

            if (null == oRootNode)
            {
                tnc = m_tvXmlContent.Nodes;
            }
            else
            {
                tnc = oRootNode.Nodes;
            }

            foreach (TreeNode tnode in tnc)
            {
                if (tnode.Checked)
                {
                    XmlDataSelectionInfo xdsi = tnode.Tag as XmlDataSelectionInfo;
                    if (null != xdsi)
                    {
                        oList.Add(xdsi);
                    }
                }
                if (!getSelectedXmlNodeInfo(oList, tnode))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 3
0
        } // end method()

        private bool FillSubtree(TreeNode oParentNode, XmlElement oXmlElement, string sPath = "")
        {
            string fn = "XmlDataSelectorCtl.FillSubtree()";

            try
            {
                string scurtitle = "<" + oXmlElement.Name + ">";
                if (!hasChildElements(oXmlElement))
                {
                    scurtitle += " = '" + oXmlElement.InnerText + "'";
                }
                TreeNode tncur = new TreeNode(scurtitle);
                tncur.ForeColor = Color.Blue;
                if (null != oParentNode)
                {
                    oParentNode.Nodes.Add(tncur);
                }
                else
                {
                    m_tvXmlContent.Nodes.Add(tncur);
                }
                string spath = (null == sPath) ? "" : sPath;
                if (!string.IsNullOrEmpty(spath))
                {
                    spath += ".";
                }
                spath += oXmlElement.Name;
                XmlDataSelectionInfo xdsi = new XmlDataSelectionInfo(spath, XmlItemType.Element);
                tncur.Tag = xdsi;


                foreach (XmlAttribute attribute in oXmlElement.Attributes)
                {
                    TreeNode tnatt = new TreeNode(attribute.Name + " = '" + attribute.Value + "'");
                    tnatt.ForeColor = Color.DarkRed;
                    string sattpath            = spath + ":" + attribute.Name;
                    XmlDataSelectionInfo xdsia = new XmlDataSelectionInfo(sattpath, XmlItemType.Attribute);
                    tnatt.Tag = xdsia;
                    tncur.Nodes.Add(tnatt);
                }

                foreach (XmlNode ochildnode in oXmlElement.ChildNodes)
                {
                    XmlElement ochildelt = ochildnode as XmlElement;
                    if (null == ochildelt)
                    {
                        continue;
                    }

                    if (!FillSubtree(tncur, ochildelt, spath))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception exc)
            {
                Util.HandleExc(this, fn, exc);
                return(false);
            }
        }