Exemplo n.º 1
0
        internal void EnableFolding(bool enableFolding)
        {
            if (enableFolding)
            {
                switch (innerType)
                {
                    case Enumerations.WebResourceType.Script:
                    case Enumerations.WebResourceType.Css:
                        {
                            if (!foldingManagerInstalled)
                            {
                                foldingManager = FoldingManager.Install(textEditor.TextArea);
                                foldingManagerInstalled = true;
                            }

                            foldingManager.UpdateFoldings(CreateBraceFoldings(textEditor.Document), -1);
                        }
                        break;

                    case Enumerations.WebResourceType.WebPage:
                        {
                            if (!foldingManagerInstalled)
                            {
                                foldingManager = FoldingManager.Install(textEditor.TextArea);
                                foldingManagerInstalled = true;
                            }

                            htmlFoldingStrategy = new HtmlFoldingStrategy();
                            htmlFoldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);
                        }
                        break;

                    case Enumerations.WebResourceType.Data:
                    case Enumerations.WebResourceType.Xsl:
                        {
                            if (!foldingManagerInstalled)
                            {
                                foldingManager = FoldingManager.Install(textEditor.TextArea);
                                foldingManagerInstalled = true;
                            }

                            xmlFoldingStrategy = new XmlFoldingStrategy();
                            xmlFoldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);
                        }
                        break;
                }

                FoldingEnabled = true;
            }
            else
            {
                if (foldingManager != null)
                {
                    foldingManager.Clear();
                }

                FoldingEnabled = false;
            }
        }
Exemplo n.º 2
0
        private void init()
        {
            foldingStrategy = new XmlFoldingStrategy();
            textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();

            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;
        }
 private void SetLanguage(string fileSystemPath)
 {
     switch ((Path.GetExtension(fileSystemPath) ?? "").ToUpperInvariant())
     {
         case ".XML":
             _textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML");
             _foldingManager = FoldingManager.Install(_textEditor.TextArea);
             _foldingStrategy = new XmlFoldingStrategy();
             _foldingStrategy.UpdateFoldings(_foldingManager, _textEditor.Document);
             break;
         case ".SH":
             _textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("TeX");
             break;
         case ".PROP":
             _textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("TeX");
             break;
         case ".SMALI":
             _textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("Java");
             break;
     }
 }
Exemplo n.º 4
-19
 public MiniXamlPage()
 {
     InitializeComponent();
     DataContext = this;
     var foldingManager = FoldingManager.Install(textEditor.TextArea);
     var foldingStrategy = new XmlFoldingStrategy();
     foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);
     textEditor.Options.HighlightCurrentLine = true;
     textEditor.ShowLineNumbers = true;
 }