Exemplo n.º 1
0
        /// <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)
        {
            DTE dte = (DTE)(GetService(typeof(DTE)));

            //Test(dte);
            dte.OutString("开始收集构架应用程序名称信息.", true);
            FormMain frm = new FormMain(dte.Solution.FullName);

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Solution sln = dte.Solution;

            if (string.IsNullOrEmpty(sln.FullName))
            {
                FolderBrowserDialog dialog = new FolderBrowserDialog();
                dialog.RootFolder  = Environment.SpecialFolder.MyComputer;
                dialog.Description = "项目存储路径";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    sln.Create(string.Format("iTelluro.Explorer.{0}.sln", SolutionCommon.ProjectName), string.Format("iTelluro.Explorer.{0}", SolutionCommon.ProjectName));
                    dte.Solution.SaveAs(Path.Combine(dialog.SelectedPath, string.Format("iTelluro.Explorer.{0}.sln", SolutionCommon.ProjectName)));
                }
                else
                {
                    return;
                }
            }

            SolutionCommon.Dte = dte;
            SolutionStrategy strategy = new SolutionStrategy(dte);

            strategy.BeginStrategy();
        }
        /// <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();
        }