📄 toolbargenerator.cs
字号:
namespace FreeTextBoxControls
{
using FreeTextBoxControls.Support;
using System;
using System.Collections.Generic;
public class ToolbarGenerator
{
static ToolbarGenerator()
{
ToolbarGenerator.DefaultConfigString = "ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImage,InsertRule|Cut,Copy,Paste;Undo,Redo,Print";
ToolbarGenerator.DefaultPlusTablesConfigString = "ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImage,InsertRule|Cut,Copy,Paste;Undo,Redo,Print;InsertTable,InsertTableRowBelow,InsertTableRowAbove,DeleteTableRow,InsertTableColumnBelow,InsertTableColumnAbove,DeleteTableColumn";
ToolbarGenerator.EnableAllConfigString = "ParagraphMenu, FontFacesMenu, FontSizesMenu, FontForeColorsMenu, FontForeColorPicker, FontBackColorsMenu, FontBackColorPicker, Bold, Italic, Underline, Strikethrough, Superscript, Subscript, CreateLink, Unlink, RemoveFormat, JustifyLeft, JustifyRight, JustifyCenter, JustifyFull, BulletedList, NumberedList, Indent, Outdent, Cut, Copy, Paste, Delete, Undo, Redo, Print, Save, SymbolsMenu, StylesMenu, InsertHtmlMenu, InsertRule, InsertDate, InsertTime, ieSpellCheck, NetSpell, WordClean, InsertImageFromGallery, InsertTable, InsertTableRowBelow, InsertTableRowAbove, DeleteTableRow, InsertTableColumnBelow, InsertTableColumnAbove, DeleteTableColumn, InsertForm, InsertForm,InsertTextBox,InsertTextArea,InsertRadioButton,InsertCheckBox,InsertDropDownList,InsertButton, InsertImageFromGallery, InsertDiv";
ToolbarGenerator.MinimalConfigString = "Bold,Italic,Underline";
}
public static ToolbarItem ToolbarItemFromString(string StringName)
{
string text1 = StringName.ToLower();
if (text1 != null)
{
int num1;
if (<PrivateImplementationDetails>{621EEA27-812F-4C37-8F4B-11BD0CF27F8F}.$$method0x6000203-1 == null)
{
Dictionary<string, int> dictionary1 = new Dictionary<string, int>(0x40);
dictionary1.Add("save", 0);
dictionary1.Add("bold", 1);
dictionary1.Add("italic", 2);
dictionary1.Add("underline", 3);
dictionary1.Add("strikethrough", 4);
dictionary1.Add("superscript", 5);
dictionary1.Add("subscript", 6);
dictionary1.Add("removeformat", 7);
dictionary1.Add("justifyleft", 8);
dictionary1.Add("justifycenter", 9);
dictionary1.Add("justifyright", 10);
dictionary1.Add("justifyfull", 11);
dictionary1.Add("bulletedlist", 12);
dictionary1.Add("numberedlist", 13);
dictionary1.Add("indent", 14);
dictionary1.Add("outdent", 15);
dictionary1.Add("cut", 0x10);
dictionary1.Add("copy", 0x11);
dictionary1.Add("paste", 0x12);
dictionary1.Add("delete", 0x13);
dictionary1.Add("undo", 20);
dictionary1.Add("redo", 0x15);
dictionary1.Add("print", 0x16);
dictionary1.Add("createlink", 0x17);
dictionary1.Add("unlink", 0x18);
dictionary1.Add("insertimagefromgallery", 0x19);
dictionary1.Add("insertimage", 0x1a);
dictionary1.Add("insertrule", 0x1b);
dictionary1.Add("insertdate", 0x1c);
dictionary1.Add("inserttime", 0x1d);
dictionary1.Add("fontfacesmenu", 30);
dictionary1.Add("fontsizesmenu", 0x1f);
dictionary1.Add("fontforecolorsmenu", 0x20);
dictionary1.Add("fontbackcolorsmenu", 0x21);
dictionary1.Add("stylesmenu", 0x22);
dictionary1.Add("inserthtmlmenu", 0x23);
dictionary1.Add("symbolsmenu", 0x24);
dictionary1.Add("paragraphmenu", 0x25);
dictionary1.Add("wordclean", 0x26);
dictionary1.Add("netspell", 0x27);
dictionary1.Add("iespellcheck", 40);
dictionary1.Add("inserttable", 0x29);
dictionary1.Add("edittable", 0x2a);
dictionary1.Add("deletetablerow", 0x2b);
dictionary1.Add("deletetablecolumn", 0x2c);
dictionary1.Add("inserttablerow", 0x2d);
dictionary1.Add("inserttablerowafter", 0x2e);
dictionary1.Add("inserttablerowbefore", 0x2f);
dictionary1.Add("inserttablecolumn", 0x30);
dictionary1.Add("inserttablecolumnafter", 0x31);
dictionary1.Add("inserttablecolumnbefore", 50);
dictionary1.Add("insertform", 0x33);
dictionary1.Add("insertbutton", 0x34);
dictionary1.Add("insertradiobutton", 0x35);
dictionary1.Add("insertdropdownlist", 0x36);
dictionary1.Add("insertcheckbox", 0x37);
dictionary1.Add("inserttextarea", 0x38);
dictionary1.Add("inserttextbox", 0x39);
dictionary1.Add("preview", 0x3a);
dictionary1.Add("selectall", 0x3b);
dictionary1.Add("fontforecolorpicker", 60);
dictionary1.Add("fontbackcolorpicker", 0x3d);
dictionary1.Add("editstyle", 0x3e);
dictionary1.Add("insertdiv", 0x3f);
<PrivateImplementationDetails>{621EEA27-812F-4C37-8F4B-11BD0CF27F8F}.$$method0x6000203-1 = dictionary1;
}
if (<PrivateImplementationDetails>{621EEA27-812F-4C37-8F4B-11BD0CF27F8F}.$$method0x6000203-1.TryGetValue(text1, out num1))
{
switch (num1)
{
case 0:
return new Save();
case 1:
return new Bold();
case 2:
return new Italic();
case 3:
return new Underline();
case 4:
return new StrikeThrough();
case 5:
return new SuperScript();
case 6:
return new SubScript();
case 7:
return new RemoveFormat();
case 8:
return new JustifyLeft();
case 9:
return new JustifyCenter();
case 10:
return new JustifyRight();
case 11:
return new JustifyFull();
case 12:
return new BulletedList();
case 13:
return new NumberedList();
case 14:
return new Indent();
case 15:
return new Outdent();
case 0x10:
return new Cut();
case 0x11:
return new Copy();
case 0x12:
return new Paste();
case 0x13:
return new Delete();
case 20:
return new Undo();
case 0x15:
return new Redo();
case 0x16:
return new Print();
case 0x17:
return new CreateLink();
case 0x18:
return new Unlink();
case 0x19:
return new InsertImageFromGallery();
case 0x1a:
return new InsertImage();
case 0x1b:
return new InsertRule();
case 0x1c:
return new InsertDate();
case 0x1d:
return new InsertTime();
case 30:
return new FontFacesMenu();
case 0x1f:
return new FontSizesMenu();
case 0x20:
return new FontForeColorsMenu();
case 0x21:
return new FontBackColorsMenu();
case 0x22:
return new StylesMenu();
case 0x23:
return new InsertHtmlMenu();
case 0x24:
return new SymbolsMenu();
case 0x25:
return new ParagraphMenu();
case 0x26:
return new WordClean();
case 0x27:
return new NetSpell();
case 40:
return new IeSpellCheck();
case 0x29:
return new InsertTable();
case 0x2a:
return new EditTable();
case 0x2b:
return new DeleteTableRow();
case 0x2c:
return new DeleteTableColumn();
case 0x2d:
case 0x2e:
return new InsertTableRowAfter();
case 0x2f:
return new InsertTableRowBefore();
case 0x30:
case 0x31:
return new InsertTableColumnAfter();
case 50:
return new InsertTableColumnBefore();
case 0x33:
return new InsertForm();
case 0x34:
return new InsertButton();
case 0x35:
return new InsertRadioButton();
case 0x36:
return new InsertDropDownList();
case 0x37:
return new InsertCheckBox();
case 0x38:
return new InsertTextArea();
case 0x39:
return new InsertTextBox();
case 0x3a:
return new Preview();
case 0x3b:
return new SelectAll();
case 60:
return new FontForeColorPicker();
case 0x3d:
return new FontBackColorPicker();
case 0x3e:
return new EditStyle();
case 0x3f:
return new InsertDiv();
}
}
}
return new ToolbarSeparator();
}
public static ToolbarCollection ToolbarsFromString(string toolbarLayout)
{
ToolbarCollection collection1 = new ToolbarCollection();
try
{
string[] textArray1 = toolbarLayout.Replace(" ", "").Replace(";", ",;,").Replace(",,", ",").ToLower().Split(new char[] { '|' });
for (int num1 = 0; num1 < textArray1.Length; num1++)
{
Toolbar toolbar1 = new Toolbar();
string[] textArray2 = textArray1[num1].Split(new char[] { ',' });
for (int num2 = 0; num2 < textArray2.Length; num2++)
{
toolbar1.Items.Add(ToolbarGenerator.ToolbarItemFromString(textArray2[num2]));
}
collection1.Add(toolbar1);
}
}
catch (Exception exception1)
{
throw new Exception("Invalid ToolbarLayout -> " + exception1.ToString());
}
return collection1;
}
public static ToolbarCollection Default
{
get
{
return ToolbarGenerator.ToolbarsFromString(ToolbarGenerator.DefaultConfigString);
}
}
public static ToolbarCollection DefaultPlusTables
{
get
{
return ToolbarGenerator.ToolbarsFromString(ToolbarGenerator.DefaultPlusTablesConfigString);
}
}
public static ToolbarCollection EnableAll
{
get
{
return ToolbarGenerator.ToolbarsFromString(ToolbarGenerator.EnableAllConfigString);
}
}
public static ToolbarCollection Minimal
{
get
{
return ToolbarGenerator.ToolbarsFromString(ToolbarGenerator.MinimalConfigString);
}
}
public static string DefaultConfigString;
public static string DefaultPlusTablesConfigString;
public static string EnableAllConfigString;
public static string MinimalConfigString;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -