示例#1
0
        public async Task BuildAsync(ProjectInfo projectInfo)
        {
            try
            {
                if (projectInfo.SelectedProject != null)
                {
                    string configName = dte.Solution.SolutionBuild.ActiveConfiguration.Name;
                    Microsoft.VisualStudio.VCProjectEngine.VCProject vcProj =
                        (Microsoft.VisualStudio.VCProjectEngine.VCProject)projectInfo.SelectedProject.DTEProject.Object;
                    Microsoft.VisualStudio.VCProjectEngine.IVCCollection configs =
                        (Microsoft.VisualStudio.VCProjectEngine.IVCCollection)vcProj.Configurations;
                    Microsoft.VisualStudio.VCProjectEngine.VCConfiguration config =
                        FindConfig(configs, configName);
                    var solutionName = Path.GetFileNameWithoutExtension(dte.Solution.FileName);

                    dte.Windows.Item(EnvDTE.Constants.vsWindowKindSolutionExplorer).Activate();
                    dte.ToolWindows.SolutionExplorer.GetItem($"{solutionName}\\{projectInfo.SelectedProject.DTEProject.Name}").Select(EnvDTE.vsUISelectionType.vsUISelectionTypeSelect);
                    m_buildCompletedEvent.Reset();
                    dte.Events.BuildEvents.OnBuildDone += BuildEvents_OnBuildDone;
                    dte.ExecuteCommand("ClassViewContextMenus.ClassViewProject.Build");
                    await Task.Run(() => m_buildCompletedEvent.WaitOne());
                }
            }
            catch (Exception ex)
            {
                WriteLine(1, "Could not start debugging\nEXCEPTION: " + ex.ToString());
            }
        }
        public void OpenFileInVisualStudio(string filename, int lineNumber)
        {
            try
            {
                EnvDTE80.DTE2 boa = (EnvDTE80.DTE2)Msdev.GetIDEInstance(_solutionPath);

                if (boa == null)
                {
                    boa = OpenBoaSolution();
                }

                File.WriteAllText(Path.Combine(Environment.CurrentDirectory, "filename.txt"), filename);

                boa.ExecuteCommand("File.OpenFile", filename);

                ((EnvDTE.TextSelection)boa.ActiveDocument.Selection).GotoLine(lineNumber, true);
                boa.ActiveWindow.Activate();

                boa.MainWindow.WindowState   = vsWindowState.vsWindowStateMinimize;
                boa.ActiveWindow.WindowState = vsWindowState.vsWindowStateMinimize;

                boa.ActiveWindow.Activate();
                boa.MainWindow.Activate();
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
        }
        public async void AssociateIt(int selectedWorkItemId, object mm)
        {
            await ParentSection.RefreshAsync();

            IPendingChangesExt pendingChangesExt = ParentSection.GetService <IPendingChangesExt>();

            var model = pendingChangesExt.GetType().GetField("m_workItemsSection", BindingFlags.NonPublic | BindingFlags.Instance);

            var modelType       = model.FieldType;
            var workItemSection = model.GetValue(pendingChangesExt);

            var selectedWil = workItemSection.GetType().GetProperty("SelectedWorkItems").GetValue(workItemSection) as ObservableCollection <WorkItemValueProvider>;
            var availablWil = workItemSection.GetType().GetProperty("WorkItemsListProvider").GetValue(workItemSection) as WorkItemsListProvider;

            try
            {
                while (!availablWil.WorkItems.Where(x => x.Id == selectedWorkItemId).Any())
                {
                    await System.Threading.Tasks.Task.Delay(25);
                }

                selectedWil.Clear();
                selectedWil.Add(availablWil.WorkItems.Where(x => x.Id == selectedWorkItemId).First());

                EnvDTE80.DTE2 dte2 = Package.GetGlobalService(typeof(DTE)) as DTE2;
                dte2.ExecuteCommand("TeamFoundationContextMenus.WorkItemActionLink.TfsContextPendingChangesPageWorkItemActionLinkAssociate");
                selectedWil.Clear();
            }
            catch (Exception ex)
            {
                ParentSection.ShowNotification(ex.ToString(), NotificationType.Error);
            }
        }
示例#4
0
        void OnTransformSelectedExec(object sender, EventArgs e)
        {
            this.SaveAllDocumentsBeforeBuild();

            _dte.ExecuteCommand("View.Output", "");
            OutputWindowHelper outHelper = new OutputWindowHelper(_dte);
            List <ProjectItem> toProcess = new List <ProjectItem>();

            //Get items to be transformed.
            Project selectedProject = ToDteProject(GetSelectedProject(_serviceProvider));

            FindProjectItems(selectedProject, toProcess);
            outHelper.Clear();
            outHelper.AddMessage(string.Format(Resources.StartCodeGen, selectedProject.Name));
            outHelper.AddMessage(Resources.Seperator);

            uint         pdwCookie = 0;
            uint         count     = (uint)toProcess.Count;
            IVsStatusbar service   = _serviceProvider.GetService(typeof(IVsStatusbar)) as IVsStatusbar;

            if (service != null)
            {
                service.Progress(ref pdwCookie, 1, Resources.TextTemplatingStatusBarLabel, 0, count);
            }

            uint complete  = 1;
            bool errorFlag = false;

            foreach (ProjectItem item in toProcess)
            {
                Application.DoEvents();
                VSProjectItem vsItem = item.Object as VSProjectItem;
                if (vsItem != null)
                {
                    errorFlag |= this.RunCustomTool(item, vsItem, GetCustomTool(item), outHelper);
                }
                if (service != null)
                {
                    service.Progress(ref pdwCookie, 1, Resources.TextTemplatingStatusBarLabel, complete, count);
                }
                complete++;
                Application.DoEvents();
            }

            outHelper.AddMessage(Resources.Seperator);
            outHelper.AddMessage(Resources.EndCodeGen);
            if (service != null)
            {
                service.Progress(ref pdwCookie, 0, string.Empty, count, count);
            }
        }
示例#5
0
 public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
 {
     DTE.ExecuteCommand("View.ViewCode");
 }
 public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
 {
     DTE.ExecuteCommand("View.SolutionExplorer");
 }
示例#7
0
 private void EnterRenameState()
 {
     EnvDTE80.DTE2 _applicationObject = GetGlobalService(typeof(DTE)) as EnvDTE80.DTE2;
     _applicationObject.ExecuteCommand("File.Rename");
 }
 public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
 {
     DTE.ExecuteCommand("Edit.GoToDefinition");
 }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            VsProjectHelper.Initialize();
            VsProjectHelper prjHelperInstance = VsProjectHelper.GetInstance;
            List <string>   prjlist           = new List <string>();
            Project         prj = null;

            prjlist.Add("Empty");

            IEnumerator prjEnum = prjHelperInstance.GetProjects().GetEnumerator();

            while (prjEnum.MoveNext())
            {
                prj = (Project)prjEnum.Current;
                prjlist.Add(prj.Name);
            }

            ProjectWizardViewTizenCrossPlatform nWizard = new ProjectWizardViewTizenCrossPlatform(replacementsDictionary["$projectname$"], replacementsDictionary["$solutiondirectory$"],
                                                                                                  Trans_boolean(replacementsDictionary["$hasCommon$"]), Trans_boolean(replacementsDictionary["$hasMobile$"]), Trans_boolean(replacementsDictionary["$hasTV$"]),
                                                                                                  Trans_boolean(replacementsDictionary["$hasWearable$"]), Trans_boolean(replacementsDictionary["$hasSharedLib$"]), prjlist);

            if (nWizard.ShowDialog() == false)
            {
                EnvDTE80.DTE2 dte2 = VsProjectHelper.GetInstance.GetDTE2();
                if (replacementsDictionary["$exclusiveproject$"] == "True")
                {
                    Directory.Delete(replacementsDictionary["$solutiondirectory$"], true);
                    dte2.ExecuteCommand("File.NewProject");
                }
                else
                {
                    Directory.Delete(replacementsDictionary["$destinationdirectory$"], true);
                    dte2.ExecuteCommand("File.AddNewProject");
                }
                throw new WizardCancelledException();
            }
            else
            {
                replacementsDictionary["$select_common$"]   = nWizard.manifestData.Select_common.ToString().ToLower();
                replacementsDictionary["$select_mobile$"]   = nWizard.manifestData.Select_mobile.ToString().ToLower();
                replacementsDictionary["$select_tv$"]       = nWizard.manifestData.Select_tv.ToString().ToLower();
                replacementsDictionary["$select_wearable$"] = nWizard.manifestData.Select_wearable.ToString().ToLower();
                if (nWizard.manifestData.Shared_library)
                {
                    replacementsDictionary["$hasSharedLib$"] = "true";
                }
                else
                {
                    replacementsDictionary["$hasSharedLib$"] = nWizard.manifestData.Selected_project_name;
                }
            }

            // Project Name change
            int    idx     = replacementsDictionary["$safeprojectname$"].IndexOf("Tizen");
            string prjName = replacementsDictionary["$safeprojectname$"];

            replacementsDictionary["$namespace$"]   = prjName;
            replacementsDictionary["$lib_prjName$"] = prjName;
            if (idx != -1)// && Trans_boolean(replacementsDictionary["$hasSharedLib$"]))
            {
                if (replacementsDictionary["$hasSharedLib$"] != "true")
                {
                    replacementsDictionary["$common_prjName$"] = prjName;
                }
                else
                {
                    replacementsDictionary["$common_prjName$"] = prjName + ".Tizen";
                }
                replacementsDictionary["$mobile_prjName$"]   = prjName + ".Mobile";
                replacementsDictionary["$tv_prjName$"]       = prjName + ".TV";
                replacementsDictionary["$wearable_prjName$"] = prjName + ".Wearable";
            }
            else
            {
                replacementsDictionary["$common_prjName$"]   = prjName + ".Tizen";
                replacementsDictionary["$mobile_prjName$"]   = prjName + ".Tizen.Mobile";
                replacementsDictionary["$tv_prjName$"]       = prjName + ".Tizen.TV";
                replacementsDictionary["$wearable_prjName$"] = prjName + ".Tizen.Wearable";
            }
        }