UpdateFoldings() публичный Метод

Create NewFoldings for the specified document and updates the folding manager with them.
public UpdateFoldings ( ICSharpCode.AvalonEdit.Folding.FoldingManager manager, TextDocument document ) : void
manager ICSharpCode.AvalonEdit.Folding.FoldingManager
document ICSharpCode.AvalonEdit.Document.TextDocument
Результат void
Пример #1
0
        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();
        }
Пример #2
0
        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;
        }
Пример #3
0
        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();
        }
Пример #4
0
        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;
        }
Пример #5
0
        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;
        }
Пример #6
0
        private void InstallFoldingStrategy()
        {
            foldingManager = FoldingManager.Install(textEditor.TextArea);
            foldingStrategy = new BraceFoldingStrategy();
            foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);

            AddFoldingStrategyTimer();
        }