//OpenFile Method for DragDrop Events
 private void OpenFile(string sFile)
 {
     txtXMLPath.Text = System.IO.Path.GetFileName(sFile);
     if (!sFile.Contains(".xml"))
     {
         MessageBox.Show(sFile + " Is Not An XML File!");
     }
     else if (sFile == xmlpath)
     {
         MessageBox.Show(sFile + " Is Already Open!");
     }
     else
     {
         xmlpath            = sFile.ToString();
         txtXMLPath.ToolTip = "Full Path: " + xmlpath;
         LoadXml(xmlpath);
         foldingStrategy = new XmlFoldingStrategy();
         if (foldingStrategy != null)
         {
             if (foldingManager == null)
             {
                 foldingManager = FoldingManager.Install(xmlin.TextArea);
             }
             foldingStrategy.UpdateFoldings(foldingManager, xmlin.Document);
         }
         else
         {
             if (foldingManager != null)
             {
                 FoldingManager.Uninstall(foldingManager);
                 foldingManager = null;
             }
         }
     }
 }
        void initFolding()
        {
            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;
                }
            }

            DispatcherTimer foldingUpdateTimer = new DispatcherTimer();

            foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2);
            foldingUpdateTimer.Tick    += foldingUpdateTimer_Tick;
            foldingUpdateTimer.Start();
        }
Beispiel #3
0
 private void NewCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     FoldingManager.Uninstall(_sourceXsltFoldingManager);
     _mainViewModel.New();
     _sourceXsltFoldingManager = FoldingManager.Install(SourceXslt.TextArea);
     UpdateFolding();
 }
Beispiel #4
0
        /// <summary>
        /// Shows the given output in the text view.
        /// </summary>
        void ShowOutput(AvalonEditTextOutput textOutput, IHighlightingDefinition highlighting = null, DecompilerTextViewState state = null)
        {
            Debug.WriteLine("Showing {0} characters of output", textOutput.TextLength);
            Stopwatch w = Stopwatch.StartNew();

            textEditor.ScrollToHome();
            if (foldingManager != null)
            {
                FoldingManager.Uninstall(foldingManager);
                foldingManager = null;
            }
            textEditor.Document                  = null; // clear old document while we're changing the highlighting
            uiElementGenerator.UIElements        = textOutput.UIElements;
            referenceElementGenerator.References = textOutput.References;
            definitionLookup = textOutput.DefinitionLookup;
            textEditor.SyntaxHighlighting = highlighting;

            Debug.WriteLine("  Set-up: {0}", w.Elapsed); w.Restart();
            textEditor.Document = textOutput.GetDocument();
            Debug.WriteLine("  Assigning document: {0}", w.Elapsed); w.Restart();
            if (textOutput.Foldings.Count > 0)
            {
                if (state != null)
                {
                    state.RestoreFoldings(textOutput.Foldings);
                    textEditor.ScrollToVerticalOffset(state.VerticalOffset);
                    textEditor.ScrollToHorizontalOffset(state.HorizontalOffset);
                }
                foldingManager = FoldingManager.Install(textEditor.TextArea);
                foldingManager.UpdateFoldings(textOutput.Foldings.OrderBy(f => f.StartOffset), -1);
                Debug.WriteLine("  Updating folding: {0}", w.Elapsed); w.Restart();
            }
        }
 //Reload Button
 private void btnReload_Click(object sender, RoutedEventArgs e)
 {
     txtFind.Text    = String.Empty;
     txtFind2.Text   = String.Empty;
     txtReplace.Text = String.Empty;
     txtEval.Text    = String.Empty;
     txtValue.Text   = String.Empty;
     tvxpath.Items.Clear();
     if (xmlin.Text != string.Empty)
     {
         LoadXml(xmlpath);
         foldingStrategy = new XmlFoldingStrategy();
         if (foldingStrategy != null)
         {
             if (foldingManager == null)
             {
                 foldingManager = FoldingManager.Install(xmlin.TextArea);
             }
             foldingStrategy.UpdateFoldings(foldingManager, xmlin.Document);
         }
         else
         {
             if (foldingManager != null)
             {
                 FoldingManager.Uninstall(foldingManager);
                 foldingManager = null;
             }
         }
     }
 }
        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;
                }
            }
        }
 void HighlightingComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (textEditor.SyntaxHighlighting == null) {
         foldingStrategy = null;
     } else {
         switch (textEditor.SyntaxHighlighting) {
             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;
         }
     }
 }
		public void Dispose()
		{
			if (foldingManager != null) {
				FoldingManager.Uninstall(foldingManager);
				foldingManager = null;
			}
		}
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.
                }
                updateThread.Abort();

                if ((foldingManager != null) && (FoldingStrategy != null))
                {
                    FoldingManager.Uninstall(FoldingManager);
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.

                // Note disposing has been done.
                disposed = true;
            }
        }
Beispiel #10
0
 /// <summary>
 /// Folding method
 /// </summary>
 private void Folding()
 {
     if (AvalonJsonEditor.SyntaxHighlighting == null)
     {
         _foldingStrategy = null;
     }
     else
     {
         AvalonJsonEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
         _foldingStrategy = null;
     }
     if (_foldingStrategy != null)
     {
         if (_foldingManager == null)
         {
             _foldingManager = FoldingManager.Install(AvalonJsonEditor.TextArea);
         }
         UpdateFoldings();
     }
     else
     {
         if (_foldingManager == null)
         {
             return;
         }
         FoldingManager.Uninstall(_foldingManager);
         _foldingManager = null;
     }
 }
Beispiel #11
0
        void InstallFoldingManager()
        {
            foldingManager = FoldingManager.Install(TextArea);

            foldingUpdateTimer          = new DispatcherTimer();
            foldingUpdateTimer.Interval = TimeSpan.FromSeconds(1);
            foldingUpdateTimer.Tick    += (o, e) =>
            {
                if (Document != null)
                {
                    foldingStrategy.UpdateFoldings(foldingManager, Document);
                }
            };
            foldingUpdateTimer.Start();

            TextArea.DocumentChanged += (o, e) => {
                if (foldingManager != null)
                {
                    FoldingManager.Uninstall(foldingManager);
                }
                if (TextArea.Document != null)
                {
                    foldingManager = FoldingManager.Install(TextArea);
                }
            };
        }
        private void SyntaxModeCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Language language = (Language)_syntaxModeCombo.SelectedItem;

            if (_foldingManager != null)
            {
                _foldingManager.Clear();
                FoldingManager.Uninstall(_foldingManager);
            }

            string scopeName = _registryOptions.GetScopeByLanguageId(language.Id);

            _textMateInstallation.SetGrammar(null);
            _textEditor.Document = new TextDocument(ResourceLoader.LoadSampleFile(scopeName));
            _textMateInstallation.SetGrammar(scopeName);

            if (language.Id == "xml")
            {
                _foldingManager = FoldingManager.Install(_textEditor.TextArea);

                var strategy = new XmlFoldingStrategy();
                strategy.UpdateFoldings(_foldingManager, _textEditor.Document);
                return;
            }
        }
Beispiel #13
0
 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;
         }
     }
 }
Beispiel #14
0
        private void init()
        {
            foldingStrategy = new XmlFoldingStrategy();
            textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
            foldingManager = FoldingManager.Install(textEditor.TextArea);

            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;
                }
            }

            DispatcherTimer foldingUpdateTimer = new DispatcherTimer();

            foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2);
            foldingUpdateTimer.Tick    += foldingUpdateTimer_Tick;
            foldingUpdateTimer.Start();

            RawlerLib.UIData.UISyncContext = UISyncContext;
        }
Beispiel #15
0
        /// <summary>
        /// Shows the given output in the text view.
        /// </summary>
        void ShowOutput(AvaloniaEditTextOutput textOutput, IHighlightingDefinition highlighting = null, DecompilerTextViewState state = null)
        {
            Debug.WriteLine("Showing {0} characters of output", textOutput.TextLength);
            Stopwatch w = Stopwatch.StartNew();

            ClearLocalReferenceMarks();
            textEditor.ScrollToHome();
            if (foldingManager != null)
            {
                FoldingManager.Uninstall(foldingManager);
                foldingManager = null;
            }
            textEditor.Document                  = null; // clear old document while we're changing the highlighting
            uiElementGenerator.UIElements        = textOutput.UIElements;
            referenceElementGenerator.References = textOutput.References;
            references       = textOutput.References;
            definitionLookup = textOutput.DefinitionLookup;
            textEditor.SyntaxHighlighting            = highlighting;
            textEditor.Options.EnableEmailHyperlinks = textOutput.EnableHyperlinks;
            textEditor.Options.EnableHyperlinks      = textOutput.EnableHyperlinks;
            if (activeRichTextColorizer != null)
            {
                textEditor.TextArea.TextView.LineTransformers.Remove(activeRichTextColorizer);
            }
            if (textOutput.HighlightingModel != null)
            {
                activeRichTextColorizer = new RichTextColorizer(textOutput.HighlightingModel);
                textEditor.TextArea.TextView.LineTransformers.Insert(highlighting == null ? 0 : 1, activeRichTextColorizer);
            }

            // Change the set of active element generators:
            foreach (var elementGenerator in activeCustomElementGenerators)
            {
                textEditor.TextArea.TextView.ElementGenerators.Remove(elementGenerator);
            }
            activeCustomElementGenerators.Clear();

            foreach (var elementGenerator in textOutput.elementGenerators)
            {
                textEditor.TextArea.TextView.ElementGenerators.Add(elementGenerator);
                activeCustomElementGenerators.Add(elementGenerator);
            }

            Debug.WriteLine("  Set-up: {0}", w.Elapsed); w.Restart();
            textEditor.Document = textOutput.GetDocument();
            Debug.WriteLine("  Assigning document: {0}", w.Elapsed); w.Restart();
            if (textOutput.Foldings.Count > 0)
            {
                if (state != null)
                {
                    state.RestoreFoldings(textOutput.Foldings);
                    textEditor.ScrollToVerticalOffset(state.VerticalOffset);
                    textEditor.ScrollToHorizontalOffset(state.HorizontalOffset);
                }
                foldingManager = FoldingManager.Install(textEditor.TextArea);
                foldingManager.UpdateFoldings(textOutput.Foldings.OrderBy(f => f.StartOffset), -1);
                Debug.WriteLine("  Updating folding: {0}", w.Elapsed); w.Restart();
            }
        }
Beispiel #16
0
 public void UnnstallFoldingManager()
 {
     if (FoldingManager != null)
     {
         FoldingManager.Uninstall(FoldingManager);
         FoldingManager = null;
     }
 }
Beispiel #17
0
 private void UninstallFolding()
 {
     if (_foldingManager != null)
     {
         FoldingManager.Uninstall(_foldingManager);
         _foldingManager = null;
     }
 }
        void RemoveExistingFoldingManager(AvalonEditTextEditorAdapter textEditorAdapter)
        {
            var existingFoldingManager = textEditorAdapter.TextEditor.TextArea.GetService(typeof(FoldingManager)) as FoldingManager;

            if (existingFoldingManager != null)
            {
                FoldingManager.Uninstall(existingFoldingManager);
            }
        }
Beispiel #19
0
 public void ResetFoldingManager()
 {
     if (_foldingManager != null)
     {
         FoldingManager.Uninstall(_foldingManager);
     }
     _foldingManager = FoldingManager.Install(this.editor.TextArea);
     UpdateFoldings();
 }
        private void UninstallFoldingManager()
        {
            _foldingTimer.Stop();
            _foldingTimer.Tick -= OnFoldingTimerTick;
            _foldingTimer       = null;

            FoldingManager.Uninstall(FoldingManager);
            FoldingManager = null;
        }
Beispiel #21
0
 private void Editor_PropertyChanging(object sender, PropertyChangingEventArgs e)
 {
     if (e.PropertyName == "Document")
     {
         FoldingManager.Uninstall(this.FoldingManager);
         this.FoldingManager       = null;
         this.IgnoreNextTextChange = true;
     }
     ;
 }
Beispiel #22
0
 public void Dispose()
 {
     m_Timer.Stop();
     m_Timer.Tick -= OnTimerTick;
     if (FoldingManager != null)
     {
         FoldingManager.Uninstall(FoldingManager);
         FoldingManager = null;
     }
 }
        private void TextEditor_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (_currentFoldingManager == null)
            {
                return;
            }

            FoldingManager.Uninstall(_currentFoldingManager);
            _currentFoldingManager = null;
        }
Beispiel #24
0
        /// <summary>
        /// Shows the given output in the text view.
        /// </summary>
        void ShowOutput(AvalonEditTextOutput textOutput, IHighlightingDefinition highlighting = null, DecompilerTextViewState state = null)
        {
            Debug.WriteLine("Showing {0} characters of output", textOutput.TextLength);
            Stopwatch w = Stopwatch.StartNew();

            ClearLocalReferenceMarks();
            textEditor.ScrollToHome();
            if (foldingManager != null)
            {
                FoldingManager.Uninstall(foldingManager);
                foldingManager = null;
            }
            textEditor.Document                  = null; // clear old document while we're changing the highlighting
            uiElementGenerator.UIElements        = textOutput.UIElements;
            referenceElementGenerator.References = textOutput.References;
            references       = textOutput.References;
            definitionLookup = textOutput.DefinitionLookup;
            textEditor.SyntaxHighlighting = highlighting;

            // Change the set of active element generators:
            foreach (var elementGenerator in activeCustomElementGenerators)
            {
                textEditor.TextArea.TextView.ElementGenerators.Remove(elementGenerator);
            }
            activeCustomElementGenerators.Clear();

            foreach (var elementGenerator in textOutput.elementGenerators)
            {
                textEditor.TextArea.TextView.ElementGenerators.Add(elementGenerator);
                activeCustomElementGenerators.Add(elementGenerator);
            }

            Debug.WriteLine("  Set-up: {0}", w.Elapsed); w.Restart();
            textEditor.Document = textOutput.GetDocument();
            Debug.WriteLine("  Assigning document: {0}", w.Elapsed); w.Restart();
            if (textOutput.Foldings.Count > 0)
            {
                if (state != null)
                {
                    state.RestoreFoldings(textOutput.Foldings);
                    textEditor.ScrollToVerticalOffset(state.VerticalOffset);
                    textEditor.ScrollToHorizontalOffset(state.HorizontalOffset);
                }
                foldingManager = FoldingManager.Install(textEditor.TextArea);
                foldingManager.UpdateFoldings(textOutput.Foldings.OrderBy(f => f.StartOffset), -1);
                Debug.WriteLine("  Updating folding: {0}", w.Elapsed); w.Restart();
            }

            // update class bookmarks
            var document = textEditor.Document;

            manager.UpdateClassMemberBookmarks(textOutput.DefinitionLookup.ToDictionary(line => document.GetLineByOffset(line).LineNumber),
                                               typeof(TypeBookmark),
                                               typeof(MemberBookmark));
        }
Beispiel #25
0
        void HighlightingComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (textEditor != null && textEditor.SyntaxHighlighting == null)
            {
                foldingStrategy = null;
            }
            else if (textEditor != null)
            {
                string       Syntax   = string.Empty;
                ComboBoxItem selected = SyntaxBox.SelectedValue as ComboBoxItem;
                if (selected != null)
                {
                    Syntax = selected.Content.ToString();
                }
                switch (Syntax)
                {
                case "XML":
                case "HTML":
                case "ASP/XHTML":
                    textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
                    foldingStrategy = new XmlFoldingStrategy();
                    break;

                case "C#":
                case "C++":
                case "PHP":
                case "Java":
                case "JavaScript":
                    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);
                }
                UpdateFoldings();
            }
            else
            {
                if (foldingManager != null)
                {
                    FoldingManager.Uninstall(foldingManager);
                    foldingManager = null;
                }
            }
        }
Beispiel #26
0
        public void SetFolding(IHighlightingDefinition SyntaxHighlighting)
        {
            if (SyntaxHighlighting == null)
            {
                foldingStrategy = null;
            }
            else
            {
                switch (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 (textEditor.Document != null)
                {
                    if (foldingManager == null)
                    {
                        foldingManager = FoldingManager.Install(textEditor.TextArea);
                    }

                    foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);
                }
                else
                {
                    _InstallFoldingManager = true;
                }
            }
            else
            {
                if (foldingManager != null)
                {
                    FoldingManager.Uninstall(foldingManager);
                    foldingManager = null;
                }
            }
        }
Beispiel #27
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_foldingManager != null)
         {
             FoldingManager.Uninstall(_foldingManager);
             _foldingManager = null;
         }
     }
 }
Beispiel #28
0
        static public void GetStrategyFromName2(this TextEditor editor, IEditorContext control)
        {
            FoldingManager.Uninstall(control.FoldingManager);
            AbstractFoldingStrategy NewFoldingStrategy     = null;
            IIndentationStrategy    NewIndentationStrategy = null;

            if (editor.SyntaxHighlighting == null)
            {
            }                                                    //control.FoldingStrategy = null;
            else
            {
                switch (editor.SyntaxHighlighting.Name)
                {
                case "XML":
                    NewFoldingStrategy     = new XmlFoldingStrategy();
                    NewIndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
                    break;

                case "C#":
                case "C++":
                case "PHP":
                case "Java":
                    NewFoldingStrategy     = new CSharpPragmaRegionFoldingStrategy();
                    NewIndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy();
                    break;

                default:
                    NewFoldingStrategy     = new CSharpPragmaRegionFoldingStrategy();
                    NewIndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
                    break;
                }
            }
            //control.FoldingStrategy is not assigned
            //control.FoldingStrategy,editor.TextArea.IndentationStrategy
            if (NewFoldingStrategy != null)
            {
                control.FoldingStrategy = NewFoldingStrategy;
                if (control.FoldingManager == null)
                {
                    control.FoldingManager = FoldingManager.Install(editor.TextArea);
                }

                control.FoldingStrategy.UpdateFoldings(control.FoldingManager, editor.Document);
            }
            else
            {
                if (control.FoldingManager != null)
                {
                    FoldingManager.Uninstall(control.FoldingManager);
                    control.FoldingManager = null;
                }
            }
        }
Beispiel #29
0
        /// <summary>
        /// Setup the foldings of the text editor.
        /// </summary>
        /// <param name="textEditor">The text editor</param>
        public void TextEditor_Foldings(TextEditor textEditor)
        {
            if (_foldingManager != null)
            {
                FoldingManager.Uninstall(_foldingManager);
            }

            _foldingManager = FoldingManager.Install(textEditor.TextArea);
            var foldingStrategy = new AvalonEdit_BraceFoldingStrategy();

            foldingStrategy.UpdateFoldings(_foldingManager, textEditor.Document);
        }
Beispiel #30
0
        private void Fold()
        {
            if (this.txtEditor.SyntaxHighlighting == null)
            {
                foldingStrategy = null;
            }
            else
            {
                foldingStrategy = new BeginEndFoldingStrategy();
                txtEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();

                if (false)
                {
                    switch (txtEditor.SyntaxHighlighting.Name)
                    {
                    case "XML":
                        foldingStrategy = new XmlFoldingStrategy();
                        txtEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
                        break;

                    case "C#":
                    case "C++":
                    case "PHP":
                    case "Java":
                        txtEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(txtEditor.Options);
                        foldingStrategy = new BraceFoldingStrategy();
                        break;

                    default:
                        txtEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
                        foldingStrategy = null;
                        break;
                    }
                }
            }
            if (foldingStrategy != null)
            {
                if (foldingManager == null)
                {
                    foldingManager = FoldingManager.Install(txtEditor.TextArea);
                }
                foldingStrategy.UpdateFoldings(foldingManager, txtEditor.Document);
            }
            else
            {
                if (foldingManager != null)
                {
                    FoldingManager.Uninstall(foldingManager);
                    foldingManager = null;
                }
            }
        }