private void setPresets() { if (!int.TryParse(divisorTextBox.Text, out int divisor) || divisor < 1 || divisor > 64) { updateState(); return; } if (!BeatDivisor.ValidDivisors.Value.Presets.Contains(divisor)) { if (BeatDivisorPresetCollection.COMMON.Presets.Contains(divisor)) { BeatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.COMMON; } else if (BeatDivisorPresetCollection.TRIPLETS.Presets.Contains(divisor)) { BeatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.TRIPLETS; } else { BeatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.Custom(divisor); } } BeatDivisor.Value = divisor; this.HidePopover(); }
private void cycleDivisorType(int direction) { Debug.Assert(Math.Abs(direction) == 1); int nextDivisorType = (int)beatDivisor.ValidDivisors.Value.Type + direction; if (nextDivisorType > (int)BeatDivisorType.Triplets) { nextDivisorType = (int)BeatDivisorType.Common; } else if (nextDivisorType < (int)BeatDivisorType.Common) { nextDivisorType = (int)BeatDivisorType.Triplets; } switch ((BeatDivisorType)nextDivisorType) { case BeatDivisorType.Common: beatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.COMMON; break; case BeatDivisorType.Triplets: beatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.TRIPLETS; break; case BeatDivisorType.Custom: beatDivisor.ValidDivisors.Value = BeatDivisorPresetCollection.Custom(beatDivisor.ValidDivisors.Value.Presets.Max()); break; } }