Exemplo n.º 1
0
        private void btnRemoveRefs_Click(object sender, EventArgs e)
        {
            References dllRefs = this.dataGridView1.Tag as References;

            if (dllRefs == null)
            {
                return;
            }
            DataGridViewSelectedRowCollection selRows = this.dataGridView1.SelectedRows;

            if (selRows == null || selRows.Count < 1)
            {
                return;
            }
            if (MsgBox.ShowOkCancel("确认删除?") == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            this.Cursor = Cursors.WaitCursor;
            for (int i = 0; i < selRows.Count; i++)
            {
                Reference dllRef = selRows[i].Tag as Reference;
                if (dllRef != null)
                {
                    dllRef.Remove();
                    this.dataGridView1.Rows.Remove(selRows[i]);
                }
            }
            this.Cursor = Cursors.Default;
        }
Exemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.treeView1.SelectedNode == null || this.treeView1.SelectedNode.Tag == null)
            {
                MsgBox.ShowTip("请选择要引用的dll");
                return;
            }
            string dllFileName = string.Empty;

            if (string.IsNullOrEmpty(_selDllPath) == false)
            {
                dllFileName = Path.GetFileName(_selDllPath);
            }
            TreeNode selNode = this.treeView1.SelectedNode;

            if (string.IsNullOrEmpty(dllFileName) == false)
            {
                if (dllFileName != selNode.Text)
                {
                    DialogResult rlt = MsgBox.ShowOkCancel("所选dll名称与要修改引用的dll名称不一致,仍要修改吗?");
                    if (rlt == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }
            _selDllPath       = selNode.Tag as string;
            this.DialogResult = DialogResult.OK;
        }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < this.treeView1.Nodes.Count; i++)
     {
         for (int j = 0; j < this.treeView1.Nodes[i].Nodes.Count; j++)
         {
             TreeNode node = this.treeView1.Nodes[i].Nodes[j];
             if (node.Checked == false)
             {
                 continue;
             }
             string tip = string.Format("确定删除:{0}?", node.Text);
             if (MsgBox.ShowOkCancel(tip) == System.Windows.Forms.DialogResult.OK)
             {
                 try
                 {
                     File.Delete(node.Tag.ToString());
                     node.Remove();
                     if (node.Parent.Nodes.Count < 2)
                     {
                         node.Parent.Remove();
                     }
                 }
                 catch (Exception ex)
                 {
                     MsgBox.ShowTip(ex.Message);
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            Solution sol = _app.Solution as Solution;

            if (sol == null || string.IsNullOrEmpty(sol.FileName))
            {
                MsgBox.ShowTip("请先打开已有解决方案或者新建一个解决方案");
                return;
            }
            if (this.combOutPath.Text == null)
            {
                MsgBox.ShowTip("请先输入输出路径");
                return;
            }
            if (this.combSolutionPlatform.SelectedItem == null)
            {
                MsgBox.ShowTip("请先选择解决平台");
                return;
            }
            DialogResult rlt = MsgBox.ShowOkCancel("您确定要批量修改输出路径吗?");

            if (rlt == DialogResult.Cancel)
            {
                return;
            }
            string outPath     = this.combOutPath.Text.Trim();
            string solPlatform = this.combSolutionPlatform.SelectedItem.ToString();
            int    num         = 0;

            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                object obj   = this.dataGridView1[0, i].Value;
                bool   isSel = (bool)obj;
                if (isSel == false)
                {
                    continue;
                }
                Project proj = this.dataGridView1.Rows[i].Tag as Project;
                if (proj != null)
                {
                    foreach (Configuration config in proj.ConfigurationManager)
                    {
                        if (config.ConfigurationName == solPlatform)
                        {
                            config.Properties.Item("OutputPath").Value = outPath;
                            this.dataGridView1[2, i].Value             = outPath;
                            num++;
                            break;
                        }
                    }
                }
            }
            MsgBox.ShowTip(string.Format("修改输出路径完成,总共修改{0}个项目", num));
        }
        private void btnRemoveEmptyDllRef_Click(object sender, EventArgs e)
        {
            Solution sol = _app.Solution as Solution;

            if (sol == null || string.IsNullOrEmpty(sol.FileName))
            {
                MsgBox.ShowTip("请先打开已有解决方案或者新建一个解决方案");
                return;
            }
            DialogResult rlt = MsgBox.ShowOkCancel("您确定要移除dll引用路径为空的引用吗?");

            if (rlt == DialogResult.Cancel)
            {
                return;
            }
            int num = 0;

            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                object obj   = this.dataGridView1[0, i].Value;
                bool   isSel = (bool)obj;
                if (isSel == false)
                {
                    continue;
                }
                Project proj = this.dataGridView1.Rows[i].Tag as Project;
                if (proj != null)
                {
                    try
                    {
                        VSProject vsProj = proj.Object as VSProject;
                        if (vsProj == null)
                        {
                            continue;
                        }
                        References dllRefs = vsProj.References;
                        foreach (Reference dllRef in dllRefs)
                        {
                            if (string.IsNullOrEmpty(dllRef.Path))
                            {
                                dllRef.Remove();
                                num++;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
            MsgBox.ShowTip(string.Format("移除空引用完成,总共移除{0}个空引用", num));
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            Solution sol = _app.Solution as Solution;

            if (sol == null || string.IsNullOrEmpty(sol.FileName))
            {
                MsgBox.ShowTip("请先打开已有解决方案或者新建一个解决方案");
                return;
            }
            if (this.combFramework.SelectedItem == null)
            {
                MsgBox.ShowTip("请先选择解决平台");
                return;
            }
            DialogResult rlt = MsgBox.ShowOkCancel("您确定要批量修改.NET Framework版本吗?");

            if (rlt == DialogResult.Cancel)
            {
                return;
            }
            string framework = this.combFramework.SelectedItem.ToString();
            int    num       = 0;

            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                object obj   = this.dataGridView1[0, i].Value;
                bool   isSel = (bool)obj;
                if (isSel == false)
                {
                    continue;
                }
                Project proj = this.dataGridView1.Rows[i].Tag as Project;
                if (proj != null)
                {
                    proj.Properties.Item("TargetFramework").Value = this.GetFrameworkId(framework);
                    this.dataGridView1[2, i].Value = framework;
                    num++;
                }
            }
            MsgBox.ShowTip(string.Format("修改输出路径完成,总共修改{0}个项目", num));
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
Exemplo n.º 7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            Solution sol = _app.Solution as Solution;

            if (sol == null || string.IsNullOrEmpty(sol.FileName))
            {
                MsgBox.ShowTip("请先打开已有解决方案或者新建一个解决方案");
                return;
            }
            DialogResult rlt = MsgBox.ShowOkCancel("您确定要批量修改生成前事件和生成后事件吗?");

            if (rlt == DialogResult.Cancel)
            {
                return;
            }
            string preBuildEvent  = this.txtPreBuildEvent.Text.Trim();
            string postBuildEvent = this.txtPostBuildEvent.Text.Trim();
            int    num            = 0;

            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                object obj   = this.dataGridView1[0, i].Value;
                bool   isSel = (bool)obj;
                if (isSel == false)
                {
                    continue;
                }
                Project proj = this.dataGridView1.Rows[i].Tag as Project;
                if (proj != null)
                {
                    proj.Properties.Item("PreBuildEvent").Value  = preBuildEvent;
                    proj.Properties.Item("PostBuildEvent").Value = postBuildEvent;
                    this.dataGridView1[2, i].Value = preBuildEvent;
                    this.dataGridView1[3, i].Value = postBuildEvent;
                    num++;
                }
            }
            MsgBox.ShowTip(string.Format("修改输出路径完成,总共修改{0}个项目", num));
        }
Exemplo n.º 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;
                }
                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;
            }
        }