Rev 161 | Rev 165 | 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 uint value { get; set; }
public nitdcscore.Utils.InputPair data { get; set; }
public Command() {
value = 0;
}
public abstract int Send();
public abstract int Send(uint 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(uint value) {
if (this.cmd.Equals(""))
return -1;
this.value = value;
return Globals.bios.SendData(this.ToString());
}
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() {
Globals.SendKey.Keyboard.KeyPress(key);
return 1;
}
public override int Send(uint value) {
this.value = value;
if (this.value == 1)
this.Send();
else return 1;
return 0;
}
public override string ToString() {
return "VKey:" + key.ToString() + ":" + base.value + "\n";
}
}
public class CommandTrackIRKey : Command {
VirtualKeyCode key;
public CommandTrackIRKey(VirtualKeyCode vkey)
: base() {
this.key = vkey;
}
public override int Send() {
Globals.SendKey.Keyboard.KeyDown(VirtualKeyCode.CONTROL);
Utils.delayms(1);
Globals.SendKey.Keyboard.KeyPress(key);
Globals.SendKey.Keyboard.KeyUp(VirtualKeyCode.CONTROL);
return 1;
}
public override int Send(uint value) {
this.value = value;
if (this.value == 1)
this.Send();
else
return 1;
return 0;
}
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(ctl.value, out cmd)) {
cmd.value = this.value;
cmd.data = this.data;
cmd.Send(this.value);
Console.Write(cmd.ToString());
return 1;
}
return 0;
}
public override int Send(uint value) {
this.value = value;
if (this.value == 1)
this.Send();
return 1;
}
public override string ToString() {
return "";
//return "CommandIf:" + this.value + "\n";
}
}
}