public static DialogResult ShowDialog(IWin32Window owner, StylesContainer sc, Group[] groups) { CodeEditorSettings ces = new CodeEditorSettings { stylesContainer = sc, groupControls = new GroupControl[groups.Length] }; Color c; int s; for (int i = 0; i < groups.Length; i++) { s = groups[i].Style; c = Color.FromArgb(sc.ForeColorRed[s], sc.ForeColorGreen[s], sc.ForeColorBlue[s]); ces.groupControls[i] = new GroupControl(groups[i], c) { Dock = DockStyle.Top, Parent = ces.panelGroup }; ces.groupControls[i].BringToFront(); } return(ces.ShowDialog(owner)); }
public static StylesContainer Deserialize(string path) { XmlSerializer serializer = new XmlSerializer( typeof(StylesContainer)); FileStream fs = new FileStream(path, FileMode.Open); StylesContainer obj = (StylesContainer)serializer.Deserialize(fs); fs.Close(); return(obj); }
public TextEditor() { InitializeComponent(); undoRedoList = new UndoRedoDynamicArray <UndoRedoStruct>(20, 20); CaretForeColor = Color.White; try { StylesContainer = StylesContainer.Deserialize(@"Settings/ScriptnesStyles.set"); StylesContainer.MarginBackColorRed = 96; StylesContainer.MarginBackColorGreen = 96; StylesContainer.MarginBackColorBlue = 112; Styles[Style.Default].Font = StylesContainer.Font; Styles[Style.Default].ForeColor = Color.FromArgb(StylesContainer.ForeColorRed[0], StylesContainer.ForeColorGreen[0], StylesContainer.ForeColorBlue[0]); Styles[Style.Default].Bold = StylesContainer.Bold; Styles[Style.Default].BackColor = Color.FromArgb(StylesContainer.BackColorRed, StylesContainer.BackColorGreen, StylesContainer.BackColorBlue); Styles[Style.Default].Size = StylesContainer.Size; StyleClearAll(); for (int i = 0; i < 256; i++) { Styles[i].ForeColor = Color.FromArgb(StylesContainer.ForeColorRed[i], StylesContainer.ForeColorGreen[i], StylesContainer.ForeColorBlue[i]); Styles[i].BackColor = Color.FromArgb(StylesContainer.BackColorRed, StylesContainer.BackColorGreen, StylesContainer.BackColorBlue); } Styles[255].BackColor = Color.FromArgb(StylesContainer.MarginBackColorRed, StylesContainer.MarginBackColorGreen, StylesContainer.MarginBackColorBlue); StylesContainer.Serialize(@"Settings/ScriptnesStyles.set"); code = new Code(@"CSVs\Syntax\args.csv", @"CSVs\Syntax\commands.csv", @"CSVs\Syntax\groups.csv"); code.ImportDefines(); } catch (Exception) { } autocom = new AutocompleteMenu { SearchPattern = @"\!", TargetControlWrapper = new ScintillaWrapper(this), AutoPopup = true, LeftPadding = 0, }; CanUndoRedo = true; BeforeInsert += beforeInsert; Insert += insert; BeforeDelete += beforeDelete; Delete += delete; CharAdded += charAdded; autocom.Selected += selected; ClearCmdKey(Keys.Control | Keys.Z); ClearCmdKey(Keys.Control | Keys.Y); ClearCmdKey(Keys.Control | Keys.Q); ClearCmdKey(Keys.Control | Keys.W); ClearCmdKey(Keys.Control | Keys.E); ClearCmdKey(Keys.Control | Keys.R); ClearCmdKey(Keys.Control | Keys.T); ClearCmdKey(Keys.Control | Keys.Y); ClearCmdKey(Keys.Control | Keys.U); ClearCmdKey(Keys.Control | Keys.I); ClearCmdKey(Keys.Control | Keys.O); ClearCmdKey(Keys.Control | Keys.P); ClearCmdKey(Keys.Control | Keys.A); ClearCmdKey(Keys.Control | Keys.S); ClearCmdKey(Keys.Control | Keys.D); ClearCmdKey(Keys.Control | Keys.F); ClearCmdKey(Keys.Control | Keys.G); ClearCmdKey(Keys.Control | Keys.H); ClearCmdKey(Keys.Control | Keys.J); ClearCmdKey(Keys.Control | Keys.K); ClearCmdKey(Keys.Control | Keys.B); ClearCmdKey(Keys.Control | Keys.N); Margin margin = Margins[bookmarkMargin]; margin.Width = 16; margin.Sensitive = true; margin.Type = MarginType.Symbol; margin.Mask = Marker.MaskAll; margin.Cursor = MarginCursor.Arrow; Margins[0].Type = MarginType.RightText; Margins[0].Width = 35; /*StylesContainer sc = new StylesContainer * { * Font = font, * Size = size, * BackColorRed = backColor.R, * BackColorGreen = backColor.G, * BackColorBlue = backColor.B, * Bold = bold * }; * * * sc.ForeColorRed = new int[256]; * sc.ForeColorGreen = new int[256]; * sc.ForeColorBlue = new int[256]; * for (int r = 0; r < 256; r++) * { * sc.ForeColorRed[r] = Styles[r].ForeColor.R; * sc.ForeColorGreen[r] = Styles[r].ForeColor.G; * sc.ForeColorBlue[r] = Styles[r].ForeColor.B; * } * sc.Serialize(@"Settings/ScriptnesStyles.set");*/ Marker marker = Markers[bookmarkMarker]; marker.Symbol = MarkerSymbol.SmallRect; marker.SetBackColor(Color.FromArgb(105, 75, 224)); marker.SetForeColor(Color.FromArgb(70, 50, 150)); TextChanged += textChanged; }