void OnSplitView(object sender, ExecutedRoutedEventArgs e) { if (secondaryTextEditor == null) { // create secondary editor this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star), MinHeight = minRowHeight }); secondaryTextEditor = CreateTextEditor(); secondaryTextEditorAdapter = (CodeEditorAdapter)secondaryTextEditor.TextArea.GetService(typeof(ITextEditor)); Debug.Assert(primaryTextEditorAdapter != null); secondaryTextEditor.SetBinding(TextEditor.DocumentProperty, new Binding(TextEditor.DocumentProperty.Name) { Source = primaryTextEditor }); secondaryTextEditor.SetBinding(TextEditor.IsReadOnlyProperty, new Binding(TextEditor.IsReadOnlyProperty.Name) { Source = primaryTextEditor }); secondaryTextEditor.SyntaxHighlighting = primaryTextEditor.SyntaxHighlighting; secondaryTextEditor.UpdateCustomizedHighlighting(); gridSplitter = new GridSplitter { Height = 4, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top }; SetRow(gridSplitter, 2); this.Children.Add(gridSplitter); secondaryTextEditor.Margin = new Thickness(0, 4, 0, 0); SetRow(secondaryTextEditor, 2); this.Children.Add(secondaryTextEditor); secondaryTextEditorAdapter.FileNameChanged(); FetchParseInformation(); } else { // remove secondary editor this.Children.Remove(secondaryTextEditor); this.Children.Remove(gridSplitter); secondaryTextEditorAdapter.Language.Detach(); DisposeTextEditor(secondaryTextEditor); secondaryTextEditor = null; secondaryTextEditorAdapter = null; gridSplitter = null; this.RowDefinitions.RemoveAt(this.RowDefinitions.Count - 1); this.ActiveTextEditor = primaryTextEditor; } }
public CodeEditor() { CodeEditorOptions.Instance.PropertyChanged += CodeEditorOptions_Instance_PropertyChanged; CustomizedHighlightingColor.ActiveColorsChanged += CustomizedHighlightingColor_ActiveColorsChanged; ParserService.ParseInformationUpdated += ParserServiceParseInformationUpdated; this.FlowDirection = FlowDirection.LeftToRight; // code editing is always left-to-right this.CommandBindings.Add(new CommandBinding(SharpDevelopRoutedCommands.SplitView, OnSplitView)); textMarkerService = new TextMarkerService(this); iconBarManager = new IconBarManager(); changeWatcher = new DefaultChangeWatcher(); primaryTextEditor = CreateTextEditor(); primaryTextEditorAdapter = (CodeEditorAdapter)primaryTextEditor.TextArea.GetService(typeof(ITextEditor)); Debug.Assert(primaryTextEditorAdapter != null); activeTextEditor = primaryTextEditor; this.Document = primaryTextEditor.Document; primaryTextEditor.SetBinding(TextEditor.DocumentProperty, new Binding("Document") { Source = this }); this.ColumnDefinitions.Add(new ColumnDefinition()); this.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star), MinHeight = minRowHeight }); SetRow(primaryTextEditor, 1); this.Children.Add(primaryTextEditor); }
void OnSplitView(object sender, ExecutedRoutedEventArgs e) { if (secondaryTextEditor == null) { // create secondary editor this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star), MinHeight = minRowHeight }); secondaryTextEditor = CreateTextEditor(); secondaryTextEditorAdapter = (CodeEditorAdapter)secondaryTextEditor.TextArea.GetService(typeof(ITextEditor)); Debug.Assert(primaryTextEditorAdapter != null); secondaryTextEditor.SetBinding(TextEditor.DocumentProperty, new Binding(TextEditor.DocumentProperty.Name) { Source = primaryTextEditor }); secondaryTextEditor.SetBinding(TextEditor.IsReadOnlyProperty, new Binding(TextEditor.IsReadOnlyProperty.Name) { Source = primaryTextEditor }); secondaryTextEditor.SyntaxHighlighting = primaryTextEditor.SyntaxHighlighting; gridSplitter = new GridSplitter { Height = 4, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top }; SetRow(gridSplitter, 2); this.Children.Add(gridSplitter); secondaryTextEditor.Margin = new Thickness(0, 4, 0, 0); SetRow(secondaryTextEditor, 2); this.Children.Add(secondaryTextEditor); secondaryTextEditorAdapter.FileNameChanged(); FetchParseInformation(); } else { // remove secondary editor this.Children.Remove(secondaryTextEditor); this.Children.Remove(gridSplitter); secondaryTextEditorAdapter.Language.Detach(); DisposeTextEditor(secondaryTextEditor); secondaryTextEditor = null; secondaryTextEditorAdapter = null; gridSplitter = null; this.RowDefinitions.RemoveAt(this.RowDefinitions.Count - 1); this.ActiveTextEditor = primaryTextEditor; } }