Ejemplo n.º 1
0
        /// <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)
        {
            var DTE      = (DTE2)this.ServiceProvider.GetService(typeof(DTE));
            var solution = (IVsSolution)this.ServiceProvider.GetService(typeof(IVsSolution));

            FormProjectPicker form = new FormProjectPicker();

            List <EnvDTE.Project> projectList = new List <EnvDTE.Project>();

            foreach (IVsHierarchy hier in Utility.GetProjectsInSolution(solution, __VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION))
            {
                EnvDTE.Project project = Utility.GetDTEProject(hier);
                if (project != null)
                {
                    projectList.Add(project);
                    form.projectList.Items.Add(project.Name);
                }
            }

            form.ShowDialog();

            if (form.projectList.SelectedItem == null)
            {
                return;
            }

            String selectedProjectName = form.projectList.SelectedItem.ToString();

            if (selectedProjectName == "")
            {
                return;
            }

            EnvDTE.Project targetProject = projectList[form.projectList.SelectedIndex];

            TextSelection sel =
                (TextSelection)DTE.ActiveDocument.Selection;
            CodeClass     sourceClass   = (CodeClass)sel.ActivePoint.get_CodeElement(vsCMElement.vsCMElementClass);
            List <string> functionList  = new List <string>();
            string        interfaceName = "I" + sourceClass.Name;

            Utility.AddClassToProject(targetProject, interfaceName, false);

            System.Threading.Timer timer = null;
            timer = new System.Threading.Timer((obj) =>
            {
                AddFunctionToClass(targetProject, sourceClass, interfaceName);
                timer.Dispose();
            },
                                               null, 100, System.Threading.Timeout.Infinite);
        }
Ejemplo n.º 2
0
        /// <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)
        {
            FormProjectPicker form = new FormProjectPicker();

            var DTE      = (DTE2)this.ServiceProvider.GetService(typeof(DTE));
            var solution = (IVsSolution)this.ServiceProvider.GetService(typeof(IVsSolution));

            List <EnvDTE.Project> projectList = new List <EnvDTE.Project>();

            foreach (IVsHierarchy hier in Utility.GetProjectsInSolution(solution, __VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION))
            {
                EnvDTE.Project project = Utility.GetDTEProject(hier);
                if (project != null)
                {
                    projectList.Add(project);
                    form.projectList.Items.Add(project.Name);
                }
            }

            form.ShowDialog();

            if (form.projectList.SelectedItem == null)
            {
                return;
            }

            String selectedProjectName = form.projectList.SelectedItem.ToString();

            if (selectedProjectName == "")
            {
                return;
            }

            String className = GetSelectionClassName(DTE);

            EnvDTE.Project targetProject = projectList[form.projectList.SelectedIndex];
            Utility.AddClassToProject(targetProject, className, form.checkBoxVivotekProject.Checked);
        }