-
Notifications
You must be signed in to change notification settings - Fork 1
/
HotKeyFileHelper.cs
99 lines (87 loc) · 2.9 KB
/
HotKeyFileHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using WindowsInput.Native;
namespace OSC_To_keypress_Console
{
class HotKeyFileReader
{
public string[] readFromFile(string filePath)
{
return System.IO.File.ReadAllLines(filePath);
}
public HotKeyInfo translalteToHotkeys(string filePath)
{
HotKeyInfo hotkeyInfo = new HotKeyInfo();
string[] fileContents = readFromFile(filePath);
int i = 0;
foreach (string line in fileContents)
{
String[] splitLine = line.Split("\t");
VirtualKeyCode key = (VirtualKeyCode)Enum.Parse(typeof(VirtualKeyCode), splitLine[0], true);
VirtualKeyCode modifier = (VirtualKeyCode)Enum.Parse(typeof(VirtualKeyCode), splitLine[1], true);
string address = splitLine[2];
//if has datatypevalue line
if(splitLine.Length == 5)
{
string dataType = splitLine[3];
string dataTypeValue = splitLine[4];
hotkeyInfo.addHotKey(i, key, modifier, address, dataType, dataTypeValue);
}
i++;
}
return hotkeyInfo;
}
}
class HotKeyInfo
{
private List<VirtualKeyCode> hotkeys;
private List<VirtualKeyCode> modifiers;
private List<String> addresses;
private List<String> dataTypes;
private List<String> dataTypeValues;
public HotKeyInfo()
{
hotkeys = new List<VirtualKeyCode>();
modifiers = new List<VirtualKeyCode>();
addresses = new List<string>();
dataTypes = new List<string>();
dataTypeValues = new List<string>();
}
public void addHotKey(int arrayPosition, VirtualKeyCode hotkey, VirtualKeyCode modifier, string address, string dataType, string dataTypeValue)
{
hotkeys.Add(hotkey);
modifiers.Add(modifier);
addresses.Add(address);
dataTypes.Add(dataType);
dataTypeValues.Add(dataTypeValue);
}
public VirtualKeyCode getHotkey(int position)
{
return hotkeys[position];
}
public VirtualKeyCode getModifier(int position)
{
return modifiers[position];
}
public string getAddress(int position)
{
return addresses[position];
}
public string getDataType(int position)
{
return dataTypes[position];
}
public string getDataTypeValue(int position)
{
return dataTypeValues[position];
}
public int getHotkeyCount()
{
return hotkeys.Count;
}
}
}