diff --git a/DICUI.Avalonia/App.axaml b/DICUI.Avalonia/App.axaml new file mode 100644 index 00000000..c1a2b88f --- /dev/null +++ b/DICUI.Avalonia/App.axaml @@ -0,0 +1,8 @@ + + + + + + diff --git a/DICUI.Avalonia/App.axaml.cs b/DICUI.Avalonia/App.axaml.cs new file mode 100644 index 00000000..40ee8f77 --- /dev/null +++ b/DICUI.Avalonia/App.axaml.cs @@ -0,0 +1,24 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; + +namespace DICUI.Avalonia +{ + public class App : Application + { + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow(); + } + + base.OnFrameworkInitializationCompleted(); + } + } +} diff --git a/DICUI.Avalonia/ComboBoxItems/CategoryComboBoxItem.cs b/DICUI.Avalonia/ComboBoxItems/CategoryComboBoxItem.cs new file mode 100644 index 00000000..2eb67000 --- /dev/null +++ b/DICUI.Avalonia/ComboBoxItems/CategoryComboBoxItem.cs @@ -0,0 +1,29 @@ +using DICUI.Utilities; +using DICUI.Web; + +namespace DICUI.Avalonia +{ + /// + /// Represents a single item in the Category combo box + /// + public class CategoryComboBoxItem + { + private object data; + + public CategoryComboBoxItem(DiscCategory? category) => data = category; + + public static implicit operator DiscCategory? (CategoryComboBoxItem item) => item.data as DiscCategory?; + + public string Name + { + get { return (data as DiscCategory?).LongName(); } + } + + public bool IsChecked { get; set; } + + public DiscCategory? Value + { + get { return data as DiscCategory?; } + } + } +} diff --git a/DICUI.Avalonia/ComboBoxItems/KnownSystemComboBoxItem.cs b/DICUI.Avalonia/ComboBoxItems/KnownSystemComboBoxItem.cs new file mode 100644 index 00000000..0f9160b3 --- /dev/null +++ b/DICUI.Avalonia/ComboBoxItems/KnownSystemComboBoxItem.cs @@ -0,0 +1,35 @@ +using Avalonia.Media; +using DICUI.Data; +using DICUI.Utilities; + +namespace DICUI.Avalonia +{ + /// + /// Represents a single item in the System combo box + /// + public class KnownSystemComboBoxItem + { + private object data; + + public KnownSystemComboBoxItem(KnownSystem? system) => data = system; + public KnownSystemComboBoxItem(KnownSystemCategory? category) => data = category; + + public ISolidColorBrush Foreground { get => IsHeader() ? Brushes.Gray : Brushes.Black; } + + public bool IsHeader() => data is KnownSystemCategory?; + public bool IsSystem() => data is KnownSystem?; + + public static implicit operator KnownSystem? (KnownSystemComboBoxItem item) => item.data as KnownSystem?; + + public string Name + { + get + { + if (IsHeader()) + return "---------- " + (data as KnownSystemCategory?).LongName() + " ----------"; + else + return (data as KnownSystem?).LongName(); + } + } + } +} diff --git a/DICUI.Avalonia/ComboBoxItems/LanguageComboBoxItem.cs b/DICUI.Avalonia/ComboBoxItems/LanguageComboBoxItem.cs new file mode 100644 index 00000000..7216b1fc --- /dev/null +++ b/DICUI.Avalonia/ComboBoxItems/LanguageComboBoxItem.cs @@ -0,0 +1,29 @@ +using DICUI.Utilities; +using DICUI.Web; + +namespace DICUI.Avalonia +{ + /// + /// Represents a single item in the Language combo box + /// + public class LanguageComboBoxItem + { + private object data; + + public LanguageComboBoxItem(Language? region) => data = region; + + public static implicit operator Language? (LanguageComboBoxItem item) => item.data as Language?; + + public string Name + { + get { return (data as Language?).LongName(); } + } + + public bool IsChecked { get; set; } + + public Language? Value + { + get { return data as Language?; } + } + } +} diff --git a/DICUI.Avalonia/ComboBoxItems/MediaTypeComboBoxItem.cs b/DICUI.Avalonia/ComboBoxItems/MediaTypeComboBoxItem.cs new file mode 100644 index 00000000..4dbc4abc --- /dev/null +++ b/DICUI.Avalonia/ComboBoxItems/MediaTypeComboBoxItem.cs @@ -0,0 +1,20 @@ +using DICUI.Data; +using DICUI.Utilities; + +namespace DICUI.Avalonia +{ + /// + /// Represents a single item in the MediaType combo box + /// + public class MediaTypeComboBoxItem + { + private MediaType? data; + + public MediaTypeComboBoxItem(MediaType? mediaType) => data = mediaType; + + public static implicit operator MediaType? (MediaTypeComboBoxItem item) => item.data; + + public string Name { get { return data.LongName(); } + } + } +} diff --git a/DICUI.Avalonia/ComboBoxItems/RegionComboBoxItem.cs b/DICUI.Avalonia/ComboBoxItems/RegionComboBoxItem.cs new file mode 100644 index 00000000..2309b43a --- /dev/null +++ b/DICUI.Avalonia/ComboBoxItems/RegionComboBoxItem.cs @@ -0,0 +1,30 @@ +using DICUI.Utilities; +using DICUI.Web; + +namespace DICUI.Avalonia +{ + /// + /// Represents a single item in the Region combo box + /// + public class RegionComboBoxItem + { + private object data; + + public RegionComboBoxItem(Region? region) => data = region; + + public static implicit operator Region? (RegionComboBoxItem item) => item.data as Region?; + + public string Name + { + get + { + return (data as Region?).LongName(); + } + } + + public Region? Value + { + get { return data as Region?; } + } + } +} diff --git a/DICUI.Avalonia/Constants.cs b/DICUI.Avalonia/Constants.cs new file mode 100644 index 00000000..600af0c7 --- /dev/null +++ b/DICUI.Avalonia/Constants.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using DICUI.Data; + +namespace DICUI.Avalonia +{ + /// + /// Variables for UI elements + /// + 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); + public static List SpeedsForDVDAsCollection { get; } = GetDoubleCollectionFromIntList(dvd); + public static List SpeedsForBDAsCollection { get; } = GetDoubleCollectionFromIntList(bd); + private static List GetDoubleCollectionFromIntList(IReadOnlyList list) + => new List(list.Select(i => Convert.ToDouble(i)).ToList()); + } +} diff --git a/DICUI.Avalonia/DICUI.Avalonia.csproj b/DICUI.Avalonia/DICUI.Avalonia.csproj new file mode 100644 index 00000000..36a0f517 --- /dev/null +++ b/DICUI.Avalonia/DICUI.Avalonia.csproj @@ -0,0 +1,36 @@ + + + WinExe + net472;net48;netcoreapp3.1 + Icon.ico + 1.16.1 + Copyright © 2020 + + + + + + + + + + + + + + DiscInformationWindow.axaml + + + LogWindow.axaml + + + MainWindow.axaml + + + OptionsWindow.axaml + + + + + + diff --git a/DICUI.Avalonia/DiscInformationWindow.axaml b/DICUI.Avalonia/DiscInformationWindow.axaml new file mode 100644 index 00000000..52e22e14 --- /dev/null +++ b/DICUI.Avalonia/DiscInformationWindow.axaml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +