Esempio n. 1
0
        private void LoadFileFolder_Click(object sender, EventArgs e) //文件下载
        {
            CleanWindows();                                           //将窗体程序相应地方清空

            searchFileText.Text = "";                                 //搜索框文本清空
            searchFileName      = "";                                 //将搜索名称清空
            searchResult.Clear();                                     //清空搜索结果
            allPath.Clear();                                          //清空所有路径

            fileFolderName = openFileFolderText.Text;                 //保存文件夹路径
            TreeViewFunction.ClearTreeView(treeView1);                //每次重新兼树前将树清空

            try
            {
                if (TreeViewFunction.allxmlNodeinTree != null) //如果数组非空
                {
                    TreeViewFunction.allxmlNodeinTree.Clear(); //将数组清空
                }//若存储叶节点数组非空,则将数组清空
                TreeViewFunction.SetManyTree(xmlName, fileFolderName, treeView1);
                ReadAndWriteXML.WriteFolderOrFileToXml(xmlName, fileFolderName, 2);
                ShowHistory(xmlName, openFileFolderText, 2);//显示历史记录
                if (allPath != null)
                {
                    allPath.Clear();                                            //请空所有路径数组
                }
                allPath = GetallXMLNodePath(TreeViewFunction.allxmlNodeinTree); //获得当前xml文档的所有绝对路径
            }
            catch (Exception ex)
            {
                //MessageBox.Show("error,error code:" + ex.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                MessageBox.Show("文件格式错误!");
                TreeViewFunction.ClearTreeView(treeView1);//将树清空
            }
        }
Esempio n. 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            searchFileText.DroppedDown = false;                              //设置下拉框隐藏
            DataGridViewFunction.SetDataGridView(dataGridView1);             //默认设置表格1
            DataGridViewFunction.SetDataGridView(dataGridView2);             //默认设置表格2
            DataGridViewFunction.InitDataGridView(dataGridView1, "Warning"); //初始化表格1
            DataGridViewFunction.InitDataGridView(dataGridView2, "Error");   //初始化表格2

            ReadAndWriteXML.CreateXmlFile(xmlName, 4, 4, 4);                 //创建xml文件
            ShowHistory(xmlName, openFileText, 1);                           //显示历史文件记录
            ShowHistory(xmlName, openFileFolderText, 2);                     //显示历史文件夹记录
            AutoScale(this);
        }
Esempio n. 3
0
 /// <summary>
 /// 在ComboBox中显示历史记录
 /// </summary>
 /// <param name="xmlName">存储历史记录的XML文件夹</param>
 /// <param name="comboBox">被显示的ComboBox控件</param>
 /// <param name="type">显示记录的类型(1:文件 2:文件夹 3:搜索记录)</param>
 private void ShowHistory(string xmlName, ComboBox comboBox, int type)//在ComboBox中显示历史记录
 {
     comboBox.Items.Clear();
     if (File.Exists(xmlName))
     {
         Collection <string> names = ReadAndWriteXML.LoadXmlFile(xmlName, type);
         foreach (string str in names)
         {
             comboBox.Items.Add(str);
         }
         if (comboBox.Items.Count > 0)
         {
             comboBox.SelectedIndex = 0;
         }
     }
 }
Esempio n. 4
0
        private void button5_Click(object sender, EventArgs e)                  //查找文件
        {
            CleanWindows();                                                     //将窗体程序相应地方清空

            ReadAndWriteXML.WriteFolderOrFileToXml(xmlName, searchFileName, 3); //将历史搜索结果写入XML程序
            if (searchFileName.Length == 0)                                     //若无查找内容
            {
                MessageBox.Show("请输入查找的内容");
            }
            else
            {
                if (searchTreeNode != null)
                {
                    searchTreeNode.ForeColor = Color.Black;                                         //将上次选中树节点的颜色变为黑色
                }
                treeView1.CollapseAll();                                                            //关闭所有节点
                ExpandNodes(treeView1.Nodes, searchFileName);                                       //选择展开某节点
                DataGridViewFunction.ShowSerarchResult(searchResult, dataGridView1, dataGridView2); //在DataGridView中显示结果

                showw.Text = Convert.ToString(DataGridViewFunction.wCount);                         //lable刷新显示warning数量
                showe.Text = Convert.ToString(DataGridViewFunction.eCount);                         //lable刷新显示error数量
            }
        }