public static CommandTargetToOleShim ConnectController(IVsEditorAdaptersFactoryService adapterService, ITextView textView, Controller controller) { IVsTextView viewAdapter = adapterService.GetViewAdapter(textView); CommandTargetToOleShim oleControllerShim = null; // Connect main controller to VS text view filter chain. // The chain looks like VS IDE -> language main controller -> Core editor // However, IDE wants IOleCommandTarget and core editor, although managed, // is represented by OLE command target as well. Since R controller // is not specific to VS and does not use OLE, we create OLE-to-managed target shim // and managed target-to-OLE shims. if (viewAdapter != null) { // Create OLE shim that wraps main controller ICommandTarget and represents // it as IOleCommandTarget that is accepted by VS IDE. oleControllerShim = new CommandTargetToOleShim(textView, controller); IOleCommandTarget nextOleTarget; viewAdapter.AddCommandFilter(oleControllerShim, out nextOleTarget); // nextOleTarget is typically a core editor wrapped into OLE layer. // Create a wrapper that will present OLE target as ICommandTarget to // HTML main controller so controller can operate in platform-agnostic way. ICommandTarget nextCommandTarget = VsAppShell.Current.TranslateCommandTarget(textView, nextOleTarget); controller.ChainedController = nextCommandTarget; } return oleControllerShim; }
public HelpWindowVisualComponent() { _session = VsAppShell.Current.ExportProvider.GetExportedValue<IRSessionProvider>().GetInteractiveWindowRSession(); _session.Disconnected += OnRSessionDisconnected; _windowContentControl = new ContentControl(); Control = _windowContentControl; var c = new Controller(); c.AddCommandSet(GetCommands()); Controller = c; CreateBrowser(); VSColorTheme.ThemeChanged += OnColorThemeChanged; }
public HelpVisualComponent() { _codeColorBuilder = VsAppShell.Current.ExportProvider.GetExportedValue<IVignetteCodeColorBuilder>(); _coreShell = VsAppShell.Current.ExportProvider.GetExportedValue<ICoreShell>(); var workflow = VsAppShell.Current.ExportProvider.GetExportedValue<IRInteractiveWorkflowProvider>().GetOrCreate(); workflow.RSessions.BrokerStateChanged += OnBrokerStateChanged; _session = workflow.RSession; _session.Disconnected += OnRSessionDisconnected; _windowContentControl = new ContentControl(); Control = _windowContentControl; var c = new Controller(); c.AddCommandSet(GetCommands()); Controller = c; CreateBrowser(); VSColorTheme.ThemeChanged += OnColorThemeChanged; }