public void SetText(string text) { Text = text; textEditor.Text = text; if (text.Length > 200 && !text.Contains("\n")) { wordWrap.IsChecked = true; } if (solutionFileRegex.IsMatch(text)) { IsXml = false; using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("StructuredLogViewer.Avalonia.Resources.SolutionFile.xshd")) using (var reader = XmlReader.Create(stream)) { textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } return; } bool looksLikeXml = Utilities.LooksLikeXml(text); if (looksLikeXml && !IsXml) { IsXml = true; var highlighting = HighlightingManager.Instance.GetDefinition("XML"); highlighting.GetNamedColor("XmlTag").Foreground = new SimpleHighlightingBrush(Color.FromRgb(163, 21, 21)); textEditor.SyntaxHighlighting = highlighting; var foldingManager = FoldingManager.Install(textEditor.TextArea); var foldingStrategy = new XmlFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } else if (!looksLikeXml && IsXml) { IsXml = false; textEditor.SyntaxHighlighting = null; } }
public void SetDocumentEditor(TextEditorBase TE) { mTextEditor = TE; IHighlightingDefinition HD = TE.HighlightingDefinition; if (HD != null) { textEditor.SyntaxHighlighting = HD; } else { // try to use Avalon highlighting built in to find the correct highlight by file extension string ext = Path.GetExtension(FileName).ToLower(); textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinitionByExtension(ext); } IFoldingStrategy FG = TE.FoldingStrategy; if (FG != null) { try { mFoldingManager = FoldingManager.Install(textEditor.TextArea); } catch { } mFoldingStrategy = FG; InitFoldings(); } textEditor.TextArea.Caret.PositionChanged += Caret_PositionChanged; //TODO: set indentation manager // Add tools in toolbar if (TE.Tools != null) { foreach (TextEditorToolBarItem t in TE.Tools) { AddToolbarTool(t.Image, t.clickHandler, t.toolTip, t.toolVisibility); } } }
public Details() { InitializeComponent(); this.Reset(); this.treeviewTargets.ItemsSource = this.TargetsToBuild; DispatcherTimer foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; foldingUpdateTimer.Tick += this.foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); this.foldingStrategy = new XmlFoldingStrategy(); this.textBoxXml.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); this.foldingManager = FoldingManager.Install(this.textBoxXml.TextArea); this.foldingStrategy.UpdateFoldings(this.foldingManager, this.textBoxXml.Document); }
private void _init() { if (_textEditor.SyntaxHighlighting == null) { _foldingStrategy = null; } else { switch (_textEditor.SyntaxHighlighting.Name) { case "XML": _foldingStrategy = new XmlFoldingStrategy(); _textEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); break; default: _textEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); _foldingStrategy = null; break; } } if (_foldingStrategy != null) { if (_foldingManager == null) { _foldingManager = FoldingManager.Install(_textEditor.TextArea); } _foldingStrategy.UpdateFoldings(_foldingManager, _textEditor.Document); } else { if (_foldingManager != null) { FoldingManager.Uninstall(_foldingManager); _foldingManager = null; } } _foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; }
private void SetObject() { if (this.GridValue != null) { string text = (string)this.GridValue.Value; if (text != null && text.Trim().StartsWith("<")) { this.Editor.Text = Serializer.FormatXml(text); this.Editor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"); this.Editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); this.foldingStrategy = new XmlFoldingStrategy(); } else { this.Editor.Text = text; this.Editor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("TXT"); this.Editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); foldingStrategy = null; } if (foldingStrategy != null) { if (foldingManager == null) { foldingManager = FoldingManager.Install(this.Editor.TextArea); } foldingStrategy.UpdateFoldings(foldingManager, this.Editor.Document); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } } }
public SvgPage() { InitializeComponent(); // string workingDir = IoPath.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string workingDir = IoPath.GetFullPath("..\\"); _svgFilePath = IoPath.Combine(workingDir, SvgFileName); _xamlFilePath = IoPath.Combine(workingDir, XamlFileName); _backFilePath = IoPath.Combine(workingDir, BackFileName); _directoryInfo = new DirectoryInfo(workingDir); textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"); TextEditorOptions options = textEditor.Options; if (options != null) { //options.AllowScrollBelowDocument = true; options.EnableHyperlinks = true; options.EnableEmailHyperlinks = true; options.EnableVirtualSpace = false; options.HighlightCurrentLine = true; //options.ShowSpaces = true; //options.ShowTabs = true; //options.ShowEndOfLine = true; } textEditor.ShowLineNumbers = true; _foldingManager = FoldingManager.Install(textEditor.TextArea); _foldingStrategy = new XmlFoldingStrategy(); _searchPanel = SearchPanel.Install(textEditor); textEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); this.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display); this.Loaded += OnPageLoaded; this.SizeChanged += OnPageSizeChanged; }
private void IndentLines() { foldingStrategy = new BraceFoldingStrategy(); if (foldingStrategy != null) { if (foldingManager == null) { foldingManager = FoldingManager.Install(textEditor.TextArea); } foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } }
public PyScriptControl() { LoadIPyHighlighting(); InitializeComponent(); IsDebug = true; CurrentFile = new ScriptFile(); TextEditor.TextChanged += TextEditor_TextChanged; TextEditor.TextArea.TextEntering += TextArea_TextEntering; TextEditor.TextArea.TextEntered += TextArea_TextEntered; TextEditor.MouseWheel += TextEditor_PreviewMouseWheel; TextEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(); TextEditor.Options.ConvertTabsToSpaces = true; foldingManager = FoldingManager.Install(TextEditor.TextArea); foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, TextEditor.Document); pythonAutoCompletionHelper = new PythonAutoCompletionHelper(); }
private void OpenCommand_Executed(object sender, ExecutedRoutedEventArgs e) { var ofd = new OpenFileDialog(); ofd.Filter = "Supported file types|*.xsl;*.xslt|All files|*.*"; if (ofd.ShowDialog() == true) { try { FoldingManager.Uninstall(this.sourceXsltFoldingManager); this._mainViewModel.OpenFile(ofd.FileName); this.sourceXsltFoldingManager = FoldingManager.Install(this.SourceXslt.TextArea); this.UpdateFolding(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private XsltTestWindow(List <EvolutionChange> changes) : this() { Changes = changes; foldingManager = FoldingManager.Install(tbOldDoc.TextArea); foldingManager = FoldingManager.Install(tbNewDoc.TextArea); foldingManager = FoldingManager.Install(tbXslt.TextArea); tbOldDoc.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); tbOldDoc.ShowLineNumbers = true; tbNewDoc.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); tbNewDoc.ShowLineNumbers = true; tbXslt.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); tbXslt.ShowLineNumbers = true; foldingStrategy = new XmlFoldingStrategy(); }
public void LoadDocument(Stream memoryStream) { if (textEditor == null || memoryStream == null) { return; } memoryStream.Position = 0; textEditor.Load(memoryStream); memoryStream.Close(); if (_foldingManager == null || _foldingStrategy == null) { _foldingManager = FoldingManager.Install(textEditor.TextArea); _foldingStrategy = new XmlFoldingStrategy(); } _foldingStrategy.UpdateFoldings(_foldingManager, textEditor.Document); }
private void FoldingUpdateTimer_Tick(object sender, EventArgs e) { try { if (_foldingManager == null && editor.TextArea?.Document?.Text != null) { _foldingManager = FoldingManager.Install(editor.TextArea); } if (_foldingStrategy != null && _foldingManager != null && editor.Document != null) { _foldingStrategy.UpdateFoldings(_foldingManager, editor.Document); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("FoldingUpdateTimer_Tick Exception: " + ex.Message); // silently fails } }
public CodeEditor(FileData aModelData) { InitializeComponent(); aModelData.AttachEditor(editor); this.data = aModelData; editor.ShowLineNumbers = true; editor.Options.ConvertTabsToSpaces = true; editor.Options.IndentationSize = 4; editor.Foreground = new SolidColorBrush(Colors.White); editor.SyntaxHighlighting = AvalonExtensions.LoadHighlightingDefinition("Debugger.Resources.Angelscript.xshd"); editor.Text = data.Code; editor.FontFamily = new FontFamily("Consolas"); editor.TextArea.TextView.CurrentLineBackground = new SolidColorBrush(Colors.LightGray); editor.TextArea.TextView.BackgroundRenderers.Add(new LineHighlighter()); editor.TextArea.LeftMargins.Insert(0, bpMargin = new BreakpointMargin(aModelData)); SearchPanel panel = SearchPanel.Install(editor.TextArea); aModelData.PropertyChanged += aModelData_PropertyChanged; foldingManager = FoldingManager.Install(editor.TextArea); codeFolding = new BraceFoldingStrategy(); UpdateFolding(); // If using IDE data then give ourselves an IntellisenseSource if (Debug.SessionData.inst().Settings.UseIDEData) { intelSource = IDE.Intellisense.Sources.SourceBuilder.GetSourceForExtension(System.IO.Path.GetExtension(aModelData.SectionName)); } depthScanner = new IDE.Intellisense.DepthScanner(); depthScanner.Process(editor.Text); editor.MouseHover += editor_MouseHover; editor.TextArea.MouseWheel += editor_MouseWheel; editor.KeyUp += editor_KeyUp; editor.TextChanged += editor_TextChanged; t = new System.Timers.Timer(); t.Interval = 175; t.Elapsed += t_Elapsed; t.Start(); }
public MainWindow() { InitializeComponent(); textEditor.Text = File.ReadAllText("Sample.xml"); XSD.Text = File.ReadAllText("Schema.xsd"); XmlSchemaSet schemas = new XmlSchemaSet(); schemas.Add("", XmlReader.Create(new StringReader(File.ReadAllText("Schema.xsd")))); schemas.Compile(); XsdInformation = XHelper.XsdParser.AnalyseSchema(schemas); foldingManager = FoldingManager.Install(textEditor.TextArea); foldingStrategy = new CustomXmlFoldingStrategy(); TryToUpdateFoldings(); textEditor.TextChanged += IntelliSense; textEditor.TextArea.TextEntered += TextArea_TextEntered; textEditor.TextArea.Caret.PositionChanged += IntelliSense; }
public CodeEditorView() { InitializeComponent(); Loaded += (s, e) => { if (foldingManager == null) { foldingManager = FoldingManager.Install(textEditor.TextArea); } braceStrategy = new BraceFoldingStrategy(); regionStrategy = new RegionFoldingStrategy(); textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options); DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += FoldingUpdateTimer_Tick; foldingUpdateTimer.Start(); }; }
public override void BeginInit() { base.BeginInit(); base.Document.UndoStack.SizeLimit = 1600; this.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C++"); this.ShowLineNumbers = true; this.FontFamily = new FontFamily("Consolas"); this.FontSize = 13.3; // 10pt TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options); foldingManager = FoldingManager.Install(this.TextArea); foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, this.Document); // var search = new SearchInputHandler(this.TextArea); //this.TextArea.DefaultInputHandler.NestedInputHandlers.Add(search); SearchPanel.Install(this.TextArea); }
public bool LoadDocument(Stream stream) { this.UnloadDocument(); if (textEditor == null || stream == null) { return(false); } textEditor.Load(stream); if (_foldingManager == null || _foldingStrategy == null) { _foldingManager = FoldingManager.Install(textEditor.TextArea); _foldingStrategy = new XmlFoldingStrategy(); } _foldingStrategy.UpdateFoldings(_foldingManager, textEditor.Document); return(true); }
protected internal void InitializeFolding(AbstractFoldingStrategy foldingStrategy) { if (_foldingManager != null) { FoldingManager.Uninstall(_foldingManager); } var foldingManager = FoldingManager.Install(Editor.TextArea); foldingStrategy.UpdateFoldings(foldingManager, Editor.Document); var foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; foldingUpdateTimer.Tick += (o, args) => foldingStrategy.UpdateFoldings(foldingManager, Editor.Document); foldingUpdateTimer.Start(); _foldingManager = foldingManager; }
void HighlightingComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { switch (TextEditor.SyntaxHighlighting.Name) { case "XML": foldingStrategy = new XmlFoldingStrategy(); TextEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); break; case "C#": case "C++": case "PHP": case "Java": TextEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(TextEditor.Options); foldingStrategy = new BraceFoldingStrategy(); break; default: TextEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); foldingStrategy = null; break; } if (foldingStrategy != null) { if (foldingManager == null) { foldingManager = FoldingManager.Install(TextEditor.TextArea); } UpdateFoldings(); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } }
public MainWindow() { InitializeComponent(); ReLoadTheme(); for (int i = 0; i < 5; i++) { Editor.Text += $"[Section{i + 1}]"; Editor.Text += Environment.NewLine; Editor.Text += "Key = Value; Summary"; Editor.Text += Environment.NewLine; Editor.Text += Environment.NewLine; } Editor.Document.Changed += Document_Changed; Editor.MouseMove += (o, e) => Method(); Editor.KeyUp += (o, e) => Method(); Editor.TextArea.TextEntered += TextArea_TextEntered; foldingManager = FoldingManager.Install(Editor.TextArea); foldingStrategy = new FoldingStrategy(); Update(); }
public FileConverterOutput() { InitializeComponent(); textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"); TextEditorOptions options = textEditor.Options; if (options != null) { options.AllowScrollBelowDocument = true; options.EnableHyperlinks = true; options.EnableEmailHyperlinks = true; //options.ShowSpaces = true; //options.ShowTabs = true; //options.ShowEndOfLine = true; } textEditor.IsReadOnly = true; textEditor.ShowLineNumbers = true; _foldingManager = FoldingManager.Install(textEditor.TextArea); _foldingStrategy = new XmlFoldingStrategy(); _wpfSettings = new WpfDrawingSettings(); _wpfSettings.CultureInfo = _wpfSettings.NeutralCultureInfo; _fileReader = new FileSvgReader(_wpfSettings); _fileReader.SaveXaml = false; _fileReader.SaveZaml = false; mouseHandlingMode = MouseHandlingMode.None; _worker = new BackgroundWorker(); _worker.WorkerReportsProgress = true; _worker.WorkerSupportsCancellation = true; _worker.DoWork += new DoWorkEventHandler(OnWorkerDoWork); _worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OnWorkerCompleted); _worker.ProgressChanged += new ProgressChangedEventHandler(OnWorkerProgressChanged); }
public SqlInput() { InitializeComponent(); textEditor.Options.ShowTabs = true; textEditor.Options.ShowSpaces = true; textEditor.Options.ConvertTabsToSpaces = true; textEditor.Options.HighlightCurrentLine = true; textEditor.ShowLineNumbers = true; foldingManager = FoldingManager.Install(textEditor.TextArea); foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); textEditor.TextArea.TextEntering += textEditor_TextArea_TextEntering; textEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered; DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); }
public XppSourceEditor() : base() { // FontFamily = "{Binding Source={x:Static settings:Settings.Default}, Path=SourceFont}" var fontFamilyBinding = new Binding("SourceFont") { Source = Properties.Settings.Default }; this.SetBinding(FontFamilyProperty, fontFamilyBinding); // Configure the X++ folding manager. // The indentation strategy is probably not needed since the view is readonly... this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options); var xppFoldingStrategy = new BraceFoldingStrategy(); var xppFoldingManager = FoldingManager.Install(this.TextArea); xppFoldingStrategy.UpdateFoldings(xppFoldingManager, this.Document); this.IsReadOnly = true; this.SyntaxHighlighting = LoadHighlightDefinition("SocratexGraphExplorer.XppPlugin.Resources.Xpp-Mode.xshd"); }
public XsltTestWindow() { InitializeComponent(); foldingManager = FoldingManager.Install(tbOldDoc.TextArea); foldingManager = FoldingManager.Install(tbNewDoc.TextArea); foldingManager = FoldingManager.Install(tbXslt.TextArea); tbOldDoc.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); tbOldDoc.ShowLineNumbers = true; tbNewDoc.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); tbNewDoc.ShowLineNumbers = true; tbXslt.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); tbXslt.ShowLineNumbers = true; foldingStrategy = new XmlFoldingStrategy(); if (Directory.Exists(BASE_DIR)) { FileInfo[] fileInfos = (new DirectoryInfo(BASE_DIR)).GetFiles("*.xslt"); fileNames = fileInfos.Select(a => a.Name); cbXsltList.ItemsSource = fileNames; if (fileNames.Contains("tmp.xslt")) { OpenXslt("tmp.xslt"); } } #if DEBUG #else bTestOutputCreation.Visibility = Visibility.Collapsed; bSaveRef.Visibility = Visibility.Collapsed; pXSLT.Visibility = Visibility.Collapsed; #endif }
public XmlEditor() { Content = new TextEditor(); //LoadCommandBindings(); Content.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"); Content.Visibility = System.Windows.Visibility.Visible; Content.ShowLineNumbers = true; Content.Options.ShowTabs = true; Content.TextArea.Caret.PositionChanged += new EventHandler(Caret_PositionChanged); foldingManager = FoldingManager.Install(Content.TextArea); foldingStrategy = new XmlFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, Content.Document); fsw = new FileSystemWatcher(); fsw.Changed += new FileSystemEventHandler(fsw_Changed); fsw.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.CreationTime | NotifyFilters.DirectoryName; }
private void PrepareFoldingStrategy() { try { this._foldingManager1 = FoldingManager.Install(this._editor1.TextArea); BraceFoldingStrategy.UpdateFoldings(this._foldingManager1, this._document); this._foldingManager2 = FoldingManager.Install(this._editor2.TextArea); BraceFoldingStrategy.UpdateFoldings(this._foldingManager2, this._document); var foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(3) }; foldingUpdateTimer.Tick += this.BraceFoldingUpdateTimerTick; foldingUpdateTimer.Start(); } catch (Exception error) { Framework.EventBus.Publish(error); } }
void SetUpTextEditor() { _editor = new TextEditor { SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"), ShowLineNumbers = true, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Auto }; _editor.SetValue(AutomationProperties.AutomationIdProperty, "UI_XMLEditor_AutoID"); _jsonEditor = new TextEditor { SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("JavaScript"), ShowLineNumbers = true, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Auto }; _jsonEditor.SetValue(AutomationProperties.AutomationIdProperty, "UI_JsonEditor_AutoID"); _foldingStrategy = new XmlFoldingStrategy(); _foldingManager = FoldingManager.Install(_editor.TextArea); _editor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); _jsonEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); _foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; _foldingUpdateTimer.Tick += OnFoldingUpdateTimerOnTick; _foldingUpdateTimer.Start(); }
public TextViewerControl() { InitializeComponent(); var textArea = textEditor.TextArea; SearchPanel.Install(textArea); foldingManager = FoldingManager.Install(textEditor.TextArea); textArea.MouseRightButtonDown += TextAreaMouseRightButtonDown; var textView = textArea.TextView; textView.Options.HighlightCurrentLine = true; textView.Options.EnableEmailHyperlinks = false; textView.Options.EnableHyperlinks = false; textEditor.IsReadOnly = true; if (SettingsService.UseDarkTheme) { textEditor.Background = ThemeManager.BackgroundBrush; textEditor.Foreground = ThemeManager.ControlTextBrush; textView.CurrentLineBackground = (Brush) new BrushConverter().ConvertFromString("#505050"); textArea.SelectionBrush = (Brush) new BrushConverter().ConvertFromString("#264F78"); textArea.SelectionForeground = (Brush) new BrushConverter().ConvertFromString("#C8C8C8"); var foldingMargin = textArea.LeftMargins.OfType <FoldingMargin>().First(); foldingMargin.FoldingMarkerBackgroundBrush = ThemeManager.BackgroundBrush; foldingMargin.FoldingMarkerBrush = ThemeManager.ControlTextBrush; foldingMargin.SelectedFoldingMarkerBackgroundBrush = ThemeManager.BackgroundBrush; foldingMargin.SelectedFoldingMarkerBrush = ThemeManager.ControlTextBrush; } else { textView.CurrentLineBackground = new SolidColorBrush(Color.FromRgb(224, 224, 224)); textView.CurrentLineBorder = new Pen(Brushes.Transparent, 0); } }
void HighlightingComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (textEditor.SyntaxHighlighting == null) { foldingStrategy = null; } else { switch (textEditor.SyntaxHighlighting.Name) { case "XML": foldingStrategy = new XmlFoldingStrategy(); textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; default: textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); foldingStrategy = null; break; } } if (foldingStrategy != null) { if (foldingManager == null) { foldingManager = FoldingManager.Install(textEditor.TextArea); } UpdateFoldings(); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } }
public void Init() { if (DisplayedFileType.IsAmong(EDisplayedFileType.XML, EDisplayedFileType.XSD, EDisplayedFileType.RNG, EDisplayedFileType.SCH) && (tbDocument.SyntaxHighlighting == null || tbDocument.SyntaxHighlighting.Name != "XML")) { tbDocument.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); if (foldingStrategy == null) { foldingManager = FoldingManager.Install(tbDocument.TextArea); foldingStrategy = new XmlFoldingStrategy(); } } if (DisplayedFileType == EDisplayedFileType.RNC && (tbDocument.SyntaxHighlighting == null || tbDocument.SyntaxHighlighting.Name != "RNC")) { System.Xml.XmlReader reader; using (StringReader sr = new StringReader(Properties.Resources.RNC)) { reader = new System.Xml.XmlTextReader(sr); tbDocument.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, HighlightingManager.Instance); } } if (DisplayedFileType == EDisplayedFileType.XQuery && (tbDocument.SyntaxHighlighting == null || tbDocument.SyntaxHighlighting.Name != "XQuery")) { System.Xml.XmlReader reader; using (StringReader sr = new StringReader(Properties.Resources.XQuery)) { reader = new System.Xml.XmlTextReader(sr); tbDocument.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, HighlightingManager.Instance); } } tbDocument.ShowLineNumbers = true; UpdateFolding(); }