zoukankan      html  css  js  c++  java
  • Syncfusion HTMLUI研究一

    HTMLUI可以加载HTML页面,并且相比WebKit等占用资源特别少

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <body marginheight="0" marginwidth="0" bgcolor="#ffffff">
    <div>
        <span style="font:Bold">12121</span>
        <span style="font:Bold;Color:Blue">121212</span>
        <span style="font:Bold;Color:Blue">121212</span>
    </div>
    <hr></hr>
    <div>
        <span style="font:Bold;font-size:9pt">1212</span>
        <span style="font:Bold;font-size:9pt">1221</span>
        <span style="font:Bold;font-size:9pt">1212</span>
    </div>
    <p>
        <span style="font:Bold;font-size:9pt">12121</span>
        
        <span id="aaa" style="24px;height:24px;"></span>
        
        <span style="font:Bold;font-size:9pt">121212</span>
    </p>
    </div>
    </body>
    </html>




    (1)HTMLUI源码中绘制部分

    /// <summary>
    /// Starts the drawing of the document from the start element.
    /// </summary>
    /// <param name="e">Paint event data.</param>
    private void ProcessDraw(PaintEventArgs e)
    {
        if (e == null)
            throw new ArgumentNullException("e");
    
        if (m_startDrawElement == null)
        {
            this.RenderRoot.DrawElement(e);
        }
        else
        {
            m_startDrawElement.DrawElement(e);
    
            // Reset start element.
            m_startDrawElement = null;
        }
    }

    如果m_startDrawElement为null,在根html tag下绘制,否则在指定元素下绘制。
    (2)FlowLayoutPanel中使用HTMLUI时,要先用一个UserControl或者其它控件作为HTMLUI的父控件,不然滚动时会出现花屏现象。

    (3)动态改变HTMLUI元素内容代码

    private void htmluiControl1_PreRenderDocument(object sender, Syncfusion.Windows.Forms.HTMLUI.PreRenderDocumentArgs e)
            {
                Hashtable htmlelements = new Hashtable();
                htmlelements = e.Document.ElementsByUserID;
                Label lable=new Label();
                lable.Text = "1";
                lable.Width = 24;
                lable.Height = 24;
                lable.BackColor = Color.Red;
                BaseElement aaa = htmlelements["aaa"] as BaseElement;
                    new CustomControlBase(aaa, lable);
    
            }
    
            private void ChangeLableValue(HTMLUIControl htmluiControl,string str)
            {
    
                var v = htmluiControl.Document.GetElementsByUserIdHash()["aaa"];
                Label v1= htmluiControl.Document.GetControlByElement((IHTMLElement) v) as Label;
                v1.Text = str;
            }

    (4)有时创建会报线程间操作无效: 从不是创建控件“”的线程访问它,经检查原因在PreRenderDocument,修改PreRenderDocument如下。

    private void htmluiControl1_PreRenderDocument(object sender, Syncfusion.Windows.Forms.HTMLUI.PreRenderDocumentArgs e)
            {
                Hashtable htmlelements = new Hashtable();
                htmlelements = e.Document.ElementsByUserID;
    
                Action<Hashtable> action = (data) =>
                {
                    Label lable = new Label();
                    lable.Text = "1";
                    lable.Width = 24;
                    lable.Height = 24;
                    lable.BackColor = Color.Red;
                    BaseElement aaa = htmlelements["aaa"] as BaseElement;
                    new CustomControlBase(aaa, lable);
                };
                Invoke(action, htmlelements);
    
            }

     一起研究的来群:616945527

  • 相关阅读:
    apns libcurl
    apns libcurl
    epoll
    epoll
    Linux服务器压测
    Linux服务器压测
    libevent
    libevent
    shell脚本
    shell脚本
  • 原文地址:https://www.cnblogs.com/zhaogaojian/p/8491521.html
Copyright © 2011-2022 走看看