Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         int c = listView1.SelectedIndices[0];                                          //获得选中项的索引
         currentFolder = listView1.Items[c].SubItems[1].Text + listView1.Items[c].Text; //组装绝对地址
         currentPD.FolderName(listView1.Items[currentRowIndex].Text);
         if ((currentPD == null) || (currentPD.Contacts == null))
         {
             return;
         }
         FmContacts fmContacts = new FmContacts(currentXMLpath);
         fmContacts.Pdetails = currentPD;
         fmContacts.ShowDialog();
         listView1.Focus();
         ShowOnListview();
         listView1.Items[currentRowIndex].Selected = true;//设定选中
     }
     catch
     {
         this.isActived = false;
         MessageBox.Show("未选择项目或项目未建立项目信息文件。", " 提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         this.isActived = true;
     }
 }
Ejemplo n.º 2
0
        }//打开双击文件夹

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //在此处设断点,发现点击不同的Item后,此事件居然执行了2次
            //第一次是取消当前Item选中状态,导致整个ListView的SelectedIndices变为 空集
            //第二次才将新选中的Item设置为选中状态,SelectedIndices变为 非空集
            //如果不加listview.SelectedIndices.Count>0判断,将导致获取listview.Items[]索引超界的异常
            if (listView1.SelectedIndices.Count > 0)
            {
                int c = listView1.SelectedIndices[0];                                          //获得选中项的索引
                currentFolder = listView1.Items[c].SubItems[1].Text + listView1.Items[c].Text; //组装绝对地址

                int    pos_int = listView1.Items[currentRowIndex].Text.LastIndexOf("】");
                string tmp_str = listView1.Items[currentRowIndex].SubItems[1].Text + listView1.Items[currentRowIndex].Text +
                                 @"\" + listView1.Items[currentRowIndex].Text.Remove(0, pos_int + 1) + ".xml";//组装XML文件绝对地址
                if (File.Exists(tmp_str))
                {
                    XML_Class x = new XML_Class();
                    pd = x.ReadXml(tmp_str);
                }
                else
                {
                    pd = null;
                }
                if (pd != null)
                {
                    tmp_str = listView1.Items[currentRowIndex].Text.ToString();
                    tmp_str = pd.FolderName(tmp_str);
                }
                ShowDetailsOnDV(pd);
            }
        }
Ejemplo n.º 3
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            getPdetailsFromTexts();

            //DirectoryInfo Dinfo = new DirectoryInfo(@"E:\项目文件\" + Pdetails.FolderName());//创建文件夹地址字符串
            DirectoryInfo Dinfo = new DirectoryInfo(msc_FolderList.defaultPath + @"\" + Pdetails.FolderName()); //创建文件夹地址字符串

            Dinfo.Create();                                                                                     //创建文件夹

            XML_Class XmlFile = new XML_Class();

            XmlFile.FilePath = xmlPath == null ? msc_FolderList.defaultPath + Pdetails.FolderName() + @"\foldersPD.xml" : xmlPath;
            XmlFile.WriteXml(Pdetails);
            XmlFile.SaveXml();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }