public ClientWizard(string clientKind, EnvDTE.Project project, IVsUIShell uiShell, IVsPackageInstaller packageInstaller, IVsPackageInstallerServices packageInstallerServices) { InitializeComponent(); _clientKind = clientKind; _dte = project.DTE; _project = project; _uiShell = uiShell; _packageInstaller = packageInstaller; _packageInstallerServices = packageInstallerServices; var edmxs = _dte.GetSolutionEdmx(_project).ToList(); edmx.ItemsSource = edmxs; edmx.SelectedItem = edmxs.FirstOrDefault(); var services = _dte.GetSolutionSvc(_project).ToList(); service.ItemsSource = services; service.SelectedItem = services.FirstOrDefault(); generationOptions.ItemsSource = new[] { GenerationOptions.GetViewModel(GenerationOptions.Kind.All), GenerationOptions.GetViewModel(GenerationOptions.Kind.WithoutGlobalWithoutFramework), GenerationOptions.GetViewModel(GenerationOptions.Kind.FrameworkOnly), GenerationOptions.GetViewModel(GenerationOptions.Kind.GlobalOnly) }; generationOptions.SelectedIndex = edmxs.Count == 0 || services.Count == 0 ? 2 : 0; if (!GenerationOptions.CanBeRunnedWithNoCopy(_dte)) { copyTemplates.IsChecked = true; copyTemplates.IsEnabled = false; } }
private bool TryUninstallAndAddRedoAction( string source, string packageName, string versionOpt, bool includePrerelease, EnvDTE.DTE dte, EnvDTE.Project dteProject, IOleUndoManager undoManager ) { var uninstalled = TryUninstallPackage(packageName, dte, dteProject); if (uninstalled) { // if the install succeeded, then add an uninstall item to the undo manager. undoManager?.Add( new InstallPackageUndoUnit( this, source, packageName, versionOpt, includePrerelease, dte, dteProject, undoManager ) ); } return(uninstalled); }
public ServiceOption4Thrift(EnvDTE.DTE dte, EnumGenType genType = EnumGenType.AsyncClientDll) { _dte = dte; _genType = genType; InitializeComponent(); }
/// <summary> /// When a solution is opened, this function creates a new <code>DocumentRepository</code> and /// registers the <code>LocalHistoryDocumentListener</code> to listen for save events. /// </summary> public int OnAfterOpenSolution(object pUnkReserved, int fNewSolution) { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering OnAfterOpenSolution() of: {0}", this.ToString())); dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); if (dte == null) { ErrorHandler.ThrowOnFailure(1); } // The solution name can be empty if the user opens a file without opening a solution if (dte.Solution != null && dte.Solution.FullName.Length != 0) { RegisterDocumentListener(); RegisterSelectionListener(); } // Get the instance of the ToolWindow if there is one toolWindow = this.FindToolWindow(typeof(LocalHistoryToolWindow), 0, false); if (toolWindow != null) { // TODO: remove this // BUG: This will cause a null pointer exception if no solution is open when the user opens the tool window. documentRepository.Control = (LocalHistoryControl)toolWindow.Content; } return(VSConstants.S_OK); }
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); }
public QMake(EnvDTE.DTE dte, string fileName, bool recursiveRun, VersionInformation vi) { dteObject = dte; file = fileName; recursive = recursiveRun; qtVersionInformation = vi; }
/// <summary> /// Initializes the package. /// </summary> /// <remarks>This method is called right after the package is sited, so this is the place to initialize /// code that relies on services provided by Visual Studio.</remarks> protected override void Initialize() { base.Initialize(); if (!this.SetupMode) { System.ComponentModel.Design.IServiceContainer sc = (System.ComponentModel.Design.IServiceContainer) this; sc.AddService(typeof(IVsPackage), this, false); // Ensure that the IDE enviroment is available. EnvDTE.DTE dte = (EnvDTE.DTE) this.GetService(typeof(EnvDTE.DTE)); if (dte == null) { throw new InvalidOperationException(Strings.CouldNotGetVSEnvironment); } this.Core.Initialize(null, true); this.Helper.Initialize(); // Ensuring that the form is created on the UI thread. if (InvisibleForm.Instance == null) { throw new InvalidOperationException(Strings.NoInvisbileForm); } // Set up the menu items. this.AddMenuItems(); } }
public override void OnAfterCreated(EnvDTE.DTE dteObject) { this.chkT4RunOnBuild.Checked = this.Settings.T4RunAsBuild; this.txtT4RunAsBuildTemplate.Enabled = chkT4RunOnBuild.Checked; this.txtT4RunAsBuildTemplate.Text = this.Settings.T4RunAsBuildTemplate; this.chkSmartRunT4MVC.Checked = this.Settings.SmartRunT4MVC; }
public override bool AddProjectFile(string slnPath, string projPath) { EnvDTE.DTE dte = FindOrCreateDTE(slnPath); if (dte == null) { return(false); } EnvDTE.Project project = FindProject(dte, projPath); if (project == null) { try { CreateFileDirectoryIfNotExists(projPath); File.WriteAllText(projPath, GetProjectFileContents(dte.Version, Path.GetFileNameWithoutExtension(projPath), GetEnginePathFromCurrentFolder(projPath) != null)); } catch { return(false); } dte.Solution.AddFromFile(projPath); dte.Solution.SaveAs(slnPath); } return(true); }
public override bool AddSourceFile(string slnPath, string projPath, string sourceFilePath, string code) { EnvDTE.DTE dte = FindOrCreateDTE(slnPath); if (dte == null) { return(false); } EnvDTE.Project project = FindProject(dte, projPath); if (project == null) { if (!AddProjectFile(slnPath, projPath)) { return(false); } project = FindProject(dte, projPath); if (project == null) { return(false); } } CreateFileDirectoryIfNotExists(sourceFilePath); File.WriteAllText(sourceFilePath, code); project.ProjectItems.AddFromFile(sourceFilePath); return(true); }
/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private void MenuItemCallback(object sender, EventArgs e) { // Show a Message Box to prove we were here EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; IntPtr parentHwnd = IntPtr.Zero; uiShell.GetDialogOwnerHwnd(out parentHwnd); NativeWindow parentShim = new NativeWindow(); parentShim.AssignHandle(parentHwnd); AttachDialog dialog = new AttachDialog(); DialogResult result = dialog.ShowDialog(parentShim); if (result == DialogResult.OK) { foreach (int selected_id in dialog.SelectedItems) { foreach (EnvDTE90a.Process4 p in dte.Debugger.LocalProcesses) { System.Diagnostics.Debug.WriteLine("Found process {0}", p.ProcessID); if (p.ProcessID != selected_id) { continue; } p.Attach(); System.Diagnostics.Debug.WriteLine("Attaching to process successful."); break; } } } }
public static void SetFontSize(this EnvDTE.DTE dte, DependencyObject view) { const string CATEGORY_FONTS_AND_COLORS = "FontsAndColors"; const string PAGE_TEXT_EDITOR = "TextEditor"; const string PROPERTY_FONT_SIZE = "FontSize"; ThreadHelper.ThrowIfNotOnUIThread(); try { var fontSizeObject = dte.Properties[CATEGORY_FONTS_AND_COLORS, PAGE_TEXT_EDITOR]?.Item(PROPERTY_FONT_SIZE)?.Value ?? 0.0; var fontSize = Convert.ToDouble(fontSizeObject, CultureInfo.InvariantCulture); if (fontSize > 1) { // Default in VS is 10, but looks like 12 in WPF view.SetValue(Appearance.TextFontSizeProperty, fontSize * 1.2); } } catch { // ignored } }
private VsInstance(Version version, Process process, DTE dte, IRemoteComInvoker invoker) { this.Version = version; this.Process = process; Dte = dte; ComInvoker = invoker; }
/// <summary> /// Set BreakPoint from clipboard /// </summary> private void SetBreakPointFromClipboard() { EnvDTE.DTE dte = this.package.GetDTE(); var text = Clipboard.GetText(); var lines = text.Split(new String[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); var regex = new Regex(@"^(\s*)(.+)\((\d+)\):", RegexOptions.Compiled); foreach (string line in lines) { var match = regex.Match(line); if (match.Success) { try { var fileName = match.Groups[2].Value; var lineNumber = Int32.Parse(match.Groups[3].Value); dte.Debugger.Breakpoints.Add(string.Empty, fileName, lineNumber); } catch (FormatException) { ; } } } }
private void Initialize(IServiceProvider serviceProvider) { ThreadHelper.JoinableTaskFactory.Run(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); _dte = (EnvDTE.DTE)serviceProvider.GetService(typeof(EnvDTE.DTE)); if (_dte != null) { _dteEvents = _dte.Events; _dteBuildEvents = _dteEvents.BuildEvents; _dteBuildEvents.OnBuildBegin += (scope, action) => StopCoverageProcess(); } if (serviceProvider.GetService(typeof(SVsShell)) is IVsShell shell) { var packageToBeLoadedGuid = new Guid(OutputToolWindowPackage.PackageGuidString); shell.LoadPackage(ref packageToBeLoadedGuid, out var package); var outputWindowInitializedFile = Path.Combine(FCCEngine.AppDataFolder, "outputWindowInitialized"); if (File.Exists(outputWindowInitializedFile)) { OutputToolWindowCommand.Instance.FindToolWindow(); } else { // for first time users, the window is automatically docked OutputToolWindowCommand.Instance.ShowToolWindow(); File.WriteAllText(outputWindowInitializedFile, string.Empty); } } }); }
public UpdateGeneratedCodeWizard(EnvDTE.DTE dte) { InitializeComponent(); DataContext = this; _dte = dte; Loaded += (_, __) => Run().ConfigureAwait(true); }
/// <summary> /// Completes our initialization. This may be called from out overridden Initialize method and sometimes waiting until after the zombie state has /// gone from VS. /// </summary> private void InitializeMenus() { if (!this.SetupMode) { IServiceContainer sc = this; sc.AddService(typeof(IVsPackage), this, false); // Ensure that the IDE enviroment is available. EnvDTE.DTE dte = (EnvDTE.DTE)this.GetService(typeof(EnvDTE.DTE)); if (dte == null) { throw new InvalidOperationException(Strings.CouldNotGetVSEnvironment); } ProjectUtilities.Initialize(this); this.Core.Initialize(null, true); this.Helper.Initialize(); // Ensuring that the form is created on the UI thread. if (InvisibleForm.Instance == null) { throw new InvalidOperationException(Strings.NoInvisbleForm); } // Set up the menu items. this.commandSet = new PackageCommandSet(this); this.commandSet.Initialize(); } }
/// <summary> /// Get information from the registry based for the project /// factory corresponding to the TypeGuid of the element /// </summary> private RegisteredProjectType GetRegisteredProject(ProjectElement element) { ProjectElement elementToUse = (element == null) ? this.nestedProjectElement : element; if (elementToUse == null) { throw new ArgumentNullException("element"); } // Get the project type guid from project elementToUse string typeGuidString = elementToUse.GetMetadataAndThrow(ProjectFileConstants.TypeGuid, new Exception()); Guid projectFactoryGuid = new Guid(typeGuidString); EnvDTE.DTE dte = this.ProjectMgr.Site.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; Debug.Assert(dte != null, "Could not get the automation object from the services exposed by this project"); if (dte == null) { throw new InvalidOperationException(); } RegisteredProjectType registeredProjectType = RegisteredProjectType.CreateRegisteredProjectType(projectFactoryGuid); Debug.Assert(registeredProjectType != null, "Could not read the registry setting associated to this project."); if (registeredProjectType == null) { throw new InvalidOperationException(); } return(registeredProjectType); }
private void _timer_Tick(object sender, EventArgs e) { _timer.Enabled = false; if (_serviceProvider != null) { EnvDTE.DTE dte = (EnvDTE.DTE)_serviceProvider.GetService(typeof(EnvDTE.DTE)); if (_qdinit == false) { _qdinit = true; _init = true; try { _typeQB.InvokeMember("PostInit", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod, null, _queryDesigner, null); if (_qbbase != null) { EnumChildWindows(Handle, new EnumWindowsCallback(EnumWindows), IntPtr.Zero); } _check_Tick(this, EventArgs.Empty); _typeQB.InvokeMember("ShowAddTableDialogIfNeeded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod, null, _queryDesigner, null); } finally { _init = false; _check.Enabled = true; } } } }
private static bool AttachToProcess(EnvDTE.DTE dte, Process processOutput, Guid portSupplier, string transportQualifierUri) { var debugger3 = (EnvDTE90.Debugger3)dte.Debugger; var transports = debugger3.Transports; EnvDTE80.Transport transport = null; for (int i = 1; i <= transports.Count; ++i) { var t = transports.Item(i); if (Guid.Parse(t.ID) == portSupplier) { transport = t; break; } } if (transport == null) { return(false); } var processes = debugger3.GetProcesses(transport, transportQualifierUri); if (processes.Count < 1) { return(false); } var process = processes.Item(1); return(AttachToProcess(processOutput, process)); }
public CodeCoverage(IWpfTextView view, EnvDTE.DTE dte) { this.dte = dte; this.view = view; this.layer = view.GetAdornmentLayer("CodeCoverage"); this.layer.Opacity = 0.4; // Listen to any event that changes the layout (text changes, scrolling, etc) view.LayoutChanged += OnLayoutChanged; // Color for uncovered code: Brush brush = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xCF, 0xB8)); brush.Freeze(); Brush penBrush = new SolidColorBrush(Color.FromArgb(0xD0, 0xFF, 0xCF, 0xB8)); penBrush.Freeze(); Pen pen = new Pen(penBrush, 0.5); pen.Freeze(); uncoveredBrush = brush; uncoveredPen = pen; // Color for covered code: brush = new SolidColorBrush(Color.FromArgb(0xFF, 0xBD, 0xFC, 0xBF)); brush.Freeze(); penBrush = new SolidColorBrush(Color.FromArgb(0xD0, 0xBD, 0xFC, 0xBF)); penBrush.Freeze(); pen = new Pen(penBrush, 0.5); pen.Freeze(); coveredBrush = brush; coveredPen = pen; }
protected override void Initialize() { base.Initialize(); dte = (EnvDTE.DTE) this.GetService(typeof(EnvDTE.DTE)); dte.Events.SolutionEvents.Opened += SolutionEvents_Opened; dte.Events.SolutionEvents.AfterClosing += SolutionEvents_AfterClosing; }
private void openProblemInEditor(object sender, MainToolWindowUI.OpenProblemInEditorEventArgs e) { Problem problem = e.Problem; IVsUIShellOpenDocument shellOpenDocument = (IVsUIShellOpenDocument)GetService(typeof(IVsUIShellOpenDocument)); Debug.Assert(shellOpenDocument != null); Guid guidCodeView = VSConstants.LOGVIEWID.Code_guid; Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp = null; IVsUIHierarchy hierarchy = null; uint itemId = 0; IVsWindowFrame windowFrame = null; if (shellOpenDocument.OpenDocumentViaProject(problem.FilePath, ref guidCodeView, out sp, out hierarchy, out itemId, out windowFrame) != VSConstants.S_OK) { Debug.WriteLine("Error opening file " + problem.FilePath); return; } Debug.Assert(windowFrame != null); windowFrame.Show(); EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(SDTE)); Debug.Assert(dte != null); Debug.Assert(dte.ActiveDocument != null); var selection = (EnvDTE.TextSelection)dte.ActiveDocument.Selection; Debug.Assert(selection != null); selection.GotoLine(problem.Line > 0 ? problem.Line : 1); // Line cannot be 0 here }
public OutputConsoleLogger( [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider, IOutputConsoleProvider consoleProvider) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (consoleProvider == null) { throw new ArgumentNullException(nameof(consoleProvider)); } NuGetUIThreadHelper.JoinableTaskFactory.Run(async() => { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); ErrorListProvider = new ErrorListProvider(serviceProvider); _dte = serviceProvider.GetDTE(); _buildEvents = _dte.Events.BuildEvents; _buildEvents.OnBuildBegin += (_, __) => { ErrorListProvider.Tasks.Clear(); }; _solutionEvents = _dte.Events.SolutionEvents; _solutionEvents.AfterClosing += () => { ErrorListProvider.Tasks.Clear(); }; OutputConsole = consoleProvider.CreatePackageManagerConsole(); }); }
public static List <string> GetSkusList() { EnvDTE.DTE dte = ((EnvDTE.DTE)ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE).GUID)); string edition = dte.Edition; return(GetSupportedSkus(edition)); }
/// <summary> /// Executes the action. /// </summary> public override void Execute() { EnvDTE.DTE vs = this.GetService <EnvDTE.DTE>(true); string keyFilePath; if (this.KeyFile == null) { string solutionPath = (string)vs.Solution.Properties.Item("Path").Value; string solutionDir = Path.GetDirectoryName(solutionPath); keyFilePath = Path.Combine(solutionDir, this.Name + ".snk"); // Find the .NET SDK directory to execute the sn.exe command. RegistryKey regKeySN = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Microsoft SDKs\Windows\v8.1A"); string sdkDir = Path.Combine(regKeySN.GetValue(@"InstallationFolder").ToString(), "bin", "NETFX 4.5.1 Tools"); if (!Directory.Exists(sdkDir)) { throw new InvalidOperationException("Could not find the Visual Studio SDK directory to execute the sn.exe command. Searching folder " + sdkDir); } string snPath = Path.Combine(sdkDir, "sn.exe"); if (!File.Exists(snPath)) { throw new InvalidOperationException("Could not find the sn.exe command in the Visual Studio SDK directory. Searching for " + snPath); } // Make sure the directory exists. Directory.CreateDirectory(Path.GetDirectoryName(keyFilePath)); // Launch the process and wait until it's done (with a 10 second timeout). ProcessStartInfo startInfo = new ProcessStartInfo(snPath, string.Format("-k \"{0}\"", keyFilePath)); startInfo.CreateNoWindow = true; startInfo.UseShellExecute = false; Process snProcess = Process.Start(startInfo); snProcess.WaitForExit(10000); // Add the key file to the Solution Items. DteHelper.SelectSolution(vs); vs.ItemOperations.AddExistingItem(keyFilePath); // The AddExistingItem operation also shows the item in a new window, close that. vs.ActiveWindow.Close(EnvDTE.vsSaveChanges.vsSaveChangesNo); } else { keyFilePath = this.keyFile; } //set the assemblykeyfile property for every Project foreach (EnvDTE.Project project in vs.Solution.Projects) { if (project.Properties != null) { if (project.Kind == BusinessComponents.Constants.ClassLibraryProjectType) { project.Properties.Item("SignAssembly").Value = true; project.Properties.Item("AssemblyOriginatorKeyFile").Value = keyFilePath; } } } }
private void UpdateCodeAnalysisRuleSetPropertiesInAllProjects(string oldFileFullPath, string newFileFullPath) { EnvDTE.DTE dte = (EnvDTE.DTE)_serviceProvider.GetService(typeof(SDTE)); foreach (EnvDTE.Project project in dte.Solution.Projects) { UpdateCodeAnalysisRuleSetPropertiesInProject(project, oldFileFullPath, newFileFullPath); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public SolutionEventListener (EnvDTE.DTE dteService, IVsSolution2 solutionService) { m_dteService = dteService; m_solutionService = solutionService; m_solutionService.AdviseSolutionEvents (this, out m_listenerCookie); }
/// <summary> /// Get the list of all supported projects in the current solution. This method /// recursively iterates through all projects. /// </summary> public static IEnumerable <EnvDTE.Project> GetAllEnvDTEProjects(EnvDTE.DTE dte) { return(NuGetUIThreadHelper.JoinableTaskFactory.Run(async delegate { var result = await GetAllEnvDTEProjectsAsync(dte); return result; })); }
public static void AttachDebugger(DTE dte, Process targetProcess, string engine = "Managed") { dte?.Debugger .LocalProcesses .Cast <Process2>() .FirstOrDefault(p => p.ProcessID == targetProcess.Id) ?.Attach2(engine); }
public FsiLanguageServiceHelper() { EnvDTE.DTE dte = (EnvDTE.DTE)Package.GetGlobalService(typeof(EnvDTE.DTE)); fsiAssembly = Assembly.Load(String.Format("FSharp.VS.FSI, Version={0}.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", dte.Version)); fsiLanguageServiceType = fsiAssembly.GetType("Microsoft.VisualStudio.FSharp.Interactive.FsiLanguageService"); sessionsType = fsiAssembly.GetType("Microsoft.VisualStudio.FSharp.Interactive.Session.Sessions"); fsiWindowType = fsiAssembly.GetType(FsiToolWindowClassName); }
private DbInitProjectRunner(Project project, EnvDTE.DTE dte, DataSet <DbInitInput> input) { ThreadHelper.ThrowIfNotOnUIThread(); Project = project; DTE = dte; VsProject = GetVsProject(project); Input = input; }
public async Task InitializeAsync(IAsyncServiceProvider provider, CancellationToken cancellationToken) { // Switch to the main thread - the call to AddCommand in addUnitTestProj's constructor requires // the UI thread. await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); _dte = await provider.GetServiceAsync(typeof(EnvDTE.DTE)) as EnvDTE.DTE; }
public virtual void InitializeContext() { this.solution = VsIdeTestHostContext.ServiceProvider.GetService<ISolution>(); this.dte = VsIdeTestHostContext.ServiceProvider.GetService<EnvDTE.DTE>(); this.patternManager = VsIdeTestHostContext.ServiceProvider.GetService<IPatternManager>(); this.instanceName = "a" + Guid.NewGuid().ToString().Replace("-", ""); this.solution.CreateInstance(this.DeploymentDirectory, this.instanceName); }
/// <summary> /// Creates a new DTE environment /// </summary> public SharedEnvironment() { Type dteType = Type.GetTypeFromProgID("VisualStudio.DTE.10.0"); Assert.IsNotNull(dteType, "Visual Studio DTE Type could not be found"); extensibility = (EnvDTE.DTE)(System.Activator.CreateInstance(dteType)); extensibility.MainWindow.Visible = false; MessageFilter.Register(); extensibility.Solution.Open(Path.Combine(Environment.CurrentDirectory, Path.Combine(Paths.Default.ProjectFiles, "TestProject1\\TestProject1.sln"))); }
private EditorBroker(ServiceBroker sb) { // Register priority command target, this dispatches mappable keys like Enter, Backspace, Arrows, etc. int hr = sb.VsRegisterPriorityCommandTarget.RegisterPriorityCommandTarget( 0, (IOleCommandTarget)this, out this.CmdTargetCookie); if (hr != VSConstants.S_OK) Marshal.ThrowExceptionForHR(hr); this.Dte = (EnvDTE.DTE)sb.Site.GetService(typeof(EnvDTE.DTE)); }
public SolutionEvent(ServiceProvider sp) { serviceProvider = sp; solution = (IVsSolution)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(IVsSolution)); dte = (EnvDTE.DTE)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(EnvDTE.DTE)); //serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution; if (solution != null) { solution.AdviseSolutionEvents(this, out solutionEventsCookie); } }
public void Initialize() { this.reader = new Mock<IRegistryReader>(); this.reader.Setup(r => r.ReadValue()).Returns(this.ProjectsDirectory); if (!Directory.Exists(this.ProjectsDirectory)) { Directory.CreateDirectory(this.ProjectsDirectory); } this.dte = VsIdeTestHostContext.Dte; }
/// <summary> /// Initialization of the IVsOutputWindowPane /// note: probably slow initialization, /// and be careful with using in Initialize() of package or constructor, /// may be inner exception for COM object in VS (tested on VS2013 with docked to output panel) /// Otherwise, use the IVsUIShell.FindToolWindow (again, only with __VSFINDTOOLWIN.FTW_fFindFirst) /// </summary> /// <param name="name">Name of the pane</param> /// <param name="ow"></param> /// <param name="dteContext"></param> public void paneAttach(string name, IVsOutputWindow ow, EnvDTE.DTE dteContext) { dte = dteContext; if(_paneCOM != null || _paneDTE != null) { Log.Debug("paneAttach-COM: skipped"); return; // currently we work only with one pane } Guid id = GuidList.OWP_SBE; ow.CreatePane(ref id, name, 1, 1); ow.GetPane(ref id, out _paneCOM); }
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(); }
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(); } }
private void SubscribeToEvents() { _dteService = _serviceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; if(null != _dteService) { _buildEvents = _dteService.Events.BuildEvents; _windowEvents = _dteService.Events.WindowEvents; if(null != _buildEvents) { _buildEvents.OnBuildBegin += _buildEvents_OnBuildBegin; _buildEvents.OnBuildDone += _buildEvents_OnBuildDone; } if(null != _windowEvents) { _windowEvents.WindowActivated += _windowEvents_WindowActivated; } } }
protected BaseUndoUnit( PackageInstallerService packageInstallerService, string source, string packageName, string versionOpt, EnvDTE.DTE dte, EnvDTE.Project dteProject, IOleUndoManager undoManager) { this.packageInstallerService = packageInstallerService; this.packageName = packageName; this.versionOpt = versionOpt; this.dte = dte; this.dteProject = dteProject; this.undoManager = undoManager; }
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { dte = automationObject as EnvDTE.DTE; defaultDestinationFolder = replacementsDictionary["$destinationdirectory$"]; basePath = Path.GetDirectoryName((string)customParams[0]); safeProjectName = replacementsDictionary["$safeprojectname$"]; var doc = Helpers.LoadWizardXml(replacementsDictionary); var ns = Helpers.WizardNamespace; foreach (var element in doc.Root.Elements(ns + "Projects").Elements(ns + "Project")) { var definition = new ProjectDefinition(element, replacementsDictionary); if (replacementsDictionary.MatchesCondition(definition.Condition)) definitions.Add(definition); } }
public ViewModelWizard(EnvDTE.DTE dte, EnvDTE.ProjectItem viewModel, IVsPackageInstallerServices packageInstallerServices) { InitializeComponent(); _dte = dte; _viewModel = viewModel; _packageInstallerServices = packageInstallerServices; var edmxs = _dte.GetSolutionEdmx(_viewModel.ContainingProject, skipWaqsAlreadyUsed: false).ToList(); edmx.ItemsSource = edmxs; edmx.SelectedItem = edmxs.FirstOrDefault(); var views = _dte.GetSolutionXaml(_viewModel.ContainingProject).ToList(); views.Insert(0, new DTEExtensions.FilePathes { DisplayPath = "", FullPath = null }); view.ItemsSource = views; view.SelectedItem = views.FirstOrDefault(); }
internal FSharpCompletionCommandHandler(IVsTextView textViewAdapter, ITextView textView, FSharpCompletionHandlerProvider fsharpCompletionHandlerProvider) { this.m_textView = textView; this.m_provider = fsharpCompletionHandlerProvider; this.dte = this.m_provider.ServiceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; textViewAdapter.AddCommandFilter(this, out m_nextCommandHandler); Task.Delay(2000).ContinueWith((a) => { // Probably it is possible to find it through package as well. this.fsiToolWindow = CommandChainNodeWrapper.GetFilterByFullClassName(textViewAdapter, FsiLanguageServiceHelper.FsiToolWindowClassName); }); this.textViewAdapter = textViewAdapter; }
public void TextViewCreated(IWpfTextView textView) { _view = textView; if (_dte == null) { _dte=ServiceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; if (_dte != null) { _commandEvents = _dte.Events.CommandEvents; _commandEvents.AfterExecute += _commandEvents_AfterExecute; EnvDTE.Command cmd = _dte.Commands.Item("Edit.Find"); guidFind = cmd.Guid; idFind=cmd.ID; } } }
public QtVersionDialog(EnvDTE.DTE dte) { dteObj = dte; QtVersionManager vM = QtVersionManager.The(); InitializeComponent(); this.cancelButton.Text = SR.GetString(SR.Cancel); this.okButton.Text = SR.GetString(SR.OK); this.groupBox1.Text = SR.GetString("QtVersionDialog_BoxTitle"); this.Text = SR.GetString("QtVersionDialog_Title"); this.versionComboBox.Items.AddRange(vM.GetVersions()); if (this.versionComboBox.Items.Count > 0) { string defVersion = vM.GetSolutionQtVersion(dteObj.Solution); if (defVersion != null && defVersion.Length > 0) { this.versionComboBox.Text = defVersion; } else if (dte.Solution != null && HelperFunctions.ProjectsInSolution(dte) != null) { IEnumerator prjEnum = HelperFunctions.ProjectsInSolution(dte).GetEnumerator(); prjEnum.Reset(); if (prjEnum.MoveNext()) { EnvDTE.Project prj = prjEnum.Current as EnvDTE.Project; defVersion = vM.GetProjectQtVersion(prj); } } if (defVersion != null && defVersion.Length > 0) this.versionComboBox.Text = defVersion; else this.versionComboBox.Text = (string)this.versionComboBox.Items[0]; } //if (SR.LanguageName == "ja") //{ // this.cancelButton.Location = new System.Drawing.Point(224, 72); // this.cancelButton.Size = new Size(80, 22); // this.okButton.Location = new System.Drawing.Point(138, 72); // this.okButton.Size = new Size(80, 22); //} this.KeyPress += new KeyPressEventHandler(this.QtVersionDialog_KeyPress); }
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { dte = automationObject as EnvDTE.DTE; defaultDestinationFolder = replacementsDictionary["$destinationdirectory$"]; basePath = Path.GetDirectoryName((string)customParams[0]); safeProjectName = replacementsDictionary["$safeprojectname$"]; var wizardData = "<root>" + replacementsDictionary["$wizarddata$"] + "</root>"; var doc = new XmlDocument(); doc.LoadXml(wizardData); var nsmgr = new XmlNamespaceManager(doc.NameTable); nsmgr.AddNamespace("vs", "http://schemas.microsoft.com/developer/vstemplate/2005"); foreach (var element in doc.SelectNodes("//vs:Projects/vs:Project", nsmgr).OfType<XmlElement>()) { var name = propertyRegex.Replace(element.GetAttribute("Name"), match => replacementsDictionary[match.Value]); var startup = string.Equals(element.GetAttribute("Startup"), "true", StringComparison.InvariantCultureIgnoreCase); definitions.Add(new ProjectDefinition { Name = name, Path = element.InnerText, Startup = startup }); } }
public void InitializeContext() { this.dte = VsIdeTestHostContext.ServiceProvider.GetService<EnvDTE.DTE>(); this.manager = VsIdeTestHostContext.ServiceProvider.GetService<IPatternManager>(); var componentModel = VsIdeTestHostContext.ServiceProvider.GetService<SComponentModel, IComponentModel>(); var installedToolkits = componentModel.GetService<IEnumerable<IInstalledToolkitInfo>>(); this.toolkit = installedToolkits.SingleOrDefault(t => t.Id == TestToolkitId); #if VSVER11 || VSVER12 //Copy TestToolkit template to VSExp template cache this.testToolkitTemplatePath = string.Format(CultureInfo.InvariantCulture, TestToolkitTemplateCacheFormat, dte.Version); Directory.CreateDirectory(Environment.ExpandEnvironmentVariables(this.testToolkitTemplatePath + @"\~PC\Projects\MyTemplate1.zip")); Directory.CreateDirectory(Environment.ExpandEnvironmentVariables(this.testToolkitTemplatePath + @"\~PC\Projects\MyTemplate2.zip")); File.Copy(Path.Combine(this.TestContext.DeploymentDirectory, @"MyTemplate1.gen.vstemplate"), Environment.ExpandEnvironmentVariables(this.testToolkitTemplatePath + @"\~PC\Projects\MyTemplate1.zip\MyTemplate1.gen.vstemplate"), true); File.Copy(Path.Combine(this.TestContext.DeploymentDirectory, @"MyTemplate2.gen.vstemplate"), Environment.ExpandEnvironmentVariables(this.testToolkitTemplatePath + @"\~PC\Projects\MyTemplate2.zip\MyTemplate2.gen.vstemplate"), true); #endif }
public void Show() { if (_dte == null) { // Check whether there are any VS processes running. // TODO: Show dialog with instances to connect to. For now make a new one...? // var instances = MsdevManager.Msdev.GetIDEInstances(false); // For now, just create a new instance Type type = Type.GetTypeFromProgID("VisualStudio.DTE"); object dte = Activator.CreateInstance(type, true); _dte = (EnvDTE.DTE)dte; //System.IServiceProvider serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider(_dte as Microsoft.VisualStudio.OLE.Interop.IServiceProvider); //IVsShell shell = serviceProvider.GetService(typeof(SVsShell)) as IVsShell; //if (shell == null) //{ // return; //} //IEnumPackages enumPackages; //int result = shell.GetPackageEnum(out enumPackages); //IVsPackage package = null; //Guid PackageToBeLoadedGuid = // new Guid("10e82a35-4493-43be-b6d3-228399509924"); //shell.LoadPackage(ref PackageToBeLoadedGuid, out package); _dte.MainWindow.WindowState = EnvDTE.vsWindowState.vsWindowStateNormal; // Load the AppToolsClient into Visual Studio, and connect the pipes. } _dte.MainWindow.Visible = true; // Now bring the _dte to the front (this might be done by the AppToolsClient?) if (_dte.MainWindow.WindowState == EnvDTE.vsWindowState.vsWindowStateMinimize) { _dte.MainWindow.WindowState = EnvDTE.vsWindowState.vsWindowStateNormal; } _dte.MainWindow.Activate(); _dte.MainWindow.SetFocus(); _dte.ExecuteCommand("ExcelDna.AttachExcel", _pipeName); }
public ServerWizard(EnvDTE.Project project, IVsUIShell uiShell, IVsPackageInstaller packageInstaller, IVsPackageInstallerServices packageInstallerServices) { InitializeComponent(); _dte = project.DTE; _project = project; _uiShell = uiShell; _packageInstaller = packageInstaller; _packageInstallerServices = packageInstallerServices; var edmxs = _dte.GetSolutionEdmx(_project).ToList(); edmx.ItemsSource = edmxs; edmx.SelectedItem = edmxs.FirstOrDefault(); generationOptions.ItemsSource = new[] { GenerationOptions.GetViewModel(GenerationOptions.Kind.All), GenerationOptions.GetViewModel(GenerationOptions.Kind.WithoutGlobalWithoutFramework), GenerationOptions.GetViewModel(GenerationOptions.Kind.FrameworkOnly), GenerationOptions.GetViewModel(GenerationOptions.Kind.GlobalOnly) }; generationOptions.SelectedIndex = edmxs.Count == 0 ? 2 : 0; if (! GenerationOptions.CanBeRunnedWithNoCopy(_dte)) { copyTemplates.IsChecked = true; copyTemplates.IsEnabled = false; } }
public MainWinWrapper(EnvDTE.DTE dte) { dteObject = dte; }
public PreviewPaneService(SVsServiceProvider serviceProvider) { _dte = serviceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; }
public VSExternalToolProxy(EnvDTE.DTE applicationObject) : base() { m_applicationObject = applicationObject; }
/// <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}", this.ToString())); base.Initialize(); // 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 tool window CommandID toolwndCommandID = new CommandID(Guids.guidBistro_DesignerCmdSet, (int)PkgCmdIDList.cmdidBistroExplorer); MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID); mcs.AddCommand( menuToolWin ); } RegisterProjectFactory(new Projects.FSharp.Factory(this)); RegisterProjectFactory(new Projects.CSharp.Factory(this)); RegisterProjectFactory(new FSharp.ProjectExtender.Factory(this)); dte = GetService(typeof(EnvDTE._DTE)) as EnvDTE.DTE; //explorer = (ExplorerWindow)this.FindToolWindow(typeof(ExplorerWindow), 0, true); //System.IServiceProvider service = (System.IServiceProvider)this.GetService(typeof(System.IServiceProvider)); explorer = (ExplorerWindow)this.FindToolWindow(typeof(ExplorerWindow), 0, true); explorer.Initialize(dte); explorer.AddEvents(); }
/// <summary> /// When a solution is opened, this function creates a new <code>DocumentRepository</code> and /// registers the <code>LocalHistoryDocumentListener</code> to listen for save events. /// </summary> public int OnAfterOpenSolution(object pUnkReserved, int fNewSolution) { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering OnAfterOpenSolution() of: {0}", this.ToString())); dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); if (dte == null) ErrorHandler.ThrowOnFailure(1); // The solution name can be empty if the user opens a file without opening a solution if (dte.Solution != null && dte.Solution.FullName.Length != 0) { RegisterDocumentListener(); RegisterSelectionListener(); } // Get the instance of the ToolWindow if there is one toolWindow = this.FindToolWindow(typeof(LocalHistoryToolWindow), 0, false); if(toolWindow != null) { // TODO: remove this // BUG: This will cause a null pointer exception if no solution is open when the user opens the tool window. documentRepository.Control = (LocalHistoryControl)toolWindow.Content; } return VSConstants.S_OK; }
public VSExternalToolProxy(ISynchronizeInvoke target, EnvDTE.DTE applicationObject) : base(target) { m_applicationObject = applicationObject; }
public FSharpCompletionSource(FSharpCompletionSourceProvider sourceProvider, ITextBuffer textBuffer) { this.sourceProvider = sourceProvider; this.dte = this.sourceProvider.ServiceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; this.textBuffer = textBuffer; }