Exemplo n.º 1
0
        /// <summary>
        /// 在DataGridView中显示搜索结果
        /// </summary>
        /// <param name="searchList">搜索结果字符串数组</param>
        /// <param name="dataGridView1">DataGridView控件1</param>
        /// <param name="dataGridView2">DataGridView控件2</param>
        public static void ShowSerarchResult(Collection <string> searchList, DataGridView dataGridView1, DataGridView dataGridView2)
        {
            DataGridViewFunction.ClearDataGridView(dataGridView1); //每次点击事件后将表格1中的数据清空,重新显示
            DataGridViewFunction.ClearDataGridView(dataGridView2); //每次点击事件后将表格2中的数据清空,重新显示
            int i = 0;

            wCount = 0;
            eCount = 0;
            foreach (string s in searchList)                                               //遍历输出
            {
                string xmlNodeName = s.Substring(s.LastIndexOf("/*") + 2);                 //获取xml结点的名称
                foreach (XmlNode node in TreeViewFunction.allxmlNodeinTree)                //遍历子节点
                {
                    if (xmlNodeName == node.Name)                                          //若找到子节点
                    {
                        XmlNodeList xmlNodeList = node.ChildNodes;                         //获得该节点下的所有子节点
                        foreach (XmlNode x in xmlNodeList)                                 //遍历
                        {
                            if (x.Name.Count() > 7 && x.Name.Substring(0, 7) == "warning") //匹配节点,选出“警告”提示
                            {
                                CreatNewRow(dataGridView1, x, i++, s);
                                wCount++;
                            }
                            if (x.Name.Count() > 5 && x.Name.Substring(0, 5) == "error")//匹配节点,选出“错误”提示
                            {
                                CreatNewRow(dataGridView1, x, i++, s);
                                eCount++;
                            }
                        }
                    }
                }
                DataGridViewFunction.SetRowColor(dataGridView1); //设置表格1的颜色
                DataGridViewFunction.SetRowColor(dataGridView2); //设置表格2的颜色
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 使窗体程序部分内容清空
 /// </summary>
 private void CleanWindows()
 {
     DataGridViewFunction.ClearDataGridView(dataGridView1); //将表格1清空
     DataGridViewFunction.ClearDataGridView(dataGridView1); //将表格2清空
     showw.Text = "";                                       ///将标签清空
     showe.Text = "";                                       //将标签清空
     // searchFileText.Items.Clear();//清空下拉框
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)//treeview响应事件
        {
            if (searchTreeNode != null)
            {
                searchTreeNode.ForeColor = Color.Black;
            }
            if (e.Node.Nodes.Count == 0)                                                          //若选中叶节点
            {
                CleanWindows();                                                                   //将窗体程序相应地方清空

                foreach (XmlNode x in TreeViewFunction.allxmlNodeinTree)                          //遍历存储的xml结点
                {
                    if (x.Name == e.Node.Text)                                                    //若两个结点名称相同
                    {
                        DataGridViewFunction.ShowCompileMessage(dataGridView1, dataGridView2, x); //显示信息
                        showw.Text = Convert.ToString(DataGridViewFunction.wCount);
                        showe.Text = Convert.ToString(DataGridViewFunction.eCount);
                        break;//退出循环
                    }
                }
            }
        }
Exemplo n.º 5
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数量
            }
        }