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

📄 freetextbox.cs

📁 Freetextbox是优秀的在线编辑器
💻 CS
📖 第 1 页 / 共 5 页
字号:
namespace FreeTextBoxControls
{
    using FreeTextBoxControls.Design;
    using FreeTextBoxControls.Licensing;
    using FreeTextBoxControls.Support;
    using System;
    using System.Collections;
    using System.Collections.Specialized;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Text.RegularExpressions;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    [ParseChildren(true), Designer(typeof(FreeTextBoxDesigner)), PersistChildren(true), ToolboxData("<{0}:FreeTextBox runat=\"server\"></{0}:FreeTextBox>"), DefaultProperty("Text"), LicenseProvider(typeof(FtbLicenseProvider)), ValidationProperty("Text")]
    public class FreeTextBox : Control, IPostBackDataHandler, INamingContainer, IPostBackEventHandler, IDisposable
    {
        public event EventHandler ProcessText;
        public event EventHandler SaveClick;
        public event EventHandler TextChanged;

        public FreeTextBox()
        {
            this.license = null;
            this.ProcessText = (EventHandler) Delegate.Combine(this.ProcessText, new EventHandler(this.InternalProcessText));
            try
            {
                this.license = (FtbLicense) LicenseManager.Validate(typeof(FreeTextBox), this);
            }
            catch
            {
            }
        }

        private string CreateResourceString(string filename, ResourceType resourceType)
        {
            FreeTextBoxControls.ToolbarStyleConfiguration configuration1 = this.ButtonSet;
            if (configuration1 == FreeTextBoxControls.ToolbarStyleConfiguration.NotSet)
            {
                configuration1 = FreeTextBoxControls.ToolbarStyleConfiguration.Office2003;
            }
            switch (resourceType)
            {
                case ResourceType.Button:
                    if (this.ButtonImagesLocation == ResourceLocation.InternalResource)
                    {
                        return ClientScriptWrapper.GetWebResourceUrl(this, string.Concat(new object[] { "FreeTextBoxControls.Resources.Images.", configuration1, ".", filename, ".gif" }), this.AssemblyResourceHandlerPath);
                    }
                    return (this.SupportFolder + this.ButtonFolder + "/" + filename + "." + this.ButtonFileExtention).ToLower();

                case ResourceType.Toolbar:
                    if (this.ToolbarImagesLocation == ResourceLocation.InternalResource)
                    {
                        return ClientScriptWrapper.GetWebResourceUrl(this, string.Concat(new object[] { "FreeTextBoxControls.Resources.Images.", configuration1, ".", filename, ".gif" }), this.AssemblyResourceHandlerPath);
                    }
                    return (this.SupportFolder + this.ButtonFolder + "/" + filename + "." + this.ButtonFileExtention).ToLower();

                case ResourceType.JavaScript:
                    if (this.JavaScriptLocation == ResourceLocation.InternalResource)
                    {
                        return ClientScriptWrapper.GetWebResourceUrl(this, "FreeTextBoxControls.Resources.JavaScript." + filename, this.AssemblyResourceHandlerPath);
                    }
                    return (this.SupportFolder + filename);
            }
            return string.Empty;
        }

        private string CreateUniqueToolbarItemID(Toolbar toolbar, ToolbarItem toolbarItem)
        {
            string[] textArray1 = new string[] { this.ClientID, "_", this.Toolbars.IndexOf(toolbar).ToString(), "_", toolbar.Items.IndexOf(toolbarItem).ToString() };
            return string.Concat(textArray1);
        }

        public override void Dispose()
        {
            base.Dispose();
            this.Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (disposing && (this.license != null))
            {
                this.license.Dispose();
                this.license = null;
            }
        }

        private void InternalProcessText(object source, EventArgs args)
        {
            FreeTextBox box1 = (FreeTextBox) source;
            string text1 = box1.Text;
            Formatter formatter1 = new Formatter();
            if ((box1.RemoveServerNameFromUrls || box1.ConvertHtmlSymbolsToHtmlCodes) || box1.RemoveScriptNameFromBookmarks)
            {
                try
                {
                    string text2 = this.Page.Request.Url.AbsoluteUri.ToString();
                    string text3 = text2.Substring(0, text2.IndexOf(this.Page.Request.ServerVariables["HTTP_HOST"]) + this.Page.Request.ServerVariables["HTTP_HOST"].Length);
                    if (box1.RemoveScriptNameFromBookmarks)
                    {
                        string text4 = this.Page.Request.ServerVariables["HTTP_HOST"];
                        string text5 = this.Page.Request.ServerVariables["SCRIPT_NAME"];
                        string text6 = this.Page.Request.QueryString.ToString();
                        text1 = formatter1.RemoveScriptNameFromBookmarks(text1, text2);
                        text1 = formatter1.RemoveScriptNameFromBookmarks(text1, text2.Replace("&", "&amp;"));
                    }
                    if (box1.RemoveServerNameFromUrls)
                    {
                        text1 = formatter1.RemoveServerNameFromUrls(text1, text3);
                    }
                    if (box1.ConvertHtmlSymbolsToHtmlCodes)
                    {
                        text1 = formatter1.HtmlSymbolsToHtmlCodes(text1);
                    }
                }
                catch
                {
                }
            }
            if (this.StripAllScripting)
            {
                text1 = formatter1.RemoveScriptTags(text1);
            }
            if (this.FormatHtmlTagsToXhtml && this.license.IsPro)
            {
                text1 = formatter1.HtmlToXhtml(text1);
                if (this.StripAllScripting)
                {
                    text1 = formatter1.RemoveJavaScriptEventsFromTags(text1);
                }
            }
            box1.Text = text1;
        }

        public static bool IsRichCapable(HttpContext context)
        {
            BrowserInfo info1 = BrowserInfo.GetBrowserInfo();
            return info1.IsRichCapable;
        }

        public bool LoadPostData(string postDataKey, NameValueCollection values)
        {
            string text1 = this.Text;
            string text2 = values[this.ClientID];
            if (!text1.Equals(text2))
            {
                this.Text = text2;
                this.viewStateText = text2;
                return true;
            }
            return false;
        }

        [Category("Toolbar")]
        protected override void LoadViewState(object savedState)
        {
            HttpContext.Current.Trace.Write("FreeTextBox", "Loading ViewState");
            object[] objArray1 = null;
            if (savedState != null)
            {
                objArray1 = (object[]) savedState;
                base.LoadViewState(objArray1[0]);
                if (objArray1[1] != null)
                {
                    ((IStateManager) this.Toolbars).LoadViewState(objArray1[1]);
                }
                if (objArray1[2] != null)
                {
                    ((IStateManager) this.ButtonStyle).LoadViewState(objArray1[2]);
                }
                if (objArray1[3] != null)
                {
                    ((IStateManager) this.ButtonStyleActive).LoadViewState(objArray1[3]);
                }
            }
        }

        protected override void OnInit(EventArgs e)
        {
            if (!this.DesignMode)
            {
                this.browserInfo = BrowserInfo.GetBrowserInfo();
                if (((this.browserInfo != null) && this.browserInfo.IsRichCapable) && (this.AutoGenerateToolbarsFromString && !this.ToolbarsCreated))
                {
                    ToolbarCollection collection1 = ToolbarGenerator.ToolbarsFromString(this.ToolbarLayout);
                    for (int num1 = collection1.Count - 1; num1 > -1; num1--)
                    {
                        this.Toolbars.Insert(0, collection1[num1]);
                    }
                    this.ToolbarsCreated = true;
                }
            }
            base.OnInit(e);
        }

        protected override void OnLoad(EventArgs e)

⌨️ 快捷键说明

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