public void CreateEditor() { this.editor = new ICSharpCode.AvalonEdit.TextEditor(); using (System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Program.BasePath + "config/squirrel.xshd")) { try { this.editor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance); } catch (System.IO.FileNotFoundException) { this.WriteToConsole("Could not read syntax highlighter definitions file."); } } editor.TextChanged += delegate(object s, System.EventArgs args) { this.EditorTextChanged(); }; editor.TextArea.TextEntered += delegate(object s, System.Windows.Input.TextCompositionEventArgs args) { this.EditorTextChanged(); }; this.RegisterCompletionEvents(); this.editor.FontFamily = new System.Windows.Media.FontFamily("Consolas, Courier New"); this.editor.WordWrap = false; this.editor.ShowLineNumbers = true; this.editor.FontSize = 13; // code folding foldingManager = ICSharpCode.AvalonEdit.Folding.FoldingManager.Install(editor.TextArea); foldingStrategy = new AvalonEdit.Sample.BraceFoldingStrategy(); this.foldingStrategy.UpdateFoldings(this.foldingManager, this.editor.Document); this.editorHost.Child = this.editor; }
public DisplayTextEditorView(Presenter Presenter) { InitializeComponent(); this.Presenter = Presenter; DataContext = Presenter; TextEditorBody.WordWrap = false; TextEditorBody.ShowLineNumbers = true; TextEditorBody.FontFamily = new FontFamily("Consolas"); TextEditorBody.FontSize = 12; TextEditorBody.LineNumbersForeground = Brushes.DarkGray; ExtentionAvalonEdit.AvalonEditContextMenu(TextEditorBody); if (!string.IsNullOrWhiteSpace(Presenter.TextEditorViewModel.Text)) { if (Presenter.TextEditorViewModel.FormatType == AvalonEditSyntaxTypes.Xml) { TextEditorBody.SetSyntaxType(AvalonEditSyntaxTypes.Xml); //AvalonEdit Folding FoldingManager = ICSharpCode.AvalonEdit.Folding.FoldingManager.Install(TextEditorBody.TextArea); FoldingStrategy = new ICSharpCode.AvalonEdit.Folding.XmlFoldingStrategy(); FoldingStrategy = new ICSharpCode.AvalonEdit.Folding.XmlFoldingStrategy(); TextEditorBody.Text = MyHRMobile.Common.Utility.XmlTool.BeautifyXML(Presenter.TextEditorViewModel.Text); FoldingStrategy.UpdateFoldings(FoldingManager, TextEditorBody.Document); } else if (Presenter.TextEditorViewModel.FormatType == AvalonEditSyntaxTypes.Json) { TextEditorBody.SetSyntaxType(AvalonEditSyntaxTypes.Json); TextEditorBody.Text = Presenter.TextEditorViewModel.Text; } else { TextEditorBody.SetSyntaxType(AvalonEditSyntaxTypes.None); TextEditorBody.Text = Presenter.TextEditorViewModel.Text; } } }
public void CreateEditor(){ this.editor = new ICSharpCode.AvalonEdit.TextEditor(); using (System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Program.BasePath + "config/squirrel.xshd")) { try { this.editor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance); } catch (System.IO.FileNotFoundException) { this.WriteToConsole("Could not read syntax highlighter definitions file."); } } editor.TextChanged += delegate(object s, System.EventArgs args) { this.EditorTextChanged(); }; editor.TextArea.TextEntered += delegate(object s, System.Windows.Input.TextCompositionEventArgs args) { this.EditorTextChanged(); }; this.RegisterCompletionEvents(); this.editor.FontFamily = new System.Windows.Media.FontFamily("Consolas, Courier New"); this.editor.WordWrap = false; this.editor.ShowLineNumbers = true; this.editor.FontSize = 13; // code folding foldingManager = ICSharpCode.AvalonEdit.Folding.FoldingManager.Install(editor.TextArea); foldingStrategy = new AvalonEdit.Sample.BraceFoldingStrategy(); this.foldingStrategy.UpdateFoldings(this.foldingManager, this.editor.Document); this.editorHost.Child = this.editor; }
//........................................................... public XmlViewer() : base() { SyntaxHighlighting = s_highlighter; m_folding_manager = avalon.Folding.FoldingManager.Install(TextArea); }