public frmNetFrameworkSetting(DTE2 app)
        {
            InitializeComponent();

            _app = app;

            this.combFramework.SelectedIndex = 0;

            List <Project> pros = ProjectUtility.GetAllProjects(_app);

            if (pros != null && pros.Count > 0)
            {
                this.dataGridView1.Rows.Add(pros.Count);
                for (int i = 0; i < pros.Count; i++)
                {
                    this.dataGridView1[0, i].Value = true;
                    this.dataGridView1[1, i].Value = pros[i].Name;

                    string frameworkId = pros[i].Properties.Item("TargetFramework").Value.ToString();
                    this.dataGridView1[2, i].Value = GetFrameworkString(frameworkId);

                    this.dataGridView1.Rows[i].Tag = pros[i];
                }
            }
        }
        public frmDll2Lib(DTE2 app)
        {
            InitializeComponent();

            _app = app;

            this.LoadUserConfig();

            List <Project> pros = ProjectUtility.GetAllProjects(_app);

            if (pros != null && pros.Count > 0)
            {
                this.dataGridView1.Tag = pros;
                //初始化datagridview
                this.dataGridView1.Rows.Add(pros.Count);
                for (int i = 0; i < pros.Count; i++)
                {
                    this.dataGridView1[0, i].Value = true;
                    this.dataGridView1[1, i].Value = pros[i].Name;
                    this.dataGridView1[2, i].Value = string.Empty;
                    this.dataGridView1[3, i].Value = string.Empty;
                    this.dataGridView1[4, i].Value = string.Empty;
                    this.dataGridView1.Rows[i].Tag = pros[i];
                }
                //获取所有解决方案配置名称
                string activeConfigName = string.Empty;
                for (int i = 0; i < pros.Count; i++)
                {
                    foreach (Configuration config in pros[i].ConfigurationManager)
                    {
                        activeConfigName = pros[i].ConfigurationManager.ActiveConfiguration.ConfigurationName;

                        string configName = config.ConfigurationName;
                        if (this.combSolutionPlatform.Items.Contains(configName) == false)
                        {
                            this.combSolutionPlatform.Items.Add(configName);
                        }
                    }
                }
                if (this.combSolutionPlatform.Items.Count > 0)
                {
                    this.combSolutionPlatform.SelectedItem = activeConfigName;
                }
            }
            _isLoaded = true;
        }
Example #3
0
        public frmDllRefSetting(DTE2 app)
        {
            InitializeComponent();

            _app = app;

            List <Project> pros = ProjectUtility.GetAllProjects(_app);

            if (pros != null && pros.Count > 0)
            {
                for (int i = 0; i < pros.Count; i++)
                {
                    this.combProjects.Items.Add(pros[i].Name);
                }
                this.combProjects.Tag = pros;

                //获取所有解决方案配置名称
                string activeConfigName = string.Empty;
                for (int i = 0; i < pros.Count; i++)
                {
                    foreach (Configuration config in pros[i].ConfigurationManager)
                    {
                        activeConfigName = pros[i].ConfigurationManager.ActiveConfiguration.ConfigurationName;

                        string configName = config.ConfigurationName;
                        if (this.combSolutionPlatform.Items.Contains(configName) == false)
                        {
                            this.combSolutionPlatform.Items.Add(configName);
                        }
                    }
                }
                if (this.combSolutionPlatform.Items.Count > 0)
                {
                    this.combSolutionPlatform.SelectedItem = activeConfigName;
                }
            }

            this.LoadUserConfig();

            this.LoadThirdDllPathUserConfig();
        }
Example #4
0
        public frmDllRefFileCopy(DTE2 app)
        {
            InitializeComponent();

            _app = app;

            List <Project> pros = ProjectUtility.GetAllProjects(_app);

            if (pros != null && pros.Count > 0)
            {
                for (int i = 0; i < pros.Count; i++)
                {
                    this.combProjects.Items.Add(pros[i].Name);
                }
                this.combProjects.Tag = pros;
            }

            this.LoadUserConfig();

            DllRefReflectUtility.ClearTempFiles();
            DllRefReflectUtility.SubDirGuid = Guid.NewGuid().ToString();
        }
Example #5
0
        public frmPlatformSetting(DTE2 app)
        {
            InitializeComponent();

            _app = app;

            this.combPlatform.SelectedIndex = 0;

            List <Project> pros = ProjectUtility.GetAllProjects(_app);

            if (pros != null && pros.Count > 0)
            {
                this.dataGridView1.Rows.Add(pros.Count);
                string activeConfigName = string.Empty;
                for (int i = 0; i < pros.Count; i++)
                {
                    foreach (Configuration config in pros[i].ConfigurationManager)
                    {
                        activeConfigName = pros[i].ConfigurationManager.ActiveConfiguration.ConfigurationName;

                        string configName = config.ConfigurationName;
                        if (this.combSolutionPlatform.Items.Contains(configName) == false)
                        {
                            this.combSolutionPlatform.Items.Add(configName);
                        }
                    }

                    this.dataGridView1[0, i].Value = true;
                    this.dataGridView1[1, i].Value = pros[i].Name;

                    this.dataGridView1.Rows[i].Tag = pros[i];
                }
                if (this.combSolutionPlatform.Items.Count > 0)
                {
                    this.combSolutionPlatform.SelectedItem = activeConfigName;
                }
            }
        }
Example #6
0
        /// <summary>
        /// 根据名称查找项目
        /// </summary>
        /// <param name="dllName">dll名称</param>
        /// <returns>项目Project</returns>
        private Project FindProItem(string dllName, string solPlatform)
        {
            List <Project> pros = ProjectUtility.GetAllProjects(_app);

            if (pros == null || pros.Count < 1)
            {
                return(null);
            }
            for (int i = 0; i < pros.Count; i++)
            {
                Project proj     = pros[i];
                string  fileName = proj.Properties.Item("OutputFileName").Value.ToString();
                if (fileName.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase))
                {
                    string name = fileName.Substring(0, fileName.Length - 4);
                    if (name.Equals(dllName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        return(proj);
                    }
                }
            }
            return(null);
        }
Example #7
0
        public frmBuildEventSetting(DTE2 app)
        {
            InitializeComponent();

            _app = app;

            List <Project> pros = ProjectUtility.GetAllProjects(_app);

            if (pros != null && pros.Count > 0)
            {
                this.dataGridView1.Rows.Add(pros.Count);
                for (int i = 0; i < pros.Count; i++)
                {
                    this.dataGridView1[0, i].Value = false;
                    this.dataGridView1[1, i].Value = pros[i].Name;

                    this.dataGridView1[2, i].Value = pros[i].Properties.Item("PreBuildEvent").Value.ToString();
                    this.dataGridView1[3, i].Value = pros[i].Properties.Item("PostBuildEvent").Value.ToString();

                    this.dataGridView1.Rows[i].Tag = pros[i];
                }
            }
        }
Example #8
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                Solution3 sol3 = _app.Solution as Solution3;
                if (sol3 == null || string.IsNullOrEmpty(sol3.FileName))
                {
                    MsgBox.ShowTip("请先打开已有解决方案或者新建一个解决方案");
                    return;
                }
                List <Project> existProjs = ProjectUtility.GetAllProjects(_app);
                for (int i = 0; i < this.treeView1.Nodes.Count; i++)
                {
                    TreeNode rootNode = this.treeView1.Nodes[i];
                    if (rootNode.Checked && rootNode.Nodes.Count > 0)
                    {
                        string foldName      = rootNode.Tag as string;
                        bool   isExistFolder = false;
                        for (int j = 1; j < sol3.Projects.Count; j++)
                        {
                            Project proj = sol3.Projects.Item(j);
                            if (proj.Kind != ProjectKinds.vsProjectKindSolutionFolder)
                            {
                                continue;
                            }
                            if (sol3.Projects.Item(j).Name.Equals(foldName, StringComparison.CurrentCultureIgnoreCase))
                            {
                                isExistFolder = true;
                                break;
                            }
                        }
                        if (isExistFolder == false)
                        {
                            Project solFolder = sol3.AddSolutionFolder(rootNode.Tag as string);
                        }
                        for (int j = 0; j < rootNode.Nodes.Count; j++)
                        {
                            if (rootNode.Nodes[j].Checked)
                            {
                                string projPath = rootNode.Nodes[j].Tag as string;
                                bool   isExist  = false;
                                for (int k = 0; k < existProjs.Count; k++)
                                {
                                    if (existProjs[k].FileName.Equals(projPath, StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        isExist = true;
                                        break;
                                    }
                                }
                                if (isExist == false)
                                {
                                    Project proj = sol3.AddFromFile(projPath, false);
                                }
                                else
                                {
                                    MsgBox.ShowTip(Path.GetFileNameWithoutExtension(projPath) + "已经加载");
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int j = 0; j < rootNode.Nodes.Count; j++)
                        {
                            if (rootNode.Nodes[j].Checked)
                            {
                                string projPath = rootNode.Nodes[j].Tag as string;
                                bool   isExist  = false;
                                for (int k = 0; k < existProjs.Count; k++)
                                {
                                    if (existProjs[k].FileName.Equals(projPath, StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        isExist = true;
                                        break;
                                    }
                                }
                                if (isExist == false)
                                {
                                    Project proj = sol3.AddFromFile(projPath, false);
                                }
                                else
                                {
                                    MsgBox.ShowTip(Path.GetFileNameWithoutExtension(projPath) + "已经加载");
                                }
                            }
                        }
                    }
                }
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            catch (Exception ex)
            {
                MsgBox.ShowTip(ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Example #9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                Solution3 sol3 = _app.Solution as Solution3;
                if (sol3 == null || string.IsNullOrEmpty(sol3.FileName))
                {
                    MsgBox.ShowTip("请先打开已有解决方案或者新建一个解决方案");
                    return;
                }
                string saveDir = this.txtSaveDir.Text.Trim();
                if (string.IsNullOrEmpty(saveDir) || Directory.Exists(saveDir) == false)
                {
                    MsgBox.ShowTip("请选择项目保存位置");
                    return;
                }
                string rootDir = this.txtRootDir.Text.Trim();
                rootDir = rootDir.TrimEnd('.');
                if (string.IsNullOrEmpty(rootDir))
                {
                    MsgBox.ShowTip("根名字空间不能为空");
                    return;
                }
                bool isExistFolder = false;
                for (int j = 1; j < sol3.Projects.Count; j++)
                {
                    Project proj = sol3.Projects.Item(j);
                    if (proj.Kind != ProjectKinds.vsProjectKindSolutionFolder)
                    {
                        continue;
                    }
                    if (sol3.Projects.Item(j).Name.Equals(rootDir, StringComparison.CurrentCultureIgnoreCase))
                    {
                        isExistFolder = true;
                        break;
                    }
                }
                if (isExistFolder == false)
                {
                    Project solFolder = sol3.AddSolutionFolder(rootDir);
                }
                List <Project> existProjs = ProjectUtility.GetAllProjects(_app);
                for (int i = 0; i < this.richTextBox1.Lines.Length; i++)
                {
                    string subDir = this.richTextBox1.Lines[i].Trim();
                    subDir = subDir.TrimStart('.').TrimEnd('.');
                    if (string.IsNullOrEmpty(subDir))
                    {
                        continue;
                    }
                    subDir = rootDir + "." + subDir;

                    string projPath = Path.Combine(saveDir, subDir + "\\" + subDir + ".csproj");
                    bool   isExist  = false;
                    for (int k = 0; k < existProjs.Count; k++)
                    {
                        if (existProjs[k].FileName.Equals(projPath, StringComparison.CurrentCultureIgnoreCase))
                        {
                            isExist = true;
                            break;
                        }
                    }
                    if (isExist == false)
                    {
                        if (File.Exists(projPath))
                        {
                            DialogResult rlt = MsgBox.ShowOkCancel("项目保存位置下已经存在:" + subDir + ",是否需要加载?");
                            if (rlt == DialogResult.OK)
                            {
                                sol3.AddFromFile(projPath, false);
                            }
                            continue;
                        }
                        string  templatePath = sol3.GetProjectTemplate("ClassLibrary.zip", "CSharp");
                        Project proj         = sol3.AddFromTemplate(templatePath, Path.Combine(saveDir, subDir), subDir, true);
                    }
                    else
                    {
                        MsgBox.ShowTip(subDir + "已经存在");
                    }
                }
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            catch (Exception ex)
            {
                MsgBox.ShowTip(ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Example #10
0
        /// <summary>
        /// 根据名称查找项目dll输出路径
        /// </summary>
        /// <param name="dllName">dll名称</param>
        /// <returns>dll的输出路径</returns>
        private string FindProItemOutPath(string dllName, string solPlatform)
        {
            List <Project> pros = ProjectUtility.GetAllProjects(_app);

            if (pros == null || pros.Count < 1)
            {
                return(null);
            }
            for (int i = 0; i < pros.Count; i++)
            {
                Project proj     = pros[i];
                string  fileName = proj.Properties.Item("OutputFileName").Value.ToString();
                if (fileName.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase))
                {
                    string name = fileName.Substring(0, fileName.Length - 4);
                    if (name.Equals(dllName, StringComparison.CurrentCultureIgnoreCase) == false)
                    {
                        continue;
                    }
                }
                foreach (Configuration config in proj.ConfigurationManager)
                {
                    if (config.ConfigurationName == solPlatform)
                    {
                        string rootDir    = Path.GetDirectoryName(proj.FileName);
                        string outputPath = config.Properties.Item("OutputPath").Value.ToString();
                        char[] charList   = outputPath.ToCharArray();
                        int    num        = 0;
                        for (int j = 0; j < charList.Length; j++)
                        {
                            if (charList[j] == '.')
                            {
                                bool isOK = true;
                                for (int k = 0; k < j; k++)
                                {
                                    if (charList[k] != '.')
                                    {
                                        isOK = false;
                                    }
                                }
                                if (isOK)
                                {
                                    num++;
                                }
                            }
                        }
                        for (int j = 0; j < num - 1; j++)
                        {
                            rootDir = rootDir.Substring(0, rootDir.LastIndexOf('\\'));
                        }
                        if (outputPath.StartsWith("."))
                        {
                            outputPath = outputPath.Substring(outputPath.LastIndexOf('.') + 2);
                        }
                        outputPath = Path.Combine(rootDir, outputPath);
                        outputPath = Path.Combine(outputPath, fileName);
                        if (outputPath.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase) == false)
                        {
                            continue;
                        }
                        return(outputPath);
                    }
                }
            }
            return(null);
        }