/// <summary> /// Initializes a new instance of the <see cref="AvalonEditor"/> class. /// </summary> /// <exception cref="System.InvalidOperationException">Failed to load syntax definition</exception> public AvalonEditor() { _foldingManager = FoldingManager.Install(TextArea); _folding = new XmlFoldingStrategy(); _htmlIndent = new HtmlIndentationStrategy(); _defaultIndent = new DefaultIndentationStrategy(); AutoIndent = true; AutoIndentAmount = 1; ShowLineNumbers = true; // Load our HTML highlighting using (var s = typeof(AvalonEditor).Assembly.GetManifestResourceStream(typeof(AvalonEditor), "HtmlHighlighting.xml")) { if (s == null) throw new InvalidOperationException("Failed to load syntax definition"); using (var r = XmlReader.Create(s)) { var highlightingDefinition = HighlightingLoader.Load(r, HighlightingManager.Instance); SyntaxHighlighting = highlightingDefinition; } } IsDirty = false; Task.Factory.StartNew(FoldingUpdateLoop); }
void InitFolding() { if (txtResult.SyntaxHighlighting == null) { foldingStrategyA = null; } else { foldingStrategyA = new BraceFoldingStrategy(); } if (foldingStrategyA != null) { if (foldingManagerA == null) foldingManagerA = FoldingManager.Install(txtResult.TextArea); foldingStrategyA.UpdateFoldings(foldingManagerA, textEditorA.Document); } else { if (foldingManagerA != null) { FoldingManager.Uninstall(foldingManagerA); foldingManagerA = null; } } }
public void UpdateFoldings(FoldingManager manager, TextDocument document, AbstractFoldingStrategy chained) { int firstErrorOffset; IEnumerable <NewFolding> foldings = CreateNewFoldings(document, out firstErrorOffset, chained.CreateNewFoldings(document, out firstErrorOffset)); manager.UpdateFoldings(foldings, firstErrorOffset); }
/// <summary> /// Determine whether or not highlighting can be /// suppported by a particular folding strategy. /// </summary> /// <param name="syntaxHighlighting"></param> public void SetFolding(IHighlightingDefinition syntaxHighlighting) { if (syntaxHighlighting == null) { this.mFoldingStrategy = null; } else { switch (syntaxHighlighting.Name) { case "XML": case "HTML": mFoldingStrategy = new XmlFoldingStrategy() { ShowAttributesWhenFolded = true }; this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; case "C#": this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options); mFoldingStrategy = new CSharpBraceFoldingStrategy(); break; case "C++": case "PHP": case "Java": this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options); mFoldingStrategy = new CSharpBraceFoldingStrategy(); break; case "VBNET": this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options); mFoldingStrategy = new VBNetFoldingStrategy(); break; default: this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); mFoldingStrategy = null; break; } if (mFoldingStrategy != null) { if (this.Document != null) { if (mFoldingManager == null) mFoldingManager = FoldingManager.Install(this.TextArea); this.mFoldingStrategy.UpdateFoldings(mFoldingManager, this.Document); } else this.mInstallFoldingManager = true; } else { if (mFoldingManager != null) { FoldingManager.Uninstall(mFoldingManager); mFoldingManager = null; } } } }
public TextEditorControl(string name, int index) { InitializeComponent(); FileName = name; FileIndex = index; var foldingUpdateTimer = new DispatcherTimer {Interval = TimeSpan.FromSeconds(2)}; foldingUpdateTimer.Tick += FoldingUpdateTimerTick; foldingUpdateTimer.Start(); if (File.Exists(@"Highlighter\CustomHighlighting.xshd")) { var fileStream = new FileStream(@"Highlighter\CustomHighlighting.xshd", FileMode.Open, FileAccess.Read); using (var reader = new XmlTextReader(fileStream)) { textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } fileStream.Close(); } textEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(textEditor.Options); _foldingStrategy = new BEFoldingStrategy(); 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; } } textEditor.Text = "# Welcome to lpSolver (Linear Programming Solver)!" + Environment.NewLine; textEditor.Text += "lpmodel ModelName" + FileIndex.ToString() + " \n{" + Environment.NewLine; textEditor.Text += string.Format("\t# TODO : Objectives {0}{0}", Environment.NewLine + "\t"); textEditor.Text += "min 10*x + 20*y" + Environment.NewLine; textEditor.Text += "\tsubject to:" + Environment.NewLine; textEditor.Text += "\tx + y > 10;" + Environment.NewLine; textEditor.Text += "\t0<x;" + Environment.NewLine; textEditor.Text += "\t0<y;" + Environment.NewLine; textEditor.Text += Environment.NewLine + "\t"; textEditor.Text += Environment.NewLine; textEditor.Text += "};" + Environment.NewLine; textEditor.Text += "# __EOF" + Environment.NewLine; textEditor.ShowLineNumbers = true; FileUrl = string.Empty; }
public GeneratedCodeView() { // Load our custom highlighting definition IHighlightingDefinition customHighlighting; using (Stream s = typeof(GeneratedCodeView).Assembly.GetManifestResourceStream("CinchCodeGen.UserControls.CustomHighlighting.xshd")) { if (s == null) throw new InvalidOperationException("Could not find embedded resource"); using (XmlReader reader = new XmlTextReader(s)) { customHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd. HighlightingLoader.Load(reader, HighlightingManager.Instance); } } // and register it in the HighlightingManager HighlightingManager.Instance.RegisterHighlighting("Custom Highlighting", new string[] { ".cool" }, customHighlighting); InitializeComponent(); txtCode.SyntaxHighlighting = customHighlighting; if (txtCode.SyntaxHighlighting == null) { foldingStrategy = null; } else { foldingStrategy = new BraceFoldingStrategy(); } if (foldingStrategy != null) { if (foldingManager == null) foldingManager = FoldingManager.Install(txtCode.TextArea); foldingStrategy.UpdateFoldings(foldingManager, txtCode.Document); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); this.DataContextChanged += GeneratedCodeView_DataContextChanged; }
protected void InitializeFolding(AbstractFoldingStrategy foldingStrategy) { 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(); }
private 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"); _foldingStrategy = new XmlFoldingStrategy(); _foldingManager = FoldingManager.Install(_editor.TextArea); _editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); _foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; _foldingUpdateTimer.Tick += OnFoldingUpdateTimerOnTick; _foldingUpdateTimer.Start(); }
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); }
/// <summary> /// Create a new interface document. /// </summary> /// <param name="game">A game object used for graphical components.</param> /// <param name="directory">Path to the directory the interface resides in.</param> public EqInterfaceContent(Game game, string directory) : base() { m_interface = EqInterface.LoadInterface(game, directory); m_files = new EqFileCollection(); TextEditorSettings settings = TextEditorSettings.Default; settings.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(TextEditorSettingsChanged); // create the text editor m_textEditor = new TextEditor(); m_textEditor.Foreground = new SolidColorBrush(settings.Color_XML_Text); m_textEditor.Background = new SolidColorBrush(settings.Color_XML_Background); m_textEditor.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; m_textEditor.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; m_textEditor.WordWrap = TextEditorSettings.Default.WordWrap; m_textEditor.ShowLineNumbers = TextEditorSettings.Default.ShowLineNumbers; m_textEditor.TextChanged += new EventHandler(TextEditor_TextChanged); m_textEditor.TextArea.TextEntered += new TextCompositionEventHandler(TextArea_TextEntered); // load syntax highlighting ruleset using (Stream stream = new MemoryStream(EQXResources.equi_xml)) { using (XmlReader reader = new XmlTextReader(stream)) { m_textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } } // install the folding manager m_foldingManager = FoldingManager.Install(m_textEditor.TextArea); m_foldingStrategy = new XmlFoldingStrategy(); m_treeViewRoot = new TreeViewItem(); m_treeViewRoot.Header = m_interface.Directory.Name; m_treeViewRoot.Tag = this; foreach (EqFile file in m_interface.Files) { EqFileContent fileContent = new EqFileContent(file); m_treeViewRoot.Items.Add(fileContent.TreeViewRoot); } // embed the text editor Content = m_textEditor; }
public MainWindow() { IHighlightingDefinition coolHighlighting; using (System.IO.Stream s = typeof(MainWindow).Assembly.GetManifestResourceStream("CoolCompiler.CoolHighlighting.xshd")) { if (s == null) throw new InvalidOperationException("Could not find embedded resource"); using (XmlReader reader = new XmlTextReader(s)) { coolHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd. HighlightingLoader.Load(reader, HighlightingManager.Instance); } } HighlightingManager.Instance.RegisterHighlighting("Cool Highlighting", new string[] { ".cool" }, coolHighlighting); InitializeComponent(); foldingStrategy = new CoolFoldingStrategy(); foldingManager = FoldingManager.Install(tbEditor.TextArea); tbEditor.ShowLineNumbers = true; tbEditor.TextArea.TextEntering += tbEditor_TextArea_TextEntering; tbEditor.TextArea.TextEntered += tbEditor_TextArea_TextEntered; DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); if (Settings.Default.WindowLeft != 0) Left = Settings.Default.WindowLeft; if (Settings.Default.WindowTop != 0) Top = Settings.Default.WindowTop; if (Settings.Default.WindowWidth != 0) Width = Settings.Default.WindowWidth; if (Settings.Default.WindowTop != 0) Height = Settings.Default.WindowHeight; if (!string.IsNullOrEmpty(Settings.Default.FileName)) LoadFile(Settings.Default.FileName); Log = new StringBuilder(); CoolTokens.Load("../../output/CoolGrammar.tokens"); }
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; 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 ICSharpCode.AvalonEdit.Indentation.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; } } }
/// <summary> /// Create a new file document. /// </summary> public EqFileContent(EqFile file) : base() { m_file = file; // create the text editor m_textEditor = new TextEditor(); m_textEditor.Foreground = Brushes.White; m_textEditor.Background = new SolidColorBrush(new System.Windows.Media.Color() { R = 0x20, G = 0x20, B = 0x20, A = 0xFF }); m_textEditor.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; m_textEditor.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; m_textEditor.WordWrap = TextEditorSettings.Default.WordWrap; m_textEditor.ShowLineNumbers = TextEditorSettings.Default.ShowLineNumbers; m_textEditor.TextChanged += new EventHandler(TextEditor_TextChanged); m_textEditor.TextArea.TextEntered += new TextCompositionEventHandler(TextArea_TextEntered); // load syntax highlighting ruleset using (Stream stream = new MemoryStream(EQXResources.equi_xml)) { using (XmlReader reader = new XmlTextReader(stream)) { m_textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } } // install the folding manager m_foldingManager = FoldingManager.Install(m_textEditor.TextArea); m_foldingStrategy = new XmlFoldingStrategy(); m_treeViewRoot = new TreeViewItem(); m_treeViewRoot.Header = m_file.Filename; m_treeViewRoot.Tag = this; foreach (EqElement element in m_file.Elements) { } // embed the text editor Content = m_textEditor; }
public BuildPad() { this.InitializeComponent(); this.TextBoxPreExecute.Text = Settings.Default.DefaultBootStrapper; this.TextBoxParameters.Text = Settings.Default.DefaultParameters; 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); if (string.IsNullOrWhiteSpace(this.textBoxXml.Text)) { this.textBoxXml.Text = Settings.Default.DefaultBuildPad; } }
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 DevTools(JScriptEngine engine, Dictionary<string, object> objects, string source = "") { InitializeComponent(); this.engine = engine; this.objects = objects; editor = new ICSharpCode.AvalonEdit.TextEditor(); editor.FontFamily = new System.Windows.Media.FontFamily("Consolas"); editor.FontSize = 14; editor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(".js"); editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); editor.ShowLineNumbers = true; editor.Text = source; foldingStrategy = new BraceFoldingStrategy(); foldingManager = FoldingManager.Install(editor.TextArea); foldingStrategy.UpdateFoldings(foldingManager, editor.Document); editor.TextArea.TextEntering += textEditor_TextArea_TextEntering; editor.TextArea.TextEntered += textEditor_TextArea_TextEntered; editor.TextChanged += Editor_TextChanged; DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromTicks(20); foldingUpdateTimer.Tick += foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); var img = new Image(); img.Source = Utils.ImageToBitmapsource(Properties.Resources.start); btnStart.Content = img; btnStart.Click += (s, e) => engine.Execute(editor.Text); editor.ExtendWithContextMenu(); view.Child = editor; }
internal void InitFolding() { foldingUpdateTimer.Stop(); if (textEditor.SyntaxHighlighting == null) { foldingStrategy = null; } else { foldingStrategy = new BraceFoldingStrategy(); foldingUpdateTimer.Start(); } 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; } } }
private void SetupFolding() { textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options); foldingStrategy = new BraceFoldingStrategy(); textfoldingManager = FoldingManager.Install(textEditor.TextArea); outputfoldingManager = FoldingManager.Install(output.TextArea); var foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; foldingUpdateTimer.Tick += FoldingUpdateTimerTick; foldingUpdateTimer.Start(); }
public TextEditorControl(string name, int index, string code) { InitializeComponent(); FileName = name; FileIndex = index; var foldingUpdateTimer = new DispatcherTimer {Interval = TimeSpan.FromSeconds(2)}; foldingUpdateTimer.Tick += FoldingUpdateTimerTick; foldingUpdateTimer.Start(); if (File.Exists(@"Highlighter\CustomHighlighting.xshd")) { var fileStream = new FileStream(@"Highlighter\CustomHighlighting.xshd", FileMode.Open, FileAccess.Read); using (var reader = new XmlTextReader(fileStream)) { textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } fileStream.Close(); } textEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(textEditor.Options); _foldingStrategy = new BEFoldingStrategy(); 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; } } textEditor.Text = code; textEditor.ShowLineNumbers = true; FileUrl = string.Empty; }
private void ApplyFoldings(TextEditor editor) { try { if (editor.SyntaxHighlighting == null) foldingStrategy = null; else { switch (editor.SyntaxHighlighting.Name) { case "XML": foldingStrategy = new XmlFoldingStrategy(); editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; case "C#": case "C++": case "PHP": case "Java": foldingStrategy = new acorp.BraceFoldingStrategy(); editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(editor.Options); break; default: foldingStrategy = new acorp.BraceFoldingStrategy(); editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; } } if (foldingStrategy != null) { foldingStrategy.UpdateFoldings((editor.Tag as FoldingManager), editor.Document); } } catch { } }
/// <summary> /// Обработчик меняет стратегию разбиения текста на части. Подсветка синтаксиса меняется автоматом. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void HighlightingComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e) { // SyntaxHighlighting - это свойство, определяющее текущее правило подсветки синтаксиса 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; case "C#": case "C++": case "PHP": case "Java": textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options); _foldingStrategy = null; break; default: textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.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; } } }
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; } } } }
/// <summary> /// /// </summary> void SetFoldingStrategy() { 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; // 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 ICSharpCode.AvalonEdit.Indentation.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; } } }
private void InstallFoldingStrategy() { foldingManager = FoldingManager.Install(textEditor.TextArea); foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); AddFoldingStrategyTimer(); }