Subversion Repositories group.electronics

Rev

Rev 161 | Rev 164 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 161 Rev 162
Line 1... Line 1...
1
using System;
1
using System;
2
using System.Collections.Generic;
2
using System.Collections.Generic;
3
using System.Linq;
3
using System.Linq;
4
using System.Text;
4
using System.Text;
5
using System.Threading.Tasks;
5
using System.Threading.Tasks;
-
 
6
using WindowsInput.Native;
6
 
7
 
7
namespace nitdcscore {
8
namespace nitdcscore {
8
    public abstract class Command {
9
    public abstract class Command {
9
        public uint value { get; set; }
10
        public uint value { get; set; }
-
 
11
        public nitdcscore.Utils.InputPair data { get; set; }
10
 
12
 
11
        public Command() {
13
        public Command() {
12
            value = 0;
14
            value = 0;
13
        }
15
        }
14
        public abstract int Send();
16
        public abstract int Send();
Line 47... Line 49...
47
 
49
 
48
        public override string ToString() {
50
        public override string ToString() {
49
            return cmd + " " + base.value + "\n";
51
            return cmd + " " + base.value + "\n";
50
        }
52
        }
51
    }
53
    }
-
 
54
 
-
 
55
    public class CommandVKey : Command {
-
 
56
        VirtualKeyCode key;
-
 
57
 
-
 
58
        public CommandVKey(VirtualKeyCode vkey)
-
 
59
            : base() {
-
 
60
                this.key = vkey;
-
 
61
 
-
 
62
        }
-
 
63
 
-
 
64
        public override int Send() {
-
 
65
            Globals.SendKey.Keyboard.KeyPress(key);
-
 
66
            return 1;
-
 
67
        }
-
 
68
 
-
 
69
        public override int Send(uint value) {
-
 
70
            this.value = value;
-
 
71
            if (this.value == 1)
-
 
72
                this.Send();
-
 
73
            else return 1;
-
 
74
            return 0;
-
 
75
        }
-
 
76
 
-
 
77
        public override string ToString() {
-
 
78
            return "VKey:" + key.ToString() + ":" + base.value + "\n";
-
 
79
        }
-
 
80
    }
-
 
81
 
-
 
82
    public class CommandTrackIRKey : Command {
-
 
83
        VirtualKeyCode key;
-
 
84
 
-
 
85
        public CommandTrackIRKey(VirtualKeyCode vkey)
-
 
86
            : base() {
-
 
87
            this.key = vkey;
-
 
88
 
-
 
89
        }
-
 
90
 
-
 
91
        public override int Send() {
-
 
92
            Globals.SendKey.Keyboard.KeyDown(VirtualKeyCode.CONTROL);
-
 
93
            Utils.delayms(1);
-
 
94
            Globals.SendKey.Keyboard.KeyPress(key);
-
 
95
            Globals.SendKey.Keyboard.KeyUp(VirtualKeyCode.CONTROL);
-
 
96
            return 1;
-
 
97
        }
-
 
98
 
-
 
99
        public override int Send(uint value) {
-
 
100
            this.value = value;
-
 
101
            if (this.value == 1)
-
 
102
                this.Send();
-
 
103
            else 
-
 
104
                return 1;
-
 
105
            return 0;
-
 
106
        }
-
 
107
 
-
 
108
        public override string ToString() {
-
 
109
            return "TrackIR:" + key.ToString() + ":" + base.value + "\n";
-
 
110
        }
-
 
111
    }
-
 
112
 
-
 
113
    public class CommandIf : Command {
-
 
114
        private Control ctl { get; set; }
-
 
115
        private Dictionary<uint, Command> opts;
-
 
116
 
-
 
117
        public CommandIf(Control control, Dictionary<uint, Command> opts) {
-
 
118
            this.ctl = control;
-
 
119
            this.opts = opts;
-
 
120
        }
-
 
121
 
-
 
122
        public override int Send() {
-
 
123
            Command cmd;
-
 
124
            
-
 
125
            ctl.data = this.data;
-
 
126
            ctl.Tick();
-
 
127
 
-
 
128
            if (opts.TryGetValue(ctl.value, out cmd)) {
-
 
129
                cmd.value = this.value;
-
 
130
                cmd.data = this.data;
-
 
131
                cmd.Send(this.value);
-
 
132
                Console.Write(cmd.ToString());
-
 
133
                return 1;
-
 
134
            }
-
 
135
            return 0;
-
 
136
        }
-
 
137
 
-
 
138
        public override int Send(uint value) {
-
 
139
            this.value = value;
-
 
140
            if (this.value == 1)
-
 
141
                this.Send();
-
 
142
            return 1;
-
 
143
        }
-
 
144
 
-
 
145
        public override string ToString() {
-
 
146
            return "";
-
 
147
            //return "CommandIf:" + this.value + "\n";
-
 
148
        }
-
 
149
    }
52
}
150
}