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

📄 freetextbox.cs

📁 Freetextbox是优秀的在线编辑器
💻 CS
📖 第 1 页 / 共 5 页
字号:
                                        text6 = text6 + ")";
                                        list2.Add(text6);
                                    }
                                    else if (item1 is ToolbarDropDownList)
                                    {
                                        ToolbarDropDownList list4 = (ToolbarDropDownList) item1;
                                        string text7 = "new FTB_DropDownList('" + this.CreateUniqueToolbarItemID(toolbar1, item1) + "','" + list4.CommandIdentifier + "'";
                                        if (list4.BuiltInScript != string.Empty)
                                        {
                                            text7 = text7 + ",function() { " + list4.BuiltInScript.Replace("\r", "").Replace("\n", "").Replace("\t", "") + " }";
                                        }
                                        else if (list4.ScriptBlock != string.Empty)
                                        {
                                            text7 = text7 + ",function() { " + list4.ScriptBlock.Replace("\r", "").Replace("\n", "").Replace("\t", "") + " }";
                                        }
                                        else
                                        {
                                            text7 = text7 + ",null";
                                        }
                                        if (list4.BuiltInStateScript != string.Empty)
                                        {
                                            text7 = text7 + ",function() { " + list4.BuiltInStateScript.Replace("\r", "").Replace("\n", "").Replace("\t", "") + " }";
                                        }
                                        else if (list4.StateScriptBlock != string.Empty)
                                        {
                                            text7 = text7 + ",function() { " + list4.StateScriptBlock.Replace("\r", "").Replace("\n", "").Replace("\t", "") + " }";
                                        }
                                        else
                                        {
                                            text7 = text7 + ",null";
                                        }
                                        if (list4.BuiltInEnabledScript != string.Empty)
                                        {
                                            text7 = text7 + ",function() { " + list4.BuiltInEnabledScript.Replace("\r", "").Replace("\n", "").Replace("\t", "") + " }";
                                        }
                                        else if (list4.EnabledScriptBlock != string.Empty)
                                        {
                                            text7 = text7 + ",function() { " + list4.EnabledScriptBlock.Replace("\r", "").Replace("\n", "").Replace("\t", "") + " }";
                                        }
                                        else
                                        {
                                            text7 = text7 + ",null";
                                        }
                                        text7 = text7 + ")";
                                        list3.Add(text7);
                                    }
                                }
                            }
                        }
                    }
                    string text8 = string.Concat(new object[] { 
                        "<script language=\"JavaScript\">\r\nif (window.FTB_AddEvent) { \r\n\tFTB_AddEvent(window,'load',function () {\r\n        FTB_API['", this.ClientID, "'] = new FTB_FreeTextBox('", this.ClientID, "',\r\n\t\t\t\t\t", this.EnableToolbars.ToString().ToLower(), ",\r\n\t\t\t\t\t", this.ReadOnly.ToString().ToLower(), ",\r\n\t\t\t\t\t", this.EnableToolbars ? ("new Array(\r\n\t\t\t\t\t\t" + string.Join(",\n\t\t\t", (string[]) list2.ToArray(typeof(string))) + "\r\n\t\t\t\t\t)") : "null", ",\r\n\t\t\t\t\t", this.EnableToolbars ? ("new Array(\r\n\t\t\t\t\t\t" + string.Join(",\n\t\t\t", (string[]) list3.ToArray(typeof(string))) + "\r\n\t\t\t\t\t)") : "null", ",\t\t\t\t\r\n\t\t\t\t\t", (this.BreakMode == FreeTextBoxControls.BreakMode.Paragraph) ? "FTB_BREAK_P" : "FTB_BREAK_BR", ",\r\n\t\t\t\t\tFTB_PASTE_", this.PasteMode.ToString().ToUpper(), 
                        ",\r\n\t\t\t\t\tFTB_TAB_", this.TabMode.ToString().ToUpper(), ",\r\n\t\t\t\t\tFTB_MODE_", (this.StartMode == EditorMode.DesignMode) ? "DESIGN" : "HTML", ",\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t", (this.ClientSideTextChanged != string.Empty) ? this.ClientSideTextChanged : "null", ",\r\n\t\t\t\t\t'", this.DesignModeCss, "',\r\n\t\t\t\t\t'", this.DesignModeBodyTagCssClass, "',\r\n\t\t\t\t\t'", this.BaseUrl, "',\r\n\t\t\t\t\t'", (this.TextDirection == FreeTextBoxControls.TextDirection.RightToLeft) ? "rtl" : "", "',\r\n\t\t\t\t\t'',\r\n\t\t\t\t\t'", this.ImageGalleryUrl, 
                        "',\r\n\t\t\t\t\t'", this.ImageGalleryPath, "',\r\n\t\t\t\t\t", this.Focus.ToString().ToLower(), ",\r\n\t\t\t\t\t", this.ButtonWidth, ",\r\n\t\t\t\t\t", this.ButtonHeight, "\r\n\t\t\t\t\t"
                     });
                    text8 = text8 + "\r\n\t\t\t\t);\r\n\t\t\t});\r\n\t//FTB_API['" + this.ClientID + "'].Initialize();\r\n} else {\r\n";
                    string text9 = "FreeTextBox has not been correctly installed. To install FreeTextBox either:\\n (1) add a reference to FtbWebResource.axd in web.config:\\n<system.web>\\n<httpHandlers>\\n<add verb=\"GET\"\\npath=\"FtbWebResource.axd\"\\ntype=\"FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox\" />\\n</httpHandlers>\\n</system.web>\\n\\n(2) Save the FreeTextBox image and javascript files to a location on your website and set up FreeTextBox as follows \\n<FTB:FreeTextBox id=\"FreeTextBox1\" SupportFolder=\"ftbfileslocation\" JavaScriptLocation=\"ExternalFile\" ButtonImagesLocation=\"ExternalFile\" ToolbarImagesLocation=\"ExternalFile\" ButtonImagesLocation=\"ExternalFile\" runat=\"server\" />";
                    switch (this.InstallationErrorMessage)
                    {
                        case FreeTextBoxControls.InstallationErrorMessage.None:
                            break;

                        case FreeTextBoxControls.InstallationErrorMessage.InlineMessage:
                            text10 = text8;
                            text8 = text10 + (this.browserInfo.IsIE5plus ? ("ed = eval('" + this.ClientID + "_designEditor');") : ("ed = document.getElementById('" + this.ClientID + "_designEditor').contentWindow;")) + "ed.document.open(); ed.document.write('" + this.Page.Server.HtmlEncode(text9).Replace(@"\n", "<br>") + "');ed.document.close();";
                            break;

                        default:
                            text8 = text8 + "alert('" + text9 + "');";
                            break;
                    }
                    text8 = text8 + "\r\n}\r\n</script>";
                    this.Page.RegisterStartupScript("FreeTextBox_" + this.ClientID + "_Startup", text8);
                }
            }
        }

        protected override void Render(HtmlTextWriter writer)
        {
            if (this.browserInfo != null)
            {
                if ((this.browserInfo.IsRichCapable && (this.RenderMode != FreeTextBoxControls.RenderMode.Plain)) || (this.RenderMode == FreeTextBoxControls.RenderMode.Rich))
                {
                    this.RenderRichEditor(writer);
                }
                else
                {
                    this.RenderDownLevel(writer);
                }
            }
        }

        protected virtual void RenderButtonStyles(HtmlTextWriter writer)
        {
            writer.WriteLine("\r\n." + this.ClientID + "_Button_Off_Out {\r\n\t" + (((this.ButtonStyle.BorderColorLight == Color.Transparent) && (this.ButtonStyle.BorderColorDark == Color.Transparent)) ? "padding: 1px;" : ("\r\n\tpadding: 0px;\r\n\tborder-top: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyle.BorderColorLight) + ";\t\r\n\tborder-left: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyle.BorderColorLight) + ";\r\n\tborder-right: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyle.BorderColorDark) + ";\r\n\tborder-bottom: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyle.BorderColorDark) + "; ")) + " \r\n\tbackground-color: " + ((this.ButtonStyle.BackColor != Color.Transparent) ? ColorTranslator.ToHtml(this.ButtonStyle.BackColor) : "transparent") + ";\r\n}\r\n." + this.ClientID + "_Button_Off_Over {\r\n\t" + (((this.ButtonStyle.OverBorderColorLight == Color.Transparent) && (this.ButtonStyle.OverBorderColorDark == Color.Transparent)) ? "padding: 1px;" : ("\r\n\tpadding: 0px;\r\n\tborder-top: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyle.OverBorderColorLight) + ";\t\r\n\tborder-left: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyle.OverBorderColorLight) + ";\r\n\tborder-right: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyle.OverBorderColorDark) + ";\r\n\tborder-bottom: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyle.OverBorderColorDark) + "; ")) + " \r\n\tbackground-color: " + ((this.ButtonStyle.OverBackColor != Color.Transparent) ? ColorTranslator.ToHtml(this.ButtonStyle.OverBackColor) : "transparent") + ";\r\n\t" + ((this.ButtonStyle.UseOverBackgroundImage && (!this.browserInfo.IsMSHTML || (this.ButtonStyle.OverBackColorGradient == Color.Transparent))) ? ("background-image: url(" + this.CreateResourceString("toolbarbuttoncss.off.over", ResourceType.Toolbar) + ");") : "") + "\r\n\t" + (((this.ButtonStyle.UseOverBackgroundImage && this.browserInfo.IsMSHTML) && (this.ButtonStyle.OverBackColorGradient != Color.Transparent)) ? ("filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#FF" + ColorTranslator.ToHtml(this.ButtonStyle.OverBackColor).Replace("#", "") + "', EndColorStr='#FF" + ColorTranslator.ToHtml(this.ButtonStyle.OverBackColorGradient).Replace("#", "") + "');") : "") + "\r\n}\r\n." + this.ClientID + "_Button_On_Out {\r\n\t" + (((this.ButtonStyleActive.BorderColorLight == Color.Transparent) && (this.ButtonStyleActive.BorderColorDark == Color.Transparent)) ? "padding: 1px;" : ("\r\n\tpadding: 0px;\r\n\tborder-top: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyleActive.BorderColorLight) + ";\t\r\n\tborder-left: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyleActive.BorderColorLight) + ";\r\n\tborder-right: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyleActive.BorderColorDark) + ";\r\n\tborder-bottom: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyleActive.BorderColorDark) + "; ")) + " \r\n\tbackground-color: " + ((this.ButtonStyleActive.BackColor != Color.Transparent) ? ColorTranslator.ToHtml(this.ButtonStyleActive.BackColor) : "transparent") + ";\r\n\t" + ((this.ButtonStyleActive.UseBackgroundImage && (!this.browserInfo.IsMSHTML || (this.ButtonStyleActive.BackColorGradient == Color.Transparent))) ? ("background-image: url(" + this.CreateResourceString("toolbarbuttoncss.on.out", ResourceType.Toolbar) + ");") : "") + "\r\n\t" + (((this.ButtonStyleActive.UseBackgroundImage && this.browserInfo.IsMSHTML) && (this.ButtonStyleActive.BackColorGradient != Color.Transparent)) ? ("filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#FF" + ColorTranslator.ToHtml(this.ButtonStyleActive.BackColor).Replace("#", "") + "', EndColorStr='#FF" + ColorTranslator.ToHtml(this.ButtonStyleActive.BackColorGradient).Replace("#", "") + "');") : "") + "\r\n}\r\n." + this.ClientID + "_Button_On_Over {\r\n\t" + (((this.ButtonStyleActive.OverBorderColorLight == Color.Transparent) && (this.ButtonStyleActive.OverBorderColorDark == Color.Transparent)) ? "padding: 1px;" : ("\r\n\tpadding: 0px;\r\n\tborder-top: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyleActive.OverBorderColorLight) + ";\t\r\n\tborder-left: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyleActive.OverBorderColorLight) + ";\r\n\tborder-right: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyleActive.OverBorderColorDark) + ";\r\n\tborder-bottom: 1px solid " + ColorTranslator.ToHtml(this.ButtonStyleActive.OverBorderColorDark) + "; ")) + " \r\n\tbackground-color: " + ((this.ButtonStyleActive.OverBackColor != Color.Transparent) ? ColorTranslator.ToHtml(this.ButtonStyleActive.OverBackColor) : "transparent") + ";\r\n\t" + ((this.ButtonStyleActive.UseOverBackgroundImage && (!this.browserInfo.IsMSHTML || (this.ButtonStyleActive.BackColorGradient == Color.Transparent))) ? ("background-image: url(" + this.CreateResourceString("toolbarbuttoncss.on.over", ResourceType.Toolbar) + ");") : "") + "\r\n\t" + (((this.ButtonStyleActive.UseOverBackgroundImage && this.browserInfo.IsMSHTML) && (this.ButtonStyleActive.BackColorGradient != Color.Transparent)) ? ("filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#FF" + ColorTranslator.ToHtml(this.ButtonStyleActive.OverBackColor).Replace("#", "") + "', EndColorStr='#FF" + ColorTranslator.ToHtml(this.ButtonStyleActive.OverBackColorGradient).Replace("#", "") + "');") : "") + "\r\n}\r\n");
        }

        protected virtual void RenderDownLevel(HtmlTextWriter writer)
        {
            switch (this.DownLevelMode)
            {
                case FreeTextBoxControls.DownLevelMode.InlineHtml:
                    writer.WriteLine("<input type=\"hidden\" id=\"" + this.ClientID + "\" name=\"" + this.ClientID + "\" value=\"" + HttpContext.Current.Server.HtmlEncode(this.Text) + "\" />");
                    writer.WriteLine(this.Text);
                    return;

                case FreeTextBoxControls.DownLevelMode.Message:
                    writer.WriteLine("<input type=\"hidden\" id=\"" + this.ClientID + "\" name=\"" + this.ClientID + "\" value=\"" + HttpContext.Current.Server.HtmlEncode(this.Text) + "\" />");
                    writer.WriteLine(this.DownLevelMessage);
                    return;
            }
            writer.WriteLine("<textarea id=\"" + this.ClientID + "\" name=\"" + this.ClientID + "\"" + ((this.HtmlModeCssClass != string.Empty) ? ("class=\"" + this.HtmlModeCssClass + "\"") : "") + " cols=\"" + this.DownLevelCols.ToString() + "\" rows=\"" + this.DownLevelRows.ToString() + "\"" + (this.ReadOnly ? " readonly=\"readonly\" disabled=\"true\" onFocus=\"this.blur();\"" : "") + ">" + this.Text + "</textarea>");
        }

        protected virtual void RenderEditorStyles(HtmlTextWriter writer)
        {
            string[] textArray1 = new string[0x25];
            textArray1[0] = "\r\n.";
            textArray1[1] = this.ClientID;
            textArray1[2] = "_OuterTable {\r\n\twidth: ";
            textArray1[3] = this.Width.ToString();
            textArray1[4] = ";\r\n\tbackground-color: ";
            textArray1[5] = ColorTranslator.ToHtml(this.BackColor);
            textArray1[6] = ";\r\n}\r\n#";
            textArray1[7] = this.ClientID;
            textArray1[8] = "_toolbarArea select {\r\n\tmargin: 0px;\r\n\tpadding: 0px;\r\n\tfont: 11px Tahoma,Verdana,sans-serif;\r\n}\r\n.";
            textArray1[9] = this.ClientID;
            textArray1[10] = "_HtmlBox {\r\n\toverflow: auto;\r\n\tfont-family: Courier New, Courier;\r\n\tpadding: 4px;\r\n\tborder-right: 1px solid ";
            textArray1[11] = ColorTranslator.ToHtml(this.EditorBorderColorLight);
            textArray1[12] = ";\r\n\tborder-left: 1px solid ";
            textArray1[13] = ColorTranslator.ToHtml(this.EditorBorderColorDark);
            textArray1[14] = ";\r\n\tborder-top: 1px solid ";
            textArray1[15] = ColorTranslator.ToHtml(this.EditorBorderColorDark);
            textArray1[0x10] = ";\r\n\tborder-bottom: 1px solid ";
            textArray1[0x11] = ColorTranslator.ToHtml(this.EditorBorderColorLight);
            textArray1[0x12] = ";\r\n}\r\n.";
            textArray1[0x13] = this.ClientID;
            textArray1[20] = "_DesignBox {\r\n\t";
            textArray1[0x15] = (!this.browserInfo.IsMSHTML || (this.DesignModeCss == "")) ? "background-color: #FFFFFF;" : "";
            textArray1[0x16] = "\r\n\tborder: 0; \r\n\tborder-right: 1px solid ";
            textArray1[0x17] = ColorTranslator.ToHtml(this.EditorBorderColorLight);
            textArray1[0x18] = ";\r\n\tborder-left: 1px solid ";
            textArray1[0x19] = ColorTranslator.ToHtml(this.EditorBorderColorDark);
            textArray1[0x1a] = ";\r\n\tborder-top: 1px solid ";
            textArray1[0x1b] = ColorTranslator.ToHtml(this.EditorBorderColorDark);
            textArray1[0x1c] = ";\r\n\tborder-bottom: 1px solid ";
            textArray1[0x1d] = ColorTranslator.ToHtml(this.EditorBorderColorLight);
            textArray1[30] = ";\r\n}\r\n.";
            textArray1[0x1f] = this.ClientID;
            textArray1[0x20] = "_DesignBox body {\r\n\tbackground-color: black;\r\n}\r\n.";
            textArray1[0x21] = this.ClientID;
            textArray1[0x22] = "_Toolbar {\r\n\tmargin-bottom: 1px; \r\n\tmargin-right: 2px;\r\n\tfloat: left;\r\n\t";
            bool flag1 = this.ToolbarBackgroundImage;
            textArray1[0x23] = "";
            textArray1[0x24] = "\r\n}\r\n";
            writer.WriteLine(string.Concat(textArray1));
        }

        protected virtual void RenderRichEditor(HtmlTextWriter writer)
        {
            this.hasToolbars = (this.toolbars != null) && (this.toolbars.Count > 0);
            writer.WriteLine("<style type=\"text/css\">");
            this.RenderEditorStyles(writer);
            this.RenderButtonStyles(writer);
            this.RenderTabStyles(writer);
            writer.WriteLine("</style>");
            writer.WriteLine("<table cellpadding=\"2\" cellspacing=\"0\" class=\"" + this.ClientID + "_OuterTable\"><tr><td>");
            writer.WriteLine("<div>");
            if (this.hasToolbars && this.EnableToolbars)
            {
                writer.WriteLine("<div id=\"" + this.ClientID + "_toolbarArea\" style=\"padding-bottom:2px;clear:both;\">");
                foreach (Toolbar toolbar1 in this.Toolbars)
                {
                    toolbar1.RepeatDirection = RepeatDirection.Horizontal;
                    this.RenderToolbar(writer, toolbar1);
                }
                writer.WriteLine("</div>");
            }
            string text1 = this.Width.ToString();
            string text2 = this.Height.ToString();
            string text3 = this.Width.ToString();
            string text4 = this.Height.ToString();
            if (this.browserInfo.IsIE5plus)
            {
                if (this.Width.ToString().IndexOf("%") == -1)
                {
                    text3 = ((this.Width.Value - 2)).ToString() + "px";
                }
                if (this.Height.ToString().IndexOf("%") == -1)
                {
                    text4 = ((this.Height.Value - 1)).ToString() + "px";
                }
            }
            writer.WriteLine("\r\n\t<div id=\"" + this.ClientID + "_designEditorArea\" style=\"clear:both;padding-top:1px;\">\r\n\t    <iframe id=\"" + this.ClientID + "_designEditor\" style=\"padding: 0px; width:" + text3 + "; height: " + text4 + ";\" src=\"" + (this.EnableSsl ? this.SslUrl.ToString() : "about:blank") + "\" class=\"" + this.ClientID + "_DesignBox\"></iframe>\r\n\t</div>\r\n\t<div id=\"" + this.ClientID + "_htmlEditorArea\" style=\"clear:both;display:none;padding-bottom:1px;\">\r\n\t    <textarea id=\"" + this.ClientID + "\" name=\"" + this.ClientID + "\" disabled=\"disabled\" style=\"padding: 0px; width:" + text1 + "; height: " + text2 + ";" + ((this.TextDirection == FreeTextBoxControls.TextDirection.RightToLeft) ? "direction:rtl;" : "") + "\" class=\"" + ((this.HtmlModeCssClass == string.Empty) ? (this.ClientID + "_HtmlBox") : this.HtmlModeCssClass) + "\">" + this.Page.Server.HtmlEncode(this.Text) + "</textarea>\r\n\t</div>\r\n\t<div id=\"" + this.ClientID + "_previewPaneArea\" style=\"clear:both;display:none;padding-bottom:1px;\">\r\n\t    <iframe id=\"" + this.ClientID + "_previewPane\" style=\"padding: 0px; width:" + text3 + "; height: " + text4 + "\" src=\"" + (this.EnableSsl ? this.SslUrl.ToString() : "about:blank") + "\" class=\"" + this.ClientID + "_DesignBox\"></iframe>\r\n\t</div>\r\n");
            if (this.EnableHtmlMode)
            {
                writer.WriteLine("<div style=\"clear:both;padding-top:2px;\">");
                this.RenderTabs(writer);
                writer.WriteLine("</div>");
            }

⌨️ 快捷键说明

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