public KeyboardImitateItem(int offset, int index, RemoveEventHandler removeEventHandler, SetUpSwitchHotkeyEventHandler setUpSwitchHotkeyEventHandler) { Index = index; Name = "模拟" + index; Hotkey = Keys.None; InitializeComponent(offset, removeEventHandler, setUpSwitchHotkeyEventHandler); }
public MouseImitateItem(int index, RemoveEventHandler removeEventHandler, SetUpSwitchHotkeyEventHandler setUpSwitchHotkeyEventHandler) { Index = index; Name = "模拟" + index; Operate = "左键"; Hotkey = Keys.None; InitializeComponent(0, removeEventHandler, setUpSwitchHotkeyEventHandler); }
public KeyboardImitateItem(int offset, int index, string name, List <Keys> operate, string interval, Keys hotkey, RemoveEventHandler removeEventHandler, SetUpSwitchHotkeyEventHandler setUpSwitchHotkeyEventHandler) { Index = index; Name = name; Operate = operate; Interval = interval; Hotkey = hotkey; InitializeComponent(offset, removeEventHandler, setUpSwitchHotkeyEventHandler); }
public MouseImitateItem(int offset, int index, string name, string operate, string positionX, string positionY, string interval, Keys hotkey, RemoveEventHandler removeEventHandler, SetUpSwitchHotkeyEventHandler setUpSwitchHotkeyEventHandler) { Index = index; Name = name; Operate = operate; PositionX = positionX; PositionY = positionY; Interval = interval; Hotkey = hotkey; InitializeComponent(offset, removeEventHandler, setUpSwitchHotkeyEventHandler); }
private void InitializeComponent(int offset, RemoveEventHandler removeEventHandler, SetUpSwitchHotkeyEventHandler setUpSwitchHotkeyEventHandler) { GrpMouseItem = new GroupBox(); _lblMouseOperate = new Label(); _lblMousePosition = new Label(); _lblMousePositionX = new Label(); _lblMousePositionY = new Label(); _lblMouseInterval = new Label(); _lblMouseUnit = new Label(); _lblMouseHotkey = new Label(); _cboMouseOperate = new ComboBox(); _txtMousePositionX = new TextBox(); _txtMousePositionY = new TextBox(); _txtMouseInterval = new TextBox(); _txtMouseHotkey = new TextBox(); _btnMousePosition = new Button(); _btnMouseRemove = new Button(); _btnMouseRename = new Button(); _btnMouseSetUp = new Button(); _btnMouseSwitch = new Button(); GrpMouseItem.Controls.Add(_lblMouseOperate); GrpMouseItem.Controls.Add(_lblMousePosition); GrpMouseItem.Controls.Add(_lblMousePositionX); GrpMouseItem.Controls.Add(_lblMousePositionY); GrpMouseItem.Controls.Add(_lblMouseInterval); GrpMouseItem.Controls.Add(_lblMouseUnit); GrpMouseItem.Controls.Add(_lblMouseHotkey); GrpMouseItem.Controls.Add(_cboMouseOperate); GrpMouseItem.Controls.Add(_txtMousePositionX); GrpMouseItem.Controls.Add(_txtMousePositionY); GrpMouseItem.Controls.Add(_txtMouseInterval); GrpMouseItem.Controls.Add(_txtMouseHotkey); GrpMouseItem.Controls.Add(_btnMousePosition); GrpMouseItem.Controls.Add(_btnMouseRemove); GrpMouseItem.Controls.Add(_btnMouseRename); GrpMouseItem.Controls.Add(_btnMouseSetUp); GrpMouseItem.Controls.Add(_btnMouseSwitch); GrpMouseItem.Size = new Size(756, 214); GrpMouseItem.Location = new Point(3, 3 + offset); GrpMouseItem.TabIndex = 0; GrpMouseItem.TabStop = false; GrpMouseItem.Text = Name; GrpMouseItem.Font = new Font("字体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); GrpMouseItem.BackColor = Color.Transparent; _lblMouseOperate.Size = new Size(153, 41); _lblMouseOperate.Location = new Point(6, 43); _lblMouseOperate.TabIndex = 0; _lblMouseOperate.Text = "执行操作:"; _lblMouseOperate.TextAlign = ContentAlignment.MiddleLeft; _lblMouseOperate.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _lblMousePosition.Size = new Size(153, 41); _lblMousePosition.Location = new Point(6, 104); _lblMousePosition.TabIndex = 0; _lblMousePosition.Text = "点击位置:"; _lblMousePosition.TextAlign = ContentAlignment.MiddleLeft; _lblMousePosition.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _lblMousePositionX.Size = new Size(25, 41); _lblMousePositionX.Location = new Point(160, 104); _lblMousePositionX.TabIndex = 0; _lblMousePositionX.Text = "X"; _lblMousePositionX.TextAlign = ContentAlignment.MiddleLeft; _lblMousePositionX.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _lblMousePositionY.Size = new Size(25, 41); _lblMousePositionY.Location = new Point(289, 104); _lblMousePositionY.TabIndex = 0; _lblMousePositionY.Text = "Y"; _lblMousePositionY.TextAlign = ContentAlignment.MiddleLeft; _lblMousePositionY.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _lblMouseInterval.Size = new Size(153, 41); _lblMouseInterval.Location = new Point(6, 165); _lblMouseInterval.TabIndex = 0; _lblMouseInterval.Text = "时间间隔:"; _lblMouseInterval.TextAlign = ContentAlignment.MiddleLeft; _lblMouseInterval.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _lblMouseUnit.Size = new Size(75, 41); _lblMouseUnit.Location = new Point(339, 165); _lblMouseUnit.TabIndex = 0; _lblMouseUnit.Text = "毫秒"; _lblMouseHotkey.TextAlign = ContentAlignment.MiddleLeft; _lblMouseUnit.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _lblMouseHotkey.Size = new Size(118, 41); _lblMouseHotkey.Location = new Point(509, 104); _lblMouseHotkey.TabIndex = 0; _lblMouseHotkey.Text = "快捷键:"; _lblMouseHotkey.TextAlign = ContentAlignment.MiddleLeft; _lblMouseHotkey.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _cboMouseOperate.Size = new Size(125, 38); _cboMouseOperate.Location = new Point(160, 43); _cboMouseOperate.Cursor = Cursors.Hand; _cboMouseOperate.DropDownStyle = ComboBoxStyle.DropDownList; _cboMouseOperate.Items.AddRange(new object[] { "左键", "右键" }); _cboMouseOperate.TabIndex = 1; _cboMouseOperate.SelectedIndex = Operate == "左键" ? 0 : 1; _cboMouseOperate.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _txtMousePositionX.Size = new Size(94, 42); _txtMousePositionX.Location = new Point(189, 104); _txtMousePositionX.ReadOnly = true; _txtMousePositionX.TabIndex = 0; _txtMousePositionX.TabStop = false; _txtMousePositionX.Text = PositionX; _txtMousePositionX.TextAlign = HorizontalAlignment.Right; _txtMousePositionX.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _txtMousePositionY.Size = new Size(94, 42); _txtMousePositionY.Location = new Point(320, 104); _txtMousePositionY.ReadOnly = true; _txtMousePositionY.TabIndex = 0; _txtMousePositionY.TabStop = false; _txtMousePositionY.Text = PositionY; _txtMousePositionY.TextAlign = HorizontalAlignment.Right; _txtMousePositionY.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _txtMouseInterval.Size = new Size(175, 42); _txtMouseInterval.Location = new Point(160, 162); _txtMouseInterval.TabIndex = 3; _txtMouseInterval.Text = Interval; _txtMouseInterval.TextAlign = HorizontalAlignment.Right; _txtMouseInterval.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _txtMouseInterval.KeyPress += (_, e) => { switch (e.KeyChar) { case '\b': return; case < '0': case > '9': e.Handled = true; break; } }; _txtMouseHotkey.Size = new Size(120, 35); _txtMouseHotkey.Location = Hotkey != Keys.None ? new Point(630, 115) : new Point(630, 103); _txtMouseHotkey.ReadOnly = true; _txtMouseHotkey.TabIndex = 0; _txtMouseHotkey.TabStop = false; _txtMouseHotkey.Text = Hotkey != Keys.None ? KeyModifiers.Alt + "+" + Hotkey : Hotkey.ToString(); _txtMouseHotkey.TextAlign = HorizontalAlignment.Center; _txtMouseHotkey.Font = Hotkey != Keys.None ? new Font("宋体", 8F, FontStyle.Regular, GraphicsUnit.Point, 134) : new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); _txtMouseHotkey.BorderStyle = BorderStyle.None; _btnMousePosition.Size = new Size(83, 42); _btnMousePosition.Location = new Point(420, 104); _btnMousePosition.Cursor = Cursors.Hand; _btnMousePosition.ForeColor = SystemColors.ControlText; _btnMousePosition.TabIndex = 2; _btnMousePosition.Text = "定位"; _btnMousePosition.UseVisualStyleBackColor = true; _btnMousePosition.BackColor = Color.Transparent; _btnMousePosition.Click += (_, _) => { var getPositionBox = new GetPositionBox(GrpMouseItem.Text == string.Empty ? "定位" : GrpMouseItem.Text + "·定位", "Shift+S"); getPositionBox.ShowDialog(); _txtMousePositionX.Text = getPositionBox.PositionX.ToString(); _txtMousePositionY.Text = getPositionBox.PositionY.ToString(); PositionX = getPositionBox.PositionX.ToString(); PositionY = getPositionBox.PositionY.ToString(); }; _btnMouseRemove.Size = new Size(83, 42); _btnMouseRemove.Location = new Point(650, 43); _btnMouseRemove.Cursor = Cursors.Hand; _btnMouseRemove.ForeColor = SystemColors.ControlText; _btnMouseRemove.TabIndex = 7; _btnMouseRemove.Text = "删除"; _btnMouseRemove.UseVisualStyleBackColor = false; _btnMouseRemove.BackColor = Color.Transparent; _btnMouseRemove.Click += (_, _) => { removeEventHandler(Index); }; _btnMouseRename.Size = new Size(83, 42); _btnMouseRename.Location = new Point(472, 162); _btnMouseRename.Cursor = Cursors.Hand; _btnMouseRename.ForeColor = SystemColors.ControlText; _btnMouseRename.TabIndex = 6; _btnMouseRename.Text = "命名"; _btnMouseRename.UseVisualStyleBackColor = false; _btnMouseRename.BackColor = Color.Transparent; _btnMouseRename.Click += (_, _) => { var inputPromptBox = new InputPromptBox(GrpMouseItem.Text == string.Empty ? "命名" : GrpMouseItem.Text + "·命名", "请输入名称:", GrpMouseItem.Text); inputPromptBox.ShowDialog(); if (inputPromptBox.Flag) { GrpMouseItem.Text = inputPromptBox.Result; } }; _btnMouseSetUp.Size = new Size(83, 42); _btnMouseSetUp.Location = new Point(561, 162); _btnMouseSetUp.Cursor = Cursors.Hand; _btnMouseSetUp.BackColor = Color.Transparent; _btnMouseSetUp.ForeColor = SystemColors.ControlText; _btnMouseSetUp.TabIndex = 5; _btnMouseSetUp.Text = "设置"; _btnMouseSetUp.UseVisualStyleBackColor = false; _btnMouseSetUp.Click += (_, _) => { do { var setUpHotkeyBox = new SetUpHotkeyBox(GrpMouseItem.Text == string.Empty ? "设置" : GrpMouseItem.Text + "·设置", KeyModifiers.Alt, Hotkey); setUpHotkeyBox.ShowDialog(); if (!setUpHotkeyBox.Flag) { return; } Hotkey = setUpHotkeyBox.Hotkey; _txtMouseHotkey.Text = Hotkey != Keys.None ? $"{KeyModifiers.Alt}+{Utils.KeysChangeChar(setUpHotkeyBox.Hotkey)}" : KeyModifiers.None.ToString(); _txtMouseHotkey.Location = Hotkey != Keys.None ? new Point(630, 115) : new Point(630, 103); _txtMouseHotkey.Font = Hotkey != Keys.None ? new Font("宋体", 8F, FontStyle.Regular, GraphicsUnit.Point, 134) : new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); } while (!setUpSwitchHotkeyEventHandler(Index, Hotkey)); }; _btnMouseSwitch.Size = new Size(83, 42); _btnMouseSwitch.Location = new Point(650, 162); _btnMouseSwitch.Cursor = Cursors.Hand; _btnMouseSwitch.BackColor = Color.Transparent; _btnMouseSwitch.ForeColor = SystemColors.ControlText; _btnMouseSwitch.TabIndex = 4; _btnMouseSwitch.Text = "开启"; _btnMouseSwitch.UseVisualStyleBackColor = false; _btnMouseSwitch.Click += (_, _) => { JobSwitch(); }; }
private void InitializeComponent(int offset, RemoveEventHandler removeEventHandler, SetUpSwitchHotkeyEventHandler setUpSwitchHotkeyEventHandler) { GrpKeyboardItem = new GroupBox(); _lblKeyboardOperate = new Label(); _lblKeyboardInterval = new Label(); _lblKeyboardUnit = new Label(); _lblKeyboardHotkey = new Label(); _txtKeyboardOperate = new TextBox(); _txtKeyboardInterval = new TextBox(); _txtKeyboardHotkey = new TextBox(); _btnKeyboardKey = new Button(); _btnKeyboardRemove = new Button(); _btnKeyboardRename = new Button(); _btnKeyboardSetUp = new Button(); _btnKeyboardSwitch = new Button(); GrpKeyboardItem.Controls.Add(_lblKeyboardOperate); GrpKeyboardItem.Controls.Add(_lblKeyboardInterval); GrpKeyboardItem.Controls.Add(_lblKeyboardUnit); GrpKeyboardItem.Controls.Add(_lblKeyboardHotkey); GrpKeyboardItem.Controls.Add(_txtKeyboardOperate); GrpKeyboardItem.Controls.Add(_txtKeyboardInterval); GrpKeyboardItem.Controls.Add(_txtKeyboardHotkey); GrpKeyboardItem.Controls.Add(_btnKeyboardKey); GrpKeyboardItem.Controls.Add(_btnKeyboardRemove); GrpKeyboardItem.Controls.Add(_btnKeyboardRename); GrpKeyboardItem.Controls.Add(_btnKeyboardSetUp); GrpKeyboardItem.Controls.Add(_btnKeyboardSwitch); GrpKeyboardItem.Size = new Size(756, 214); GrpKeyboardItem.Location = new Point(3, 3 + offset); GrpKeyboardItem.TabIndex = 0; GrpKeyboardItem.TabStop = false; GrpKeyboardItem.Text = Name; GrpKeyboardItem.Font = new Font("字体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); GrpKeyboardItem.BackColor = Color.Transparent; _lblKeyboardOperate.Size = new Size(153, 41); _lblKeyboardOperate.Location = new Point(6, 63); _lblKeyboardOperate.TabIndex = 0; _lblKeyboardOperate.Text = "模拟按键:"; _lblKeyboardOperate.TextAlign = ContentAlignment.MiddleLeft; _lblKeyboardOperate.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _lblKeyboardInterval.Size = new Size(153, 41); _lblKeyboardInterval.Location = new Point(6, 145); _lblKeyboardInterval.TabIndex = 0; _lblKeyboardInterval.Text = "时间间隔:"; _lblKeyboardInterval.TextAlign = ContentAlignment.MiddleLeft; _lblKeyboardInterval.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _lblKeyboardUnit.Size = new Size(75, 41); _lblKeyboardUnit.Location = new Point(339, 145); _lblKeyboardUnit.TabIndex = 0; _lblKeyboardUnit.Text = "毫秒"; _lblKeyboardHotkey.TextAlign = ContentAlignment.MiddleLeft; _lblKeyboardUnit.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _lblKeyboardHotkey.Size = new Size(118, 41); _lblKeyboardHotkey.Location = new Point(509, 104); _lblKeyboardHotkey.TabIndex = 0; _lblKeyboardHotkey.Text = "快捷键:"; _lblKeyboardHotkey.TextAlign = ContentAlignment.MiddleLeft; _lblKeyboardHotkey.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _txtKeyboardOperate.Size = new Size(175, 42); _txtKeyboardOperate.Location = new Point(160, 63); _txtKeyboardOperate.ReadOnly = true; _txtKeyboardOperate.TabIndex = 0; _txtKeyboardOperate.TabStop = false; if (Operate != null) { _txtKeyboardOperate.Text = Utils.KeysSplice(Operate); } _txtKeyboardOperate.TextAlign = HorizontalAlignment.Right; _txtKeyboardOperate.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _txtKeyboardInterval.Size = new Size(175, 42); _txtKeyboardInterval.Location = new Point(160, 142); _txtKeyboardInterval.TabIndex = 3; _txtKeyboardInterval.Text = Interval; _txtKeyboardInterval.TextAlign = HorizontalAlignment.Right; _txtKeyboardInterval.Font = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); _txtKeyboardInterval.KeyPress += (_, e) => { switch (e.KeyChar) { case '\b': return; case < '0': case > '9': e.Handled = true; break; } }; _txtKeyboardHotkey.Size = new Size(120, 35); _txtKeyboardHotkey.Location = new Point(630, 115); _txtKeyboardHotkey.Location = Hotkey != Keys.None ? new Point(630, 115) : new Point(630, 103); _txtKeyboardHotkey.ReadOnly = true; _txtKeyboardHotkey.TabIndex = 0; _txtKeyboardHotkey.TabStop = false; _txtKeyboardHotkey.Text = Hotkey != Keys.None ? KeyModifiers.Ctrl + "+" + Hotkey : Hotkey.ToString(); _txtKeyboardHotkey.TextAlign = HorizontalAlignment.Center; _txtKeyboardHotkey.Font = Hotkey != Keys.None ? new Font("宋体", 8F, FontStyle.Regular, GraphicsUnit.Point, 134) : new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); _txtKeyboardHotkey.BorderStyle = BorderStyle.None; _btnKeyboardKey.Size = new Size(83, 42); _btnKeyboardKey.Location = new Point(339, 63); _btnKeyboardKey.Cursor = Cursors.Hand; _btnKeyboardKey.ForeColor = SystemColors.ControlText; _btnKeyboardKey.TabIndex = 2; _btnKeyboardKey.Text = "捕获"; _btnKeyboardKey.UseVisualStyleBackColor = true; _btnKeyboardKey.BackColor = Color.Transparent; _btnKeyboardKey.Click += (_, _) => { var getKeyBox = new GetKeyBox(GrpKeyboardItem.Text == string.Empty ? "捕获" : GrpKeyboardItem.Text + "·捕获"); getKeyBox.ShowDialog(); var newOperate = getKeyBox.Operate; if (newOperate != null) { _txtKeyboardOperate.Text = Utils.KeysSplice(newOperate); Operate = newOperate; } }; _btnKeyboardRemove.Size = new Size(83, 42); _btnKeyboardRemove.Location = new Point(650, 43); _btnKeyboardRemove.Cursor = Cursors.Hand; _btnKeyboardRemove.ForeColor = SystemColors.ControlText; _btnKeyboardRemove.TabIndex = 7; _btnKeyboardRemove.Text = "删除"; _btnKeyboardRemove.UseVisualStyleBackColor = false; _btnKeyboardRemove.BackColor = Color.Transparent; _btnKeyboardRemove.Click += (_, _) => { removeEventHandler(Index); }; _btnKeyboardRename.Size = new Size(83, 42); _btnKeyboardRename.Location = new Point(472, 162); _btnKeyboardRename.Cursor = Cursors.Hand; _btnKeyboardRename.ForeColor = SystemColors.ControlText; _btnKeyboardRename.TabIndex = 6; _btnKeyboardRename.Text = "命名"; _btnKeyboardRename.UseVisualStyleBackColor = false; _btnKeyboardRename.BackColor = Color.Transparent; _btnKeyboardRename.Click += (_, _) => { var inputPromptBox = new InputPromptBox(GrpKeyboardItem.Text == string.Empty ? "命名" : GrpKeyboardItem.Text + "·命名", "请输入名称:", GrpKeyboardItem.Text); inputPromptBox.ShowDialog(); if (inputPromptBox.Flag) { GrpKeyboardItem.Text = inputPromptBox.Result; } }; _btnKeyboardSetUp.Size = new Size(83, 42); _btnKeyboardSetUp.Location = new Point(561, 162); _btnKeyboardSetUp.Cursor = Cursors.Hand; _btnKeyboardSetUp.BackColor = Color.Transparent; _btnKeyboardSetUp.ForeColor = SystemColors.ControlText; _btnKeyboardSetUp.TabIndex = 5; _btnKeyboardSetUp.Text = "设置"; _btnKeyboardSetUp.UseVisualStyleBackColor = false; _btnKeyboardSetUp.Click += (_, _) => { do { var setUpHotkeyBox = new SetUpHotkeyBox(GrpKeyboardItem.Text == string.Empty ? "设置" : GrpKeyboardItem.Text + "·设置", KeyModifiers.Ctrl, Hotkey); setUpHotkeyBox.ShowDialog(); if (!setUpHotkeyBox.Flag) { return; } Hotkey = setUpHotkeyBox.Hotkey; _txtKeyboardHotkey.Text = Hotkey != Keys.None ? $"{KeyModifiers.Ctrl}+{Utils.KeysChangeChar(setUpHotkeyBox.Hotkey)}" : KeyModifiers.None.ToString(); _txtKeyboardHotkey.Location = Hotkey != Keys.None ? new Point(630, 115) : new Point(630, 103); _txtKeyboardHotkey.Font = Hotkey != Keys.None ? new Font("宋体", 8F, FontStyle.Regular, GraphicsUnit.Point, 134) : new Font("宋体", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); } while (!setUpSwitchHotkeyEventHandler(Index, Hotkey)); }; _btnKeyboardSwitch.Size = new Size(83, 42); _btnKeyboardSwitch.Location = new Point(650, 162); _btnKeyboardSwitch.Cursor = Cursors.Hand; _btnKeyboardSwitch.BackColor = Color.Transparent; _btnKeyboardSwitch.ForeColor = SystemColors.ControlText; _btnKeyboardSwitch.TabIndex = 4; _btnKeyboardSwitch.Text = "开启"; _btnKeyboardSwitch.UseVisualStyleBackColor = false; _btnKeyboardSwitch.Click += (_, _) => { JobSwitch(); }; }