Exemple #1
0
        public static void Insertlink(HTMLDesignerContrl htmlDesigner)
        {
            htmlDesigner.InsertLink();
            return;

            string innerText = "";

            if (htmlDesigner.DesignWebBrowser.idoc2.selection.type == "Text")//如果选中的是文本
            {
                IHTMLTxtRange searchRange = (IHTMLTxtRange)htmlDesigner.DesignWebBrowser.idoc2.selection.createRange();
                innerText = searchRange.htmlText;//获取文本的html代码
            }


            //if (m_pDoc2.selection.type == "Control")//如果选中的控件
            {
                /* IHTMLTxtRange searchRange = (IHTMLTxtRange)m_pDoc2.selection.createRange();
                 * innerText = searchRange.htmlText;//获取文本的html代码*/
            }

            //frmInsertLinkCode insertLink = new frmInsertLinkCode();
            //HTMLAnchorElement linkEle = htmlDesigner.CurrentElement as HTMLAnchorElement;
            //if (linkEle != null)
            //{//给弹出的控件赋值
            //    string hrefStr = linkEle.href.Replace("about:blank", "").Replace("about:", "");
            //    if (hrefStr.IndexOf("#") > 0)
            //    {
            //        insertLink.linkUrl = hrefStr.Substring(0, hrefStr.IndexOf("#"));
            //        insertLink.BookMark = hrefStr.Substring(1 + hrefStr.IndexOf("#"));
            //        insertLink.linkTarget = linkEle.target;
            //        insertLink.LinkTip = linkEle.title;
            //        insertLink.AccessKey = linkEle.accessKey;
            //    }
            //    else
            //    {
            //        insertLink.linkUrl = hrefStr;
            //    }
            //}
            //if (insertLink.ShowDialog() == DialogResult.OK)
            //{
            //    //从弹出的控件中取值
            //    if ((m_pDoc2.selection.type == "None") && (htmlDesigner.LinkBe != null))//如果没有选中文本,则对当前链接进行更改,否则插入新链接
            //    {
            //        htmlDesigner.LinkBe.Element.href = insertLink.linkUrl;
            //        htmlDesigner.LinkBe.Element.target = insertLink.linkTarget;
            //        htmlDesigner.LinkBe.Element.accessKey = insertLink.AccessKey;
            //         htmlDesigner.LinkBe.Element.tabIndex = insertLink.BookMark;
            //    }
            //    else
            //    {
            //        m_pDoc2.selection.clear();
            //        string linkURL = insertLink.linkUrl;
            //        string linkTarget = insertLink.linkTarget;
            //        string linkAccesskey = insertLink.AccessKey;
            //        string linkTip = insertLink.LinkTip;
            //        string linkBookMark = insertLink.BookMark;
            //        LINK link = new LINK();
            //        string insertlinkhtml = link.LinkHtml(innerText, linkURL, linkTarget, linkTip, linkAccesskey, linkBookMark);
            //        AddToSelection(m_pDoc2, insertlinkhtml, "");

            //    }
            //}
        }