private TextEditorControl AddNewTextEditor(string title) { var tab = new TabPage(title); var editor = new TextEditorControl(); editor.Dock = System.Windows.Forms.DockStyle.Fill; editor.IsReadOnly = false; editor.SetHighlighting("TSQL"); editor.Document.DocumentChanged += new DocumentEventHandler((sender, e) => { SetModifiedFlag(editor, true); }); // When a tab page gets the focus, move the focus to the editor control // instead when it gets the Enter (focus) event. I use BeginInvoke // because changing the focus directly in the Enter handler doesn't // work. tab.Enter += new EventHandler((sender, e) => { var page = ((TabPage)sender); page.BeginInvoke(new Action <TabPage>(p => p.Controls[0].Focus()), page); }); tab.Controls.Add(editor); fileTabs.Controls.Add(tab); if (_editorSettings == null) { _editorSettings = editor.TextEditorProperties; OnSettingsChanged(); } else { editor.TextEditorProperties = _editorSettings; } return(editor); }
public LempDemoPanel(ITextEditorProperties editorSettings) { InitializeComponent(); _inEditor = new TextEditorControl(); _inEditor.Dock = System.Windows.Forms.DockStyle.Fill; _inEditor.Document.DocumentChanged += OnDocumentChanged; _outEditor = new TextEditorControl(); _outEditor.Dock = System.Windows.Forms.DockStyle.Fill; innerSplitContainer.Panel1.Controls.Add(_inEditor); innerSplitContainer.Panel2.Controls.Add(_outEditor); if ((EditorSettings = editorSettings) == null) { EditorSettings = _inEditor.TextEditorProperties; } else { _inEditor.TextEditorProperties = EditorSettings; } _outEditor.TextEditorProperties = EditorSettings; // ICSharpCode.TextEditor doesn't have any built-in code folding // strategies, so I've included a simple one. Apparently, the // foldings are not updated automatically, so in this demo the user // cannot add or remove folding regions after loading the file. Editor.Document.FoldingManager.FoldingStrategy = new RegionFoldingStrategy(); timer.Start(); // initially update foldings & run LeMP _inEditor.SetHighlighting("C#"); _outEditor.SetHighlighting("C#"); }