예제 #1
0
        void WebBrower_WBLButtonUp(object sender, csExWB.HTMLMouseEventArgs e)
        {
            if (e.SrcElement != null)
            {
                //user is scrolling using scrollbars
                //if (e.SrcElement.tagName == "HTML")
                //    return;
                //If DIV then we can look for an HTML child element
                //AllForms.m_frmLog.AppendToLog("cEXWB1_WBLButtonUp==>" + e.SrcElement.tagName);
                TreeNodeEx tnRet = null;



                foreach (var tn in HtmlTree.Nodes)
                {
                    var treeNodeEx      = tn as TreeNodeEx;
                    var selectedElement = new SelectedElement();
                    selectedElement.tagName   = e.SrcElement.tagName.ToLower();
                    selectedElement.innerText = e.SrcElement.innerText;
                    tnRet = this.FindNodeExt(treeNodeEx, selectedElement);
                    if (tnRet != null)
                    {
                        break;
                    }
                }
                if (tnRet != null)
                {
                    tnRet.ForeColor = Color.Red;
                    tnRet.Expand();
                    HtmlTree.SelectedNode = tnRet;
                    var sb = new StringBuilder();
                    sb.AppendLine("xpath:" + tnRet.HtmlNode.XPath);
                    sb.AppendLine(HtmlAgilityPackHelper.GetStringByXPath(Html, tnRet.HtmlNode.XPath, "|"));
                    richTextBox.Text += sb.ToString();
                }
            }
            else
            {
                //AllForms.m_frmLog.AppendToLog("cEXWB1_WBLButtonUp");
            }

            //Rectangle rt = new Rectangle(m_mposX - 1, m_mposY - 1, 2, 2);
            //if (rt.Contains(e.ClientX, e.ClientY))
            //{
            //    //AllForms.m_frmLog.AppendToLog("MOUSE CLICKED");
            //}
        }