/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private void CreateCode(object sender, EventArgs e) { if (CommonContainer.CommonServer == null) { CommonContainer.CommonServer = (DTE)(GetService(typeof(DTE))); } CommonContainer.CommonServer.OutString(Resources.BeginCollectInfo, true); //获取项目的信息 FormMain frm = new FormMain(); if (frm.ShowDialog() != DialogResult.OK) { return; } FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.RootFolder = Environment.SpecialFolder.MyComputer; dialog.Description = Resources.SolutionPath; if (dialog.ShowDialog() == DialogResult.OK) { string projectName = KeywordContainer.Resove("$ProjectName$"); string space = IniManager.ReadString(Resources.NodeName, Resources.NameSpaceName, ""); CommonContainer.CommonServer.Solution.Create(string.Format("{1}.{0}.sln", projectName, space), string.Format("{1}.{0}", projectName, space)); CommonContainer.CommonServer.Solution.SaveAs(Path.Combine(dialog.SelectedPath, string.Format("{1}.{0}.sln", projectName, space))); CommonContainer.SolutionPath = dialog.SelectedPath; } else { return; } SolutionStrategy strategy = new SolutionStrategy(); strategy.BeginStrategy(); }