public static ShuffleMode Parse(string input) { ShuffleMode result = new ShuffleMode(); if (input == "Daily") { result.Type = ShuffleType.Daily; } else if (input == "Weekly") { result.Type = ShuffleType.Weekly; } else if (input == "Monthly") { result.Type = ShuffleType.Monthly; } else { try { result.Interval = TimeSpan.Parse(input); ; } catch (Exception) { result.Interval = TimeSpan.FromMinutes(1); } } return result; }
private int GetIntervalIndex(ShuffleMode mode) { if (mode.Type == ShuffleType.Daily) { return 9; } else if (mode.Type == ShuffleType.Weekly) { return 10; } else if (mode.Type == ShuffleType.Monthly) { return 11; } switch ( (int)mode.Interval.TotalMilliseconds) { case (5 * 60 * 1000): return 0; case (10 * 60 * 1000): return 1; case (15 * 60 * 1000): return 2; case (30 * 60 * 1000): return 3; case (1 * 60 * 60 * 1000): return 4; case (2 * 60 * 60 * 1000): return 5; case (4 * 60 * 60 * 1000): return 6; case (6 * 60 * 60 * 1000): return 7; case (12 * 60 * 60 * 1000): return 8; } return 0; }