Esempio n. 1
0
        private void CreateTextViewHost(string text, string filePath)
        {
            if (text == null)
            {
                text = string.Empty;
            }

            var diskBuffer = TextBufferFactoryService.CreateTextBuffer(text, ContentType);

            _editorIntance = EditorInstanceFactory.CreateEditorInstance(diskBuffer, _compositionService);

            ITextDataModel textDataModel;

            if (_editorIntance != null)
            {
                textDataModel = new TextDataModel(diskBuffer, _editorIntance.ViewBuffer);
            }
            else
            {
                textDataModel = new TextDataModel(diskBuffer, diskBuffer);
            }

            var textBuffer = textDataModel.DocumentBuffer;

            TextDocument = TextDocumentFactoryService.CreateTextDocument(textBuffer, filePath);

            SetGlobalEditorOptions();

            var textView = TextEditorFactoryService.CreateTextView(textDataModel,
                                                                   new DefaultTextViewRoleSet(),
                                                                   GlobalOptions);

            _wpftextViewHost = TextEditorFactoryService.CreateTextViewHost(textView, true);

            ApplyDefaultSettings();

            _contentControl.Content = _wpftextViewHost.HostControl;

            var baseController = new BaseController();

            BaseController = baseController;

            if (_editorIntance != null)
            {
                CommandTarget = _editorIntance.GetCommandTarget(textView);
                var controller = CommandTarget as Microsoft.Languages.Editor.Controller.Controller;
                controller.ChainedController = baseController;
            }
            else
            {
                CommandTarget = baseController;
            }

            baseController.Initialize(textView, EditorOperations, UndoManager, _coreShell);
        }
Esempio n. 2
0
        private void CreateTextViewHost(string text, string filePath)
        {
            ITextDataModel textDataModel;

            text = text ?? string.Empty;

            var diskBuffer = _textBufferFactoryService.CreateTextBuffer(text, ContentType);
            var cs         = _services.GetService <ICompositionService>();

            _editorViewModel = EditorViewModelFactory.CreateEditorViewModel(diskBuffer, _services);

            if (_editorViewModel != null)
            {
                textDataModel = new TextDataModel(diskBuffer, _editorViewModel.ViewBuffer.As <ITextBuffer>());
            }
            else
            {
                textDataModel = new TextDataModel(diskBuffer, diskBuffer);
            }

            var textBuffer = textDataModel.DocumentBuffer;

            TextDocument = _textDocumentFactoryService.CreateTextDocument(textBuffer, filePath);

            SetGlobalEditorOptions();
            var textView = _textEditorFactoryService.CreateTextView(textDataModel,
                                                                    new DefaultTextViewRoleSet(),
                                                                    GlobalOptions);

            _wpftextViewHost = _textEditorFactoryService.CreateTextViewHost(textView, true);

            ApplyDefaultSettings();
            Control.Content = _wpftextViewHost.HostControl;

            var baseController = new BaseController();

            BaseController = baseController;

            if (_editorViewModel != null)
            {
                CommandTarget = _editorViewModel.GetCommandTarget(textView.ToEditorView());
                var controller = CommandTarget as Common.Core.UI.Commands.Controller;
                Debug.Assert(controller != null);
                controller.ChainedController = baseController;
            }
            else
            {
                CommandTarget = baseController;
            }

            baseController.Initialize(textView, EditorOperations, UndoManager, _services);
        }
Esempio n. 3
0
        private void CreateTextViewHost(string text, string filePath) {
            if (text == null)
                text = string.Empty;

            var diskBuffer = TextBufferFactoryService.CreateTextBuffer(text, ContentType);
            _editorIntance = EditorInstanceFactory.CreateEditorInstance(diskBuffer, _compositionService);

            ITextDataModel textDataModel;

            if (_editorIntance != null) {
                textDataModel = new TextDataModel(diskBuffer, _editorIntance.ViewBuffer);
            } else {
                textDataModel = new TextDataModel(diskBuffer, diskBuffer);
            }

            var textBuffer = textDataModel.DocumentBuffer;
            TextDocument = TextDocumentFactoryService.CreateTextDocument(textBuffer, filePath);

            SetGlobalEditorOptions();

            var textView = TextEditorFactoryService.CreateTextView(textDataModel,
                                                                   new DefaultTextViewRoleSet(),
                                                                   GlobalOptions);
            _wpftextViewHost = TextEditorFactoryService.CreateTextViewHost(textView, true);

            ApplyDefaultSettings();

            _contentControl.Content = _wpftextViewHost.HostControl;

            var baseController = new BaseController();
            BaseController = baseController;

            if (_editorIntance != null) {
                CommandTarget = _editorIntance.GetCommandTarget(textView);
                var controller = CommandTarget as Microsoft.Languages.Editor.Controller.Controller;
                controller.ChainedController = baseController;
            } else {
                CommandTarget = baseController;
            }

            baseController.Initialize(textView, EditorOperations, UndoManager, _coreShell);
        }