internal static bool ContainsImmediateWindow(this IEnumerable<IVsTextView> vsTextViews, IVsUIShell shellService, IVsEditorAdaptersFactoryService _editorAdaptersFactoryService) { IEnumWindowFrames windowEnum = null; Marshal.ThrowExceptionForHR(shellService.GetToolWindowEnum(out windowEnum)); IVsWindowFrame[] frame = new IVsWindowFrame[1]; uint value; var immediateWindowGuid = Guid.Parse(ToolWindowGuids80.ImmediateWindow); while (windowEnum.Next(1, frame, out value) == VSConstants.S_OK) { Guid toolWindowGuid; Marshal.ThrowExceptionForHR(frame[0].GetGuidProperty((int)__VSFPROPID.VSFPROPID_GuidPersistenceSlot, out toolWindowGuid)); if (toolWindowGuid == immediateWindowGuid) { IntPtr frameTextView; Marshal.ThrowExceptionForHR(frame[0].QueryViewInterface(typeof(IVsTextView).GUID, out frameTextView)); try { var immediateWindowTextView = Marshal.GetObjectForIUnknown(frameTextView) as IVsTextView; var immediateWindowWpfTextView = _editorAdaptersFactoryService.GetWpfTextView(immediateWindowTextView); return vsTextViews.Any(vsTextView => _editorAdaptersFactoryService.GetWpfTextView(vsTextView) == immediateWindowWpfTextView); } finally { Marshal.Release(frameTextView); } } } return false; }
private void InitializeContent() { _uiShell = GetService(typeof(SVsUIShell)) as IVsUIShell; _dte = GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; _infoBarFactory = GetService(typeof(SVsInfoBarUIFactory)) as IVsInfoBarUIFactory; if (CookiecutterClientProvider.IsCompatiblePythonAvailable()) { ShowCookiecutterPage(); } else { ShowMissingDependenciesPage(); } if (CookiecutterPackage.Instance.ShowHelp) { AddInfoBar(); } RegisterCommands(new Command[] { new HomeCommand(this), new RunCommand(this), new UpdateCommand(this), new CheckForUpdatesCommand(this), new GitHubCommand(this, PackageIds.cmdidLinkGitHubHome), new GitHubCommand(this, PackageIds.cmdidLinkGitHubIssues), new GitHubCommand(this, PackageIds.cmdidLinkGitHubWiki), }, PackageGuids.guidCookiecutterCmdSet); RegisterCommands(new Command[] { new DeleteInstalledTemplateCommand(this), }, VSConstants.GUID_VSStandardCommandSet97); }
/// <summary> /// Retrieves captions and positions of all active tool windows /// </summary> /// <returns></returns> public static IEnumerable<ToolWindowData> GetToolWindowData(IVsUIShell shell) { var data = new List<ToolWindowData>(); try { IEnumWindowFrames e; shell.GetToolWindowEnum(out e); IVsWindowFrame[] frame = new IVsWindowFrame[1]; uint fetched = 0; while (VSConstants.S_OK == e.Next(1, frame, out fetched) && fetched > 0) { object objCaption; frame[0].GetProperty((int)__VSFPROPID.VSFPROPID_Caption, out objCaption); VSSETFRAMEPOS[] pos = new VSSETFRAMEPOS[1]; Guid relative; int x, y, cx, cy; frame[0].GetFramePos(pos, out relative, out x, out y, out cx, out cy); var d = new ToolWindowData() { Caption = objCaption as string, X = x, Y = y, Width = cx, Height = cy }; data.Add(d); } } catch (Exception) { } return data; }
/// <summary> /// Attempts to run the template wizard. /// </summary> /// <param name="shell">The <see cref="IVsUIShell">shell</see> associated with the wizard.</param> /// <returns>True if the wizard completed successfully; otherwise, false if the wizard was canceled.</returns> protected override bool TryRunWizard( IVsUIShell shell ) { Arg.NotNull( shell, nameof( shell ) ); createNewViewModel = false; var mapper = new ViewReplacementsMapper( Project ); var model = new ViewItemTemplateWizardViewModel(); // map replacements to model mapper.Map( Context.Replacements, model ); // only show the dialog if the context is interactive if ( Context.IsInteractive ) { var projectInfo = new ProjectInformation( Project ); var view = new ViewItemTemplateWizard( model, projectInfo ); // show the wizard if ( !( view.ShowDialog( shell ) ?? false ) ) return false; } // map model back to replacements mapper.Map( model, Context.Replacements ); // store information for view model template, which typically follows createNewViewModel = model.ViewModelOption == 1; viewModelTemplateKey = model.IsTopLevelSupported && model.IsTopLevel ? "_topLevelViewModelTemplateName" : "_viewModelTemplateName"; return true; }
public static bool? ShowDialog( this Window window, IVsUIShell shell ) { Arg.NotNull( window, nameof( window ) ); IntPtr owner; // if the shell doesn't retrieve the dialog owner or doesn't enter modal mode, just let the dialog do it's normal thing if ( shell == null || shell.GetDialogOwnerHwnd( out owner ) != 0 || shell.EnableModeless( 0 ) != 0 ) return window.ShowDialog(); var helper = new WindowInteropHelper( window ); window.WindowStartupLocation = WindowStartupLocation.CenterOwner; helper.Owner = owner; try { return window.ShowDialog(); } finally { shell.EnableModeless( 1 ); helper.Owner = IntPtr.Zero; } }
static StatusReporter() { uiShell = Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell; if (uiShell == null) { MessageBox.Show(Resources.ErrorUnableToGetShellInstance, Resources.ExtensionTitle, MessageBoxButtons.OK); } }
/// <summary> /// Default constructor for runtime behavior that can't be mocked. /// </summary> public MessageBoxService(IVsUIShell uiShell, IUIThread uiThread) { Guard.NotNull(() => uiShell, uiShell); Guard.NotNull(() => uiThread, uiThread); this.uiShell = uiShell; this.uiThread = uiThread; }
public UDNDocRunningTableMonitor(IVsRunningDocumentTable rdt, IVsMonitorSelection ms, IVsEditorAdaptersFactoryService eafs, IVsUIShell uiShell, MarkdownPackage package) { this.RunningDocumentTable = rdt; this.MonitorSelection = ms; this.EditorAdaptersFactoryService = eafs; this.UIShell = uiShell; this.package = package; ms.GetCmdUIContextCookie(GuidList.guidMarkdownUIContext, out MarkdownModeUIContextCookie); }
public UDNDocView(string sourceFilePath, IWpfTextView textEditorView, IVsWindowFrame windowFrame, MarkdownPackage package, IVsUIShell uiShell) { SourceFilePath = sourceFilePath; TextEditorView = textEditorView; WindowFrame = windowFrame; NavigateToComboData = new NavigateToComboData(textEditorView, uiShell); ParsingResultsCache = new UDNParsingResultsCache(package, sourceFilePath, textEditorView); }
/// <summary> /// Initializes a new instance of the <see cref="ExecuteSelectedTestsCommand"/> class. /// </summary> /// <param name="package">The Visual Studio Extension Package.</param> public ExecuteSelectedTestsCommand(OpenCoverUIPackage package, IVsUIShell uiShell) : base(package, new CommandID(GuidList.GuidOpenCoverUICmdSet, (int)PkgCmdIDList.CmdidCoverWithOpenCover)) { this._package = package; this._uiShell = uiShell; this._testTreeControl = IDEHelper.GetTestTreeControl(_uiShell); this._testTreeControl.LayoutUpdated += EnableDisableCommand; base.Enabled = false; }
protected override void Initialize() { base.Initialize(); _menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; _uiShell = GetService(typeof(SVsUIShell)) as IVsUIShell; AddMenuCommand(CommandIds.TotalCommander, HandleTotalCommanderMenuCommand, options => true); }
public ProductUpdateService(IVsUIShell vsUIShell, IProductUpdateSettings productUpdateSettings) { if (productUpdateSettings == null) { throw new ArgumentNullException("productUpdateSettings"); } _vsUIShell = vsUIShell; _productUpdateSettings = productUpdateSettings; }
public VsToolWindow(IServiceProvider serviceProvider, Guid toolWindowId) { this.uiShell = serviceProvider.GetService<SVsUIShell, IVsUIShell>(); this.toolWindowId = toolWindowId; this.frame = new Lazy<IVsWindowFrame>(() => ThreadHelper.Generic.Invoke(() => { IVsWindowFrame frame; ErrorHandler.ThrowOnFailure(this.uiShell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref toolWindowId, out frame)); return frame; })); }
internal VsAdapter( IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, SVsServiceProvider serviceProvider) { _editorAdaptersFactoryService = editorAdaptersFactoryService; _editorOptionsFactoryService = editorOptionsFactoryService; _serviceProvider = serviceProvider; _textManager = _serviceProvider.GetService<SVsTextManager, IVsTextManager>(); _table = new RunningDocumentTable(_serviceProvider); _uiShell = _serviceProvider.GetService<SVsUIShell, IVsUIShell>(); }
public VisualStudioDiagnosticListSuppressionStateService( SVsServiceProvider serviceProvider, VisualStudioWorkspace workspace) { _workspace = workspace; _shellService = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell)); var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList; _tableControl = errorList?.TableControl; ClearState(); InitializeFromTableControlIfNeeded(); }
private PackageManagerWindow(Project project, DTE dte, IVsUIShell vsUIShell, IVsPackageManagerFactory packageManagerFactory, IPackageRepositoryFactory repositoryFactory, IPackageSourceProvider packageSourceProvider, IRecentPackageRepository recentPackagesRepository, IHttpClientEvents httpClientEvents, IProductUpdateService productUpdateService, IPackageRestoreManager packageRestoreManager, ISolutionManager solutionManager, IOptionsPageActivator optionPageActivator) : base(F1Keyword) { InitializeComponent(); _httpClientEvents = httpClientEvents; if (_httpClientEvents != null) { _httpClientEvents.SendingRequest += OnSendingRequest; } _vsUIShell = vsUIShell; _productUpdateService = productUpdateService; _optionsPageActivator = optionPageActivator; _activeProject = project; // replace the ConsoleOutputProvider with SmartOutputConsoleProvider so that we can clear // the console the first time an entry is written to it var providerServices = new ProviderServices(); _smartOutputConsoleProvider = new SmartOutputConsoleProvider(providerServices.OutputConsoleProvider); providerServices.OutputConsoleProvider = _smartOutputConsoleProvider; _providerSettings = providerServices.ProviderSettings; AddUpdateBar(productUpdateService); AddRestoreBar(packageRestoreManager); InsertDisclaimerElement(); AdjustSortComboBoxWidth(); PreparePrereleaseComboBox(); SetupProviders( project, dte, packageManagerFactory, repositoryFactory, packageSourceProvider, providerServices, recentPackagesRepository, httpClientEvents, solutionManager); }
private CommandGroupHandler(UnconfiguredProject project, IThreadHandling threadHandler, IProjectLockService lockService, [ImportMany] IEnumerable<IDeployTargetUI> targetUIs, [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider) { this.threadHandler = threadHandler; threadHandler.VerifyOnUIThread(); this.project = project; uiShell = (IVsUIShell)serviceProvider.GetService(typeof(IVsUIShell)); docTable = (IVsRunningDocumentTable)serviceProvider.GetService(typeof(IVsRunningDocumentTable)); ProjectHierarchies = new OrderPrecedenceImportCollection<IVsHierarchy>(projectCapabilityCheckProvider: project); this.lockService = lockService; this.targetUIs = targetUIs; }
private Manager(IServiceProvider provider) { this.serviceProvider = provider; this.uiShell = (IVsUIShell)provider.GetService(typeof(SVsUIShell)); this.dte = (EnvDTE.DTE)provider.GetService(typeof(SDTE)); this.recorder = (IRecorder)this.serviceProvider.GetService(typeof(IRecorder)); this.LoadShortcuts(); this.shortcutsLoaded = true; this.shortcutsDirty = false; CreateFileSystem(); }
public void Initialize(IVsUIShell uiShell, DTE2 dte, OleMenuCommandService mcs) { if (!this.initialized) { this.UIShell = uiShell; this.DTE = dte; this.MenuCommandService = mcs; this.VSSolution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution; InitOutputPane(); this.initialized = true; } }
protected override void OnCreate() { _outputWindow = OutputWindowRedirector.GetGeneral(this); Debug.Assert(_outputWindow != null); _statusBar = GetService(typeof(SVsStatusbar)) as IVsStatusbar; _uiShell = GetService(typeof(SVsUIShell)) as IVsUIShell; _dte = GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; _infoBarFactory = GetService(typeof(SVsInfoBarUIFactory)) as IVsInfoBarUIFactory; object control = null; if (!CookiecutterClientProvider.IsCompatiblePythonAvailable()) { ReportPrereqsEvent(false); control = new MissingDependencies(); } else { ReportPrereqsEvent(true); string feedUrl = CookiecutterPackage.Instance.RecommendedFeed; if (string.IsNullOrEmpty(feedUrl)) { feedUrl = UrlConstants.DefaultRecommendedFeed; } _cookiecutterControl = new CookiecutterControl(_outputWindow, CookiecutterTelemetry.Current, new Uri(feedUrl), OpenGeneratedFolder, UpdateCommandUI); _cookiecutterControl.ContextMenuRequested += OnContextMenuRequested; control = _cookiecutterControl; _cookiecutterControl.InitializeAsync(CookiecutterPackage.Instance.CheckForTemplateUpdate).HandleAllExceptions(this, GetType()).DoNotWait(); } Content = control; RegisterCommands(new Command[] { new HomeCommand(this), new RunCommand(this), new UpdateCommand(this), new CheckForUpdatesCommand(this), new GitHubCommand(this, PackageIds.cmdidLinkGitHubHome), new GitHubCommand(this, PackageIds.cmdidLinkGitHubIssues), new GitHubCommand(this, PackageIds.cmdidLinkGitHubWiki), }, PackageGuids.guidCookiecutterCmdSet); RegisterCommands(new Command[] { new DeleteInstalledTemplateCommand(this), }, VSConstants.GUID_VSStandardCommandSet97); base.OnCreate(); OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (CookiecutterPackage.Instance.ShowHelp) { AddInfoBar(); } }
internal VsAdapter( IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, IIncrementalSearchFactoryService incrementalSearchFactoryService, SVsServiceProvider serviceProvider) { _incrementalSearchFactoryService = incrementalSearchFactoryService; _editorAdaptersFactoryService = editorAdaptersFactoryService; _editorOptionsFactoryService = editorOptionsFactoryService; _serviceProvider = serviceProvider; _textManager = _serviceProvider.GetService<SVsTextManager, IVsTextManager>(); _table = new RunningDocumentTable(_serviceProvider); _uiShell = _serviceProvider.GetService<SVsUIShell, IVsUIShell>(); _monitorSelection = _serviceProvider.GetService<SVsShellMonitorSelection, IVsMonitorSelection>(); }
public ProductUpdateService( IVsExtensionRepository extensionRepository, IVsExtensionManager extensionManager, IVsUIShell vsUIShell, IProductUpdateSettings productUpdateSettings) { if (productUpdateSettings == null) { throw new ArgumentNullException("productUpdateSettings"); } _vsUIShell = vsUIShell; _extensionRepository = extensionRepository; _extensionManager = extensionManager; _productUpdateSettings = productUpdateSettings; }
public NavigateToComboData(IWpfTextView textView, IVsUIShell uiShell) { this.textView = textView; this.uiShell = uiShell; CurrentItem = 0; this.textView.Caret.PositionChanged += (sender, args) => SetSectionComboToCaretPosition(); MarkdownSharp.Language.Loaded += () => { if (UDNDocRunningTableMonitor.CurrentUDNDocView != null) { RefreshComboItems(UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.Results); } }; }
public PackageManagerWindow(DTE dte, IVsUIShell vsUIShell, IVsPackageManagerFactory packageManagerFactory, IPackageRepositoryFactory repositoryFactory, IPackageSourceProvider packageSourceProvider, ProviderServices providerServices, IRecentPackageRepository recentPackagesRepository, IHttpClientEvents httpClientEvents, ISelectedProviderSettings selectedProviderSettings, IProductUpdateService productUpdateService) : base(F1Keyword) { InitializeComponent(); _httpClientEvents = httpClientEvents; if (_httpClientEvents != null) { _httpClientEvents.SendingRequest += OnSendingRequest; } AddUpdateBar(productUpdateService); _vsUIShell = vsUIShell; _selectedProviderSettings = selectedProviderSettings; _productUpdateService = productUpdateService; InsertDisclaimerElement(); AdjustSortComboBoxWidth(); // replace the ConsoleOutputProvider with SmartOutputConsoleProvider so that we can clear // the console the first time an entry is written to it _smartOutputConsoleProvider = new SmartOutputConsoleProvider(providerServices.OutputConsoleProvider); providerServices = new ProviderServices( providerServices.LicenseWindow, providerServices.ProgressWindow, providerServices.ScriptExecutor, _smartOutputConsoleProvider); SetupProviders( dte, packageManagerFactory, repositoryFactory, packageSourceProvider, providerServices, recentPackagesRepository, httpClientEvents); }
public static IEnumerable<IVsWindowFrame> GetDocumentWindows(IVsUIShell uiShell) { IEnumWindowFrames documentWindowEnumerator; var hr = uiShell.GetDocumentWindowEnum(out documentWindowEnumerator); if (documentWindowEnumerator == null) { yield break; } IVsWindowFrame[] windowFrames = new IVsWindowFrame[1]; uint frameCount; while (documentWindowEnumerator.Next(1, windowFrames, out frameCount) == VSConstants.S_OK && frameCount == 1) { yield return windowFrames[0]; } }
/// <summary> /// Initializes a new instance of the <see cref="DbContextItemTemplateWizard"/> class. /// </summary> /// <param name="model">The <see cref="ViewItemTemplateWizardViewModel">model</see> for the view.</param> /// <param name="projectInformation">The source <see cref="ProjectInformation">project information</see> used for browsing existing types.</param> /// <param name="shell">The <see cref="IVsUIShell">shell</see> used to provide user feedback.</param> /// <param name="dataExplorerConnectionManager">The <see cref="Lazy{T}">on-demand</see> <see cref="IVsDataConnectionDialogFactory"/> used to create new data connections.</param> /// <param name="dataConnectionDialogFactory">The <see cref="Lazy{T}">on-demand</see> <see cref="IVsDataExplorerConnectionManager">data explorer connection manager</see> used to add created data connections.</param> public DbContextItemTemplateWizard( DbContextItemTemplateWizardViewModel model, ProjectInformation projectInformation, IVsUIShell shell, Lazy<IVsDataConnectionDialogFactory> dataConnectionDialogFactory, Lazy<IVsDataExplorerConnectionManager> dataExplorerConnectionManager ) { Arg.NotNull( shell, nameof( shell ) ); Arg.NotNull( dataConnectionDialogFactory, nameof( dataConnectionDialogFactory ) ); Arg.NotNull( dataExplorerConnectionManager, nameof( dataExplorerConnectionManager ) ); InitializeComponent(); Model = model; projectInfo = projectInformation; this.shell = shell; this.dataConnectionDialogFactory = dataConnectionDialogFactory; this.dataExplorerConnectionManager = dataExplorerConnectionManager; }
internal VsAdapter( IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService, IIncrementalSearchFactoryService incrementalSearchFactoryService, IPowerToolsUtil powerToolsUtil, SVsServiceProvider vsServiceProvider) { _incrementalSearchFactoryService = incrementalSearchFactoryService; _editorAdaptersFactoryService = editorAdaptersFactoryService; _editorOptionsFactoryService = editorOptionsFactoryService; _serviceProvider = vsServiceProvider; _textManager = _serviceProvider.GetService<SVsTextManager, IVsTextManager>(); _table = new RunningDocumentTable(_serviceProvider); _uiShell = _serviceProvider.GetService<SVsUIShell, IVsUIShell>(); _monitorSelection = _serviceProvider.GetService<SVsShellMonitorSelection, IVsMonitorSelection>(); _powerToolsUtil = powerToolsUtil; _visualStudioVersion = vsServiceProvider.GetVisualStudioVersion(); }
/// <summary> /// Attempts to run the template wizard. /// </summary> /// <param name="shell">The <see cref="IVsUIShell">shell</see> associated with the wizard.</param> /// <returns>True if the wizard completed successfully; otherwise, false if the wizard was canceled.</returns> protected override bool TryRunWizard( IVsUIShell shell ) { Arg.NotNull( shell, nameof( shell ) ); var mapper = new ProjectReplacementsMapper(); var model = new ProjectTemplateWizardViewModel(); var view = new NewProjectTemplateWizard( model ); // map replacements to model mapper.Map( Context.Replacements, model ); if ( !( view.ShowDialog( shell ) ?? false ) ) return false; // map model back to replacements mapper.Map( model, Context.Replacements ); return true; }
protected override void Initialize() { /// 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. Trace.WriteLine(String.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString())); base.Initialize(); this.dte = GetService(typeof (DTE)) as DTE; if (this.dte == null) { throw new NullReferenceException("DTE is null"); } this.uiShell = GetService(typeof (IVsUIShell)) as IVsUIShell; // Initialize command events listeners this.events = this.dte.Events; // File.SaveSelectedItems command this.fileSaveSelectedItems = this.events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 331]; this.fileSaveSelectedItems.BeforeExecute += this.OnFileSaveSelectedItemsBeforeExecute; // File.SaveAll command this.fileSaveAll = this.events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 224]; this.fileSaveAll.BeforeExecute += this.OnFileSaveAllBeforeExecute; //Initialize menu command // Add our command handlers for menu (commands must exist in the .vsct file) var menuCommandService = this.GetService(typeof (IMenuCommandService)) as OleMenuCommandService; if (menuCommandService != null) { // Create the command for the menu item. var menuCommandId = new CommandID(GuidList.XamlMagicPackageCommandSet, (int) PkgCmdIDList.FormatXamlCommand); var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandId); menuCommandService.AddCommand(menuItem); } }
/// <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 initilaization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString())); base.Initialize(); _dte = GetService(typeof (DTE)) as DTE; if (_dte == null) { throw new NullReferenceException("DTE is null"); } _uiShell = GetService(typeof (IVsUIShell)) as IVsUIShell; // Initialize command events listeners _events = _dte.Events; // File.SaveSelectedItems command _fileSaveSelectedItems = _events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 331]; _fileSaveSelectedItems.BeforeExecute += OnFileSaveSelectedItemsBeforeExecute; // File.SaveAll command _fileSaveAll = _events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 224]; _fileSaveAll.BeforeExecute += OnFileSaveAllBeforeExecute; //Initialize menu command // Add our command handlers for menu (commands must exist in the .vsct file) var menuCommandService = GetService(typeof (IMenuCommandService)) as OleMenuCommandService; if (null != menuCommandService) { // Create the command for the menu item. var menuCommandId = new CommandID(GuidList.guidXamlStyler_PackageCmdSet, (int) PkgCmdIDList.cmdidBeautifyXaml); var menuItem = new MenuCommand(MenuItemCallback, menuCommandId); menuCommandService.AddCommand(menuItem); } }
public void Init() { projectManager = Substitute.For <IProjectManager>(); projectConfigurationManager = Substitute.For <ProjectConfigurationManager>(); dialogFactory = Substitute.For <IDialogFactory>(); authManager = Substitute.For <IAuthenticationManager>(); codeProviderFactory = Substitute.For <ICodeProviderFactory>(); codeProvider = Substitute.For <ICodeProvider>(); codeProviderFactory.GetCodeProvider(null).ReturnsForAnyArgs(codeProvider); messageManager = Substitute.For <MessageManager>(); SaveToPackageCmd.Initialize(projectManager, authManager, dialogFactory, projectConfigurationManager, codeProviderFactory, messageManager); saveToPackageCmd = SaveToPackageCmd.Instance; iVsUIShell = Substitute.For <IVsUIShell>(); currentPath = AppDomain.CurrentDomain.BaseDirectory; projectManager.ProjectConfigPath.Returns(Path.Combine(currentPath, "TestData\\projectConfig.xml")); projectConfigurationManager.Load(projectManager.ProjectConfigPath); projectConfigurationManager.CurrentProjectConfiguraiton.MethodConfigPath = Path.Combine(currentPath, "TestData\\method-config.xml"); templateLoader = new TemplateLoader(); templateLoader.Load(projectConfigurationManager.CurrentProjectConfiguraiton.MethodConfigPath); projectManager.MethodPath.Returns(Path.Combine(currentPath, "TestData\\TestMethod.txt")); packageManager = Substitute.For <PackageManager>(authManager, messageManager); File.Delete(Path.Combine(currentPath, "imports.mf")); }
/// <summary> /// Sets the expanded state of the folder. /// </summary> /// <param name="expanded">Flag that indicates the expanded state of the folder. /// This should be 'true' for expanded and 'false' for collapsed state.</param> protected void SetExpanded(bool expanded) { this.IsExpanded = expanded; this.SetProperty((int)__VSHPROPID.VSHPROPID_Expanded, expanded); // If we are in automation mode then skip the ui part if (!Utilities.IsInAutomationFunction(this.ProjectMgr.Site)) { IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ProjectMgr.Site, SolutionExplorer); if (null != uiWindow) { ErrorHandler.ThrowOnFailure(uiWindow.ExpandItem(this.ProjectMgr, this.ID, expanded ? EXPANDFLAGS.EXPF_ExpandFolder : EXPANDFLAGS.EXPF_CollapseFolder)); } // then post the expand command to the shell. Folder verification and creation will // happen in the setlabel code... IVsUIShell shell = XHelperMethods.GetService <IVsUIShell, SVsUIShell>(this.ProjectMgr.Site); object dummy = null; Guid cmdGroup = VsMenus.guidStandardCommandSet97; ErrorHandler.ThrowOnFailure(shell.PostExecCommand(ref cmdGroup, (uint)(expanded ? VsCommands.Expand : VsCommands.Collapse), 0, ref dummy)); } }
private IVsWindowFrame FindExistingSolutionWindowFrame() { IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); foreach (var windowFrame in VsUtility.GetDocumentWindows(uiShell)) { object property; int hr = windowFrame.GetProperty( (int)__VSFPROPID.VSFPROPID_DocData, out property); var packageManagerControl = VsUtility.GetPackageManagerControl(windowFrame); if (hr == VSConstants.S_OK && property is IVsSolution && packageManagerControl != null) { return(windowFrame); } } return(null); }
public bool ShowContextMenu(IEnumerable <object> items, Point location) { if (!_shouldShowMenu(items)) { return(false); } _updateMenu(); IVsUIShell shell = Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell; Guid guidContextMenu = Guids.RoslynGroupId; POINTS[] locationPoints = new[] { new POINTS() { x = (short)location.X, y = (short)location.Y } }; return(shell != null && ErrorHandler.Succeeded(shell.ShowContextMenu( 0, ref guidContextMenu, _menuId, locationPoints, pCmdTrgtActive: null))); }
/// <include file='doc\OleMenuCommandService.uex' path='docs/doc[@for="OleMenuCommandService.GlobalInvoke"]/*' /> /// <devdoc> /// Invokes a command on the local form or in the global environment. /// The local form is first searched for the given command ID. If it is /// found, it is invoked. Otherwise the the command ID is passed to the /// global environment command handler, if one is available. /// </devdoc> public override bool GlobalInvoke(CommandID commandID) { // is it local? if (base.GlobalInvoke(commandID)) { return(true); } // pass it to the global handler IVsUIShell uiShellSvc = GetService(typeof(SVsUIShell)) as IVsUIShell; if (uiShellSvc != null) { Object dummy = null; Guid tmpGuid = commandID.Guid; if (NativeMethods.Failed(uiShellSvc.PostExecCommand(ref tmpGuid, (uint)commandID.ID, 0, ref dummy))) { return(false); } return(true); } return(false); }
private void Button1_Click(object sender, RoutedEventArgs e) { string id = ObjectId.Text; ScriptFactory.Instance.CreateNewBlankScript(ScriptType.Sql); var dte = BaseCommand.Instance.ServiceProvider.GetService(typeof(DTE)) as DTE; if (dte != null) { var doc = (TextDocument)dte.Application.ActiveDocument.Object(null); //var query = Services.QueryService.GetSelectQuery(BaseCommand.CurrentTableName, id); //doc.EndPoint.CreateEditPoint().Insert(query); } IVsUIShell vsUIShell = (IVsUIShell)Package.GetGlobalService(typeof(SVsUIShell)); Guid guid = typeof(QueryWindow).GUID; IVsWindowFrame windowFrame; int result = vsUIShell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fFindFirst, ref guid, out windowFrame); // Find MyToolWindow windowFrame.CloseFrame((int)__FRAMECLOSE.FRAMECLOSE_NoSave); }
private void DisplayPopUpMessage(string popUpTitle, string popUpBody) { ChaseRating(); if (!string.IsNullOrEmpty(popUpBody)) { IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; uiShell.ShowMessageBox( 0, ref clsid, popUpTitle, popUpBody, string.Empty, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_NOICON, 0, out int result); } }
public EnvSelectorDialog(IVsUIShell shell, EnvDTE.DTE dte) { this.shell = shell; this.dte = dte; InitializeComponent(); this.cbEnv.DataContext = cloudSettings; this.cbEnv.ItemsSource = cloudSettings; this.lblMode.Content = $"Connected to: {cloudSettings[originalConnection].DisplayName}"; var index = 0; foreach (var item in cbEnv.Items) { var setting = (KeyValuePair <string, CloudSetting>)item; if (setting.Key == originalConnection) { this.cbEnv.SelectedIndex = index; break; } index++; } this.CheckModeSetUI(); }
///////////////////////////////////////////////////////////////////////////// // Overridden Package Implementation #region Package Members /// <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() { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); IVsUIShell uiShell = GetService <IVsUIShell, SVsUIShell>(); uiShell.EnableModeless(Convert.ToInt32(true)); // Add our command handlers for menu (commands must exist in the .vsct file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the menu item. CommandID menuCommandId = new CommandID(GuidList.GuidResxPackageCmdSet, (int)PkgCmdIdList.ResxPackage); MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandId); mcs.AddCommand(menuItem); } CreateOutputWindow(); }
private IVsUIHierarchyWindow GetSolutionExplorerToolWindow() { IVsUIHierarchyWindow uiHierarchyWindow = (IVsUIHierarchyWindow)null; IVsUIShell service = this.ServiceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; if (service != null) { uint grfFTW = 0; Guid rguidPersistenceSlot = new Guid("{3AE79031-E1BC-11D0-8F78-00A0C9110057}"); IVsWindowFrame ppWindowFrame = (IVsWindowFrame)null; service.FindToolWindow(grfFTW, ref rguidPersistenceSlot, out ppWindowFrame); if (ppWindowFrame != null) { object pvar = (object)null; ppWindowFrame.GetProperty(-3001, out pvar); if (pvar != null) { uiHierarchyWindow = pvar as IVsUIHierarchyWindow; } } } return(uiHierarchyWindow); }
public async Task BranchUIClickedAsync(ISccUIClickedEventArgs args, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); Debug.Assert(args != null, "Branch UI coordinates were not received."); IVsUIShell uiShell = (IVsUIShell)_sccProvider.GetService(typeof(SVsUIShell)); if (uiShell != null) { POINTS[] p = new POINTS[1]; p[0] = new POINTS(); p[0].x = (short)args.ClickedElementPosition.TopRight.X; p[0].y = (short)args.ClickedElementPosition.TopRight.Y; Guid commandSet = GuidList.guidSccProviderCmdSet; await _statusBarManager.RefreshBranches(); uiShell.ShowContextMenu(0, ref commandSet, PackageIds.BranchMenu, p, _statusBarManager); } }
private bool TryOpenPort() { if (port.IsOpen) { return(true); } try { port.Open(); } catch (UnauthorizedAccessException x) { // The port is open by another program // Show a Message Box to prove we were here IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; int result; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox( 0, ref clsid, "Serial Capture Tool", string.Format(CultureInfo.CurrentCulture, "Unable to open {0}. {0} is open by another program.", port.PortName), string.Empty, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_CRITICAL, 0, // false out result)); return(false); } return(true); }
/// <summary> /// Updates the caption for all windows associated to the document. /// </summary> /// <param name="site">The service provider.</param> /// <param name="caption">The new caption.</param> /// <param name="docData">The IUnknown interface to a document data object associated with a registered document.</param> public static void UpdateCaption(IServiceProvider site, string caption, IntPtr docData) { Utilities.ArgumentNotNull("site", site); if (String.IsNullOrEmpty(caption)) { throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty), "caption"); } IVsUIShell uiShell = site.GetService(typeof(SVsUIShell)) as IVsUIShell; // We need to tell the windows to update their captions. IEnumWindowFrames windowFramesEnum; ErrorHandler.ThrowOnFailure(uiShell.GetDocumentWindowEnum(out windowFramesEnum)); IVsWindowFrame[] windowFrames = new IVsWindowFrame[1]; uint fetched; while (windowFramesEnum.Next(1, windowFrames, out fetched) == VSConstants.S_OK && fetched == 1) { IVsWindowFrame windowFrame = windowFrames[0]; object data; ErrorHandler.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out data)); IntPtr ptr = Marshal.GetIUnknownForObject(data); try { if (ptr == docData) { ErrorHandler.ThrowOnFailure(windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_OwnerCaption, caption)); } } finally { if (ptr != IntPtr.Zero) { Marshal.Release(ptr); } } } }
private IVsWindowFrame FindExistingWindowFrame( Project project) { IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); foreach (var windowFrame in VsUtility.GetDocumentWindows(uiShell)) { object docView; int hr = windowFrame.GetProperty( (int)__VSFPROPID.VSFPROPID_DocView, out docView); if (hr == VSConstants.S_OK && docView is PackageManagerWindowPane) { var packageManagerWindowPane = (PackageManagerWindowPane)docView; if (packageManagerWindowPane.Model.IsSolution) { // the window is the solution package manager continue; } var projects = packageManagerWindowPane.Model.Context.Projects; if (projects.Count() != 1) { continue; } var existingProject = projects.First(); var projectName = existingProject.GetMetadata<string>(NuGetProjectMetadataKeys.Name); if (String.Equals(projectName, project.Name, StringComparison.OrdinalIgnoreCase)) { return windowFrame; } } } return null; }
private void OpenDialog <T>() where T : DialogWindow { ThreadHelper.ThrowIfNotOnUIThread(); if (!Logic.Util.Workspace.IsOpenSolution) { VsShellUtilities.ShowMessageBox( this.package, "No soluton opend", "Execute sql files", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); return; } IVsUIShell uiShell = (IVsUIShell)ServiceProvider.GetServiceAsync(typeof(SVsUIShell)).Result; Func <bool, bool> callback = OpenExecuteResultDialogMessage; var popup = Activator.CreateInstance(typeof(T), callback) as T; popup.IsCloseButtonEnabled = true; IntPtr hwnd; uiShell.GetDialogOwnerHwnd(out hwnd); popup.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; uiShell.EnableModeless(0); try { WindowHelper.ShowModal(popup, hwnd); } finally { // This will take place after the window is closed. uiShell.EnableModeless(1); } }
public void SaveDirtyFiles_ShouldReceiveFileSaveAndReturnTrue() { //Arange InitTestprojectStructure(); this.mainMethodFileProjectItem.IsDirty.Returns(true); IVsUIShell vsUIShell = Substitute.For <IVsUIShell>(); this.serviceProvider.GetService(typeof(SVsUIShell)).Returns(vsUIShell); IMessageBoxWindow messageBoxWindow = Substitute.For <IMessageBoxWindow>(); this.dialogFactory.GetMessageBoxWindow().Returns(messageBoxWindow); messageBoxWindow.ShowDialog("One or more method files is not saved. Do you want to save changes?", "Aras VS method plugin", MessageButtons.YesNoCancel, MessageIcon.Question).Returns(MessageDialogResult.Yes); MethodInfo methodInfo = new MethodInfo() { MethodName = "TestMethodName", PartialClasses = new List <string>(), ExternalItems = new List <string>() }; List <MethodInfo> methodInfos = new List <MethodInfo>(); methodInfos.Add(methodInfo); //Act bool result = this.projectManager.SaveDirtyFiles(methodInfos); //Assert this.mainMethodFileProjectItem.Received().Save(); Assert.IsTrue(result); }
/// <summary> /// Renames the file node for a case only change. /// </summary> /// <param name="newFileName">The new file name.</param> private void RenameCaseOnlyChange(string newFileName) { //Update the include for this item. string include = this.ItemNode.Item.Include; if (String.Compare(include, newFileName, StringComparison.OrdinalIgnoreCase) == 0) { this.ItemNode.Item.Include = newFileName; } else { string includeDir = Path.GetDirectoryName(include); this.ItemNode.Item.Include = Path.Combine(includeDir, newFileName); } this.ItemNode.RefreshProperties(); this.ReDraw(UIHierarchyElement.Caption); this.RenameChildNodes(this); // Refresh the property browser. IVsUIShell shell = this.ProjectMgr.Site.GetService(typeof(SVsUIShell)) as IVsUIShell; Debug.Assert(shell != null, "Could not get the ui shell from the project"); if (shell == null) { throw new InvalidOperationException(); } shell.RefreshPropertyBrowser(0); //Select the new node in the hierarchy IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ProjectMgr.Site, SolutionExplorer); uiWindow.ExpandItem(this.ProjectMgr, this.ID, EXPANDFLAGS.EXPF_SelectItem); }
/// <summary> /// Get reference to IVsUIHierarchyWindow interface from guid persistence slot. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="persistenceSlot">Unique identifier for a tool window created using IVsUIShell::CreateToolWindow. /// The caller of this method can use predefined identifiers that map to tool windows if those tool windows /// are known to the caller. </param> /// <returns>A reference to an IVsUIHierarchyWindow interface.</returns> public static IVsUIHierarchyWindow GetUIHierarchyWindow(IServiceProvider serviceProvider, Guid persistenceSlot) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } IVsUIShell shell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; if (shell == null) { throw new InvalidOperationException("Could not get the UI shell from the project"); } object pvar; if (ErrorHandler.Succeeded(shell.FindToolWindow(0, ref persistenceSlot, out IVsWindowFrame frame)) && ErrorHandler.Succeeded(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out pvar))) { return(pvar as IVsUIHierarchyWindow); } return(null); }
public BindingPaneController(IServiceProvider serviceProvider, BindingPaneViewModel viewModel, IWpfTableControl table) { ThreadHelper.ThrowIfNotOnUIThread(); this.serviceProvider = serviceProvider; this.shell = this.serviceProvider.GetService <SVsUIShell, IVsUIShell>(); this.viewModel = viewModel; this.viewModel.PropertyChanged += this.OnViewModelPropertyChanged; this.table = table; this.table.Control.Tag = this; this.traceLevelDisplayNames = Resource.TraceLevels.Split(','); this.traceLevels = new string[] { nameof(SourceLevels.Off), nameof(SourceLevels.Critical), nameof(SourceLevels.Error), nameof(SourceLevels.Warning), nameof(SourceLevels.Information), nameof(SourceLevels.Verbose), nameof(SourceLevels.ActivityTracing), nameof(SourceLevels.All), }; }
/// <summary> /// Get reference to IVsUIHierarchyWindow interface from guid persistence slot. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="persistenceSlot">Unique identifier for a tool window created using IVsUIShell::CreateToolWindow. /// The caller of this method can use predefined identifiers that map to tool windows if those tool windows /// are known to the caller. </param> /// <returns>A reference to an IVsUIHierarchyWindow interface.</returns> public static IVsUIHierarchyWindow GetUIHierarchyWindow(IServiceProvider serviceProvider, Guid persistenceSlot) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } IVsUIShell shell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; Debug.Assert(shell != null, "Could not get the ui shell from the project"); if (shell == null) { throw new InvalidOperationException(); } object pvar = null; IVsWindowFrame frame = null; IVsUIHierarchyWindow uiHierarchyWindow = null; try { if (0 == shell.FindToolWindow(0, ref persistenceSlot, out frame)) { ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out pvar)); } } finally { if (pvar != null) { uiHierarchyWindow = (IVsUIHierarchyWindow)pvar; } } return(uiHierarchyWindow); }
public OutputConsole( IVsOutputWindow vsOutputWindow, IVsUIShell vsUiShell) { if (vsOutputWindow == null) { throw new ArgumentNullException(nameof(vsOutputWindow)); } if (vsUiShell == null) { throw new ArgumentNullException(nameof(vsUiShell)); } _vsOutputWindow = vsOutputWindow; _vsUiShell = vsUiShell; _outputWindowPane = new Lazy <IVsOutputWindowPane>(() => { // create the Package Manager pane within the Output window int hr = _vsOutputWindow.CreatePane( ref GuidList.guidNuGetOutputWindowPaneGuid, Resources.OutputConsolePaneName, fInitVisible: 1, fClearWithSolution: 0); ErrorHandler.ThrowOnFailure(hr); IVsOutputWindowPane pane; hr = _vsOutputWindow.GetPane( ref GuidList.guidNuGetOutputWindowPaneGuid, out pane); ErrorHandler.ThrowOnFailure(hr); return(pane); }); }
public async Task RepositoryUIClickedAsync(ISccUIClickedEventArgs args, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); Debug.Assert(args != null, "Repository UI coordinates were not received."); IVsUIShell uiShell = (IVsUIShell)_sccProvider.GetService(typeof(SVsUIShell)); if (uiShell != null) { POINTS[] p = new POINTS[1]; p[0] = new POINTS(); p[0].x = (short)args.ClickedElementPosition.TopLeft.X; p[0].y = (short)args.ClickedElementPosition.TopLeft.Y; Guid commandSet = GuidList.guidSccProviderCmdSet; uiShell.ShowContextMenu(0, ref commandSet, PackageIds.RepositoryMenu, p, _statusBarManager); } //if (uiShell != null) //{ // int result; // uiShell.ShowMessageBox(dwCompRole: 0, // rclsidComp: Guid.Empty, // pszTitle: Resources.ProviderName, // pszText: string.Format(CultureInfo.CurrentUICulture, "Clicked", args.ClickedElementPosition.ToString()), // pszHelpFile: string.Empty, // dwHelpContextID: 0, // msgbtn: OLEMSGBUTTON.OLEMSGBUTTON_OK, // msgdefbtn: OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, // msgicon: OLEMSGICON.OLEMSGICON_INFO, // fSysAlert: 0, // false = application modal; true would make it system modal // pnResult: out result); //} }
public static async Task InitializeAsync(AsyncPackage package) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); IVsMRUItemsStore store = await package.GetServiceAsync <SVsMRUItemsStore, IVsMRUItemsStore>(); IVsUIShell uiShell = await package.GetServiceAsync <SVsUIShell, IVsUIShell>(); ISettingsManager manager = await package.GetServiceAsync <SVsSettingsPersistenceManager, ISettingsManager>(); IMenuCommandService commandService = await package.GetServiceAsync <IMenuCommandService, IMenuCommandService>(); Assumes.Present(commandService); var cmdFilesId = new CommandID(PackageGuids.guidCommands, PackageIds.ClearRecentFiles); var cmdFiles = new OleMenuCommand((s, e) => DeleteRecentFiles(store, uiShell), cmdFilesId); commandService.AddCommand(cmdFiles); var cmdProjectsId = new CommandID(PackageGuids.guidCommands, PackageIds.ClearRecentProjects); var cmdProjects = new OleMenuCommand((s, e) => DeleteRecentProjects(manager, uiShell), cmdProjectsId); commandService.AddCommand(cmdProjects); }
public int ShowMessage(OLEMSGBUTTON buttons, OLEMSGDEFBUTTON defaultButton, OLEMSGICON icon, string format, params object[] items) { IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; int result; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure( uiShell.ShowMessageBox( 0, ref clsid, "ILSpy AddIn", string.Format(CultureInfo.CurrentCulture, format, items), string.Empty, 0, buttons, defaultButton, icon, 0, // false out result ) ); return(result); }
/// <summary> /// Показывает ошибку пользователю. /// </summary> /// <param name="text"></param> /// <param name="caption"></param> /// <param name="buttons"></param> /// <param name="icon"></param> private void ShowError(string text, string caption, OLEMSGBUTTON buttons, OLEMSGICON icon) { ThreadHelper.ThrowIfNotOnUIThread(); this.OutputPane.Clear(); this.WriteToOutput(text); IVsUIShell uiShell = (IVsUIShell)this.GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; int result; ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox( 0, ref clsid, caption, text, string.Empty, 0, buttons, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, icon, 0, // false out result)); }
public void OnExecute(CommandEventArgs e) { if (_control == null) { return; // Can never happen as update already checked this } if (e.Command == AnkhCommand.SvnInfoAlphabetical) { _control.Grid.PropertySort = PropertySort.Alphabetical; } else { _control.Grid.PropertySort = PropertySort.CategorizedAlphabetical; } // And tell VS that the state of other commands changed to // avoid an ugly delay in updating the other toolbar button IVsUIShell shell = e.GetService <IVsUIShell>(); if (shell != null) { shell.UpdateCommandUI(1); // Force an immediate update } }
/// <summary> /// Dumps the current top-level window in VS /// </summary> public static void DumpVS() { var sp = ServiceProvider.GlobalProvider; if (sp == null) { return; } IVsUIShell uiShell = sp.GetService(typeof(IVsUIShell)) as IVsUIShell; IntPtr hwnd; uiShell.GetDialogOwnerHwnd(out hwnd); AutomationWrapper.DumpElement(AutomationElement.FromHandle(hwnd)); // if we have a dialog open dump the main VS window too var mainHwnd = new IntPtr(((EnvDTE.DTE)sp.GetService(typeof(EnvDTE.DTE))).MainWindow.HWnd); if (mainHwnd != hwnd) { Console.WriteLine("VS: "); AutomationWrapper.DumpElement(AutomationElement.FromHandle(mainHwnd)); } }
public IWin32Window GetDialogOwnerWindow() { IVsUIShell uishell = (IVsUIShell)GetService(typeof(IVsUIShell)); // get the VS root window. IntPtr rootHandle = (IntPtr)0; if (uishell != null) { uishell.GetDialogOwnerHwnd(out rootHandle); } if (rootHandle != (IntPtr)0) { IWin32Window parent = Control.FromHandle(rootHandle) as IWin32Window; if (parent == null) { parent = new NativeHandleWindow(rootHandle); } return(parent); } return(null); }
/// <summary> /// Renames the file node for a case only change. /// </summary> /// <param name="newFileName">The new file name.</param> private void RenameCaseOnlyChange(string oldName, string newName) { //Update the include for this item. string relName = CommonUtils.GetRelativeFilePath(this.ProjectMgr.ProjectHome, newName); Debug.Assert(String.Equals(this.ItemNode.GetMetadata(ProjectFileConstants.Include), relName, StringComparison.OrdinalIgnoreCase), "Not just changing the filename case"); this.ItemNode.Rename(relName); this.ItemNode.RefreshProperties(); ProjectMgr.ReDrawNode(this, UIHierarchyElement.Caption); this.RenameChildNodes(this); // Refresh the property browser. IVsUIShell shell = this.ProjectMgr.Site.GetService(typeof(SVsUIShell)) as IVsUIShell; Utilities.CheckNotNull(shell, "Could not get the UI shell from the project"); ErrorHandler.ThrowOnFailure(shell.RefreshPropertyBrowser(0)); //Select the new node in the hierarchy ExpandItem(EXPANDFLAGS.EXPF_SelectItem); }
private IntPtr WaitForDialogToReplace(IntPtr originalHwnd, Task task) { IVsUIShell uiShell = GetService<IVsUIShell>(typeof(IVsUIShell)); IntPtr hwnd; uiShell.GetDialogOwnerHwnd(out hwnd); int timeout = task == null ? 10000 : 60000; while (timeout > 0 && hwnd == originalHwnd && (task == null || !(task.IsFaulted || task.IsCanceled))) { timeout -= 500; System.Threading.Thread.Sleep(500); uiShell.GetDialogOwnerHwnd(out hwnd); } if (task != null && (task.IsFaulted || task.IsCanceled)) { return IntPtr.Zero; } if (hwnd == originalHwnd) { DumpElement(AutomationElement.FromHandle(hwnd)); } Assert.AreNotEqual(IntPtr.Zero, hwnd); Assert.AreNotEqual(originalHwnd, hwnd, "Main window still has focus"); return hwnd; }