📄 freetextbox.cs
字号:
}
}
/// <summary>
/// 获取或设置一个值,该值指示是否在 HTML 视图中使用等宽字体。
/// </summary>
[CategoryAttribute("行为"),DescriptionAttribute("获取或设置一个值,该值指示是否在 HTML 视图中使用等宽字体。")]
public bool HtmlModeDefaultsToMonoSpaceFont
{
get
{
object savedState = this.ViewState["HtmlModeDefaultsToMonoSpaceFont"];
return (savedState == null) ? true : (bool) savedState;
}
set
{
ViewState["HtmlModeDefaultsToMonoSpaceFont"] = value;
}
}
/// <summary>
/// 获取或设置工具条使用的预设组合。可以为:Default,EnableAll,Alternate,Minimal。
/// </summary>
[CategoryAttribute("工具条行为"),DescriptionAttribute("获取或设置工具条使用的预设组合。可以为:Default,EnableAll,Alternate,Minimal。")]
public AutoConfigure AutoConfigure
{
get
{
object savedState = this.ViewState["AutoConfigure"];
return (savedState == null) ? AutoConfigure.Default : (AutoConfigure) savedState;
}
set
{
ViewState["AutoConfigure"] = value;
}
}
/// <summary>
/// 获取或设置工具条中显示的按钮和分隔线。使用逗号(,)隔开各项,分号(;)插入一个分隔线,竖线(|)将开始新的工具条。
/// </summary>
[CategoryAttribute("工具条行为"),DescriptionAttribute("获取或设置工具条中显示的按钮和分隔线。使用逗号(,)隔开各项,分号(;)插入一个分隔线,竖线(|)将开始新的工具条。")]
public string ToolbarLayout
{
get
{
object savedState = this.ViewState["ToolbarLayout"];
return (savedState == null) ? "" : (string) savedState;
}
set
{
ViewState["ToolbarLayout"] = value;
}
}
/// <summary>
/// 获取或设置滚动条的样式模式。可以为:None,Style。
/// </summary>
[CategoryAttribute("行为"),DescriptionAttribute("获取或设置滚动条的样式模式。可以为:None,Style。")]
public ScrollbarMode ScrollbarMode
{
get
{
object savedState = this.ViewState["ScrollbarMode"];
return (savedState == null) ? ScrollbarMode.None : (ScrollbarMode) savedState;
}
set
{
ViewState["ScrollbarMode"] = value;
}
}
/// <summary>
/// 获取滚动条样式。
/// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content),PersistenceMode(PersistenceMode.InnerProperty),NotifyParentProperty(true),CategoryAttribute("外观"),DescriptionAttribute("获取滚动条样式。")]
public virtual ScrollbarStyle ScrollbarStyle
{
get
{
if (scrollbarStyle == null)
{
scrollbarStyle = new ScrollbarStyle(ColorTranslator.FromHtml("#D4D0C8"),ColorTranslator.FromHtml("#000000"),ColorTranslator.FromHtml("#D4D0C8"),ColorTranslator.FromHtml("#D4D0C8"),ColorTranslator.FromHtml("#D4D0C8"),ColorTranslator.FromHtml("#808080"),ColorTranslator.FromHtml("#808080"),ColorTranslator.FromHtml("#D4D0C8"));
if (IsTrackingViewState) ((IStateManager)scrollbarStyle).TrackViewState();
}
return scrollbarStyle;
}
}
private ScrollbarStyle scrollbarStyle;
/// <summary>
/// 获取或设置工具条模板。可以为:Default,Custom(自定义)。
/// </summary>
[CategoryAttribute("工具条行为"),DescriptionAttribute("获取或设置工具条模板。可以为:Default,Custom(自定义)。")]
public ToolbarType ToolbarType
{
get
{
object savedState = this.ViewState["ToolbarType"];
return (savedState == null) ? ToolbarType.Default : (ToolbarType) savedState;
}
set
{
ViewState["ToolbarType"] = value;
}
}
private void SetButtonStyle()
{
if (ViewState["ToolbarType"] != null)
{
if (this.ButtonPath == "") this.ButtonPath = "images/ftb/";
if (this.ToolbarType == ToolbarType.Default)
{
this.BackColor = ColorTranslator.FromHtml("#9EBEF5");
this.GutterBackColor = ColorTranslator.FromHtml("#81A9E2");
this.ButtonOverStyle = true;
this.ButtonOverImage = false;
this.ButtonDownStyle = true;
this.ButtonDownImage = false;
this.ButtonStyle.OverBackColor = Color.Empty;
this.ButtonStyle.OverBackgroundImage = this.ButtonPath + "toolbarbutton.over.gif";
this.ButtonStyle.OverBorderColorLight = ColorTranslator.FromHtml("#000080");
this.ButtonStyle.OverBorderColorDark = ColorTranslator.FromHtml("#000080");
this.ButtonStyle.DownBackColor = Color.Empty;
this.ButtonStyle.DownBackgroundImage = this.ButtonPath + "toolbarbutton.down.gif";
this.ButtonStyle.DownBorderColorLight = ColorTranslator.FromHtml("#000080");
this.ButtonStyle.DownBorderColorDark = ColorTranslator.FromHtml("#000080");
this.ToolbarBackColor = System.Drawing.Color.Empty;
this.ToolbarBackGroundImage = true;
}
}
}
// 按钮项目
/// <summary>
/// 获取或设置工具条中的按钮显示模式。可以为:Image(默认),FormButton。
/// </summary>
[CategoryAttribute("工具条项目选项"),DescriptionAttribute("获取或设置工具条中的按钮显示模式。可以为:Image(默认),FormButton。")]
public ButtonType ButtonType
{
get
{
object savedState = this.ViewState["ButtonType"];
return (savedState == null) ? ButtonType.Image : (ButtonType) savedState;
}
set
{
ViewState["ButtonType"] = value;
}
}
/// <summary>
/// 获取工具条的按钮样式。当 ButtonStyle 指定为 FormButton 时无效。当 ToolbarStyle 指定为 Custom 时,这些值可以被重写。
/// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content),PersistenceMode(PersistenceMode.InnerProperty),NotifyParentProperty(true),CategoryAttribute("工具条行为"),DescriptionAttribute("获取工具条的按钮样式。当 ButtonStyle 指定为 FormButton 时无效。当 ToolbarStyle 指定为 Custom 时,这些值可以被重写。")]
public virtual ToolbarButtonStyle ButtonStyle
{
get
{
if (buttonStyle == null)
{
if (this.ButtonPath == "") this.ButtonPath = "images/ftb/";
buttonStyle = new ToolbarButtonStyle(Color.Empty,Color.Empty,this.ButtonPath + "toolbarbutton.over.gif",ColorTranslator.FromHtml("#000080"),ColorTranslator.FromHtml("#000080"),this.ButtonPath + "toolbarbutton.down.gif",ColorTranslator.FromHtml("#000080"),ColorTranslator.FromHtml("#000080"));
if (IsTrackingViewState) ((IStateManager)buttonStyle).TrackViewState();
}
return buttonStyle;
}
}
private ToolbarButtonStyle buttonStyle;
protected override object SaveViewState()
{
// Customized state management to handle saving
// state of contained objects such as styles.
object baseState = base.SaveViewState();
object buttonStyleState = (buttonStyle != null) ? ((IStateManager)buttonStyle).SaveViewState() : null;
object scrollbarStyleState = (scrollbarStyle != null) ? ((IStateManager)scrollbarStyle).SaveViewState() : null;
object[] myState = new object[3];
myState[0] = baseState;
myState[1] = buttonStyleState;
myState[2] = scrollbarStyleState;
return myState;
}
protected override void LoadViewState(object savedState)
{
// Customized state management to handle
// state restoration of contained objects.
if (savedState != null)
{
object[] myState = (object[])savedState;
if (myState[0] != null) base.LoadViewState(myState[0]);
if (myState[1] != null) ((IStateManager)ButtonStyle).LoadViewState(myState[1]);
if (myState[2] != null) ((IStateManager)ScrollbarStyle).LoadViewState(myState[2]);
}
}
/// <summary>
/// 获取或设置一个值,该值指示当鼠标在按钮上时按钮是否改变颜色)。
/// </summary>
[CategoryAttribute("工具条项目选项"),DescriptionAttribute("获取或设置一个值,该值指示当鼠标在按钮上时按钮是否改变颜色。")]
public bool ButtonOverStyle
{
get
{
object savedState = this.ViewState["ButtonOverStyle"];
return (savedState == null) ? true : (bool) savedState;
}
set
{
ViewState["ButtonOverStyle"] = value;
}
}
/// <summary>
/// 获取或设置一个值,该值指示当鼠标在按钮上时按钮是否改变图片。
/// </summary>
[CategoryAttribute("工具条项目选项"),DescriptionAttribute("获取或设置一个值,该值指示当鼠标在按钮上时按钮是否改变图片。")]
public bool ButtonOverImage
{
get
{
object savedState = this.ViewState["ButtonOverImage"];
return (savedState == null) ? false : (bool) savedState;
}
set
{
ViewState["ButtonOverImage"] = value;
}
}
/// <summary>
/// 获取或设置一个值,该值指示当按钮按下时按钮是否改变颜色。
/// </summary>
[CategoryAttribute("工具条项目选项"),DescriptionAttribute("获取或设置一个值,该值指示当按钮按下时按钮是否改变颜色。")]
public bool ButtonDownStyle
{
get
{
object savedState = this.ViewState["ButtonDownStyle"];
return (savedState == null) ? true : (bool) savedState;
}
set
{
ViewState["ButtonDownStyle"] = value;
}
}
/// <summary>
/// 获取或设置一个值,该值指示当按钮按下时按钮是否改变图片。
/// </summary>
[CategoryAttribute("工具条项目选项"),DescriptionAttribute("获取或设置一个值,该值指示当按钮按下时按钮是否改变图片。")]
public bool ButtonDownImage
{
get
{
object savedState = this.ViewState["ButtonDownImage"];
return (savedState == null) ? false : (bool) savedState;
}
set
{
ViewState["ButtonDownImage"] = value;
}
}
/// <summary>
/// 获取或设置按钮图片所在的地址。默认为 String.Empty。当 ToolbarType 指定为 Default 时会自动指定 ButtonPath。
/// </summary>
[CategoryAttribute("外部的"),DescriptionAttribute("获取或设置按钮图片所在的地址。默认为 String.Empty。当 ToolbarType 指定为 Default 时会自动指定 ButtonPath。")]
public string ButtonPath
{
get
{
object savedState = this.ViewState["ButtonPath"];
return (savedState == null) ? "" : ResolveUrl((string) savedState);
}
set
{
value = value.Replace("\\","/");
value = value.Trim('/');
value += "/";
ViewState["ButtonPath"] = value;
}
}
/// <summary>
/// 获取或设置图片文件的后缀(gif,jpg,png)。
/// </summary>
[CategoryAttribute("外部的"),DescriptionAttribute("获取或设置图片文件的后缀(GIF,JPG,PNG)。")]
public string ButtonFileExtention
{
get
{
object savedState = this.ViewState["ButtonFileExtention"];
return (savedState == null) ? "GIF" : (string) savedState;
}
set
{
ViewState["ButtonFileExtention"] = value;
}
}
/// <summary>
/// 获取或设置外部文件所在的地址。默认(HelperFiles)。
/// </summary>
[CategoryAttribute("外部的"),DescriptionAttribute("获取或设置外部文件所在的地址。默认(HelperFiles)")]
public string HelperFilesPath
{
get
{
object savedState = this.ViewState["HelperFilesPath"];
return (savedState == null) ? "HelperFiles" : ResolveUrl((string) savedState);
}
set
{
value = value.Replace("\\","/");
value = value.Trim('/');
ViewState["HelperFilesPath"] = value;
}
}
/// <summary>
/// 获取或设置外部文件的参数。
/// </summary>
[CategoryAttribute("外部的"),DescriptionAttribute("获取或设置外部文件的参数。")]
public string HelperFilesParameters
{
get
{
object savedState = this.ViewState["HelperFilesParameters"];
return (savedState == null) ? "" : (string) savedState;
}
set
{
ViewState["HelperFilesParameters"] = value;
}
}
/// <summary>
/// 获取或设置脚本文件所在地址(默认为 jscript)。
/// </summary>
[CategoryAttribute("外部的"),DescriptionAttribute("获取或设置脚本文件所在地址(默认为 jscript)。")]
public string ScriptFilePath
{
get
{
object savedState = this.ViewState["ScriptFilePath"];
return (savedState == null) ? "jscript" : (string) savedState;
}
set
{
value = value.Replace("\\","/");
value = value.Trim('/');
ViewState["ScriptFilePath"] = value;
}
}
#endregion
#region 控件描述
protected override void OnInit( EventArgs e )
{
// Check for form tags
GetFormClientID();
base.OnInit(e);
}
private string GetFormClientID()
{
if(IsHtmlForm(this.Parent))
{
return this.Parent.ClientID;
}
Control c = this.Parent;
while(c != null)
{
c = c.Parent;
if(IsHtmlForm(c))
{
return c.Parent.ClientID;
}
}
throw new Exception(string.Format("类型“{1}”的控件“{0}”必须放在具有 runat=server 的窗体标记内。",this.ClientID,this.GetType().ToString()));
}
private bool IsHtmlForm(Control c)
{
return (c is HtmlForm);
}
protected override void OnLoad(EventArgs e)
{
if ((this.ClientID + "")== "") throw new Exception("FreeTextBox 控件必须指定 ID 属性。");
if (this.DownlevelMode == DownlevelMode.BasicEditor && !this.IsBasicEditorCapable)
{
this.DownlevelMode = DownlevelMode.TextArea;
}
InitializeToolbars();
SetUpToolbarItems();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -