/// <summary> /// Shows the tool window when the menu item is clicked. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event args.</param> private void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); // Get the instance number 0 of this tool window. This window is single instance so this instance // is actually the only one. // The last flag is set to true so that if the tool window does not exists it will be created. ToolWindowPane window = this.package.FindToolWindow(typeof(BootstrapImport), 0, true); if ((null == window) || (null == window.Frame)) { throw new NotSupportedException("Cannot create tool window"); } BootstrapImportControl control = (BootstrapImportControl)window.Content; EnvDTE.DTE dte = (EnvDTE.DTE)Package.GetGlobalService(typeof(EnvDTE.DTE)); if (dte.Solution.Projects.Count > 0) { EnvDTE.Project project = dte.Solution.Projects.Item(1); EnvDTE.Project activeProject = null; foreach (String s in (Array)dte.Solution.SolutionBuild.StartupProjects) { foreach (EnvDTE.Project proj in dte.Solution.Projects) { if (s == proj.UniqueName) { activeProject = proj; } } } if (activeProject != null) { project = activeProject; } string projectPath = Path.GetDirectoryName(project.FileName); control.ProjectPath = projectPath + "\\"; } IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show()); }
private static void OnSetProjectPathChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { BootstrapImportControl UserControl1Control = d as BootstrapImportControl; UserControl1Control.OnSetProjectPathChanged(e); }