protected override void Initialize() { base.Initialize(); VSUtils.ForegroundThreadGuard.BindThread(); var componentModel = (IComponentModel)GetService(typeof(SComponentModel)); classificationColorManager = componentModel.DefaultExportProvider.GetExportedValue<ClassificationColorManager>(); shellService = GetService(typeof(SVsShell)) as IVsShell; if (shellService != null) ErrorHandler.ThrowOnFailure(shellService.AdviseBroadcastMessages(this, out broadcastEventCookie)); IServiceContainer serviceContainer = this; serviceContainer.AddService(typeof(GeneralOptionsPage), delegate { return GetDialogPage(typeof(GeneralOptionsPage)); }, promote:true); serviceContainer.AddService(typeof(FantomasOptionsPage), delegate { return GetDialogPage(typeof(FantomasOptionsPage)); }, promote:true); OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; var shell = GetService(typeof(SVsUIShell)) as IVsUIShell; var logger = new Logger(ServiceProvider.GlobalProvider); if (mcs != null) { var newFolderMenu = new FolderMenuCommands(DTE.Value, mcs, shell); newFolderMenu.SetupCommands(); } }
private void AdviseBroadcastMessages() { shellService = serviceProvider.GetService(typeof(SVsShell)) as IVsShell; if (shellService != null) ErrorHandler.ThrowOnFailure(shellService.AdviseBroadcastMessages(this, out broadcastEventCookie)); }
/// <summary> /// Initializes a new instance of the <see cref="ShellEventListener"/> class. /// </summary> /// <param name="package">The package hosting the event listener.</param> /// <param name="shellService">The shell service.</param> internal ShellEventListener(EditorConfigPackage package, IVsShell shellService) : base(package) { _shellService = shellService; if (_shellService == null) return; _shellService.AdviseBroadcastMessages(this, out _broadcastEventCookie); _shellService.AdviseShellPropertyChanges(this, out _propertyEventCookie); }
public void Initialize() { shellService = provider.GetService(typeof(SVsShell)) as IVsShell; if (shellService != null) { ErrorHandler.ThrowOnFailure(shellService.AdviseBroadcastMessages(this, out cookie)); } }
internal ShellEvents() { ThreadHelper.ThrowIfNotOnUIThread(); IVsShell svc = VS.GetRequiredService <SVsShell, IVsShell>(); svc.AdviseShellPropertyChanges(this, out _); svc.AdviseBroadcastMessages(this, out _); }
private void AdviseBroadcastMessages() { shellService = serviceProvider.GetService(typeof(SVsShell)) as IVsShell; if (shellService != null) { ErrorHandler.ThrowOnFailure(shellService.AdviseBroadcastMessages(this, out broadcastEventCookie)); } }
public VisualStudioThemeEngine(IServiceProvider serviceProvider) { dte = (DTE2)serviceProvider.GetService(typeof(SDTE)); // Register to Visual Studio theme change shellService = serviceProvider.GetService(typeof(SVsShell)) as IVsShell; if (shellService != null) ErrorHandler.ThrowOnFailure(shellService.AdviseBroadcastMessages(this, out broadcastCookie)); }
/// <summary> /// Initializes a new instance of the <see cref="ShellEventListener" /> class. /// </summary> /// <param name="package">The package hosting the event listener.</param> /// <param name="shellService">The shell service.</param> internal ShellEventListener(CodeMaidPackage package, IVsShell shellService) : base(package) { _shellService = shellService; if (_shellService != null) { _shellService.AdviseBroadcastMessages(this, out _broadcastEventCookie); _shellService.AdviseShellPropertyChanges(this, out _propertyEventCookie); } }
/// <summary> /// Initializes a new instance of the <see cref="ShellEventListener"/> class. /// </summary> /// <param name="package">The package hosting the event listener.</param> /// <param name="shellService">The shell service.</param> internal ShellEventListener(VSTalkPackage package, IVsShell shellService) : base(package) { _shellService = shellService; if (_shellService != null) { _shellService.AdviseBroadcastMessages(this, out _broadcastEventCookie); _shellService.AdviseShellPropertyChanges(this, out _propertyEventCookie); } }
public VsUIServices(ICoreShell coreShell) { ProgressDialog = new VsProgressDialog(coreShell.Services); FileDialog = new VsFileDialog(coreShell); _coreShell = coreShell; _vsShell = VsPackage.GetGlobalService(typeof(SVsShell)) as IVsShell; _vsShell.AdviseBroadcastMessages(this, out _vsShellBroadcastEventsCookie); _uiShell = VsPackage.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell; }
/*private static Dictionary<string, Themes> DefaultThemes { get; } = new Dictionary<string, Themes> { * { "de3dbbcd-f642-433c-8353-8f1df4370aba", Themes.Light }, * { "a4d6a176-b948-4b29-8c66-53c97a1ed7d0", Themes.Light }, * { "1ded0138-47ce-435e-84ef-9ec1f439b749", Themes.Dark } * };*/ #endregion #region Init public static bool Initialize(IVsShell Shell) { try { ThreadHelper.ThrowIfNotOnUIThread(); return(Shell.AdviseBroadcastMessages(new ThemeListener(), out _) == VSConstants.S_OK); } catch { return(false); } }
/// <summary> /// Initializes a new instance of the <see cref="ShellEventListener"/> class. /// </summary> /// <param name="package">The package hosting the event listener.</param> /// <param name="shellService">The shell service.</param> internal ShellEventListener(EditorConfigPackage package, IVsShell shellService) : base(package) { _shellService = shellService; if (_shellService == null) { return; } _shellService.AdviseBroadcastMessages(this, out _broadcastEventCookie); _shellService.AdviseShellPropertyChanges(this, out _propertyEventCookie); }
public VisualStudioThemeEngine(IServiceProvider serviceProvider) { dte = (DTE2)serviceProvider.GetService(typeof(SDTE)); // Register to Visual Studio theme change shellService = serviceProvider.GetService(typeof(SVsShell)) as IVsShell; if (shellService != null) { ErrorHandler.ThrowOnFailure(shellService.AdviseBroadcastMessages(this, out broadcastCookie)); } }
// -------------------------------------------------------------------------------------------- /// <summary> /// Creates the pane window. /// </summary> /// <param name = "hwndParent">Handle to the parent window.</param> /// <param name = "x">Absolute x ordinate.</param> /// <param name = "y">Absolute y ordinate.</param> /// <param name = "cx">x ordinate relative to x.</param> /// <param name = "cy">y ordinate relative to y.</param> /// <param name = "pane">Pointer to a handle to the new window pane.</param> /// <returns> /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. /// </returns> // -------------------------------------------------------------------------------------------- int IVsWindowPane.CreatePaneWindow(IntPtr hwndParent, int x, int y, int cx, int cy, out IntPtr pane) { OnCreate(); IntPtr hwnd = Window.Handle; var style = (int)UnsafeNativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_STYLE); // --- Set up the required styles of an IVsWindowPane style |= (NativeMethods.WS_CLIPSIBLINGS | NativeMethods.WS_CHILD | NativeMethods.WS_VISIBLE); style &= ~(NativeMethods.WS_POPUP | NativeMethods.WS_MINIMIZE | NativeMethods.WS_MAXIMIZE | NativeMethods.WS_DLGFRAME | NativeMethods.WS_SYSMENU | NativeMethods.WS_THICKFRAME | NativeMethods.WS_MINIMIZEBOX | NativeMethods.WS_MAXIMIZEBOX); UnsafeNativeMethods.SetWindowLong(hwnd, NativeMethods.GWL_STYLE, (IntPtr)style); style = (int)UnsafeNativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_EXSTYLE); style &= ~(NativeMethods.WS_EX_DLGMODALFRAME | NativeMethods.WS_EX_NOPARENTNOTIFY | NativeMethods.WS_EX_TOPMOST | NativeMethods.WS_EX_MDICHILD | NativeMethods.WS_EX_TOOLWINDOW | NativeMethods.WS_EX_CONTEXTHELP | NativeMethods.WS_EX_APPWINDOW); UnsafeNativeMethods.SetWindowLong(hwnd, NativeMethods.GWL_EXSTYLE, (IntPtr)style); UnsafeNativeMethods.SetParent(hwnd, hwndParent); UnsafeNativeMethods.SetWindowPos(hwnd, IntPtr.Zero, x, y, cx, cy, NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE); UnsafeNativeMethods.ShowWindow(hwnd, NativeMethods.SW_SHOWNORMAL); // --- Sync broadcast events so we update our UI when colors/fonts change. if (_VsShell == null) { _VsShell = GetService <SVsShell, IVsShell>(); if (_VsShell != null) { NativeMethods.ThrowOnFailure(_VsShell.AdviseBroadcastMessages(this, out _BroadcastEventCookie)); } } pane = hwnd; return(NativeMethods.S_OK); }
// /// <include file='doc\VsWindowPane.uex' path='docs/doc[@for="VsWindowPane.CreatePaneWindow"]/*' /> /// <devdoc> /// Called by Visual Studio when it wants to open this window pane. /// </devdoc> public virtual int CreatePaneWindow(IntPtr hwndParent, int x, int y, int cx, int cy, out IntPtr pane) { IntPtr hwnd = GetWindow().Handle; int style = (int)NativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_STYLE); // set up the required styles of an IVsWindowPane style |= (NativeMethods.WS_CLIPSIBLINGS | NativeMethods.WS_CHILD | NativeMethods.WS_VISIBLE); style &= ~(NativeMethods.WS_POPUP | NativeMethods.WS_MINIMIZE | NativeMethods.WS_MAXIMIZE | NativeMethods.WS_DLGFRAME | NativeMethods.WS_SYSMENU | NativeMethods.WS_THICKFRAME | NativeMethods.WS_MINIMIZEBOX | NativeMethods.WS_MAXIMIZEBOX); NativeMethods.SetWindowLong(hwnd, NativeMethods.GWL_STYLE, (IntPtr)style); style = (int)NativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_EXSTYLE); style &= ~(NativeMethods.WS_EX_DLGMODALFRAME | NativeMethods.WS_EX_NOPARENTNOTIFY | NativeMethods.WS_EX_TOPMOST | NativeMethods.WS_EX_MDICHILD | NativeMethods.WS_EX_TOOLWINDOW | NativeMethods.WS_EX_CONTEXTHELP | NativeMethods.WS_EX_APPWINDOW); NativeMethods.SetWindowLong(hwnd, NativeMethods.GWL_EXSTYLE, (IntPtr)style); NativeMethods.SetParent(hwnd, (IntPtr)hwndParent); NativeMethods.SetWindowPos(hwnd, IntPtr.Zero, x, y, cx, cy, NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE); NativeMethods.ShowWindow(hwnd, NativeMethods.SW_SHOWNORMAL); // Sync broadcast events so we update our UI when colors/fonts change. // if (vsBroadcastEventCookie == 0) { vsShell = (IVsShell)GetService(typeof(IVsShell)); if (vsShell != null) { vsShell.AdviseBroadcastMessages(this, ref vsBroadcastEventCookie); } } OnWindowPaneCreate(); pane = hwnd; return(NativeMethods.S_OK); }
public int Create(IntPtr parent, out IntPtr pHandle) { IntPtr hwnd = _pane.Window.Handle; int style = (int)UnsafeNativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_STYLE); // set up the required styles of an IVsWindowPane style |= (NativeMethods.WS_CLIPSIBLINGS | NativeMethods.WS_CHILD | NativeMethods.WS_VISIBLE); style &= ~(NativeMethods.WS_POPUP | NativeMethods.WS_MINIMIZE | NativeMethods.WS_MAXIMIZE | NativeMethods.WS_DLGFRAME | NativeMethods.WS_SYSMENU | NativeMethods.WS_THICKFRAME | NativeMethods.WS_MINIMIZEBOX | NativeMethods.WS_MAXIMIZEBOX); UnsafeNativeMethods.SetWindowLong(hwnd, NativeMethods.GWL_STYLE, (IntPtr)style); style = (int)UnsafeNativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_EXSTYLE); style &= ~(NativeMethods.WS_EX_DLGMODALFRAME | NativeMethods.WS_EX_NOPARENTNOTIFY | NativeMethods.WS_EX_TOPMOST | NativeMethods.WS_EX_MDICHILD | NativeMethods.WS_EX_TOOLWINDOW | NativeMethods.WS_EX_CONTEXTHELP | NativeMethods.WS_EX_APPWINDOW); UnsafeNativeMethods.SetWindowLong(hwnd, NativeMethods.GWL_EXSTYLE, (IntPtr)style); UnsafeNativeMethods.SetParent(hwnd, (IntPtr)parent); // UnsafeNativeMethods.SetWindowPos(hwnd, IntPtr.Zero, x, y, cx, cy, NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE); UnsafeNativeMethods.ShowWindow(hwnd, NativeMethods.SW_SHOWNORMAL); // Sync broadcast events so we update our UI when colors/fonts change. // if (_vsShell == null) { _vsShell = ServiceProvider.GlobalProvider.GetService(typeof(SVsShell)) as IVsShell; if (_vsShell != null) { NativeMethods.ThrowOnFailure(_vsShell.AdviseBroadcastMessages(this, out _broadcastEventCookie)); } } pHandle = hwnd; return(NativeMethods.S_OK); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); try { if (VisualStudio.Solution != null) { Log.Message("Starting Tidy Tabs inside Visual Studio {0} {1} for solution {2}", VisualStudio.Edition, VisualStudio.Version, VisualStudio.Solution.FullName); } windowEvents = VisualStudio.Events.WindowEvents; documentEvents = VisualStudio.Events.DocumentEvents; textEditorEvents = VisualStudio.Events.TextEditorEvents; solutionEvents = VisualStudio.Events.SolutionEvents; buildEvents = VisualStudio.Events.BuildEvents; windowEvents.WindowActivated += WindowEventsWindowActivated; documentEvents.DocumentClosing += DocumentEventsOnDocumentClosing; documentEvents.DocumentSaved += DocumentEventsOnDocumentSaved; textEditorEvents.LineChanged += TextEditorEventsOnLineChanged; solutionEvents.Opened += SolutionEventsOnOpened; buildEvents.OnBuildBegin += BuildEventsOnOnBuildBegin; shell = (IVsShell)GetService(typeof(SVsShell)); if (shell != null) { shell.AdviseBroadcastMessages(this, out shellCookie); } OleMenuCommandService menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (menuCommandService != null) { CommandID menuCommandId = new CommandID(GuidList.guidTidyTabsCmdSet, (int)PkgCmdIDList.cmdidTidyTabs); MenuCommand menuItem = new MenuCommand(TidyTabsMenuItemCommandActivated, menuCommandId); menuCommandService.AddCommand(menuItem); } } catch (Exception ex) { Log.Exception(ex); } }
private void CheckVsStarted() { _vsShell = (IVsShell)VsPackage.GetGlobalService(typeof(SVsShell)); object value; _vsShell.GetProperty((int)__VSSPROPID4.VSSPROPID_ShellInitialized, out value); if (value is bool) { if ((bool)value) { _appConstants.Initialize(); Started?.Invoke(this, EventArgs.Empty); } else { _vsShell.AdviseShellPropertyChanges(this, out _vsShellEventsCookie); } } _vsShell.AdviseBroadcastMessages(this, out _vsShellBroadcastEventsCookie); }
private VirtualMemoryNotificationListener( IThreadingContext threadingContext, IVsShell shell, VisualStudioWorkspace workspace) : base(threadingContext, assertIsForeground: true) { _workspace = workspace; _workspaceCacheService = workspace.Services.GetService <IWorkspaceCacheService>() as WorkspaceCacheService; if (GCSettings.IsServerGC) { // Server GC has been explicitly enabled, which tends to run with higher memory pressure than the // default workstation GC. Allow this case without triggering frequent feature shutdown. return; } _workspace.WorkspaceChanged += OnWorkspaceChanged; // Note: We never unhook this event sink. It lives for the lifetime of the host. ErrorHandler.ThrowOnFailure(shell.AdviseBroadcastMessages(this, out var cookie)); }
/// <include file='doc\WindowPane.uex' path='docs/doc[@for="WindowPane.IVsWindowPane.CreatePaneWindow"]/*' /> /// <internalonly/> /// <devdoc> /// IVsWindowPane implementation. /// </devdoc> int IVsWindowPane.CreatePaneWindow(IntPtr hwndParent, int x, int y, int cx, int cy, out IntPtr pane) { OnCreate(); IntPtr hwnd = Window.Handle; int style = (int)UnsafeNativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_STYLE); // set up the required styles of an IVsWindowPane style |= (NativeMethods.WS_CLIPSIBLINGS | NativeMethods.WS_CHILD | NativeMethods.WS_VISIBLE); style &= ~(NativeMethods.WS_POPUP | NativeMethods.WS_MINIMIZE | NativeMethods.WS_MAXIMIZE | NativeMethods.WS_DLGFRAME | NativeMethods.WS_SYSMENU | NativeMethods.WS_THICKFRAME | NativeMethods.WS_MINIMIZEBOX | NativeMethods.WS_MAXIMIZEBOX); UnsafeNativeMethods.SetWindowLong(hwnd, NativeMethods.GWL_STYLE, (IntPtr)style); style = (int)UnsafeNativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_EXSTYLE); style &= ~(NativeMethods.WS_EX_DLGMODALFRAME | NativeMethods.WS_EX_NOPARENTNOTIFY | NativeMethods.WS_EX_TOPMOST | NativeMethods.WS_EX_MDICHILD | NativeMethods.WS_EX_TOOLWINDOW | NativeMethods.WS_EX_CONTEXTHELP | NativeMethods.WS_EX_APPWINDOW); UnsafeNativeMethods.SetWindowLong(hwnd, NativeMethods.GWL_EXSTYLE, (IntPtr)style); UnsafeNativeMethods.SetParent(hwnd, (IntPtr)hwndParent); UnsafeNativeMethods.SetWindowPos(hwnd, IntPtr.Zero, x, y, cx, cy, NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE); UnsafeNativeMethods.ShowWindow(hwnd, NativeMethods.SW_SHOWNORMAL); // Sync broadcast events so we update our UI when colors/fonts change. // if (_vsShell == null) { _vsShell = (IVsShell)GetService(typeof(SVsShell)); if (_vsShell != null) { NativeMethods.ThrowOnFailure(_vsShell.AdviseBroadcastMessages(this, out _broadcastEventCookie)); } } pane = hwnd; return NativeMethods.S_OK; }
public ShellEventListener([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider) { _shell = serviceProvider.GetService<SVsShell, IVsShell>(); ErrorHandler.ThrowOnFailure(_shell.AdviseBroadcastMessages(this, out _broadcastEventCookie)); }
public ShellEventListener([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider) { _shell = serviceProvider.GetService <SVsShell, IVsShell>(); ErrorHandler.ThrowOnFailure(_shell.AdviseBroadcastMessages(this, out _broadcastEventCookie)); }