From bf8aac6f8115741837bef604e546d596304388d1 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 13 Sep 2020 20:41:09 -0700 Subject: [PATCH] Move some constants around --- DICUI.Avalonia/Constants.cs | 28 ------------------- DICUI.Library/Data/Constants.cs | 45 +++++++++++++++++++++++++++++- DICUI.Test/UI/AllowedSpeedsTest.cs | 2 +- DICUI/Constants.cs | 29 ------------------- 4 files changed, 45 insertions(+), 59 deletions(-) diff --git a/DICUI.Avalonia/Constants.cs b/DICUI.Avalonia/Constants.cs index 600af0c7..a78d14d6 100644 --- a/DICUI.Avalonia/Constants.cs +++ b/DICUI.Avalonia/Constants.cs @@ -10,40 +10,12 @@ namespace DICUI.Avalonia /// public static class Constants { - public const string StartDumping = "Start Dumping"; - public const string StopDumping = "Stop Dumping"; - public const int LogWindowMarginFromMainWindow = 40; // Private lists of known drive speed ranges private static IReadOnlyList cd { get; } = new List { 1, 2, 3, 4, 6, 8, 12, 16, 20, 24, 32, 40, 44, 48, 52, 56, 72 }; private static IReadOnlyList dvd { get; } = cd.Where(s => s <= 24).ToList(); private static IReadOnlyList bd { get; } = cd.Where(s => s <= 16).ToList(); - private static IReadOnlyList unknown { get; } = cd; // TODO: All or {1}? Maybe null? - - /// - /// Get list of all drive speeds for a given MediaType - /// - /// MediaType? that represents the current item - /// Read-only list of drive speeds - public static IReadOnlyList GetSpeedsForMediaType(MediaType? type) - { - switch (type) - { - case MediaType.CDROM: - case MediaType.GDROM: - return cd; - case MediaType.DVD: - case MediaType.HDDVD: - case MediaType.NintendoGameCubeGameDisc: - case MediaType.NintendoWiiOpticalDisc: - return dvd; - case MediaType.BluRay: - return bd; - default: - return unknown; - } - } // Create collections for UI based on known drive speeds public static List SpeedsForCDAsCollection { get; } = GetDoubleCollectionFromIntList(cd); diff --git a/DICUI.Library/Data/Constants.cs b/DICUI.Library/Data/Constants.cs index 49244e82..04a03399 100644 --- a/DICUI.Library/Data/Constants.cs +++ b/DICUI.Library/Data/Constants.cs @@ -1,5 +1,48 @@ -namespace DICUI.Data +using System.Collections.Generic; +using System.Linq; + +namespace DICUI.Data { + /// + /// Constant values for UI + /// + public static class Interface + { + // Button values + public const string StartDumping = "Start Dumping"; + public const string StopDumping = "Stop Dumping"; + + // Private lists of known drive speed ranges + private static IReadOnlyList cd { get; } = new List { 1, 2, 3, 4, 6, 8, 12, 16, 20, 24, 32, 40, 44, 48, 52, 56, 72 }; + private static IReadOnlyList dvd { get; } = cd.Where(s => s <= 24).ToList(); + private static IReadOnlyList bd { get; } = cd.Where(s => s <= 16).ToList(); + private static IReadOnlyList unknown { get; } = new List { 1 }; + + /// + /// Get list of all drive speeds for a given MediaType + /// + /// MediaType? that represents the current item + /// Read-only list of drive speeds + public static IReadOnlyList GetSpeedsForMediaType(MediaType? type) + { + switch (type) + { + case MediaType.CDROM: + case MediaType.GDROM: + return cd; + case MediaType.DVD: + case MediaType.HDDVD: + case MediaType.NintendoGameCubeGameDisc: + case MediaType.NintendoWiiOpticalDisc: + return dvd; + case MediaType.BluRay: + return bd; + default: + return unknown; + } + } + } + /// /// Template field values for submission info /// diff --git a/DICUI.Test/UI/AllowedSpeedsTest.cs b/DICUI.Test/UI/AllowedSpeedsTest.cs index 386ae01c..079676e6 100644 --- a/DICUI.Test/UI/AllowedSpeedsTest.cs +++ b/DICUI.Test/UI/AllowedSpeedsTest.cs @@ -14,7 +14,7 @@ namespace DICUI.Test.Data [InlineData(null, 72)] // TODO: Update when fully determined public void GetAllowedDriveSpeedForMediaTypeTest(MediaType? mediaType, int maxExpected) { - var actual = Constants.GetSpeedsForMediaType(mediaType); + var actual = Interface.GetSpeedsForMediaType(mediaType); Assert.Equal(maxExpected, actual.Last()); } } diff --git a/DICUI/Constants.cs b/DICUI/Constants.cs index 5539d33c..1123f2d6 100644 --- a/DICUI/Constants.cs +++ b/DICUI/Constants.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Media; -using DICUI.Data; namespace DICUI { @@ -11,40 +10,12 @@ namespace DICUI /// public static class Constants { - public const string StartDumping = "Start Dumping"; - public const string StopDumping = "Stop Dumping"; - public const int LogWindowMarginFromMainWindow = 10; // Private lists of known drive speed ranges private static IReadOnlyList cd { get; } = new List { 1, 2, 3, 4, 6, 8, 12, 16, 20, 24, 32, 40, 44, 48, 52, 56, 72 }; private static IReadOnlyList dvd { get; } = cd.Where(s => s <= 24).ToList(); private static IReadOnlyList bd { get; } = cd.Where(s => s <= 16).ToList(); - private static IReadOnlyList unknown { get; } = cd; // TODO: All or {1}? Maybe null? - - /// - /// Get list of all drive speeds for a given MediaType - /// - /// MediaType? that represents the current item - /// Read-only list of drive speeds - public static IReadOnlyList GetSpeedsForMediaType(MediaType? type) - { - switch (type) - { - case MediaType.CDROM: - case MediaType.GDROM: - return cd; - case MediaType.DVD: - case MediaType.HDDVD: - case MediaType.NintendoGameCubeGameDisc: - case MediaType.NintendoWiiOpticalDisc: - return dvd; - case MediaType.BluRay: - return bd; - default: - return unknown; - } - } // Create collections for UI based on known drive speeds public static DoubleCollection SpeedsForCDAsCollection { get; } = GetDoubleCollectionFromIntList(cd);