public void NotifyKeyPressed(KeyCoordinates coordinates, bool longKeyPressed) { if (coordinates == null) { Logger.Instance.LogMessage(TracingLevel.ERROR, $"NotifyKeyPressed was called with null coordinates"); return; } Logger.Instance.LogMessage(TracingLevel.INFO, $"NotifyKeyPressed: Row: {coordinates.Row} Column: {coordinates.Column}"); if (uiHandler == null) { Logger.Instance.LogMessage(TracingLevel.ERROR, $"NotifyKeyPressed was called but gameHandler is null"); return; } if (longKeyPressed) { uiHandler.ProcessLongKeyPressed(coordinates); } else { uiHandler.ProcessKeyPressed(coordinates); } }
/// <summary> /// Constructor /// </summary> /// <param name="settings"></param> /// <param name="coordinates"></param> /// <param name="state"></param> /// <param name="title"></param> /// <param name="titleParameters"></param> public TitleParametersPayload(JObject settings, KeyCoordinates coordinates, uint state, string title, TitleParameters titleParameters) { Settings = settings; Coordinates = coordinates; State = state; Title = title; TitleParameters = titleParameters; }
private async Task HandleMuteChange(KeyCoordinates coordinates) { // Get the index of the app in the applications list int appIndex = (currentPage * appsPerPage) + coordinates.Column - ACTION_KEY_COLUMN_START; if (appIndex >= audioApps.Count) { Logger.Instance.LogMessage(TracingLevel.ERROR, $"HandleVolumeChange: AppIndex is out of range! Index: {appIndex} Apps: {audioApps?.Count}"); return; } await BRAudio.ToggleAppMute(audioApps[appIndex].Name); }
public async void ProcessKeyPressed(KeyCoordinates coordinates) { // Exit button pressed if (coordinates.IsCoordinatesSame(EXIT_KEY_LOCATION)) { tmrRefreshVolume.Stop(); await connection.SwitchProfileAsync(null); return; } // Next Button pressed if (coordinates.IsCoordinatesSame(NEXT_KEY_LOCATION)) { if ((currentPage + 1) * appsPerPage < audioApps.Count) // Are there more apps than the ones we are currently showing { currentPage++; GenerateMixer(); } return; } // Prev Button pressed if (coordinates.IsCoordinatesSame(PREV_KEY_LOCATION)) { currentPage--; if (currentPage < 0) { currentPage = 0; } GenerateMixer(); return; } // Plus/Minus button pressed if (coordinates.Row == PLUS_KEY_ROW || coordinates.Row == MINUS_KEY_ROW) { await HandleVolumeChange(coordinates); await HandleAppRowChange(); } // App button pressed (mute/unmute) if (coordinates.Row == APP_KEY_ROW) { await HandleMuteChange(coordinates); await HandleAppRowChange(); } }
private async Task HandleVolumeChange(KeyCoordinates coordinates) { // Get the index of the app in the applications list int appIndex = (currentPage * appsPerPage) + coordinates.Column - ACTION_KEY_COLUMN_START; if (appIndex >= audioApps.Count) { Logger.Instance.LogMessage(TracingLevel.ERROR, $"HandleVolumeChange: AppIndex is out of range! Index: {appIndex} Apps: {audioApps?.Count}"); return; } int absVolumeStep = Math.Abs(mixerSettings.VolumeStep); if (coordinates.Row == MINUS_KEY_ROW) { absVolumeStep *= -1; // Make it DECREASE the amount } await BRAudio.AdjustAppVolume(audioApps[appIndex].Name, absVolumeStep); }
public DisplayAction(SDConnection connection, InitialPayload payload) : base(connection, payload) { Logger.Instance.LogMessage(TracingLevel.DEBUG, $"[{Thread.CurrentThread.ManagedThreadId}] DisplayAction loading"); var deviceInfo = payload.DeviceInfo.Devices.Where(d => d.Id == connection.DeviceId).FirstOrDefault(); sequentialKey = 0; if (deviceInfo != null && payload?.Coordinates != null) { coordinates = payload.Coordinates; deviceColumns = deviceInfo.Size.Cols; locationRow = coordinates.Row; locationColumn = coordinates.Column; sequentialKey = (deviceColumns * locationRow) + locationColumn; } else { Logger.Instance.LogMessage(TracingLevel.ERROR, $"DisplayAction invalid ctor settings Device: {deviceInfo} Payload: {payload}"); } UIManager.Instance.UIActionEvent += Instance_UIActionEvent; Logger.Instance.LogMessage(TracingLevel.DEBUG, $"[{Thread.CurrentThread.ManagedThreadId}] DisplayAction up: {sequentialKey}"); }
public void ProcessLongKeyPressed(KeyCoordinates coordinates) { ProcessKeyPressed(coordinates); }
private static void LoadAltGrid(CharacterInfo pickedCharacter, int sourcePage, int altPage) { int minPage = 0; int maxPage = pickedCharacter.Alts.Count / 10; foreach (var button in buttons) { KeyCoordinates coordinates = button.ButtonInfo.Coordinates; if (coordinates.Row == 0) { switch (coordinates.Column) { case 0: // Return button button.SetImage(Path.Combine(_executionFolder, @"Images\back.png")); button.OnClick = () => { ChangeGridPage(sourcePage); }; break; case 2: // Prev button button.SetImage(Path.Combine(_executionFolder, @"Images\previous.png")); if (altPage > minPage) { button.OnClick = () => { LoadAltGrid(pickedCharacter, sourcePage, altPage - 1); } } ; else { button.OnClick = null; } break; case 3: // Indicator button.Connection.SetTitleAsync($"{altPage + 1}/{Math.Ceiling(pickedCharacter.Alts.Count/10f)}"); break; case 4: // Next button button.SetImage(Path.Combine(_executionFolder, @"Images\next.png")); if (altPage < maxPage) { button.OnClick = () => { LoadAltGrid(pickedCharacter, sourcePage, altPage + 1); } } ; else { button.OnClick = null; } break; case 1: // Unused button default: break; } } else { int altCharacterPosition = altPage * 10 + coordinates.Column + (coordinates.Row - 1) * 5; if (altCharacterPosition >= pickedCharacter.Alts.Count) { button.ResetImage(); } else { var pickedAlt = pickedCharacter.Alts[altCharacterPosition]; button.SetImage(pickedAlt.IconPath); button.OnClick = () => { USM.Send(new ChangeCharacterMessage { CharacterName = pickedAlt.Name, PlayerId = _targetCharacter }); button.Connection.SwitchProfileAsync(""); }; } } } }