public AddCourseDialog(EnvDTE._DTE dte)
 {
     m_applicationObject = dte;
     InitializeComponent();
     LocalizeLabels();
     txtCourseURL.Focus();
 }
Exemplo n.º 2
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary,
                               WizardRunKind runKind, object[] customParams)
        {
            // Get solution dir and start the logger
            _solutionFolder = replacementsDictionary["$solutiondirectory$"];
            Logger.Log("RootWizard - RunStarted, start");
            Logger.Log(".. namespace=" + replacementsDictionary["$registeredorganization$"] + ", safe=" + replacementsDictionary["$safeprojectname$"]);

            // VS objects
            _dte      = automationObject as EnvDTE._DTE;
            _solution = (Solution2)_dte.Solution;

            // Create the desired path and namespace to generate the project at
            string templateFilePath = (string)customParams[0];
            string vsixFilePath     = Path.GetDirectoryName(templateFilePath);

            _originalDestinationFolder = replacementsDictionary["$destinationdirectory$"];
            _realTemplatePath          = Path.Combine(vsixFilePath, @"real_template\sample.vstemplate");;
            _desiredNamespace          = replacementsDictionary["$safeprojectname$"];

            // Copy from $safeprojectname$ passed in my root vstemplate
            if (GlobalDictionary.Count == 0)
            {
                GlobalDictionary["$saferootprojectname$"] = replacementsDictionary["$safeprojectname$"];
                GlobalDictionary["$template_location"]    = (string)customParams[0];
            }
        }
Exemplo n.º 3
0
 public RemoveCourseDialog(EnvDTE._DTE dte)
 {
     m_applicationObject = dte;
     InitializeComponent();
     LocalizeLabels();
     populateDeleteCourseList();
 }
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            try
            {
                EnvDTE._DTE         theDTE             = DteResources.Instance.GetDteInstance();
                EnvDTE.TextDocument activeTextDocument = (EnvDTE.TextDocument)theDTE.ActiveDocument.Object("TextDocument");
                TextSelection       selection          = activeTextDocument.Selection;

                this.SubstituteStringFromSelection_RemoveCheckSteps(activeTextDocument);
            }
            catch (InvalidOperationException)
            {
                VsShellUtilities.ShowMessageBox(this.ServiceProvider, "The code selection is unbalanced; please try again selecting in the correct lines of code for a complete set of opening and closing check steps.", "Error in Text Selection",
                                                OLEMSGICON.OLEMSGICON_INFO,
                                                OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                                OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }
            catch (Exception ex)
            {
                VsShellUtilities.ShowMessageBox(this.ServiceProvider, string.Format("Exception type='{0}', Message='{1}'", ex.GetType().ToString(), ex.Message), "Exception",
                                                OLEMSGICON.OLEMSGICON_INFO,
                                                OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                                OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }
        }
Exemplo n.º 5
0
        public void RunStarted(object automationObject, Dictionary <string, string> props, WizardRunKind runKind, object[] customParams)
        {
            this.dte = automationObject as EnvDTE._DTE;

            // Check that SharpDX is correctly installed
            if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SharpDXSdkDir")))
            {
                MessageBox.Show("Unable to find SharpDX installation directory. Expecting [SharpDXSdkDir] environment variable", "SharpDX Toolkit Wizard Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw new WizardCancelledException("Expecting [SharpDXSdkDir] environment variable");
            }
            props.Add("$safeclassname$", props["$safeprojectname$"].Replace(".", string.Empty));

            props["$currentVsCulture$"] = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;

            //Call win form created in the project to accept user input
            wizardForm = new WizardForm(props);
            var result = wizardForm.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                throw new WizardCancelledException();
            }

            // Hack on WinRT / WinRT XAML to run the certificate wizards as well as our own wizard
            if (GetKey(props, "$sharpdx_platform_winrt$") || GetKey(props, "$sharpdx_platform_winrt_xaml$"))
            {
                try
                {
                    var assembly = Assembly.Load("Microsoft.VisualStudio.WinRT.TemplateWizards, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
                    var type     = assembly.GetType("Microsoft.VisualStudio.WinRT.TemplateWizards.CreateProjectCertificate.Wizard");
                    winRTCertificateWizard = (IWizard)Activator.CreateInstance(type);
                }
                catch (Exception ex)
                {
                }
            }
            if (winRTCertificateWizard != null)
            {
                winRTCertificateWizard.RunStarted(automationObject, props, runKind, customParams);
            }

            // Set spritebatch feature if spritetexture or spritefont is true
            if (GetKey(props, "$sharpdx_feature_spritetexture$") || GetKey(props, "$sharpdx_feature_spritefont$"))
            {
                props["$sharpdx_feature_spritebatch$"] = "true";
            }

            if (GetKey(props, "$sharpdx_feature_model3d$") || GetKey(props, "$sharpdx_feature_primitive3d$"))
            {
                props["$sharpdx_feature_3d$"] = "true";
            }

            if (GetKey(props, "$sharpdx_platform_winrt_xaml$"))
            {
                props["$sharpdx_platform_winrt$"] = "true";
            }

            isPlatformWP8 = props.ContainsKey("$sharpdx_platform_wp8$");
        }
Exemplo n.º 6
0
        /// <summary>
        /// Returns a reference to the currrent solution
        /// </summary>
        /// <returns>Solution object</returns>
        public static Solution GetSolution()
        {
            // Get the DTE
            EnvDTE._DTE dte = GetDTE();

            // Get the current solution
            return(dte.Solution);
        }
        /// <summary>
        /// Called when the AddIn is loaded. This method allows each of the commands to
        /// store member variables with the objects passed in and ensure that the menu
        /// items and commands have been properly added to the object model.
        /// </summary>
        /// <param name="application"> Root object in the application </param>
        /// <param name="connectMode"> 'Mode' in which the environment is starting up the addin </param>
        /// <param name="addIn"> Object representing this AddIn in the Object Model</param>
        public void OnConnection(EnvDTE._DTE application, Extensibility.ext_ConnectMode connectMode, EnvDTE.AddIn addIn)
        {
            try
            {
                m_applicationObject = (EnvDTE._DTE)application;
                m_addInInstance     = (EnvDTE.AddIn)addIn;

                m_strCommandName = "AMDeleteCourse";
                m_strName        = AMResources.GetLocalizedString("AMDeleteCourseName");
                m_strItemText    = AMResources.GetLocalizedString("AMDeleteCourseItemText");

                string            description          = AMResources.GetLocalizedString("AMDeleteCourseDescription");
                EnvDTE.Commands   commands             = null;
                EnvDTE.Command    command              = null;
                _CommandBars      officeCommandBars    = null;
                CommandBar        officeCommandBar     = null;
                CommandBarControl officeCommandControl = null;
                CommandBar        officeAcademic       = null;

                object [] contextGuids;
                contextGuids = new object[] { };

                commands = m_applicationObject.Commands;
                try
                {
                    command = commands.AddNamedCommand(m_addInInstance, m_strCommandName, m_strName, description,
                                                       false, 108, ref contextGuids, (int)(EnvDTE.vsCommandStatus.vsCommandStatusEnabled | EnvDTE.vsCommandStatus.vsCommandStatusSupported));

                    // Add the new command to the tools menu
                    officeCommandBars = m_applicationObject.CommandBars;
                    string amFacultyMenuItem = AMResources.GetLocalizedString("AMFacultyMenuItem");
                    try
                    {
                        officeAcademic = (CommandBar)officeCommandBars[amFacultyMenuItem];
                    }
                    catch
                    {
                    }
                    if (officeAcademic == null)
                    {
                        officeCommandBar = (CommandBar)officeCommandBars["Tools"];
                        officeAcademic   = (CommandBar)m_applicationObject.Commands.AddCommandBar(amFacultyMenuItem, EnvDTE.vsCommandBarType.vsCommandBarTypeMenu, officeCommandBar, 1);
                    }
                    officeCommandControl         = command.AddControl((object)officeAcademic, 1);
                    officeCommandControl.Caption = m_strItemText;
                }
                catch
                {
                    // Falling into this simply means that the command was already registered.
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception e = " + e.Message);
            }
        }
Exemplo n.º 8
0
 public AddExistingCourseDialog(EnvDTE._DTE dte)
 {
     //
     // Required for Windows Form Designer support
     //
     m_applicationObject = dte;
     InitializeComponent();
     txtServer.Focus();
     LocalizeLabels();
 }
        public DeleteCourseDialog(EnvDTE._DTE dte)
        {
            m_applicationObject = dte;
            InitializeComponent();
            LocalizeLabels();

            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Constants.KeyName);
            string sAppDataPath             = (string)key.GetValue(Constants.ValueName);

            courseListFile = sAppDataPath + Constants.ApplicationPath + Constants.ManagedCoursesFileName;

            populateDeleteCourseList();
        }
Exemplo n.º 10
0
        public void RunStarted(object automationObject, Dictionary <string, string> props, WizardRunKind runKind, object[] customParams)
        {
            this.dte = automationObject as EnvDTE._DTE;

            props.Add("$safeclassname$", props["$safeprojectname$"].Replace(".", string.Empty));
            props["$currentVsCulture$"] = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;

            //Call win form created in the project to accept user input
            wizardForm = new WizardForm(props);
            var result = wizardForm.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                throw new WizardCancelledException();
            }

            // Hack on WinRT / WinRT XAML to run the certificate wizards as well as our own wizard
            if (GetKey(props, "$sharpdx_platform_winrt$") || GetKey(props, "$sharpdx_platform_winrt_xaml$"))
            {
                try
                {
                    var assembly = Assembly.Load("Microsoft.VisualStudio.WinRT.TemplateWizards, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
                    var type     = assembly.GetType("Microsoft.VisualStudio.WinRT.TemplateWizards.CreateProjectCertificate.Wizard");
                    winRTCertificateWizard = (IWizard)Activator.CreateInstance(type);
                }
                catch (Exception ex)
                {
                }
            }
            if (winRTCertificateWizard != null)
            {
                winRTCertificateWizard.RunStarted(automationObject, props, runKind, customParams);
            }

            // Set spritebatch feature if spritetexture or spritefont is true
            if (GetKey(props, "$sharpdx_feature_spritetexture$") || GetKey(props, "$sharpdx_feature_spritefont$"))
            {
                props["$sharpdx_feature_spritebatch$"] = "true";
            }

            if (GetKey(props, "$sharpdx_feature_model3d$") || GetKey(props, "$sharpdx_feature_primitive3d$"))
            {
                props["$sharpdx_feature_3d$"] = "true";
            }

            if (GetKey(props, "$sharpdx_platform_winrt_xaml$"))
            {
                props["$sharpdx_platform_winrt$"] = "true";
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Registers a command and places it on the Tools menu.
        /// </summary>
        public void OnConnection(EnvDTE._DTE application, Extensibility.ext_ConnectMode connectMode, EnvDTE.AddIn addIn)
        {
            m_applicationObject = (EnvDTE._DTE)application;
            m_addInInstance     = (EnvDTE.AddIn)addIn;

            m_strCommandName = "AMRemoveCourse";
            m_strName        = AMResources.GetLocalizedString("AMRemoveCourseName");
            m_strItemText    = AMResources.GetLocalizedString("AMRemoveCourseItemText");

            string strDescription = AMResources.GetLocalizedString("AMRemoveCourseDescription");

            EnvDTE.Commands commands = null;
            EnvDTE.Command  command  = null;
            Microsoft.Office.Core._CommandBars      officeCommandBars    = null;
            Microsoft.Office.Core.CommandBar        officeCommandBar     = null;
            Microsoft.Office.Core.CommandBarControl officeCommandControl = null;
            Microsoft.Office.Core.CommandBar        officeAcademic       = null;
            object [] contextGuids;
            contextGuids = new object[] { };

            commands = m_applicationObject.Commands;
            try
            {
                command = commands.AddNamedCommand(m_addInInstance, m_strCommandName, m_strName, strDescription,
                                                   false, 108, ref contextGuids, (int)(EnvDTE.vsCommandStatus.vsCommandStatusEnabled | EnvDTE.vsCommandStatus.vsCommandStatusSupported));

                // Add the new command to the tools menu
                officeCommandBars = m_applicationObject.CommandBars;
                string amStudentMenuItem = AMResources.GetLocalizedString("AMStudentMenuItem");
                try
                {
                    officeAcademic = (CommandBar)officeCommandBars[amStudentMenuItem];
                }
                catch
                {
                }
                if (officeAcademic == null)
                {
                    officeCommandBar = (CommandBar)officeCommandBars["Tools"];
                    officeAcademic   = (CommandBar)m_applicationObject.Commands.AddCommandBar(amStudentMenuItem, EnvDTE.vsCommandBarType.vsCommandBarTypeMenu, officeCommandBar, 1);
                }
                officeCommandControl         = command.AddControl((object)officeAcademic, 1);
                officeCommandControl.Caption = m_strItemText;
            }
            catch (System.Exception /*e*/)
            {
                // Falling into this simply means that the command was already registered.
            }
        }
 public void RunStarted(object automationObject,
                        Dictionary <string, string> replacementsDictionary,
                        WizardRunKind runKind, object[] customParams)
 {
     try
     {
         this._currentDTE                = automationObject as EnvDTE._DTE;
         this._vsTemplatePath            = (string)customParams[0];
         this._originalSolutionDirectory = replacementsDictionary["$solutiondirectory$"];
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Message: {ex.ToString()}. Stack Trace: {ex.StackTrace}");
     }
 }
Exemplo n.º 13
0
        public void RunStarted(object automationObject,
                               Dictionary <string, string> replacementsDictionary,
                               WizardRunKind runKind, object[] customParams)
        {
            try
            {
                this._currentDTE = automationObject as EnvDTE._DTE;

                this.GetSitecoreConfiguration(replacementsDictionary, customParams);
                this.RememberTemplateInformation(replacementsDictionary);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Message: {ex.ToString()}. Stack Trace: {ex.StackTrace}");
            }
        }
Exemplo n.º 14
0
        public void RunStarted(object automationObject, Dictionary<string, string> props, WizardRunKind runKind, object[] customParams)
        {
            this.dte = automationObject as EnvDTE._DTE;

            props.Add("$safeclassname$", props["$safeprojectname$"].Replace(".", string.Empty));
            props["$currentVsCulture$"] = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;

            //Call win form created in the project to accept user input
            wizardForm = new WizardForm(props);
            var result = wizardForm.ShowDialog();
            if (result == DialogResult.Cancel)
            {
                throw new WizardCancelledException();
            }

            // Hack on WinRT / WinRT XAML to run the certificate wizards as well as our own wizard
            if (GetKey(props, "$sharpdx_platform_winrt$") || GetKey(props, "$sharpdx_platform_winrt_xaml$"))
            {
                try
                {
                    var assembly = Assembly.Load("Microsoft.VisualStudio.WinRT.TemplateWizards, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
                    var type = assembly.GetType("Microsoft.VisualStudio.WinRT.TemplateWizards.CreateProjectCertificate.Wizard");
                    winRTCertificateWizard = (IWizard)Activator.CreateInstance(type);
                }
                catch (Exception ex)
                {
                }
            }
            if (winRTCertificateWizard != null) winRTCertificateWizard.RunStarted(automationObject, props, runKind, customParams);

            // Set spritebatch feature if spritetexture or spritefont is true
            if (GetKey(props, "$sharpdx_feature_spritetexture$") || GetKey(props, "$sharpdx_feature_spritefont$"))
            {
                props["$sharpdx_feature_spritebatch$"] = "true";
            }

            if (GetKey(props, "$sharpdx_feature_model3d$") || GetKey(props, "$sharpdx_feature_primitive3d$"))
            {
                props["$sharpdx_feature_3d$"] = "true";
            }

            if (GetKey(props, "$sharpdx_platform_winrt_xaml$"))
            {
                props["$sharpdx_platform_winrt$"] = "true";
            }
        }
Exemplo n.º 15
0
 // RunStarted() method gets called before the template wizard creates the project.
 void IWizard.RunStarted(object application, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     this.dte     = application as EnvDTE._DTE;
     this.runKind = runKind;
     this.replacementsDictionary = replacementsDictionary;
     // Store the solution name locally while processing the solution template
     if (runKind == WizardRunKind.AsMultiProject)
     {
         solutionName = replacementsDictionary["$safeprojectname$"];
     }
     replacementsDictionary.Add("$solutionname$", solutionName);
     if (runKind == WizardRunKind.AsNewProject)
     {
         // Make the solution root path available for all the projects
         replacementsDictionary.Add("$solutionrootpath$", GetSolutionRootPath() + solutionName + "\\");
         AddProjectGuidsTo(replacementsDictionary);
     }
 }
        // RunStarted() method gets called before the template wizard creates the project.
        void IWizard.RunStarted(object application, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) {
            this.dte = application as EnvDTE._DTE;
            this.runKind = runKind;
            this.replacementsDictionary = replacementsDictionary;

            // Store the solution name locally while processing the solution template
            if (runKind == WizardRunKind.AsMultiProject) {
                solutionName = replacementsDictionary["$safeprojectname$"];
            }

            replacementsDictionary.Add("$solutionname$", solutionName);

            if (runKind == WizardRunKind.AsNewProject) {
                // Make the solution root path available for all the projects
                replacementsDictionary.Add("$solutionrootpath$", GetSolutionRootPath() + solutionName + "\\");

                AddProjectGuidsTo(replacementsDictionary);
            }
        }
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            try
            {
                EnvDTE._DTE         theDTE             = DteResources.Instance.GetDteInstance();
                EnvDTE.TextDocument activeTextDocument = (EnvDTE.TextDocument)theDTE.ActiveDocument.Object("TextDocument");
                TextSelection       selection          = activeTextDocument.Selection;

                this.SubstituteStringFromSelection_AddCheckStep(activeTextDocument);
            }
            catch (NullReferenceException)
            {
            }
            catch (Exception ex)
            {
                VsShellUtilities.ShowMessageBox(this.ServiceProvider, string.Format("Exception type='{0}', Message='{1}'", ex.GetType().ToString(), ex.Message), "Exception",
                                                OLEMSGICON.OLEMSGICON_INFO,
                                                OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                                OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }
        }
        public static EnvDTE.Command ReplaceCommandInMenu(
            EnvDTE.AddIn addInInstance,
            EnvDTE._DTE applicationObject,
            int iconNumber,
            string progID,
            string commandName,
            string commandButtonText,
            string commandDescription,
            string commandBarName
            )
        {
            object []    contextGUIDS = new object[] { };
            Commands     commands     = applicationObject.Commands;
            _CommandBars commandBars  = applicationObject.CommandBars;

            try
            {
                Command command = FindCommand(commands, progID + "." + commandName);
                if (command != null)                  // if we found one
                {
                    command.Delete();                 // delete it as we're going to replace it
                }
                // call commands.AddNamedCommand to add it
                command = commands.AddNamedCommand(
                    addInInstance, commandName, commandButtonText,
                    commandDescription, true, iconNumber, ref contextGUIDS,
                    (int)vsCommandStatus.vsCommandStatusSupported +
                    (int)vsCommandStatus.vsCommandStatusEnabled);

                CommandBar        commandBar        = (CommandBar)commandBars[commandBarName];
                CommandBarControl commandBarControl = command.AddControl(commandBar, 1);

                return(command);
            }
            catch (System.Exception e)
            {
                MessageBox.Show("Exception in ReplaceCommandInMenu: " + e.Message);
                return(null);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Retuns an instance of the Active VS.NET Project COM object
        /// </summary>
        /// <returns></returns>
        public static Project GetActiveProject()
        {
            EnvDTE._DTE dte = GetDTE();
            if (dte == null)
            {
                return(null);
            }

            if (dte.ActiveDocument == null)
            {
                return(null);
            }

            Project proj = dte.ActiveDocument.ProjectItem.ContainingProject;

            if (proj == null)
            {
                return(null);
            }

            return(proj);
        }
Exemplo n.º 20
0
        public void RunStarted(object automationObject,
                               Dictionary <string, string> replacementsDictionary,
                               WizardRunKind runKind, object[] customParams)
        {
            foreach (string key in LanguageDSLWizard.ReplacementsDictionaryCustom.Keys)
            {
                replacementsDictionary.Add(key, LanguageDSLWizard.ReplacementsDictionaryCustom[key]);
            }
            replacementsDictionary["$safeprojectname$"] = LanguageDSLWizard.ProjectName;

            EnvDTE._DTE dte  = automationObject as EnvDTE._DTE;
            string      path = dte.Solution.Properties.Item("Path").Value.ToString();

            System.IO.FileInfo info = new System.IO.FileInfo(path);

            //this.projectdir = info.DirectoryName + System.IO.Path.DirectorySeparatorChar + LanguageDSLWizard.ProjectName + System.IO.Path.DirectorySeparatorChar + "VSPluginDSL" + System.IO.Path.DirectorySeparatorChar;
            this.projectdir = info.DirectoryName + System.IO.Path.DirectorySeparatorChar + LanguageDSLWizard.ProjectName + System.IO.Path.DirectorySeparatorChar;
            using (StrongNameKey strongNameKey = LanguageDSLWizard.GenerateKeyFile ? new StrongNameKey() : new StrongNameKey(LanguageDSLWizard.ExistingKeyFilePath))
            {
                strongNameKey.SaveTo(System.IO.Path.Combine(this.projectdir, "Key.snk"));
            }
        }
Exemplo n.º 21
0
        public void TestScaffoldClass()
        {
            ScaffoldTool scaffold = new ScaffoldTool(new TraceOutputter());

            // TODO-johnls-1/2/2008: This property is really just a hack
            scaffold.NoRemoting = true;
            scaffold.ScriptPath = new ParsedPath("HelloWorld.csr", PathType.File);

            System.Threading.Thread t = new System.Threading.Thread(delegate()
            {
                EnvDTE._DTE dte = null;

                while ((dte = GetIDEInstances("HelloWorld.sln")) == null)
                {
                    System.Threading.Thread.Sleep(100);
                }

                dte.Application.Quit();
            });

            t.Start();

            scaffold.Execute();

            if (scaffold.Output.HasOutputErrors)
            {
                t.Abort();
            }
            else
            {
                if (!t.Join(10000))
                {
                    t.Abort();
                }
            }

            Assert.IsFalse(scaffold.Output.HasOutputErrors, "Scaffold failed");
        }
Exemplo n.º 22
0
        // Get a table of the currently running instances of the Visual Studio .NET IDE.
        private static EnvDTE._DTE GetIDEInstances(string name)
        {
            Hashtable             runningObjects = GetRunningObjectTableSnapshot();
            IDictionaryEnumerator rotEnumerator  = runningObjects.GetEnumerator();

            while (rotEnumerator.MoveNext())
            {
                string candidateName = (string)rotEnumerator.Key;

                // VS DTE objects always start with this magic prefix...
                if (!candidateName.StartsWith("!VisualStudio.DTE"))
                {
                    continue;
                }

                EnvDTE._DTE ide = rotEnumerator.Value as EnvDTE._DTE;

                if (ide == null)
                {
                    continue;
                }

                try
                {
                    string solutionFile = ide.Solution.FullName;

                    if (solutionFile != String.Empty && solutionFile.IndexOf(name) >= 0)
                    {
                        return(ide);
                    }
                }
                catch
                {
                }
            }

            return(null);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RegexToolWindowCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private RegexToolWindowCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(this.ShowToolWindow, menuCommandID);
                commandService.AddCommand(menuItem);
            }
            //
            this.dte = ServiceProvider.GetService(typeof(_DTE)) as _DTE;
            if (dte == null)
            {
                throw new ArgumentNullException("DTE");
            }
        }
Exemplo n.º 24
0
        public void RunStarted(object automationObject,
                               Dictionary <string, string> replacementsDictionary,
                               WizardRunKind runKind, object[] customParams)
        {
            try
            {
                this.dte = automationObject as EnvDTE._DTE;
                this._replacementsDictionary = replacementsDictionary;
                this._runKind = runKind;

                // Store the solution name locally while processing the solution template
                if (_runKind == WizardRunKind.AsMultiProject)
                {
                    _solutionName = replacementsDictionary["$safeprojectname$"];

                    //Call win form created in the project to accept user input
                    _wizardFrm = new ProjectCustomProps();

                    if (replacementsDictionary.ContainsKey("$rootnamespace$"))
                    {
                        _wizardFrm.RootNamespace = replacementsDictionary["$rootnamespace$"];
                    }
                    if (replacementsDictionary.ContainsKey("$ownername$"))
                    {
                        _wizardFrm.OwnerName = replacementsDictionary["$ownername$"];
                    }
                    if (replacementsDictionary.ContainsKey("$owneremail$"))
                    {
                        _wizardFrm.OwnerEmail = replacementsDictionary["$owneremail$"];
                    }
                    if (replacementsDictionary.ContainsKey("$ownerwebsite$"))
                    {
                        _wizardFrm.OwnerWebsite = replacementsDictionary["$ownerwebsite$"];
                    }
                    if (replacementsDictionary.ContainsKey("$devenvironmenturl$"))
                    {
                        _wizardFrm.DevelopmentUrl = replacementsDictionary["$devenvironmenturl$"];
                    }
                    if (replacementsDictionary.ContainsKey("$useiisexpress$"))
                    {
                        _wizardFrm.UseIISExpress = Convert.ToBoolean(replacementsDictionary["$useiisexpress$"]);
                    }
                    _wizardFrm.RefreshTextValues();
                    _wizardFrm.ShowDialog();

                    if (_wizardFrm.CancelWizard)
                    {
                        throw new WizardCancelledException();
                    }

                    // Add custom parameters.
                    _rootnamespace     = _wizardFrm.RootNamespace;
                    _ownername         = _wizardFrm.OwnerName;
                    _owneremail        = _wizardFrm.OwnerEmail;
                    _ownerwebsite      = _wizardFrm.OwnerWebsite;
                    _devenvironmenturl = _wizardFrm.DevelopmentUrl;
                    _useiisexpress     = _wizardFrm.UseIISExpress.ToString();
                }
                updateReplacementDictionaryItem("$solutionname$", _solutionName);
                updateReplacementDictionaryItem("$rootnamespace$", _rootnamespace);
                updateReplacementDictionaryItem("$ownername$", _ownername);
                updateReplacementDictionaryItem("$owneremail$", _owneremail);
                updateReplacementDictionaryItem("$ownerwebsite$", _ownerwebsite);
                updateReplacementDictionaryItem("$devenvironmenturl$", _devenvironmenturl);
                updateReplacementDictionaryItem("$useiisexpress$", _useiisexpress);
            }
            catch (Exception ex)
            {
                if (!(ex is WizardCancelledException))
                {
                    MessageBox.Show(ex.ToString());
                }
                else
                {
                    throw new WizardCancelledException("User cancelled template wizard");
                }
            }
        }
Exemplo n.º 25
0
 public TagetClassSelect(EnvDTE._DTE applicationObject)
 {
     InitializeComponent();
     _applicationObject = applicationObject;
     PopulateDialog();
 }
Exemplo n.º 26
0
 //------------------------ "do" methods separate from "walk" methods here
 public static void do_DTE(EnvDTE._DTE applicationObject)
 {
     Debug.WriteLine("DTE applicationObject: {0}", applicationObject.Name);
 }
        /// <summary>
        /// Returns a reference to the Development Tools Extensibility (DTE) object
        /// </summary>
        /// <returns>DTE object</returns>
        public static EnvDTE._DTE GetDTE()
        {

            if (DTE != null)
                return DTE;

            // Get the DTE

            // The following method works fine IF you only have one instance of VS .NET open...
            // It returns the first created instance of VS .NET...not necessarily the current instance!
            //			return (EnvDTE._DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE");

            // This code was adapted from Girish Hegde's on-line article
            // "Adding or Changing Code using FileCodeModel in Visual Studio .NET
            EnvDTE.DTE dte = null;

            // Get the ROT
            UCOMIRunningObjectTable rot;
            uint uret = GetRunningObjectTable(0, out rot);
            if (uret == S_OK)
            {
                // Get an enumerator to access the registered objects
                UCOMIEnumMoniker EnumMon;
                rot.EnumRunning(out EnumMon);
                if (EnumMon != null)
                {
                    // Just grab a bunch of them at once, 100 should be
                    // plenty for a test
                    const int NumMons = 100;
                    UCOMIMoniker[] aMons = new UCOMIMoniker[NumMons];
                    int Fetched = 0;
                    EnumMon.Next(NumMons, aMons, out Fetched);

                    // Set up a binding context so we can access the monikers
                    string Name;
                    UCOMIBindCtx ctx;
                    uret = CreateBindCtx(0, out ctx);

                    // Create the ROT name of the _DTE object using the process id
                    System.Diagnostics.Process currentProcess =
                        System.Diagnostics.Process.GetCurrentProcess();

                    string dteName = "VisualStudio.DTE.";
                    string processID = ":" + currentProcess.Id.ToString();

                    // for each moniker retrieved
                    for (int i = 0; i < Fetched; i++)
                    {
                        // Get the display string
                        aMons[i].GetDisplayName(ctx, null, out Name);

                        // If this is the one we are interested in...
                        if (Name.IndexOf(dteName) != -1 && Name.IndexOf(processID) != -1)
                        {
                            object temp;
                            rot.GetObject(aMons[i], out temp);

                            dte = (EnvDTE.DTE)temp;
                            break;
                        }
                    }
                }
            }

            // *** Cache the reference if found
            DTE = dte;

            return dte;
        }
Exemplo n.º 28
0
        /// <summary>
        /// Returns a reference to the Development Tools Extensibility (DTE) object
        /// </summary>
        /// <returns>DTE object</returns>
        public static EnvDTE._DTE GetDTE()
        {
            if (DTE != null)
            {
                return(DTE);
            }

            // Get the DTE

            // The following method works fine IF you only have one instance of VS .NET open...
            // It returns the first created instance of VS .NET...not necessarily the current instance!
            //			return (EnvDTE._DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE");

            // This code was adapted from Girish Hegde's on-line article
            // "Adding or Changing Code using FileCodeModel in Visual Studio .NET
            EnvDTE.DTE dte = null;

            // Get the ROT
            UCOMIRunningObjectTable rot;
            uint uret = GetRunningObjectTable(0, out rot);

            if (uret == S_OK)
            {
                // Get an enumerator to access the registered objects
                UCOMIEnumMoniker EnumMon;
                rot.EnumRunning(out EnumMon);
                if (EnumMon != null)
                {
                    // Just grab a bunch of them at once, 100 should be
                    // plenty for a test
                    const int      NumMons = 100;
                    UCOMIMoniker[] aMons   = new UCOMIMoniker[NumMons];
                    int            Fetched = 0;
                    EnumMon.Next(NumMons, aMons, out Fetched);

                    // Set up a binding context so we can access the monikers
                    string       Name;
                    UCOMIBindCtx ctx;
                    uret = CreateBindCtx(0, out ctx);

                    // Create the ROT name of the _DTE object using the process id
                    System.Diagnostics.Process currentProcess =
                        System.Diagnostics.Process.GetCurrentProcess();

                    string dteName   = "VisualStudio.DTE.";
                    string processID = ":" + currentProcess.Id.ToString();

                    // for each moniker retrieved
                    for (int i = 0; i < Fetched; i++)
                    {
                        // Get the display string
                        aMons[i].GetDisplayName(ctx, null, out Name);

                        // If this is the one we are interested in...
                        if (Name.IndexOf(dteName) != -1 && Name.IndexOf(processID) != -1)
                        {
                            object temp;
                            rot.GetObject(aMons[i], out temp);

                            dte = (EnvDTE.DTE)temp;
                            break;
                        }
                    }
                }
            }

            // *** Cache the reference if found
            DTE = dte;

            return(dte);
        }
Exemplo n.º 29
0
        public void RunStarted(object automationObject, Dictionary<string, string> props, WizardRunKind runKind, object[] customParams)
        {
            this.dte = automationObject as EnvDTE._DTE;

            // Check that SharpDX is correctly installed
            if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SharpDXSdkDir")))
            {
                MessageBox.Show("Unable to find SharpDX installation directory. Expecting [SharpDXSdkDir] environment variable", "SharpDX Toolkit Wizard Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw new WizardCancelledException("Expecting [SharpDXSdkDir] environment variable");
            }
            props.Add("$safeclassname$", props["$safeprojectname$"].Replace(".", string.Empty));

            props["$currentVsCulture$"] = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;

            //Call win form created in the project to accept user input
            wizardForm = new WizardForm(props);
            var result = wizardForm.ShowDialog();
            if (result == DialogResult.Cancel)
            {
                throw new WizardCancelledException();
            }

            // Hack on WinRT / WinRT XAML to run the certificate wizards as well as our own wizard
            if (GetKey(props, "$sharpdx_platform_winrt$") || GetKey(props, "$sharpdx_platform_winrt_xaml$"))
            {
                try
                {
                    var assembly = Assembly.Load("Microsoft.VisualStudio.WinRT.TemplateWizards, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
                    var type = assembly.GetType("Microsoft.VisualStudio.WinRT.TemplateWizards.CreateProjectCertificate.Wizard");
                    winRTCertificateWizard = (IWizard)Activator.CreateInstance(type);
                }
                catch (Exception ex)
                {
                }
            }
            if (winRTCertificateWizard != null) winRTCertificateWizard.RunStarted(automationObject, props, runKind, customParams);

            // Set spritebatch feature if spritetexture or spritefont is true
            if (GetKey(props, "$sharpdx_feature_spritetexture$") || GetKey(props, "$sharpdx_feature_spritefont$"))
            {
                props["$sharpdx_feature_spritebatch$"] = "true";
            }

            if (GetKey(props, "$sharpdx_feature_model3d$") || GetKey(props, "$sharpdx_feature_primitive3d$"))
            {
                props["$sharpdx_feature_3d$"] = "true";
            }

            if (GetKey(props, "$sharpdx_platform_winrt_xaml$"))
            {
                props["$sharpdx_platform_winrt$"] = "true";
            }

            isPlatformWP8 = props.ContainsKey("$sharpdx_platform_wp8$");
        }
 /// <summary>
 /// Called when the AddIn is discarded. This method allows each of the commands to
 /// to unregister and close down on exiting.
 /// </summary>
 /// <param name="application"> Root object in the application </param>
 /// <param name="connectMode"> 'Mode' in which the environment is closing the addin </param>
 /// <param name="addIn"> Object representing this AddIn in the Object Model</param>
 public void OnDisconnection(EnvDTE._DTE application, Extensibility.ext_DisconnectMode disconnectMode, EnvDTE.AddIn addIn)
 {
     application.Commands.Item("FacultyClient.Connect." + m_strCommandName, 0).Delete();
 }
Exemplo n.º 31
0
 public static void WalkDTE(EnvDTE._DTE applicationObject)
 {
     do_DTE(applicationObject);
     WalkSolution(applicationObject.Solution);
 }