⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itexteditor.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI.WebControls;
using System.Text;

namespace CommunityServer.Controls
{
	public interface ITextEditor
	{
        string Text
        {
            get;
            set;
        }

        Unit Height { get; set;}
        Unit Width { get; set;}
        int Rows { get; set;}
        int Columns {get; set;}

		string StyleName {get;set;}

        //will allow us to control if HTML editing is enabled
        bool EnableHtmlModeEditing
        {
            get;
            set;
        }

        bool IsRichTextCapable
        {
            get;
        }
	}

    public class DefaultTextEditor : System.Web.UI.WebControls.TextBox, ITextEditor
    {
        public DefaultTextEditor():base()
        {

        }

        //we can probably remove this
        public void Configure()
        {   
			if(this.Height.IsEmpty)
				this.Height = Unit.Pixel(400);

			if(this.Width.IsEmpty)
				this.Width = Unit.Percentage(100);

			if(this.Rows == 0)
				this.Rows = 20;

			if(this.Columns == 0)
				this.Columns = 20;

            this.TextMode = TextBoxMode.MultiLine;
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad (e);
			Configure();
            this.Page.RegisterClientScriptBlock("InsertText",RenderScript());
        }


        public bool IsRichTextCapable
        {
            get{return true;}
        }

        bool _isAdmin = false;

    	public string StyleName
    	{
    		get { throw new NotImplementedException(); }
    		set { throw new NotImplementedException(); }
    	}

    	public bool EnableHtmlModeEditing
        {
            get{return _isAdmin;}
            set{_isAdmin = value;}
        }



        protected string RenderScript()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"JavaScript\">");
            string uk = this.UniqueID;//.Replace(":","_");
            sb.Append("function InsertText(textToInsert) {");
            
			sb.Append("var objPostEditor;");
			sb.Append("if(document.getElementById) {");			
			sb.Append("objPostEditor = document.getElementById(\"PostForm." + this.UniqueID + "\");");
//			sb.AppendFormat("PostForm.{0};",uk);
			sb.Append("} else {");
			sb.Append("objPostEditor = document.all[\"PostForm." + this.UniqueID + "\"];}");
			sb.Append("objPostEditor.value += textToInsert +\" \";");
			sb.Append("objPostEditor.focus();}");
            //sb.AppendFormat("document.PostForm.{0}.value += textToInsert +\" \";",uk);
            //sb.AppendFormat("document.PostForm.{0}.focus();",uk);
            sb.Append("</script>");

            return sb.ToString();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -