Exemplo n.º 1
0
        private void Dgv_guize_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                //获得当前选中行
                int index = dgv_guize.SelectedRows[0].Index;
                //获得对应的buzhouinfo
                BuzhouInfo mybuzhou = Setting.list_guize[index];

                //显示处理详情控件
                //显示详情控件
                Control control_xiangqing = null;
                if (mybuzhou._name.Contains("替换"))
                {
                    control_xiangqing = new UCBuzhou(mybuzhou._zhengze, mybuzhou._tihuan)
                    {
                        Dock = DockStyle.Fill
                    };
                    (control_xiangqing as UCBuzhou).tb_zhengze.TextChanged += Tb_zhengze_TextChanged;
                    (control_xiangqing as UCBuzhou).tb_tihuan.TextChanged  += Tb_tihuan_TextChanged;
                    (control_xiangqing as UCBuzhou).tb_zhengze.Leave       += UCchuli_Leave;
                    (control_xiangqing as UCBuzhou).tb_tihuan.Leave        += UCchuli_Leave;
                }
                else if (mybuzhou._name.Contains("缀") || mybuzhou._name.Contains("清除"))
                {
                    control_xiangqing = new System.Windows.Forms.TextBox()
                    {
                        Dock = DockStyle.Fill, Text = mybuzhou._text, Multiline = true
                    };
                    control_xiangqing.TextChanged += UCchuli_TextChanged;
                    control_xiangqing.Leave       += UCchuli_Leave;
                }
                panel_xiangqing.Controls.Clear();
                panel_xiangqing.Controls.Add(control_xiangqing);
            }
            catch { }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 点击整体提取按钮时触发得事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 正则提取ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //构造一个步骤info,显示在界面中
            BuzhouInfo mybuzhou = new BuzhouInfo(((ToolStripMenuItem)sender).Text);

            mybuzhou._selfname   = tb_guizemingcheng.Text;
            mybuzhou._updatedate = DateTime.Now.ToString("yyyy-MM-dd");
            if (mybuzhou._name.Contains("替换"))
            {
                mybuzhou._zhengze = "正则表达式……";
                mybuzhou._tihuan  = "替换为……";
            }
            else if (mybuzhou._name.Contains("添加"))
            {
                mybuzhou._text = "请输入……";
            }
            else if (mybuzhou._name.Contains("清除换行符"))
            {
                mybuzhou._text = "清除换行符……";
            }


            //形成一个datatable,绑定到dgvguize中
            DataTable mydt0 = dgv_guize.DataSource as DataTable;

            //判断dgv_data是否有值
            if (mydt0 == null)
            {
                mydt0 = new DataTable();
                mydt0.Columns.Add("序号");
                mydt0.Columns.Add("类型");

                mydt0.Columns.Add("名称");

                mydt0.Columns.Add("修改时间");

                mydt0.Columns.Add("正则表达式");
                mydt0.Columns.Add("替换为");
                mydt0.Columns.Add("文本");
            }


            mydt0.Rows.Add(new string[] { (mydt0.Rows.Count + 1).ToString(), mybuzhou._selfname, mybuzhou._name, mybuzhou._updatedate, mybuzhou._zhengze, mybuzhou._tihuan, mybuzhou._text });
            dgv_guize.DataSource = null;
            dgv_guize.DataSource = mydt0;
            //添加选择复选框列
            if (!dgv_guize.Columns.Contains("选择"))
            {
                DataGridViewCheckBoxColumn mycol = new DataGridViewCheckBoxColumn();
                mycol.Name         = "选择";
                mycol.HeaderText   = "选择";
                mycol.DisplayIndex = 0;
                dgv_guize.Columns.Add(mycol);
            }
            Application.DoEvents();
            GetGuize();


            //显示详情控件
            Control control_xiangqing = null;

            if (mybuzhou._name.Contains("替换"))
            {
                control_xiangqing = new UCBuzhou(mybuzhou._zhengze, mybuzhou._tihuan)
                {
                    Dock = DockStyle.Fill
                };
                (control_xiangqing as UCBuzhou).tb_zhengze.TextChanged += Tb_zhengze_TextChanged;
                (control_xiangqing as UCBuzhou).tb_tihuan.TextChanged  += Tb_tihuan_TextChanged;
                (control_xiangqing as UCBuzhou).tb_zhengze.Leave       += UCchuli_Leave;
                (control_xiangqing as UCBuzhou).tb_tihuan.Leave        += UCchuli_Leave;
            }
            else if (mybuzhou._name.Contains("缀") || mybuzhou._name.Contains("清除"))
            {
                control_xiangqing = new System.Windows.Forms.TextBox()
                {
                    Dock = DockStyle.Fill, Text = mybuzhou._text, Multiline = true
                };
                control_xiangqing.TextChanged += UCchuli_TextChanged;
                control_xiangqing.Leave       += UCchuli_Leave;
            }
            //添加步骤详情
            panel_xiangqing.Controls.Clear();
            panel_xiangqing.Controls.Add(control_xiangqing);
            Application.DoEvents();
            //UpdateDgvGuize();
            //选中新添加的最后一行
            dgv_guize.ClearSelection();
            Application.DoEvents();
            dgv_guize.CurrentCell = dgv_guize.Rows[mydt0.Rows.Count - 1].Cells[0];
            Application.DoEvents();
            //显示最后一条的步骤详情


            //清空处理前,处理后
            tb_chuliqian.Clear();
            tb_chulihou.Clear();



            //实例化一个UC处理
            //string buzhouleixing = ((ToolStripMenuItem)sender).Text;

            //UC.UCchuli myuc = new UCchuli(buzhouleixing, tb_guizemingcheng.Text)
            //{
            //    Dock = DockStyle.Top,
            //};
            //myuc.lbl_buzhou.Click += DisplayXiangqing;
            //myuc.update_buzhou += GetBuzhou;
            //myuc.update_shili += ChuLiShili;
            ////myuc.tableLayoutPanel1.BackColor = Color.SteelBlue;

            //panel_chuli.Controls.Add(myuc);
            //panel_chuli.Controls.SetChildIndex(myuc, 0);
            ////当前uclbl高亮
            //foreach (UCchuli uc in Setting.list_ucchuli)
            //{
            //    uc.lbl_buzhou.BackColor = Color.LightGray;
            //    uc.lbl_buzhou.ForeColor = Color.Black;

            //}
            ////高两
            //myuc.lbl_buzhou.BackColor = Color.SteelBlue;
            //myuc.lbl_buzhou.ForeColor = Color.White;

            //更新步骤列表setting
            //GetBuzhou();
        }