Rev 167 | Rev 176 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using WindowsInput.Native;namespace nitdcscore {public abstract class Command {public UInt64 value { get; set; }public jsdata data { get; set; }public Command() {value = 0;}public abstract int Send();public abstract int Send(UInt64 value);}public class CommandDCS : Command {public String cmd { get; set; }public CommandDCS() : base() {this.cmd = "";}public CommandDCS(String cmd) : base() {this.cmd = cmd;}public override int Send() {if (this.cmd.Equals(""))return -1;return Globals.bios.SendData(this.ToString());}public override int Send(UInt64 value) {if (this.cmd.Equals(""))return -1;this.value = value;Globals.bios.SendData(this.ToString());return 0;}public override string ToString() {return cmd + " " + base.value + "\n";}}public class CommandVKey : Command {VirtualKeyCode key;public CommandVKey(VirtualKeyCode vkey): base() {this.key = vkey;}public override int Send() {if (this.value == 1) {//Globals.SendKey.Keyboard.KeyPress(key);Globals.SendKey.Keyboard.KeyDown(key);Utils.delayms(10);Globals.SendKey.Keyboard.KeyUp(key);return 0;}return 1;}public override int Send(UInt64 value) {this.value = value;return this.Send();}public override string ToString() {return "VKey:" + key.ToString() + ":" + base.value + "\n";}}public class CommandMouseButton : Command {public static int MB_LEFT = 1;public static int MB_RIGHT = 2;// 1 = Left// 2 = Right// 3 = ?int button = 0;public CommandMouseButton(int button) : base() {this.button = button;}public override int Send() {if (button == 0)return 1;switch (button) {case 1:if (this.value == 1)Globals.SendKey.Mouse.LeftButtonDown();elseGlobals.SendKey.Mouse.LeftButtonUp();break;case 2:if (this.value == 1)Globals.SendKey.Mouse.RightButtonDown();elseGlobals.SendKey.Mouse.RightButtonUp();break;case 3:if (this.value == 1)Globals.SendKey.Mouse.XButtonDown(0);elseGlobals.SendKey.Mouse.XButtonUp(0);break;}return 0;}public override int Send(UInt64 value) {this.value = value;return this.Send();}public override string ToString() {return "Mouse:" + this.button + "=" + base.value + "\n";}}public class CommandTrackIRKey : Command {VirtualKeyCode key;public CommandTrackIRKey(VirtualKeyCode vkey): base() {this.key = vkey;}public override int Send() {if (this.value == 1) {Globals.SendKey.Keyboard.KeyDown(VirtualKeyCode.CONTROL);Utils.delayms(1);Globals.SendKey.Keyboard.KeyPress(key);Globals.SendKey.Keyboard.KeyUp(VirtualKeyCode.CONTROL);return 0;}return 1;}public override int Send(UInt64 value) {this.value = value;return this.Send();}public override string ToString() {return "TrackIR:" + key.ToString() + ":" + base.value + "\n";}}public class CommandIf : Command {private Control ctl { get; set; }private Dictionary<uint, Command> opts;public CommandIf(Control control, Dictionary<uint, Command> opts) {this.ctl = control;this.opts = opts;}public override int Send() {Command cmd;ctl.data = this.data;ctl.Tick();if (opts.TryGetValue((uint)ctl.value, out cmd)) {cmd.value = this.value;cmd.data = this.data;cmd.Send(this.value);Console.Write(cmd.ToString());return 0;}return 1;}public override int Send(UInt64 value) {this.value = value;return this.Send();}public override string ToString() {return "";//return "CommandIf:" + this.value + "\n";}}}