private async void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs args) { _viewModel = (OpenDocumentViewModel)args.NewValue; _viewModel.NuGet.PackageInstalled += NuGetOnPackageInstalled; _roslynHost = _viewModel.MainViewModel.RoslynHost; var avalonEditTextContainer = new AvalonEditTextContainer(Editor); await _viewModel.Initialize( avalonEditTextContainer, a => _syncContext.Post(o => ProcessDiagnostics(a), null), text => avalonEditTextContainer.UpdateText(text) ).ConfigureAwait(true); Editor.Document.UndoStack.ClearAll(); Editor.TextArea.TextView.LineTransformers.Insert(0, new RoslynHighlightingColorizer(_viewModel.DocumentId, _roslynHost)); _contextActionsRenderer = new ContextActionsRenderer(Editor, _textMarkerService); _contextActionsRenderer.Providers.Add(new RoslynContextActionProvider(_viewModel.DocumentId, _roslynHost)); Editor.CompletionProvider = new RoslynCodeEditorCompletionProvider(_viewModel.DocumentId, _roslynHost); }
public void CreateNewDocument() { var openDocument = new OpenDocumentViewModel(this, null); OpenDocuments.Add(openDocument); CurrentOpenDocument = openDocument; }
public void OpenDocument(DocumentViewModel document) { var openDocument = OpenDocuments.FirstOrDefault(x => x.Document == document); if (openDocument == null) { openDocument = new OpenDocumentViewModel(this, document); OpenDocuments.Add(openDocument); } CurrentOpenDocument = openDocument; }