/// <summary>
        /// 新建工程的具体函数操作。新建工程时,如果发现工程的资源管理器中有其他工程处在打开状态,则提示是否保存,
        /// 如“保存”,则调用 saveProjectOperation()函数进行工程的保存操作;
        /// 对新建的工程的名称进行合法性检查,并在工程的资源管理器中新建一个根级文件夹节点作为当前工程项目文件夹。
        /// 
        /// 注:
        /// 在新建工程时,提供的是要保存的工程的名称,
        /// 在这个路径下会产生该以该工程名称命名的文件夹,该文件夹下会生成一个同名称的,以.caproj为后缀的工程资源管理文件,
        /// 并生成一个空的设计页面,名称为:DesignView_1
        /// </summary>
        private void NewProject()
        {
            try
            {
                if (solutionTreeView.Nodes.Count > 0)
                {
                    DialogResult Sresult = CassMessageBox.Question("是否保存原有项目?");
                    if (Sresult == DialogResult.Yes)
                    {
                        saveProjectOperation();  //调用保存工程程序
                        CassViewGenerator.currentTabPage = null;
                    }
                }

                //清空原有资源管理器
                ClearResource();

                string tempNum = GetNewPnum();//临时工程序号
                NewPorject newForm = new NewPorject(tempNum);
                DialogResult Oresult = newForm.ShowDialog();
                if (Oresult == DialogResult.OK)
                {
                    //保存文件路径、工程名、工程周期
                    ProjectName = newForm.Pname;
                    ProjectInfo = newForm.Pinfo;
                    ProjectNum = tempNum;
                    PnumList.Add(ProjectNum);
                    saveName = newForm.Pname + ".caproj";
                    savePath = programPath + "\\" + newForm.Pname;
                    ProjectInfo = newForm.Pinfo;

                    //添加到工程资源管理器节点中。
                    HostControl hostControl = hostDesignManage.GetNewHost(MainPageName);
                    if (hostControl != null && hostControl.LoadBool == true)
                    {
                        ListObject listObject = new ListObject();  //新增加的链表结点
                        listObject.tabPage = AddTabForNewHost(MainPageName, hostControl);
                        TreeNode designNode = CreateNode(MainPageName, this.treeMenuPage);

                        this.solutionTreeView.Nodes.Add(designNode);

                        listObject.pathName = designNode.FullPath.Trim();
                        listObject.UndoAndRedo = new UndoOperation(listObject.tabPage);
                        currentUndo = listObject.UndoAndRedo;
                        //将对象添加到链表中
                        this.tabList.Add(listObject);
                        nodeList.Add(listObject);

                        //按键设置,用于对当前控件的选择
                        if (tabControlView.SelectedTab != null)
                        {
                            CassViewGenerator.currentTabPage = this.tabControlView.SelectedTab;
                        }

                        this.solutionTreeView.Nodes.Add(CodePageName);
                        this.solutionTreeView.ExpandAll();
                        this.dockManager.ShowContent(this.tabSolution_Property);//显示属性表

                        if (nodeList.Count > 0)   //如果有设计页面,则显示可以形成项目文件
                        {
                            this.saveProject.Enabled = true;
                        }
                        //设置编辑栏中的具体状态
                        this.aliginToolStripMenuItem.Enabled = false;
                        this.cutToolStripMenuItem.Enabled = false;
                        this.copyToolStripMenuItem.Enabled = false;
                        this.deleteControlToolStripMenuItem.Enabled = false;
                        this.selectAllMenuItem.Enabled = false;
                    }
                    else
                    {
                        CassMessageBox.Error("新建工程发生异常!");
                    }

                    Directory.CreateDirectory(savePath);
                    FileStream fStream = new FileStream(this.savePath + "//" + this.saveName, FileMode.Create);

                    DirectoryInfo[] infos = new DirectoryInfo(programPath).GetDirectories();
                    //if (infos.Length != this.ProListBox.Items.Count)
                    //{//如果工程文件夹数和现有工程数不同则判定为新加了控件
                    //    ListViewItem newProject = new ListViewItem(new string[] { ProjectName, ProjectInfo });
                    //    this.ProListBox.Items.Add(newProject);
                    //}
                    bool exist = false;
                    for (int i = 0; i < this.ProListBox.Items.Count; i++)
                    {
                        if (ProListBox.Items[i].Text == ProjectName)
                        {
                            exist = true;
                        }
                    }
                    if (!exist)
                    {
                        ListViewItem newProject = new ListViewItem(new string[] { ProjectName, ProjectInfo });
                        this.ProListBox.Items.Add(newProject);
                    }
                    this.Text = this.Text.Split('_')[0] + "_" + ProjectName;//显示当前工程名

                    this.saveProject.Enabled = true;        //允许保存工程
                    this.saveProjecttoolStripButton.Enabled = true;
                    this.closeProjecttoolStripMenuItem.Enabled = true;
                    this.addItemtoolStripSplitButton.Enabled = true;
                    this.designViewStripMenu.Enabled = true;
                    fStream.Close();

                    //新建时状态栏显示图形编辑模式
                    ModeSelect(0);
                }
            }
            catch (FileNotFoundException ex)
            {
                CassMessageBox.Error("安装文件被损坏!");
            }
            catch (DirectoryNotFoundException ex)
            {
                CassMessageBox.Error("安装文件被损坏!");
            }
            catch (SecurityException ex)
            {
                CassMessageBox.Error("文件权限被修改!");
            }
            catch (PathTooLongException e)
            {
                CassMessageBox.Error("磁盘文件物理路径过长!");
            }
            catch (NotSupportedException e)
            {
                CassMessageBox.Error("创建的目录的路径无效!");
            }
            catch (UnauthorizedAccessException e)
            {
                CassMessageBox.Error("磁盘保护,不可创建目录!");
            }
            catch (IOException e)
            {
                CassMessageBox.Error("文件操作无效!");
            }
            catch (Exception ex)
            { }
        }
        /// <summary>
        /// 修改工程名和工程信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ModifyStripMenuItem_Click(object sender, EventArgs e)
        {
            NewPorject newForm = new NewPorject(this.ProListBox.SelectedItems[0].Text, this.ProListBox.SelectedItems[0].SubItems[1].Text);
            if (newForm.ShowDialog() == DialogResult.OK)
            {
                if (this.ProListBox.SelectedItems[0].Text == ProjectName)
                {//如果修改的是当前工程
                    //先保存当前工程
                    saveProjectOperation();
                    //修改当前工程名和工程信息
                    ProjectName = newForm.Pname;
                    ProjectInfo = newForm.Pinfo;
                    this.savePath = Path.Combine(programPath, ProjectName);//修改保存路径
                    this.Text = this.Text.Split('_')[0] + "_" + ProjectName;
                }
                string NewProPath = programPath + "\\" + this.ProListBox.SelectedItems[0].Text;//修改后工程目录文件夹
                string OldProFile = Path.Combine(NewProPath, this.ProListBox.SelectedItems[0].Text) + ".caproj";//修改后为修改的工程文件路径
                string NewProFild = Path.Combine(NewProPath, newForm.Pname) + ".caproj";//修改后新的工程文件路径

                //读取旧工程文件后删除
                List<string> getInfo = new List<string>();
                string rowInfo = null;
                FileStream fRStream = new FileStream(OldProFile, FileMode.Open);
                StreamReader sReader = new StreamReader(fRStream);
                while ((rowInfo = sReader.ReadLine()) != null)
                {
                    getInfo.Add(rowInfo);
                }
                sReader.Close();
                fRStream.Close();
                File.Delete(OldProFile);

                //将读取的原有工程修改其中的工程信息后写入新的工程文件
                FileStream fWStream = new FileStream(NewProFild, FileMode.Create);
                StreamWriter sWriter = new StreamWriter(fWStream);

                for (int i = 0; i < getInfo.Count; i++)
                {
                    if (i == 0)
                    { sWriter.WriteLine(getInfo[i].Split(',')[0] + "," + newForm.Pinfo); }
                    else
                    { sWriter.WriteLine(getInfo[i]); }
                }
                sWriter.Close();
                fWStream.Close();

                //将修改前工程文件夹移植修改后的新工程文件夹
                if (!Directory.Exists(Path.Combine(programPath, newForm.Pname)))
                {//存在目标工程则只修改工程信息
                    Directory.Move(NewProPath, Path.Combine(programPath, newForm.Pname));
                }

                //修改工程管理栏中对应的工程文件名和工程信息
                this.ProListBox.SelectedItems[0].Text = newForm.Pname;
                this.ProListBox.SelectedItems[0].SubItems[1].Text = newForm.Pinfo;
            }
        }