[C#] 纯文本查看 复制代码
(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)FlowLayoutPanel使用PreRenderDocument时,有时创建会报线程间操作无效: 从不是创建控件“”的线程访问它,经检查原因在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);
}
复制代码