📄 htmleditordesigner.cs
字号:
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Web.UI;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Resources;
using System.Collections;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
namespace Lion.Data.Library.HtmlEditor
{
/// <summary>
/// <see cref="HtmlEditor"/> 服务器控件设计器。
/// </summary>
internal class HtmlEditorDesigner : System.Web.UI.Design.ControlDesigner
{
/// <summary>
/// 初始化 <see cref="HtmlEditor"/> 的新实例
/// </summary>
public HtmlEditorDesigner() {}
private HtmlEditor ftb = null;
/// <summary>
/// 使设计器准备查看、编辑和设计指定的组件
/// </summary>
/// <param name="component">此设计器的组件</param>
public override void Initialize(IComponent component)
{
ftb = (HtmlEditor)component;
base.Initialize(component);
}
/// <summary>
/// 获取用于在设计时表示关联控件的 HTML。
/// </summary>
/// <returns>用于在设计时表示控件的 HTML。</returns>
public override string GetDesignTimeHtml()
{
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
HtmlTable t = new HtmlTable();
t.CellPadding = 3;
t.CellSpacing = 1;
t.BorderColor = ColorTranslator.ToHtml(System.Drawing.Color.Black);
t.BgColor = ColorTranslator.ToHtml(ftb.BackColor);
t.Width = "550";
t.Height = "350";
HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell td = new HtmlTableCell();
td.VAlign = "top";
td.Align = "center";
// inner table for iframe
HtmlTable iframe = new HtmlTable();
iframe.BgColor = "#FFFFFF";
iframe.Width="100%";
iframe.Height="100%";
iframe.CellPadding = 0;
iframe.CellSpacing = 0;
iframe.Style.Add("border","1 solid " + ColorTranslator.ToHtml(System.Drawing.Color.Black));
HtmlTableRow tr2 = new HtmlTableRow();
HtmlTableCell td2 = new HtmlTableCell();
td2.VAlign = "middle";
td2.Align = "center";
td2.Controls.Add(new LiteralControl("<b><font face=arial size=2><font color=green>Lion.Data.Library.HtmlEdit</font>:</b> " + ftb.ID + "</font>"));
tr2.Cells.Add(td2);
iframe.Rows.Add(tr2);
td.Controls.Add(iframe);
td.Controls.Add(new LiteralControl("<br><br><br>"));
tr.Cells.Add(td);
t.Rows.Add(tr);
t.RenderControl(htw);
return sw.ToString();
}
/// <summary>
/// 获取在呈现控件时遇到错误后在设计时为指定的异常显示的 HTML。
/// </summary>
/// <param name="e">要为其显示错误信息的异常。</param>
/// <returns>设计时为指定的异常显示的 HTML。</returns>
protected override string GetErrorDesignTimeHtml(Exception e)
{
string errorstr="创建控件时出错!"+e.Message;
return CreatePlaceHolderDesignTimeHtml(errorstr);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -