Beispiel #1
0
        /// <summary>
        /// 获取默认的timerAct
        /// </summary>
        /// <param name="searchKey"></param>
        /// <param name="bId"></param>
        /// <returns></returns>
        public static TimerAct getDefaultTimerAct(string searchKey, int bId)
        {
            TimerAct      ta          = new TimerAct();
            List <string> defaultTask = Util.readListTxt("defaultTask.dat");

            for (int i = 0; i < defaultTask.Count; i++)
            {
                if (defaultTask[i] != "")
                {
                    Act a = new Act(defaultTask[i]);
                    if (a.mainArg.Contains("搜索内容"))
                    {
                        a.viceArg = a.viceArg.Replace("key", searchKey);
                    }
                    if (a.mainArg.Contains("baseId"))
                    {
                        int n = int.Parse(a.mainArg.Replace("baseId", "").Replace("+", "").Trim());
                        n         = bId + n;
                        a.mainArg = n + "";
                    }
                    ta.acts.Add(a);
                }
            }
            return(ta);
        }
Beispiel #2
0
        /// <summary>
        /// 导入搜索关键字表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loadKeys_Click(object sender, EventArgs e)
        {
            bool res = false;

            timerAct.acts.Clear();
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                List <string> list = Util.readListTxt(openFileDialog.FileName);

                foreach (string key in list)
                {
                    if (key.Trim() == "")
                    {
                        continue;
                    }
                    TimerAct t = TimerAct.getDefaultTimerAct(key, timerAct.acts.Count);
                    timerAct.acts.AddRange(t.acts);
                }
                initListBox(timerAct);
                seqBtn_Click(sender, e);
                res = true;
            }
            this.Refresh();
            if (res)
            {
                statusLab.Text = "导入关键字库成功:" + openFileDialog.FileName;
            }
            else
            {
                statusLab.Text = "取消导入关键字库:" + openFileDialog.FileName;
            }
        }
Beispiel #3
0
 /// <summary>
 /// 将内容显示到listBox
 /// </summary>
 /// <param name="timerAct"></param>
 private void initListBox(TimerAct timerAct)
 {
     listBox1.Items.Clear();
     for (int i = 0; i < timerAct.acts.Count; i++)
     {
         listBox1.Items.Add(timerAct.acts[i].getContent());
     }
 }
Beispiel #4
0
 /// <summary>
 /// 编号
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void seqBtn_Click(object sender, EventArgs e)
 {
     timerAct = getTimeAct();
     for (int i = 0; i < timerAct.acts.Count; i++)
     {
         timerAct.acts[i].id = i;
     }
     initListBox(timerAct);
     statusLab.Text = "序列编号。";
 }
Beispiel #5
0
        /// <summary>
        /// 获取listBox中的内容
        /// </summary>
        private TimerAct getTimeAct()
        {
            TimerAct t = new TimerAct();

            for (int i = 0; i < listBox1.Items.Count; i++)
            {
                Act a = new Act(listBox1.Items[i].ToString());
                if (a != null)
                {
                    t.addAct(a);
                }
            }
            return(t);
        }
Beispiel #6
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void updateBtn_Click(object sender, EventArgs e)
        {
            Act act = new Act();

            try
            {
                act.id       = int.Parse(idTxt.Text);
                act.interval = int.Parse(intervalTxt.Text);

                if (act.act == "" || act.mainArg == "")
                {
                    MessageBox.Show("参数输入不完整!请输入完整后操作");
                }

                act.act     = actComb.Text.Split(' ')[0];
                act.mainArg = mainArgComb.Text.Split(' ')[0];
                act.viceArg = otherArgsTxt.Text;
            }
            catch
            {
                MessageBox.Show("保存出错!请检查输入");
                return;
            }

            TimerAct t = getTimeAct();
            bool     n = true;

            for (int i = 0; i < t.acts.Count; i++)
            {
                if (t.acts[i].id == act.id)
                {
                    t.acts[i] = act;
                    n         = false;
                    break;
                }
            }
            if (n)
            {
                t.acts.Add(act);
            }
            initListBox(t);
            idTxt.Text     = "";
            statusLab.Text = "已保存编辑。";
        }
Beispiel #7
0
        /// <summary>
        /// 下移
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void downToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timerAct = getTimeAct();
            int c = listBox1.SelectedItems.Count;
            int i = listBox1.SelectedIndex;

            if (listBox1.SelectedItems.Count == 1)
            {
                Act a = new Act(listBox1.Items[i].ToString());
                timerAct.acts.RemoveAt(i);
                timerAct.acts.Insert(i + 1, a);

                initListBox(timerAct);
                statusLab.Text         = "上移步骤" + c;
                listBox1.SelectedIndex = i + 1;
            }
            else
            {
                statusLab.Text = "选中一个才能移动";
            }
        }
Beispiel #8
0
        /// <summary>
        /// 移动选定的步骤
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void moveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string name = ((ToolStripMenuItem)sender).Name.Replace("toolStripMenuItem", "").Replace("_", "-");
            int    step = int.Parse(name);

            timerAct = getTimeAct();
            int c = listBox1.SelectedItems.Count;
            int i = listBox1.SelectedIndex;

            if (listBox1.SelectedItems.Count == 1)
            {
                Act a = new Act(listBox1.Items[i].ToString());
                timerAct.acts.RemoveAt(i);
                timerAct.acts.Insert(i + step, a);

                initListBox(timerAct);
                statusLab.Text         = "上移步骤" + c;
                listBox1.SelectedIndex = i + step;
            }
            else
            {
                statusLab.Text = "选中一个才能移动";
            }
        }
Beispiel #9
0
 /// <summary>
 /// 关闭窗口时处理
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TimerForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     timerAct = getTimeAct();
 }
Beispiel #10
0
 public TimerForm(TimerAct timerAct)
 {
     InitializeComponent();
     this.timerAct = timerAct;
     initListBox(timerAct);
 }