public CodeEditorView() { this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted)); UpdateCustomizedHighlighting(); this.bracketRenderer = new BracketHighlightRenderer(this.TextArea.TextView); this.caretReferencesRenderer = new CaretReferencesRenderer(this); this.contextActionsRenderer = new ContextActionsRenderer(this); this.MouseHover += TextEditorMouseHover; this.MouseHoverStopped += TextEditorMouseHoverStopped; this.MouseLeave += TextEditorMouseLeave; this.TextArea.TextView.MouseDown += TextViewMouseDown; this.TextArea.Caret.PositionChanged += HighlightBrackets; SetupTabSnippetHandler(); }
public CodeEditorView() { this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted)); this.bracketRenderer = new BracketHighlightRenderer(this.TextArea.TextView); this.caretReferencesRenderer = new CaretReferencesRenderer(this); this.contextActionsRenderer = new ContextActionsRenderer(this); this.hiddenDefinitionRenderer = new HiddenDefinition.HiddenDefinitionRenderer(this); UpdateCustomizedHighlighting(); this.MouseHover += TextEditorMouseHover; this.MouseHoverStopped += TextEditorMouseHoverStopped; this.MouseLeave += TextEditorMouseLeave; this.TextArea.TextView.MouseDown += TextViewMouseDown; this.TextArea.Caret.PositionChanged += HighlightBrackets; this.TextArea.TextView.VisualLinesChanged += CodeEditorView_VisualLinesChanged; SetupTabSnippetHandler(); }
/// <summary> /// Loads the file view. /// </summary> /// <param name="fileName">Name of the file.</param> /// <returns>Flag inidcating whether the file load was successful or not.</returns> private bool LoadFileView(string fileName) { var newFile = false; try { var localFileName = fileName; if (localFileName == string.Empty) { localFileName = "Unnamed"; newFile = true; } if (this.FileIsAlreadyOpen(fileName) >= 0) { return true; } else { this.currentFileName = System.IO.Path.GetFileName(localFileName); this.currentworkingDir = System.IO.Path.GetDirectoryName(localFileName); var newTabPage = new TabItem() { ToolTip = localFileName, Visibility = System.Windows.Visibility.Visible, Header = this.currentFileName }; tabCntl.Items.Add(newTabPage); tabCntl.SelectedItem = newTabPage; var newEditor = new TextEditor {}; newEditor.Options.ShowSpaces = false; newEditor.Options.ShowTabs = false; newEditor.Options.CutCopyWholeLine = true; newEditor.Options.ConvertTabsToSpaces = true; newEditor.Options.EnableHyperlinks = false; newEditor.Options.EnableEmailHyperlinks = false; newEditor.Options.EnableTextDragDrop = false; newEditor.Options.EnableRectangularSelection = true; newEditor.ShowLineNumbers = true; newEditor.Tag = false; newEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; newEditor.VerticalScrollBarVisibility = ScrollBarVisibility.Visible; this.LoadEditorConfig(newEditor); this.ApplySyntax(newEditor); if (!newFile) { using (var featureStream = new StreamReader(fileName)) { newEditor.Text = featureStream.ReadToEnd(); } this.ReformatFile(newEditor); } this.ApplyFolding(newEditor); newEditor.IsModified = false; newEditor.TextChanged += new EventHandler(this.Edit_TextChanged); newEditor.KeyUp += new KeyEventHandler(this.Edit_KeyUp); newEditor.ContextMenu = this.CreateContextMenu(); newTabPage.Content = newEditor; var cfr = new CaretReferencesRenderer(newEditor); _findReplaceManager.CurrentEditor = new TextEditorAdapter(newEditor); tabCntl.Visibility = System.Windows.Visibility.Visible; newEditor.Visibility = System.Windows.Visibility.Visible; return true; } } catch (Exception ex) { Console.WriteLine(ex); return false; } }