public Scripts(SerialPort port, Form_Main form, String script) { myPort = port; parentForm = form; myScript = script; ActionItems = new ActionItem[] { new ActionItem("ts", doTextSend), new ActionItem("wt", doWait), new ActionItem("ml", doMouseClickL), new ActionItem("mc", doMouseClickCT), new ActionItem("mr", doMouseClickR), new ActionItem("mm", doMouseMoveAbsolute), new ActionItem("md", doMouseMoveDifferential), new ActionItem("mw", doMouseWheel), new ActionItem("al", doAlert), new ActionItem("bp", doBeep) }; }
public Form_Settings(Form_Main parent, OcrCore ocr, SerialPort port, regMatch[] match, Scripts[] scripts, Timer tmr) { InitializeComponent(); this.ocr = ocr; this.port = port; this.match = match; this.scripts = scripts; numericUpDown1.Value = ocr.threshold; String[] ports = SerialPort.GetPortNames(); comboBox1.Items.Clear(); comboBox1.Items.AddRange(ports); int li = comboBox1.FindString(port.PortName); if (li >= 0) { comboBox1.SelectedIndex = li; } comboBox2.Items.Clear(); comboBox2.Items.Add("9600"); comboBox2.Items.Add("38400"); comboBox2.Items.Add("115200"); li = comboBox2.FindString(port.BaudRate.ToString()); if (li < 0) { li = 0; } comboBox2.SelectedIndex = li; this.parent = parent; checkBox1.Checked = parent.removeSpace; matchText = new TextBox[tabControl1.TabCount]; for (int i = 0; i < tabControl1.TabCount - 1; i++) { matchText[i] = new TextBox(); } accumlate = new TextBox[tabControl1.TabCount]; for (int i = 0; i < tabControl1.TabCount - 1; i++) { accumlate[i] = new TextBox(); } script = new TextBox[tabControl1.TabCount]; for (int i = 0; i < tabControl1.TabCount; i++) { script[i] = new TextBox(); } test = new Button[tabControl1.TabCount]; for (int i = 0; i < tabControl1.TabCount; i++) { test[i] = new Button(); } for (int i = 0; i < tabControl1.TabCount - 1; i++) { tabControl1.SelectedIndex = i; Label l1 = new Label(); l1.Location = new Point(6, 16); l1.AutoSize = true; l1.Text = "Match text"; tabControl1.TabPages[i].Controls.Add(l1); Label l2 = new Label(); l2.Location = new Point(118, 72); l2.AutoSize = true; l2.Text = "Accumlate"; tabControl1.TabPages[i].Controls.Add(l2); Label l3 = new Label(); l3.Location = new Point(6, 92); l3.AutoSize = true; l3.Text = "Script"; tabControl1.TabPages[i].Controls.Add(l3); tabControl1.TabPages[i].Controls.Add(matchText[i]); matchText[i].Location = new Point(6, 34); matchText[i].Size = new Size(263, 22); tabControl1.TabPages[i].Controls.Add(matchText[i]); matchText[i].TextChanged += new EventHandler(matchText_TextChanged); accumlate[i].Location = new Point(213, 69); accumlate[i].Size = new Size(52, 22); tabControl1.TabPages[i].Controls.Add(accumlate[i]); accumlate[i].TextChanged += new EventHandler(accumlate_TextChanged); } for (int i = 0; i < tabControl1.TabCount; i++) { script[i].Location = new Point(6, 110); script[i].Size = new Size(278, 140); script[i].Multiline = true; script[i].ScrollBars = ScrollBars.Vertical; tabControl1.TabPages[i].Controls.Add(script[i]); script[i].Text = scripts[i].myScript; script[i].TextChanged += new EventHandler(script_TextChanged); test[i].Location = new Point(209, 263); test[i].Size = new Size(75, 23); test[i].Text = "Test"; tabControl1.TabPages[i].Controls.Add(test[i]); test[i].Click += new EventHandler(test_Click); } Label lb = new Label(); lb.AutoSize = true; lb.Text = "Script for [STOP] button pressed."; lb.Location = new Point(6, 90); tabControl1.TabPages[tabControl1.TabCount - 1].Controls.Add(lb); for (int i = 0; i < tabControl1.TabCount - 1; i++) { regMatch tmpMatch = match[i]; matchText[i].Text = String.Copy(tmpMatch.exps); accumlate[i].Text = tmpMatch.accumlate.ToString(); } MaximumSize = new Size(370, 585); MinimumSize = new Size(370, 585); samplePeriod = tmr; nm_SamplePeriod.Value = tmr.Interval; }