コード例 #1
0
        /// <summary>
        /// Edit pattern
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var lvi = listViewPatterns.SelectedItems[0];
            var fp  = new FormPattern();

            fp.textBoxName.Text        = lvi.SubItems[1].Text;
            fp.textBoxPatternReg.Text  = lvi.SubItems[2].Text;
            fp.textBoxPatternExec.Text = lvi.SubItems[3].Text;
            fp.textBoxCommand.Text     = lvi.SubItems[4].Text;
            if (fp.ShowDialog(this) == DialogResult.OK)
            {
                lvi.SubItems[1].Text = fp.textBoxName.Text;
                lvi.SubItems[2].Text = fp.textBoxPatternReg.Text;
                lvi.SubItems[3].Text = fp.textBoxPatternExec.Text;
                lvi.SubItems[4].Text = fp.textBoxCommand.Text;
                SaveConfig();
            }
        }
コード例 #2
0
        /// <summary>
        /// Add pattern
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmiAddPattern_Click(object sender, EventArgs e)
        {
            var fp = new FormPattern();

            fp.textBoxName.Text        = $"Pattern {++maxItemNo}";
            fp.textBoxPatternReg.Text  = ".*";
            fp.textBoxPatternExec.Text = "";
            fp.textBoxCommand.Text     = (string)ConfigRegister.Current["com2", ""];
            if (fp.ShowDialog(this) == DialogResult.OK)
            {
                var lvi = new ListViewItem(new string[] {
                    $"{listViewPatterns.Items.Count + 1}",
                    fp.textBoxName.Text,
                    fp.textBoxPatternReg.Text,
                    fp.textBoxPatternExec.Text,
                    fp.textBoxCommand.Text,
                })
                {
                    Checked = true
                };
                listViewPatterns.Items.Add(lvi);
                SaveConfig();
            }
        }