void ArrowKeys(KeyboardEventArgs e) { // Keyboard arrows only active when a blow is populated, the play button says Play (as opposed to // Stop or Wait), and the Play button is not disabled // The last test is needed because when submitting, the play button says Play if (blow != null && screen.PlayLabel == "Play" && screen.PlayDisabled == false) { if (e.Key == "ArrowLeft") { int newGap = blow.Gap - Constants.Rounding; if (newGap >= testSpec.GapMin) { blow.UpdateGap(newGap); } } else if (e.Key == "ArrowRight") { int newGap = blow.Gap + Constants.Rounding; if (newGap <= testSpec.GapMax) { blow.UpdateGap(newGap); } } } }
async Task TestBellMouseMove(MouseEventArgs e) { // Mouse movement only active when the play button says Play (as opposed to // Stop or Wait), and the Play button is not disabled // The latter test is needed because when submitting, the play button says Play if (e.Buttons == 1 && Screen.PlayLabel == "Play" && Screen.PlayDisabled == false) { int clientX = Convert.ToInt32(e.ClientX); int newGapCumulativeRow; if (Blow.IsHandstroke) { newGapCumulativeRow = Convert.ToInt32((clientX - Screen.XMargin) / TestSpec.XScale); } else { newGapCumulativeRow = Convert.ToInt32((clientX - Screen.XMargin) / TestSpec.XScale) - TestSpec.BaseGap; } int newGap = Blow.Gap + (newGapCumulativeRow - Blow.GapCumulativeRow); int newGapRounded = Convert.ToInt32((double)newGap / Constants.Rounding) * Constants.Rounding; if (newGapRounded >= TestSpec.GapMin && newGapRounded <= TestSpec.GapMax && newGapRounded != Blow.Gap) { Blow.UpdateGap(newGapRounded); await Callback.InvokeAsync(CallbackParam.MouseMove); } } }
async Task GapPlusClick() { int newGap = Blow.Gap + Constants.Rounding; if (newGap <= TestSpec.GapMax) { Blow.UpdateGap(newGap); await Callback.InvokeAsync(CallbackParam.GapPlus); } }