コード例 #1
0
        internal void RefreshDisplay(IOleServiceProvider oleServiceProvider)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var serviceProvider = oleServiceProvider.GetServiceProvider();
            var vsEditorAdaptersFactoryService = serviceProvider.GetExportedValue <IVsEditorAdaptersFactoryService>();
            var editorFactory = serviceProvider.GetExportedValue <IEditorFactory>();

            var vsTextBuffer = vsEditorAdaptersFactoryService.CreateVsTextBufferAdapter(oleServiceProvider);

            var contentTypeKey = new Guid(0x1beb4195, 0x98f4, 0x4589, 0x80, 0xe0, 0x48, 12, 0xe3, 0x2f, 240, 0x59);
            var vsUserData     = (IVsUserData)vsTextBuffer;

            vsUserData.SetData(ref contentTypeKey, "text");

            string content = GenerateContent();

            vsTextBuffer.InitializeContent(content, content.Length);
            vsTextBuffer.SetStateFlags((uint)BUFFERSTATEFLAGS.BSF_USER_READONLY);

            var textBuffer = vsEditorAdaptersFactoryService.GetDataBuffer(vsTextBuffer);

            var vsTextView = editorFactory.CreateVsTextView(
                vsTextBuffer,
                PredefinedTextViewRoles.Interactive,
                PredefinedTextViewRoles.Document,
                PredefinedTextViewRoles.PrimaryDocument);

            var wpfTextViewHost = vsEditorAdaptersFactoryService.GetWpfTextViewHost(vsTextView);

            _disassemblyControl.TextViewControl = wpfTextViewHost.HostControl;
        }