public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { _dte = automationObject as EnvDTE.DTE; _viewName = replacementsDictionary["$safeitemname$"]; _viewModelName = $"{_viewName}ViewModel"; _templatesDirectory = Path.GetDirectoryName(customParams[0] as string); }
public Locator() { _dte = Package.GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; _dispatcher = Dispatcher.FromThread(System.Threading.Thread.CurrentThread); _workerThread = new System.Threading.Thread(WorkerThreadFunc); // Load images from resource file. string[] imagePaths = new string[] { @"Resources/Structure.png", @"Resources/Class.png", @"Resources/Union.png", @"Resources/Interface.png", @"Resources/Enum.png", @"Resources/Method.png", }; foreach (string path in imagePaths) { BitmapImage bmp = Utils.LoadImageFromResource("pack://application:,,,/QtCreatorPack;component/" + path); _codeIconList.Add(bmp); } LocatorProject.Dispatcher = _dispatcher; }
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { try { m_dte = (EnvDTE.DTE)application; m_addIn = (EnvDTE.AddIn)addInInst; switch (connectMode) { case ext_ConnectMode.ext_cm_UISetup: // Create commands in the UI Setup phase. This phase is called only once when the add-in is deployed. CreateCommands(); break; case ext_ConnectMode.ext_cm_AfterStartup: InitializeAddIn(); break; case ext_ConnectMode.ext_cm_Startup: // Do nothing yet, wait until the IDE is fully initialized (OnStartupComplete will be called) break; } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { try { _dte = automationObject as EnvDTE.DTE; _projectName = replacementsDictionary["$safeprojectname$"]; _container = replacementsDictionary["$container$"]; _solutionDir = System.IO.Path.GetDirectoryName(replacementsDictionary["$destinationdirectory$"]); _templateDir = System.IO.Path.GetDirectoryName(customParams[0] as string); XamarinFormsNewProjectDialog dialog = new XamarinFormsNewProjectDialog(); dialog.ShowDialog(); _dialogResult = dialog.Result; if (_dialogResult.Cancelled) throw new WizardBackoutException(); } catch (Exception ex) { if (Directory.Exists(_solutionDir)) Directory.Delete(_solutionDir, true); throw; } }
private QtProject(EnvDTE.Project project) { if (project == null) throw new Qt4VSException(SR.GetString("QtProject_CannotConstructWithoutValidProject")); envPro = project; dte = envPro.DTE; vcPro = envPro.Object as VCProject; }
public ErrorList(DTE _dte) { dte = _dte; _errorListProvider = new ErrorListProvider(this); _errorListProvider.ProviderName = "SPSF Generator"; _errorListProvider.ProviderGuid = new Guid("{051F078C-B363-4d08-B351-206E9E62BBEF}"); _errorListProvider.Show(); }
public BuildTimeTransformationsEnabler(EnvDTE.Project project, ILogger logger, ISccBasicFileSystem io, IWin32Window ownerWindow) { _dte = project.DTE; Project = project; ProjectProperties = new ProjectProperties(project); _logger = logger; _io = io; _ownerWindow = ownerWindow; }
/// <summary> /// Initializes a new instance of the CodeOutlineCache class. /// </summary> /// <param name="control">The SourceOutlinerControl.</param> /// <param name="dte">A DTE object exposing the Visual Studio automation object model.</param> public CodeOutlineCache(SourceOutlinerControl control, EnvDTE.DTE dte) { Debug.Assert(control != null); Debug.Assert(dte != null); _control = control; _dte = dte; // Initialize the events. AdviseCodeModelEvents(); }
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { _dte = automationObject as EnvDTE.DTE; _projectName = replacementsDictionary["$safeprojectname$"]; _container = replacementsDictionary["$container$"]; _solutionDir = System.IO.Path.GetDirectoryName(replacementsDictionary["$destinationdirectory$"]); _templateDir = System.IO.Path.GetDirectoryName(customParams[0] as string); XamarinFormsNewProjectDialog dialog = new XamarinFormsNewProjectDialog(); dialog.ShowDialog(); _dialogResult = dialog.Result; }
public VisualStudioHelper(CmdArgsPackage package) { this.package = package; this.appObject = package.GetService<SDTE, EnvDTE.DTE>(); // see: https://support.microsoft.com/en-us/kb/555430 this.solutionEvents = this.appObject.Events.SolutionEvents; this.commandEvents = this.appObject.Events.CommandEvents; this.solutionEvents.Opened += SolutionEvents_Opened; this.solutionEvents.AfterClosing += SolutionEvents_AfterClosing; this.solutionEvents.BeforeClosing += SolutionEvents_BeforeClosing; this.solutionEvents.ProjectAdded += SolutionEvents_ProjectAdded; this.solutionEvents.ProjectRemoved += SolutionEvents_ProjectRemoved; this.solutionEvents.ProjectRenamed += SolutionEvents_ProjectRenamed; }
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary> /// <param term='application'>Root object of the host application.</param> /// <param term='connectMode'>Describes how the Add-in is being loaded.</param> /// <param term='addInInst'>Object representing this Add-in.</param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { m_dte = (EnvDTE.DTE)application; m_addIn = (EnvDTE.AddIn)addInInst; CommandBars commandBars; if (connectMode == ext_ConnectMode.ext_cm_UISetup) { object[] contextGUIDS = new object[] { }; //Commands2 commands = (Commands2)_applicationObject.Commands; try { //Command commandProjectSettings = commands.AddNamedCommand2(_addInInstance, "ViewGraphSettings", "View Graph", "View Graph Settings", // false, 1, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, // (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton); Command commandProjectSettings = m_dte.Commands.AddNamedCommand(m_addIn, "ViewGraphSettings", "View Graph", "View Graph Settings", false, 1, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled); commandBars = (CommandBars)m_dte.CommandBars; CommandBar codeWindowCommandBar = commandBars["Code Window"]; var popup = codeWindowCommandBar.Controls.Add(MsoControlType.msoControlButton, System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, true); popup.Caption = "View graph"; //commandProjectSettings.AddControl(popup); var commandBarEvents = (CommandBarEvents)(m_dte.Events.CommandBarEvents[popup]); commandBarEvents.Click += ViewGraphClick; } catch (System.ArgumentException) { //ignore } } }
public SSMS(object addin_instance, string assembly_location) { _addin = (AddIn)addin_instance; _DTE2 = (DTE2)_addin.DTE; _DTE = (DTE)_addin.DTE; addin_location = assembly_location; _command_manager = new command_manager(this); _window_manager = new window_manager(this); _event_manager = new event_manager(this); }
public void Exec(string commandName, EnvDTE.vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { try { handled = false; if (executeOption == EnvDTE.vsCommandExecOption.vsCommandExecOptionDoDefault) { switch (commandName) { case Res.LaunchDesignerFullCommand: handled = true; extLoader.loadDesigner(null); break; case Res.LaunchLinguistFullCommand: handled = true; ExtLoader.loadLinguist(null); break; case Res.LaunchAssistantFullCommand: handled = true; ExtLoader.loadAssistant(); break; case Res.ImportProFileFullCommand: handled = true; ExtLoader.ImportProFile(); break; case Res.ImportPriFileFullCommand: handled = true; ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(_applicationObject)); break; case Res.ExportPriFileFullCommand: handled = true; ExtLoader.ExportPriFile(); break; case Res.ExportProFileFullCommand: handled = true; ExtLoader.ExportProFile(); break; case Res.ChangeSolutionQtVersionFullCommand: QtVersionManager vManager = QtVersionManager.The(); if (formChangeQtVersion == null) { formChangeQtVersion = new FormChangeQtVersion(); } formChangeQtVersion.UpdateContent(ChangeFor.Solution); if (formChangeQtVersion.ShowDialog() == DialogResult.OK) { string newQtVersion = formChangeQtVersion.GetSelectedQtVersion(); if (newQtVersion != null) { string currentPlatform = null; try { SolutionConfiguration config = _applicationObject.Solution.SolutionBuild.ActiveConfiguration; SolutionConfiguration2 config2 = config as SolutionConfiguration2; currentPlatform = config2.PlatformName; } catch { } if (string.IsNullOrEmpty(currentPlatform)) { return; } vManager.SetPlatform(currentPlatform); foreach (Project project in HelperFunctions.ProjectsInSolution(_applicationObject)) { if (HelperFunctions.IsQt4Project(project)) { string OldQtVersion = vManager.GetProjectQtVersion(project, currentPlatform); if (OldQtVersion == null) { OldQtVersion = vManager.GetDefaultVersion(); } QtProject qtProject = QtProject.Create(project); bool newProjectCreated = false; qtProject.ChangeQtVersion(OldQtVersion, newQtVersion, ref newProjectCreated); } } vManager.SaveSolutionQtVersion(_applicationObject.Solution, newQtVersion); } } break; case Res.ProjectQtSettingsFullCommand: handled = true; EnvDTE.DTE dte = _applicationObject; Project pro = HelperFunctions.GetSelectedQtProject(dte); if (pro != null) { if (formProjectQtSettings == null) { formProjectQtSettings = new FormProjectQtSettings(); } formProjectQtSettings.SetProject(pro); formProjectQtSettings.StartPosition = FormStartPosition.CenterParent; MainWinWrapper ww = new MainWinWrapper(dte); formProjectQtSettings.ShowDialog(ww); } else { MessageBox.Show(SR.GetString("NoProjectOpened")); } break; case Res.ChangeProjectQtVersionFullCommand: handled = true; dte = _applicationObject; pro = HelperFunctions.GetSelectedProject(dte); if (pro != null && HelperFunctions.IsQMakeProject(pro)) { if (formChangeQtVersion == null) { formChangeQtVersion = new FormChangeQtVersion(); } formChangeQtVersion.UpdateContent(ChangeFor.Project); MainWinWrapper ww = new MainWinWrapper(dte); if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK) { string qtVersion = formChangeQtVersion.GetSelectedQtVersion(); QtVersionManager vm = QtVersionManager.The(); string qtPath = vm.GetInstallPath(qtVersion); HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + qtPath + "\\bin;$(PATH)", true); } } break; case Res.VSQtOptionsFullCommand: handled = true; if (formQtVersions == null) { formQtVersions = new FormVSQtSettings(); formQtVersions.LoadSettings(); } formQtVersions.StartPosition = FormStartPosition.CenterParent; MainWinWrapper mww = new MainWinWrapper(_applicationObject); if (formQtVersions.ShowDialog(mww) == DialogResult.OK) { formQtVersions.SaveSettings(); } break; case Res.CreateNewTranslationFileFullCommand: handled = true; pro = HelperFunctions.GetSelectedQtProject(_applicationObject); Translation.CreateNewTranslationFile(pro); break; case Res.CommandBarName + ".Connect.lupdate": handled = true; Translation.RunlUpdate(HelperFunctions.GetSelectedFiles(_applicationObject), HelperFunctions.GetSelectedQtProject(_applicationObject)); break; case Res.CommandBarName + ".Connect.lrelease": handled = true; Translation.RunlRelease(HelperFunctions.GetSelectedFiles(_applicationObject)); break; case Res.lupdateProjectFullCommand: handled = true; pro = HelperFunctions.GetSelectedQtProject(Connect._applicationObject); Translation.RunlUpdate(pro); break; case Res.lreleaseProjectFullCommand: handled = true; pro = HelperFunctions.GetSelectedQtProject(Connect._applicationObject); Translation.RunlRelease(pro); break; case Res.lupdateSolutionFullCommand: handled = true; Translation.RunlUpdate(Connect._applicationObject.Solution); break; case Res.lreleaseSolutionFullCommand: handled = true; Translation.RunlRelease(Connect._applicationObject.Solution); break; case Res.ConvertToQtFullCommand: case Res.ConvertToQMakeFullCommand: if (MessageBox.Show(SR.GetString("ConvertConfirmation"), SR.GetString("ConvertTitle"), MessageBoxButtons.YesNo) == DialogResult.Yes) { handled = true; dte = _applicationObject; pro = HelperFunctions.GetSelectedProject(dte); HelperFunctions.ToggleProjectKind(pro); } break; } } } catch (System.Exception e) { MessageBox.Show(e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace); } }
public ProjectExporter(EnvDTE.DTE dte) { dteObject = dte; }
protected override void Initialize() { base.Initialize(); try { Log.OpenFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\VSAnything\\VSAnything.log"); VSAnythingPackage.m_Inst = this; Log.WriteLine("----------------------------------------------------------"); Log.WriteLine("FastFind Initialise"); Log.WriteLine("FastFind Version: 4.8"); this.m_Settings.Read(); EnvDTE.DTE env_dte = (EnvDTE.DTE)base.GetService(typeof(SDTE)); string vs_version; try { vs_version = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; } catch (Exception e) { vs_version = "Error getting VS version: " + e.Message; } Log.WriteLine("Visual Studio Version: " + vs_version); this.m_DTE = new DTE(env_dte); this.m_TextFinder = new TextFinder(); this.m_FileFinder = new FileFinder(this.m_Settings); this.m_FileFinder.SetSolutionFiles(new List <string>(this.m_Settings.SolutionFiles)); this.m_SolutionFiles = new SolutionFiles(this.m_DTE); this.m_GetOpenFilesThread = new GetOpenFilesThread(env_dte); this.m_SolutionFiles.SolutionFileListChanged += new SolutionFiles.SolutionFileListChangedHandler(this.SolutionFilesChanged); this.m_DocumentEvents = env_dte.Events.get_DocumentEvents(null); this.m_SolutionEvents = env_dte.Events.SolutionEvents; this.m_WindowEvents = env_dte.Events.get_WindowEvents(null); //mariotodo 改成下面那样,不知道对不对 //this.m_DocumentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(this, (UIntPtr)System.Reflection.Emit.OpCodes.Ldftn(DocumentSaved)); //this.m_SolutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(this, (UIntPtr)ldftn(ProjectAddedOrRemoved)); //this.m_SolutionEvents.ProjectRemoved += new _dispSolutionEvents_ProjectRemovedEventHandler(this, (UIntPtr)ldftn(ProjectAddedOrRemoved)); //this.m_WindowEvents.WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(this, (UIntPtr)ldftn(WindowActivated)); this.m_DocumentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(this.DocumentSaved); this.m_SolutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(this.ProjectAddedOrRemoved); this.m_SolutionEvents.ProjectRemoved += new _dispSolutionEvents_ProjectRemovedEventHandler(this.ProjectAddedOrRemoved); this.m_WindowEvents.WindowActivated += new _dispWindowEvents_WindowActivatedEventHandler(this.WindowActivated); FastFindToolWindowPane.Initialise(this.m_DTE, this.m_SolutionFiles, this.m_FileFinder, this.m_TextFinder, this.m_GetOpenFilesThread, this.m_Settings); OleMenuCommandService mcs = base.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; this.m_FastFindCmd.Initialise(this.m_DTE, this.m_SolutionFiles, this.m_FileFinder, this.m_TextFinder, this.m_GetOpenFilesThread, mcs, this.m_Settings); this.m_FastFindWindowCmd.Initialise(this, this.m_DTE, mcs, this.m_Settings); this.m_SourceHeaderToggleCmd.Initialise(this.m_DTE, this.m_SolutionFiles, mcs); this.m_SettingsCmd.Initialise(mcs); this.m_Solution = (base.GetService(typeof(SVsSolution)) as IVsSolution2); if (this.m_Solution != null) { int ret = this.m_Solution.AdviseSolutionEvents(this, out this.m_SolutionEventsCookie); Log.WriteLine("AdviseSolutionEvents returned " + ret); } this.AddSolutionFileToSettings(); if (this.m_DTE.EnvDTE.Solution != null) { foreach (Project project in this.m_DTE.EnvDTE.Solution.Projects) { IVsHierarchy pHierarchy = null; if (this.m_Solution.GetProjectOfUniqueName(project.UniqueName, out pHierarchy) == 0 && pHierarchy != null) { this.AdviseHierarchyEvents(pHierarchy); } } } if (!this.m_Settings.ShownWelcomeForm) { new System.Threading.Thread(new ThreadStart(this.WelcomeThread)).Start(); } } catch (Exception arg_368_0) { Utils.LogException(arg_368_0); } }
private void GetDTE() { dte = VsIdeHostAdapter.VisualStudioIde.GetDteFromRot(ProgId, _processId); }
private List <SolutionInfo> VerifySolution(EnvDTE.DTE dte) { logger.Info("Checking the solution file"); // Verfify the target platform if (Platform == "Any CPU") { logger.Error("Platform 'Any CPU' is not supported."); return(null); } // Verify that project configurations are same. logger.Info(" Verifying that the configurations of the solution and projects match."); var slnBuild = dte.Solution.SolutionBuild as SolutionBuild2; if (TargetConfigurations == null) { TargetConfigurations = slnBuild.SolutionConfigurations .Cast <SolutionConfiguration2>() .Where(x => x.PlatformName == Platform) .Select(x => x.Name).ToArray(); } var projectNamesList = new List <List <string> >(); var cfgNamesList = new List <List <(string slnCfgName, string prjCfgName)> >(); SolutionConfigurations slnCfgs = slnBuild.SolutionConfigurations; foreach (SolutionConfiguration2 slnCfg in slnCfgs) { if (slnCfg.PlatformName != Platform || !TargetConfigurations.Contains(slnCfg.Name)) { continue; } var projectNames = new List <string>(); var cfgNames = new List <(string slnCfgName, string projectCfgName)>(); foreach (SolutionContext context in slnCfg.SolutionContexts) { if (!context.ShouldBuild) { continue; } if (context.PlatformName != Platform) { logger.Error($"The platform of {context.ProjectName} does not match {Platform}."); return(null); } if (context.ConfigurationName != slnCfg.Name) { logger.Info($" Configuration of {context.ProjectName} does not match ones of the solution."); logger.Info($" Solution: {slnCfg.Name}"); logger.Info($" Project: {context.ConfigurationName}"); logger.Info($" The configuration name '{context.ConfigurationName}' is replaced by '{slnCfg.Name}'."); } projectNames.Add(context.ProjectName); cfgNames.Add((slnCfg.Name, context.ConfigurationName)); } if (projectNames.Count == 0) { logger.Error( $"No project to build contains in configuration {slnCfg.Name}"); return(null); } projectNamesList.Add(projectNames); cfgNamesList.Add(cfgNames); } if (projectNamesList.Count == 0) { logger.Error($"The solution file does not contain C/C++ projects on platform {Platform}."); return(null); } for (int i = 0; i < projectNamesList.Count; i++) { projectNamesList[i].Sort(); if (i > 0) { if (!projectNamesList[i].SequenceEqual(projectNamesList[0])) { logger.Error($"The project configurations are different."); return(null); } } } // string slnDir = Path.GetDirectoryName(dte.Solution.FullName); var projectsFullPath = projectNamesList[0].ConvertAll( x => Utility.NormalizePath(Path.Combine(slnDir, x)) .ToLower()); Projects projects = dte.Solution.Projects; // Verifying existance of VC++ project, and platform. var solutionInfoList = new List <SolutionInfo>(); foreach (Project project in projects) { System.Console.WriteLine(project.Name); System.Console.WriteLine(project.FileName); System.Console.WriteLine(project.FullName); VCProject vcprj = project.Object as VCProject; if (vcprj == null) { logger.Warn( $"Project '{project.Name}' is not a Visual C++ project."); continue; } var index = projectsFullPath.FindIndex( x => x == project.FullName.ToLower()); if (index < 0) { continue; } var solutionInfo = new SolutionInfo(); solutionInfo.project = project; solutionInfo.cfgs = cfgNamesList.Select( x => (x[index].slnCfgName, x[index].prjCfgName)).ToArray(); solutionInfoList.Add(solutionInfo); } if (solutionInfoList.Count() == 0) { logger.Error("No Visual C++ projects to build."); return(null); } logger.Info("Checking the solution file - done"); return(solutionInfoList); }
public override bool Convert(EnvDTE.DTE dte) { var solutionInfoList = VerifySolution(dte); if (solutionInfoList == null) { return(false); } logger.Info("Converting the projects"); var cmProjects = new List <CMProject>(); foreach (var solutionInfo in solutionInfoList) { var cmProject = new CMProject(solutionInfo.project); cmProject.setLogger(logger); cmProject.Platform = Platform; cmProject.BuildConfigurations = solutionInfo.cfgs.Select(x => x.prjCfgName).ToArray(); foreach (var cfg in solutionInfo.cfgs) { cmProject.SetSolutionConfigurationName(cfg.prjCfgName, cfg.slnCfgName); } if (!cmProject.Prepare()) { return(false); } cmProjects.Add(cmProject); } var solutionDir = Path.GetDirectoryName(dte.Solution.FullName); foreach (var cmProject in cmProjects) { if (!cmProject.Convert(solutionDir, cmProjects)) { return(false); } } logger.Info("Converting the projects - done"); // Output CMakeLists.txt for the solution file. logger.Info("Converting the solution"); logger.Info($"--- Converting {dte.Solution.FullName} ---"); var cmakeListsPath = Path.Combine(solutionDir, "CMakeLists.txt"); var sw = new StreamWriter(cmakeListsPath); sw.WriteLine($"cmake_minimum_required(VERSION {Constants.CMAKE_REQUIRED_VERSION})"); sw.WriteLine(); sw.WriteLine("project({0})", Path.GetFileNameWithoutExtension( dte.Solution.FileName)); sw.WriteLine(); foreach (var cmProject in cmProjects) { var projectDir = Path.GetDirectoryName( cmProject.Project.FileName); var relativePath = Utility.ToRelativePath(projectDir, solutionDir); sw.WriteLine($"add_subdirectory({relativePath})"); } sw.Close(); logger.Info($" {Path.GetFileNameWithoutExtension(dte.Solution.FullName)} -> {cmakeListsPath}"); logger.Info("Converting the solution - done"); return(true); }
/// <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(); dte = this.GetService(typeof(SDTE)) as EnvDTE.DTE; // 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 themeCommandID = new CommandID(GuidList.guidThemeCreatorCmdSet, (int)PkgCmdIDList.cmdidCreateTheme); var themeMenuItem = new OleMenuCommand(ThemeCallback, themeCommandID); // callback added to enable only when right clicking Themes folder themeMenuItem.BeforeQueryStatus += themeBeforeQuery; mcs.AddCommand(themeMenuItem); CommandID moduleCommandId = new CommandID(GuidList.guidThemeCreatorCmdSet, (int)PkgCmdIDList.cmdidCreateModule); var moduleMenuItem = new OleMenuCommand(ModuleCallback, moduleCommandId); // callback added to enable only when right clicking Modules folder moduleMenuItem.BeforeQueryStatus += moduleBeforeQuery; mcs.AddCommand(moduleMenuItem); // add the Orchard.exe menu item CommandID exeCommandId = new CommandID(GuidList.guidThemeCreatorCmdSet, (int)PkgCmdIDList.cmdidRunExe); var exeMenuItem = new OleMenuCommand(ExeCallback, exeCommandId); mcs.AddCommand(exeMenuItem); // add the Build Precompiled command CommandID buildCommandId = new CommandID(GuidList.guidThemeCreatorCmdSet, (int)PkgCmdIDList.cmdidRunBuild); var buildMenuItem = new OleMenuCommand(BuildCallback, buildCommandId); mcs.AddCommand(buildMenuItem); // add the Generate Migrations command CommandID migrationsCommandId = new CommandID(GuidList.guidThemeCreatorCmdSet, (int)PkgCmdIDList.cmdidMigrations); var migrationsMenuItem = new OleMenuCommand(MigrationsCallback, migrationsCommandId); mcs.AddCommand(migrationsMenuItem); } }
///////////////////////////////////////////////////////////////////////////// // Overridden Package Implementation #region Package Members /// 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. protected override void Initialize() { base.Initialize(); seEvents = new SolutionEvents(this); outWindow = new OutputWindowWriter(this); //Install commandbar and menu items // 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. Build Command CommandID menuBuild = new CommandID(GuidList.guidMarbleExtensionCmdSet, (int)PkgCmdIDList.cmdidMarbleBuild); MenuCommand buildItem = new MenuCommand(MarbleBuildCallback, menuBuild); mcs.AddCommand(buildItem); //Rebuild Command CommandID menuRebuild = new CommandID(GuidList.guidMarbleExtensionCmdSet, (int)PkgCmdIDList.cmdidMarbleRebuild); MenuCommand rebuildItem = new MenuCommand(MarbleRebuildCallback, menuRebuild); mcs.AddCommand(rebuildItem); //Clean Command CommandID menuClean = new CommandID(GuidList.guidMarbleExtensionCmdSet, (int)PkgCmdIDList.cmdidMarbleClean); MenuCommand cleanItem = new MenuCommand(MarbleCleanCallback, menuClean); mcs.AddCommand(cleanItem); } bool bCmdsInstalled = false; applicationObject = (DTE)GetService(typeof(DTE)); CommandBars commandBars = (CommandBars)applicationObject.CommandBars; try { cbMarbleBar = commandBars["Marble"]; } catch (ArgumentException e) { } if (cbMarbleBar == null) { //Add Marble as an available command bar cbMarbleBar = commandBars.Add("Marble", MsoBarPosition.msoBarTop); } else { bCmdsInstalled = true; } //Get Red/Green Light icons for status picGreenLight = ImageHelper.GetIPictureFromImage(Resources.GreenLight.ToBitmap()); picRedLight = ImageHelper.GetIPictureFromImage(Resources.RedLight.ToBitmap()); //Add Marble Build Button CommandBarButton cbButtonBuildMarble = (CommandBarButton)cbMarbleBar.Controls.Add(Type.Missing, (int)PkgCmdIDList.cmdidMarbleBuild); cbButtonBuildMarble.Caption = "Marble Build"; cbButtonBuildMarble.TooltipText = "Builds using the Marble Framework"; cbButtonBuildMarble.Style = MsoButtonStyle.msoButtonIconAndCaption; cbButtonBuildMarble.Picture = ImageHelper.GetIPictureFromImage(Resources.Build.ToBitmap()); cbButtonBuildMarble.Click += new _CommandBarButtonEvents_ClickEventHandler(marbleBuildClick); //Add Marble Rebuild Button CommandBarButton cbButtonRebuildMarble = (CommandBarButton)cbMarbleBar.Controls.Add(Type.Missing, (int)PkgCmdIDList.cmdidMarbleRebuild); cbButtonRebuildMarble.Caption = "Marble Rebuild"; cbButtonRebuildMarble.TooltipText = "Rebuilds the solution using the Marble Framework"; cbButtonRebuildMarble.Style = MsoButtonStyle.msoButtonIconAndCaption; cbButtonRebuildMarble.Picture = ImageHelper.GetIPictureFromImage(Resources.Rebuild.ToBitmap()); cbButtonRebuildMarble.Click += new _CommandBarButtonEvents_ClickEventHandler(marbleRebuildClick); //Add Marble Clean Button CommandBarButton cbButtonCleanMarble = (CommandBarButton)cbMarbleBar.Controls.Add(Type.Missing, (int)PkgCmdIDList.cmdidMarbleClean); cbButtonCleanMarble.Caption = "Marble Clean"; cbButtonCleanMarble.TooltipText = "Cleans changes made by the Marble Framework"; cbButtonCleanMarble.Style = MsoButtonStyle.msoButtonIconAndCaption; cbButtonCleanMarble.Picture = ImageHelper.GetIPictureFromImage(Resources.Clean.ToBitmap()); cbButtonCleanMarble.Click += new _CommandBarButtonEvents_ClickEventHandler(marbleCleanClick); //Add Algorithm Name cbbAlgorithm = (CommandBarButton)cbMarbleBar.Controls.Add(); cbbAlgorithm.Caption = "Algorithm Used"; cbbAlgorithm.Style = MsoButtonStyle.msoButtonCaption; cbbAlgorithm.Enabled = false; //Add Current State cbbState = (CommandBarButton)cbMarbleBar.Controls.Add(); cbbState.Caption = sCleanText; cbbState.Style = MsoButtonStyle.msoButtonIconAndCaption; cbbState.State = MsoButtonState.msoButtonUp; cbbState.Picture = picGreenLight; //Start with green light cbbState.Enabled = true; //make command bar enabled and visible cbMarbleBar.Enabled = true; if (!bCmdsInstalled) { cbMarbleBar.Visible = true; } //Register for new/open solution events seEvents.RegisterSolutionEvents(); }
/// <summary> /// Initializes a new instance of the <see cref="MenuItemCommand"/> class. /// Adds our command handlers for menu (commands must exist in the command table file) /// </summary> /// <param name="package">Owner package, not null.</param> /// <param name="commandService">Command service to add command to, not null.</param> private MenuItemCommand(AsyncPackage package, OleMenuCommandService commandService, EnvDTE.DTE dte) { this.package = package ?? throw new ArgumentNullException(nameof(package)); commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); var menuCommandID = new CommandID(CommandSet, CommandId); var menuItem = new MenuCommand(this.Execute, menuCommandID); commandService.AddCommand(menuItem); m_dte = dte; }
public ProjectImporter(EnvDTE.DTE dte) { dteObject = dte; }
// set the application object to refer to public void setApplicationObject(EnvDTE.DTE appobj) { applicationObject = appobj; }
public bool Register(EnvDTE.DTE dte, GanjiContext context) { table = (IVsRunningDocumentTable)Package.GetGlobalService(typeof(SVsRunningDocumentTable)); // Listen to show/hide events of docs to register activate/deactivate cursor listeners. table.AdviseRunningDocTableEvents(this, out m_rdtCookie); // In turn, cursor events will register a IVsTextViewEvents indexed by the IVsTextView. provider = new GitProviderLibGit2Sharp(); provider.ContextRepository = context.RepositoryPath; provider.SolutionBaseDirectory = context.SolutionPath; provider.Open(context.RepositoryPath); // Mixing in Find events with click events. m_dte = dte; m_findEvents = dte.Events.FindEvents; m_findEvents.FindDone += new EnvDTE._dispFindEvents_FindDoneEventHandler(m_findEvents_FindDone); return true; }
/// <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(); //Create Editor Factory. Note that the base Package class will call Dispose on it. base.RegisterEditorFactory(new EditorFactory(this)); _dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); SetNDKPath(); // 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(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidBlackBerryTools); MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID); mcs.AddCommand( menuToolWin ); // Create the command for the settings window CommandID wndSettingsCommandID = new CommandID(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidBlackBerrySettings); MenuCommand menuSettingsWin = new MenuCommand(ShowSettingsWindow, wndSettingsCommandID); mcs.AddCommand(menuSettingsWin); // Create the command for the Debug Token window CommandID wndDebugTokenCommandID = new CommandID(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidBlackBerryDebugToken); MenuCommand menuDebugTokenWin = new MenuCommand(ShowDebugTokenWindow, wndDebugTokenCommandID); mcs.AddCommand(menuDebugTokenWin); // Create the command for the menu item. CommandID projCommandID = new CommandID(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidfooLocalBox); OleMenuCommand projItem = new OleMenuCommand(MenuItemCallback, projCommandID); mcs.AddCommand(projItem); } }
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary> /// <param term='application'>Root object of the host application.</param> /// <param term='connectMode'>Describes how the Add-in is being loaded.</param> /// <param term='addInInst'>Object representing this Add-in.</param> /// <seealso class='IDTExtensibility2' /> void IDTExtensibility2.OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom) { try { _addInInstance = (AddIn)AddInInst; //_DTE2 = (DTE2)_addInInstance.DTE; _DTE = (DTE)_addInInstance.DTE; //_DTE = (DTE2)_addInInstance.DTE; //ovako kaze Mladen da radi svugdje //_DTE = CType(ServiceCache.ExtensibilityModel, EnvDTE.DTE) 'Ovako kaze poljak sa dev2dev da treba za ssms2008 i 2005 switch (ConnectMode) { case ext_ConnectMode.ext_cm_UISetup: // Do nothing for this add-in with temporary user interface break; case ext_ConnectMode.ext_cm_Startup: // The add-in was marked to load on startup // Do nothing at this point because the IDE may not be fully initialized // Visual Studio will call OnStartupComplete when fully initialized break; case ext_ConnectMode.ext_cm_AfterStartup: // The add-in was loaded by hand after startup using the Add-In Manager // Initialize it in the same way that when is loaded on startup AddTemporaryUI(); break; } } catch (System.Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString()); } //List all commands //For Each com As Command In _DTE2.Commands // Debug.WriteLine(String.Format("Name={0} | GUID={1} | ID={2}", com.Name, com.Guid, com.ID)) //Next //Dim outputWindow As OutputWindow = CType(_DTE.Windows.Item(Constants.vsWindowKindOutput).Object, OutputWindow) //_outputWindowPane = outputWindow.OutputWindowPanes.Add("DTE Event Information - C# Event Watcher") //Nemam pojma zašto se taj output window vise ne vidi i ne mogu ga nikako prikazati? //Retrieve the event objects from the automation model //_textEditorEvents = events.TextEditorEvents //_textDocumentKeyPressEvents = (CType(events, EnvDTE80.Events2)).TextDocumentKeyPressEvents //Connect to each delegate exposed from each object retrieved above //AddHandler _textDocumentKeyPressEvents.AfterKeyPress, AddressOf AfterKeyPress //Name=Edit.DoubleClick | GUID={1496A755-94DE-11D0-8C3F-00C04FC2AAE2} | ID=134 //Events: AfterExecute, BeforeExecute //Ne koristi se nigdje, pa ne vidim svrhu. //_CommandEvents = _DTE.Events.CommandEvents("{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}", 134) //----Ovo dole ne briši jer možeš naučiti neke trikove, npr. kako napraviti gumb sa grafikom //If connectMode = ext_ConnectMode.ext_cm_UISetup Then // Dim commands As Commands2 = CType(_DTE2.Commands, Commands2) // Dim toolsMenuName As String // Try // 'If you would like to move the command to a different menu, change the word "Tools" to the // ' English version of the menu. This code will take the culture, append on the name of the menu // ' then add the command to that menu. You can find a list of all the top-level menus in the file // ' CommandBar.resx. // Dim resourceManager As System.Resources.ResourceManager = New System.Resources.ResourceManager("SSMSAddinTest3.CommandBar", System.Reflection.Assembly.GetExecutingAssembly()) // Dim cultureInfo As System.Globalization.CultureInfo = New System.Globalization.CultureInfo(_DTE2.LocaleID) // If (cultureInfo.TwoLetterISOLanguageName = "zh") Then // Dim parentCultureInfo As System.Globalization.CultureInfo = cultureInfo.Parent // toolsMenuName = resourceManager.GetString(String.Concat(parentCultureInfo.Name, "Tools")) // Else // toolsMenuName = resourceManager.GetString(String.Concat(cultureInfo.TwoLetterISOLanguageName, "Tools")) // End If // Catch e As Exception // 'We tried to find a localized version of the word Tools, but one was not found. // ' Default to the en-US word, which may work for the current culture. // toolsMenuName = "Tools" // End Try // 'Place the command on the tools menu. // 'Find the MenuBar command bar, which is the top-level command bar holding all the main menu items: // Dim commandBars As CommandBars = CType(_DTE2.CommandBars, CommandBars) // Dim menuBarCommandBar As CommandBar = commandBars.Item("MenuBar") // 'Find the Tools command bar on the MenuBar command bar: // Dim toolsControl As CommandBarControl = menuBarCommandBar.Controls.Item(toolsMenuName) // Dim toolsPopup As CommandBarPopup = CType(toolsControl, CommandBarPopup) // Try // 'Add a command to the Commands collection: // Dim command As Command = commands.AddNamedCommand2(_addInInstance, "SSMSAddinTest3", "SSMSAddinTest3", "Executes the command for SSMSAddinTest3", True, 59, Nothing, CType(vsCommandStatus.vsCommandStatusSupported, Integer) + CType(vsCommandStatus.vsCommandStatusEnabled, Integer), vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton) // 'Find the appropriate command bar on the MenuBar command bar: // command.AddControl(toolsPopup.CommandBar, 1) // Catch argumentException As System.ArgumentException // 'If we are here, then the exception is probably because a command with that name // ' already exists. If so there is no need to recreate the command and we can // ' safely ignore the exception. // End Try //End If //EnvDTE.Events events = _DTE.Events; }
/// <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(); //Create Editor Factory. Note that the base Package class will call Dispose on it. base.RegisterEditorFactory(new EditorFactory(this)); APITargetListSingleton api = APITargetListSingleton.Instance; InstalledAPIListSingleton apiList = InstalledAPIListSingleton.Instance; InstalledNDKListSingleton ndkList = InstalledNDKListSingleton.Instance; SimulatorListSingleton simList = SimulatorListSingleton.Instance; InstalledSimulatorListSingleton installedSimList = InstalledSimulatorListSingleton.Instance; _dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); if ((IsBlackBerrySolution(_dte)) && (apiList._installedAPIList.Count == 0)) { UpdateManager.UpdateManagerDialog ud = new UpdateManager.UpdateManagerDialog("Please choose your default API Level to be used by the Visual Studio Plug-in.", "default", false, false); ud.ShowDialog(); } SetNDKPath(); _commandEvents = new VSNDKCommandEvents((DTE2)_dte); _commandEvents.RegisterCommand(GuidList.guidVSStd97String, CommandConstants.cmdidStartDebug, startDebugCommandEvents_AfterExecute, startDebugCommandEvents_BeforeExecute); _commandEvents.RegisterCommand(GuidList.guidVSStd97String, CommandConstants.cmdidStartDebug, startDebugCommandEvents_AfterExecute, startDebugCommandEvents_BeforeExecute); _commandEvents.RegisterCommand(GuidList.guidVSStd2KString, CommandConstants.cmdidStartDebugContext, startDebugCommandEvents_AfterExecute, startDebugCommandEvents_BeforeExecute); _buildEvents = _dte.Events.BuildEvents; _buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(this.OnBuildBegin); // 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(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidBlackBerryTools); MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID); mcs.AddCommand( menuToolWin ); // Create the command for the settings window CommandID wndSettingsCommandID = new CommandID(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidBlackBerrySettings); MenuCommand menuSettingsWin = new MenuCommand(ShowSettingsWindow, wndSettingsCommandID); mcs.AddCommand(menuSettingsWin); // Create the command for the Debug Token window CommandID wndDebugTokenCommandID = new CommandID(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidBlackBerryDebugToken); MenuCommand menuDebugTokenWin = new MenuCommand(ShowDebugTokenWindow, wndDebugTokenCommandID); mcs.AddCommand(menuDebugTokenWin); // Create the command for the menu item. CommandID projCommandID = new CommandID(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidfooLocalBox); OleMenuCommand projItem = new OleMenuCommand(MenuItemCallback, projCommandID); mcs.AddCommand(projItem); } }
/// <summary> /// Sets the Visual Studio IDE object. /// </summary> /// <param name="dte">A DTE object exposing the Visual Studio automation object model.</param> public void InitializeDTE(EnvDTE.DTE dte) { // Store the dte so that it can be used later. _dte = dte; // Get the code model data. _codeCache = new CodeOutlineCache(_control, dte); }
/// <summary> /// Changes the Qt version of this project. /// </summary> /// <param name="oldVersion">the current Qt version</param> /// <param name="newVersion">the new Qt version we want to change to</param> /// <param name="newProjectCreated">is set to true if a new Project object has been created</param> /// <returns>true, if the operation performed successfully</returns> public bool ChangeQtVersion(string oldVersion, string newVersion, ref bool newProjectCreated) { newProjectCreated = false; QtVersionManager versionManager = QtVersionManager.The(); versionManager.SetPlatform(Project.ConfigurationManager.ActiveConfiguration.PlatformName); VersionInformation viOld = versionManager.GetVersionInfo(oldVersion); VersionInformation viNew = versionManager.GetVersionInfo(newVersion); string vsPlatformNameOld = null; if (viOld != null) vsPlatformNameOld = viOld.GetVSPlatformName(); string vsPlatformNameNew = viNew.GetVSPlatformName(); bool bRefreshMocSteps = (vsPlatformNameNew != vsPlatformNameOld); try { if (vsPlatformNameOld != vsPlatformNameNew) { if (!SelectSolutionPlatform(vsPlatformNameNew) || !HasPlatform(vsPlatformNameNew)) { CreatePlatform(vsPlatformNameOld, vsPlatformNameNew, viOld, viNew, ref newProjectCreated); bRefreshMocSteps = false; UpdateMocSteps(QtVSIPSettings.GetMocDirectory(envPro)); } } ConfigurationManager configManager = envPro.ConfigurationManager; if (configManager.ActiveConfiguration.PlatformName != vsPlatformNameNew) { string projectName = envPro.FullName; envPro.Save(null); dte.Solution.Remove(envPro); envPro = dte.Solution.AddFromFile(projectName, false); dte = envPro.DTE; vcPro = envPro.Object as VCProject; } } catch { Messages.DisplayErrorMessage(SR.GetString("CannotChangeQtVersion")); return false; } // We have to delete the generated files because of // major differences between the platforms or Qt-Versions. if (vsPlatformNameOld != vsPlatformNameNew || viOld.qtPatch != viNew.qtPatch || viOld.qtMinor != viNew.qtMinor || viOld.qtMajor != viNew.qtMajor) { DeleteGeneratedFiles(); Clean(); } if (bRefreshMocSteps) RefreshMocSteps(); SetQtEnvironment(newVersion); UpdateModules(viOld, viNew); versionManager.SaveProjectQtVersion(envPro, newVersion, vsPlatformNameNew); return true; }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put any initialization code that relies on services provided by Visual Studio. /// </summary> protected override void Initialize() { DisplayMessage(Resources.StatusPrefix, string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); // Add command handlers for the menu (commands must exist in the .ctc file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the tool window in the Other Windows menu. CommandID toolwndCommandID = new CommandID(GuidList.guidSourceOutlinerCmdSet, (int)PkgCmdIDList.cmdidSourceOutliner1); MenuCommand menuToolWin = new MenuCommand(new EventHandler(ShowToolWindow), toolwndCommandID); mcs.AddCommand(menuToolWin); } _dte = GetService(typeof(EnvDTE._DTE)) as EnvDTE.DTE; if (_dte == null) { throw new NullReferenceException("DTE is null"); } _window = (SourceOutlineToolWindow)this.FindToolWindow(typeof(SourceOutlineToolWindow), 0, true); _window.Package = this; _componentManager = (IOleComponentManager)GetService(typeof(SOleComponentManager)); if (_componentID == 0) { OLECRINFO[] crinfo = new OLECRINFO[1]; crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO)); crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime | (uint)_OLECRF.olecrfNeedAllActiveNotifs | (uint)_OLECRF.olecrfNeedSpecActiveNotifs; crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff; crinfo[0].uIdleTimeInterval = 100; int hr = _componentManager.FRegisterComponent(_window, crinfo, out this._componentID); if (!ErrorHandler.Succeeded(hr)) { DisplayMessage(Resources.ErrorPrefix, "Initialize->IOleComponent registration failed"); } } // Initialize the DTE and the code outline file manager, and hook up events. InitializeToolWindow(); }
/// <summary> /// Excutes the selected command. /// </summary> /// <param name="CmdName"></param> /// <param name="ExecuteOption"></param> /// <param name="VarIn"></param> /// <param name="VarOut"></param> /// <param name="Handled"></param> public void Exec(string CmdName, vsCommandExecOption ExecuteOption, ref object VarIn, ref object VarOut, ref bool Handled) { string cmdArgs = "-solution_path " + SolutionPath(); string filePath = applicationObject.SelectedItems.Item(1).ProjectItem.FileNames[1]; // set executor ICommandExecution executor = new CommandExecution(); SonarInterface sonarCommands = new SonarInterface(executor, SolutionPath(), Environment.GetEnvironmentVariable("USERPROFILE")); dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE"); Handled = false; if (CmdName == addInInstance.ProgID + "." + MYCOMMANDRESET) { Globals globals; globals = applicationObject.Solution.Globals; globals[VSSONAR_VALID_CONFIG_KEY] = "NO"; SetStatusMessage("VSSONAR ADDIN Command: Reset Configuration"); Handled = true; return; } // pre set authentication if (!ValidateConfiguration(sonarCommands)) { this.SetStatusMessage("No Valid Configuration / Or User Cancel"); System.Windows.Forms.MessageBox.Show("Cannot Validate Configuration / Or User Cancel - Check ProjectKey"); return; } if (theOutputPane != null) { theOutputPane.Clear(); theOutputPane.Activate(); } theOutputPane.OutputString("Start Analysis\r\n"); if ((ExecuteOption == vsCommandExecOption.vsCommandExecOptionDoDefault) && applicationObject.SelectedItems.MultiSelect == false) { if (CmdName == addInInstance.ProgID + "." + MYCOMMANDREPORTSERVERVIOLATIONS) { SetStatusMessage("VSSONAR ADDIN Command: GetSonarViolations"); Handled = true; PrintListToOutputPan(sonarCommands.GetSonarViolations(filePath)); } if (CmdName == addInInstance.ProgID + "." + MYCOMMANDREPORTLOCALVIOLATIONS) { SetStatusMessage("VSSONAR ADDIN Command: GetLocalViolations"); Handled = true; PrintListToOutputPan(sonarCommands.GetLocalViolations(filePath)); } if (CmdName == addInInstance.ProgID + "." + MYCOMMANDREPORTALLLOCALVIOLATIONS) { SetStatusMessage("VSSONAR ADDIN Command: GetAllLocalViolations"); Handled = true; PrintListToOutputPan(sonarCommands.GetAllLocalViolations(filePath)); } if (CmdName == addInInstance.ProgID + "." + MYCOMMANDREPORTCOVERAGE) { SetStatusMessage("VSSONAR ADDIN Command: GetCoverage"); Handled = true; PrintListToOutputPan(sonarCommands.GetCoverage(filePath)); } if (CmdName == addInInstance.ProgID + "." + MYCOMMANDREPORTSOURCEDIFF) { SetStatusMessage("VSSONAR ADDIN Command: GetSourceDiff"); Handled = true; PrintListToOutputPan(sonarCommands.GetSourceDiff(filePath)); } } theOutputPane.OutputString("End Analysis"); }
/// <summary> /// This function is called when the user clicks the menu item that shows the /// tool window. 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 ShowToolWindow(object sender, EventArgs e) { dte = (DTE)GetService(typeof(DTE)); path2 = this.UserLocalDataPath; // 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.FindToolWindow(typeof(MyToolWindow), 0, true); if ((null == window) || (null == window.Frame)) { throw new NotSupportedException(Resources.CanNotCreateWindow); } IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show()); }
private static void SetDTE(string programId) { IRunningObjectTable objectTable; IEnumMoniker moniker; GetRunningObjectTable(0, out objectTable); objectTable.EnumRunning(out moniker); moniker.Reset(); System.IntPtr fetched = new System.IntPtr(); IMoniker[] pmon = new IMoniker[1]; while (moniker.Next(1, pmon, fetched) == 0) { IBindCtx bindContext; CreateBindCtx(0, out bindContext); string s; pmon[0].GetDisplayName(bindContext, null, out s); if (s == programId) { object returnObject; objectTable.GetObject(pmon[0], out returnObject); object ide = (object)returnObject; if (ide != null) { _dte = (EnvDTE.DTE)ide; break; } } } }
/// <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(); // 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.guidDuplicateFileCmdSet, (int)PkgCmdIDList.cmdidDuplicateCmd); MenuCommand menuItem = new MenuCommand(MenuItemCallbackDuplicate, menuCommandID); mcs.AddCommand(menuItem); } // Add our command handlers for menu (commands must exist in the .vsct file) if (null != mcs) { // Create the command for the menu item. CommandID menuCommandID = new CommandID(GuidList.guidRefreshCmdSet, (int)PkgCmdIDList.cmdidRefreshCmd); MenuCommand menuItem = new MenuCommand(MenuItemCallbackRefresh, menuCommandID); mcs.AddCommand(menuItem); } // Add our command handlers for menu (commands must exist in the .vsct file) if (null != mcs) { // Create the command for the menu item. CommandID menuCommandID = new CommandID(GuidList.guidShowHelpCmdSet, (int)PkgCmdIDList.cmdidShowHelp); MenuCommand menuItem = new MenuCommand(MenuItemCallbackShowHelp, menuCommandID); mcs.AddCommand(menuItem); } // Override Edit.Delete command _applicationObject = (DTE)GetService(typeof(DTE)); var command = _applicationObject.Commands.Item("Edit.Delete"); _removeEvent = _applicationObject.Events.CommandEvents[command.Guid, command.ID]; _removeEvent.BeforeExecute += OnBeforeDeleteCommand; }
/// <summary> /// Initializes a new instance of the CodeOutlineFileManager class. /// </summary> /// <param name="control">The outline control object.</param> /// <param name="dte">A DTE object exposing the Visual Studio automation object model.</param> /// <param name="d">The source file Document.</param> /// <param name="toolWindow">The tool window for the package.</param> public CodeOutlineFileManager(SourceOutlinerControl control, EnvDTE.DTE dte, Document d, SourceOutlinerToolWindow toolWindow) { _control = control; _dte = dte; _sourceOutlinerToolWindow = toolWindow; _viewType = ViewType.TreeView; _searchCriteria = new SearchCriteria(CodeElementType.All); _currentFilterText = ""; _currentDocument = d; _codeTreeView = new System.Windows.Forms.TreeView(); _codeFilterView = new System.Windows.Forms.TreeView(); // // _codeTreeView // _codeTreeView.Dock = System.Windows.Forms.DockStyle.Fill; _codeTreeView.HideSelection = false; _codeTreeView.Location = new System.Drawing.Point(0, 45); _codeTreeView.Name = "codeTreeView"; _codeTreeView.ShowNodeToolTips = true; _codeTreeView.Size = new System.Drawing.Size(352, 294); _codeTreeView.TabIndex = 2; // // _codeFilterView // _codeFilterView.Dock = System.Windows.Forms.DockStyle.Fill; _codeFilterView.HideSelection = false; _codeFilterView.Location = new System.Drawing.Point(0, 45); _codeFilterView.Name = "codeFilterView"; _codeFilterView.ShowNodeToolTips = true; _codeFilterView.Size = new System.Drawing.Size(352, 294); _codeFilterView.TabIndex = 3; _codeFilterView.Visible = false; _codeFilterView.ShowLines = false; _codeFilterView.ShowRootLines = false; _codeFilterView.FullRowSelect = true; }
/// <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(); //Create Editor Factory. Note that the base Package class will call Dispose on it. base.RegisterEditorFactory(new EditorFactory(this)); _dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); SetNDKPath(); GetInstalledAPIList(); GetAvailableAPIList(); GetInstalledSimulatorList(); GetSimulatorList(); _commandEvents = new VSNDKCommandEvents((DTE2)_dte); _commandEvents.RegisterCommand(GuidList.guidVSStd97String, CommandConstants.cmdidStartDebug, startDebugCommandEvents_AfterExecute, startDebugCommandEvents_BeforeExecute); _buildEvents = _dte.Events.BuildEvents; _buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(this.OnBuildBegin); // 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(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidBlackBerryTools); MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID); mcs.AddCommand( menuToolWin ); // Create the command for the settings window CommandID wndSettingsCommandID = new CommandID(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidBlackBerrySettings); MenuCommand menuSettingsWin = new MenuCommand(ShowSettingsWindow, wndSettingsCommandID); mcs.AddCommand(menuSettingsWin); // Create the command for the Debug Token window CommandID wndDebugTokenCommandID = new CommandID(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidBlackBerryDebugToken); MenuCommand menuDebugTokenWin = new MenuCommand(ShowDebugTokenWindow, wndDebugTokenCommandID); mcs.AddCommand(menuDebugTokenWin); // Create the command for the menu item. CommandID projCommandID = new CommandID(GuidList.guidVSNDK_PackageCmdSet, (int)PkgCmdIDList.cmdidfooLocalBox); OleMenuCommand projItem = new OleMenuCommand(MenuItemCallback, projCommandID); mcs.AddCommand(projItem); } }