public async override void OnTick() { string value = String.Empty; List <int> eList = JsonFiles.LoadJSONList("EntryList"); SelectedCars = JsonFiles.LoadJSONList("QSelected"); List <int> fastList = JsonFiles.LoadJSONList("Fastest"); value = ""; if (eList != null && eList.Count > 0 && settings.CarPosition > 0 && settings.CarPosition <= eList.Count) { value = eList[settings.CarPosition - 1].ToString(); } int carNum = 0; Int32.TryParse(value, out carNum); await Connection.SetTitleAsync($"{value}"); if (carNum > 0) { bool isSel = false; foreach (var l in SelectedCars) { if (l == carNum) { isSel = true; break; } } bool isFast = false; foreach (var l in fastList) { if (l == carNum) { isFast = true; break; } } if (isSel) { Image newImg = Image.FromFile("Images\\BackQ.png"); await Connection.SetImageAsync(newImg, null, true); } else { if (isFast) { Image newImg = Image.FromFile("Images\\BackFast.png"); await Connection.SetImageAsync(newImg, null, true); } else { Image newImg = Image.FromFile("Images\\Back.png"); await Connection.SetImageAsync(newImg, null, true); } } } }
public override void KeyPressed(KeyPayload payload) { // Used for long press //keyPressStart = DateTime.Now; //keyPressed = true; List <int> eList = JsonFiles.LoadJSONList("EntryList"); SelectedCars = JsonFiles.LoadJSONList("Selected"); string hotkey = "Numpad"; string value = ""; int carNum = 0; if (eList != null && eList.Count > 0 && settings.CarPosition > 0 && settings.CarPosition <= eList.Count) { value = eList[settings.CarPosition - 1].ToString(); } for (int i = 0; i < value.Length; i++) { HotkeyHandler.RunHotkey("{" + hotkey + value[i] + "}"); } Int32.TryParse(value, out carNum); if (carNum > 0) { bool isSel = false; foreach (var l in SelectedCars) { if (l == carNum) { isSel = true; break; } } HotkeyHandler.RunHotkey("{Multiply}"); if (!isSel) { HotkeyHandler.RunHotkey("{Add}"); SelectedCars.Add(carNum); } else { HotkeyHandler.RunHotkey("{Subtract}"); SelectedCars.Remove(carNum); } JsonFiles.SaveJSONList("Selected", SelectedCars); } Logger.Instance.LogMessage(TracingLevel.INFO, "Key Pressed"); }