private string RendexComboboxItems(List <BBCodeComboBoxItem> items) { StringBuilder sb = new StringBuilder(); sb.Append("<div style='float:left;'>"); sb.Append("<select class=\"" + (String.IsNullOrEmpty(this.ComboboxCSSClass) ? "bbcodearea_comboBox" : this.ComboboxCSSClass) + "\" style=\"width:100px; margin-left:5px; height:20px\" onchange=\"" + _bbCodeEditorVarName + ".InsTagSel(this.options[selectedIndex].value);this.selectedIndex=0;\">"); items.ForEach(b => { BBCodeButton _b = (BBCodeButton)b; ExecJavascriptAction(ref _b); }); BBCodeComboBoxItem firstItem = items.Find(b => b.IsTitle); if (firstItem != null) { sb.Append("<option " + (String.IsNullOrEmpty(firstItem.Style) ? "" : "style=\"" + firstItem.Style + "\"") + " value=\"" + firstItem.BBCodeTagName + "\">" + HttpUtility.HtmlEncode(firstItem.Name) + "</option>"); } foreach (var item in items) { if (item.IsTitle) { continue; } sb.Append("<option " + (String.IsNullOrEmpty(item.Style) ? "" : "style=\"" + item.Style + "\"") + " value=\"" + item.BBCodeTagName + "\">" + HttpUtility.HtmlEncode(item.Name) + "</option>"); } sb.Append("</select>"); sb.Append("</div>"); return(sb.ToString()); }
protected override void RenderContents(HtmlTextWriter writer) { StringBuilder sb = new StringBuilder(); sb.Append("<div>"); sb.Append("<div class='bbcodearea_clearFix " + (String.IsNullOrEmpty(this.ButtonPanelCSSClass) ? "bbcodearea_buttonPanel" : this.ButtonPanelCSSClass) + "' " + (String.IsNullOrEmpty(ButtonPanelStyle) ? "" : "style=\"" + ButtonPanelStyle + "\"") + ">"); this.BBCodeCustomButtons.ForEach(b => { BBCodeButton _b = (BBCodeButton)b; ExecJavascriptAction(ref _b); }); foreach (var bbcodeButton in BBCodeCustomButtons) { if (!bbcodeButton.Disabled) { sb.Append("<a title=\"" + HttpUtility.HtmlEncode(bbcodeButton.AltText) + "\" href=\"" + bbcodeButton.JavascriptAction + "\" class='" + (String.IsNullOrEmpty(this.CustomButtonlCSSClass)?"bbcodearea_customButton":this.CustomButtonlCSSClass) + "' style=\"float:left;\"><img alt=\"" + bbcodeButton.AltText + "\" src=\"" + bbcodeButton.ImageFileName + "\" border=\"0\" hspace=\"2\"/></a>"); } } if (this.IsRenderSmiles && this.Smiles != null && this.Smiles.Count > 0) { sb.Append(RenderSmiles()); } if (IsRenderTextSize) { sb.Append(RendexComboboxItems(this.BBCodeTextSizeItems)); } if (IsRenderTextColor) { sb.Append(RendexComboboxItems(this.BBCodeTextColorItems)); } if (IsRenderCodeHighlighter) { sb.Append(RendexComboboxItems(this.BBCodeHighlightItems)); } sb.Append("</div>"); sb.Append("<textarea " + (TextareaAdditionalParams ?? "") + " id=\"" + TextareaID + "\" name=\"" + TextareaName + "\" style=\"width:100%; " + (TextareaStyle ?? "") + "\""); sb.Append((String.IsNullOrEmpty(TextareaCSSClass) ? "" : " class=\"" + TextareaCSSClass + "\"") + ">"); sb.Append(HttpUtility.HtmlEncode(Text) + "</textarea>"); sb.Append("</div>"); writer.Write(sb.ToString()); }
private string RenderSmiles() { StringBuilder sb = new StringBuilder(); int i = 0; Guid smileBoxID = Guid.NewGuid(); sb.Append("<a id='sm_button_" + smileBoxID + "' title=\"\" class='" + (String.IsNullOrEmpty(this.CustomButtonlCSSClass) ? "bbcodearea_customButton" : this.CustomButtonlCSSClass) + "' href=\"javascript:" + _bbCodeEditorVarName + ".ShowSmileBox('" + smileBoxID + "');\" style=\"float:left;\"><img alt=\":)\" src=\"" + this.SmileImage + "\" border=\"0\" hspace=\"2\"/></a>"); sb.Append("<div id='sm_box_" + smileBoxID + "' class=\"" + (String.IsNullOrEmpty(this.SmileboxCSSClass) ? "bbcodearea_smileBox" : this.SmileboxCSSClass) + "\" style='display:none; width:260px; position:absolute;'>"); foreach (var sm in this.Smiles) { var button = new BBCodeButton() { TagType = BBCodeTagType.Smile, BBCodeTagName = sm.JavascriptValue }; this.ExecJavascriptAction(ref button); if (i == 0) { sb.Append("<div class=\"bbcodearea_clearFix\">"); } sb.Append("<div align=center style='width:50px; height:35px; float:left;'>"); sb.Append("<a onclick=\"" + _bbCodeEditorVarName + ".HideSmileBox('" + smileBoxID + "');\" href=\"" + button.JavascriptAction + "\"><img alt=\"" + sm.Value + "\" title=\"" + sm.Title + "\" border=0 src=\"" + sm.Img + "\"/></a>"); sb.Append("</div>"); i++; if (i == 5) { sb.Append("</div>"); i = 0; } } if (i != 0) { sb.Append("</div>"); } sb.Append("</div>"); return(sb.ToString()); }
public void ExecJavascriptAction(ref BBCodeButton button) { string func = ""; switch (button.TagType) { case BBCodeTagType.Normal: func = "InsTagSel"; break; case BBCodeTagType.NormalWithEqual: func = "InsTagArgW"; break; case BBCodeTagType.NormalWithEqualAndQuote: func = "InsTagArgQuote"; break; case BBCodeTagType.Smile: func = "InsSmile"; break; } button.JavascriptAction = "javascript:" + _bbCodeEditorVarName + "." + func + "('" + button.BBCodeTagName + "');"; }