2026-02-07 14:13:29 -05:00
|
|
|
using System.Collections.Generic;
|
2023-10-18 02:59:41 -04:00
|
|
|
using System.ComponentModel;
|
2024-05-23 15:40:12 -04:00
|
|
|
using MPF.Frontend.ComboBoxItems;
|
2025-10-07 18:07:46 -04:00
|
|
|
using LogCompression = MPF.Processors.LogCompression;
|
2025-05-30 12:43:25 -04:00
|
|
|
using RedumperDriveType = MPF.ExecutionContexts.Redumper.DriveType;
|
2024-05-28 14:41:51 -04:00
|
|
|
using RedumperReadMethod = MPF.ExecutionContexts.Redumper.ReadMethod;
|
|
|
|
|
using RedumperSectorOrder = MPF.ExecutionContexts.Redumper.SectorOrder;
|
2021-08-04 14:17:53 -07:00
|
|
|
|
2024-05-23 15:40:12 -04:00
|
|
|
namespace MPF.Frontend.ViewModels
|
2021-08-04 14:17:53 -07:00
|
|
|
{
|
2023-11-14 23:40:41 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Constructor
|
|
|
|
|
/// </summary>
|
2023-11-23 03:37:00 -05:00
|
|
|
public class OptionsViewModel : INotifyPropertyChanged
|
2021-08-04 14:17:53 -07:00
|
|
|
{
|
|
|
|
|
#region Fields
|
|
|
|
|
|
2023-10-18 02:59:41 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Title for the window
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string? Title
|
|
|
|
|
{
|
|
|
|
|
get => _title;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_title = value;
|
|
|
|
|
TriggerPropertyChanged(nameof(Title));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private string? _title;
|
|
|
|
|
|
2021-08-04 14:17:53 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Current set of options
|
|
|
|
|
/// </summary>
|
2026-02-07 15:11:46 -05:00
|
|
|
public Options Options { get; }
|
2021-08-04 14:17:53 -07:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Flag for if settings were saved or not
|
|
|
|
|
/// </summary>
|
2023-10-07 23:37:01 -04:00
|
|
|
public bool SavedSettings { get; set; }
|
2021-08-04 14:17:53 -07:00
|
|
|
|
2023-10-18 02:59:41 -04:00
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
|
|
2023-11-06 22:07:40 -05:00
|
|
|
#endregion
|
2021-08-04 14:17:53 -07:00
|
|
|
|
|
|
|
|
#region Lists
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// List of available internal programs
|
|
|
|
|
/// </summary>
|
2023-11-06 23:06:11 -05:00
|
|
|
public static List<Element<InternalProgram>> InternalPrograms => PopulateInternalPrograms();
|
2021-08-04 14:17:53 -07:00
|
|
|
|
2025-10-17 00:47:36 +09:00
|
|
|
/// <summary>
|
2025-10-17 21:02:09 +09:00
|
|
|
/// List of available interface languages
|
2025-10-17 00:47:36 +09:00
|
|
|
/// </summary>
|
2025-10-17 21:02:09 +09:00
|
|
|
public static List<Element<InterfaceLanguage>> InterfaceLanguages => Element<InterfaceLanguage>.GenerateElements();
|
2025-10-17 00:47:36 +09:00
|
|
|
|
2025-10-07 18:07:46 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// List of available log compression methods
|
|
|
|
|
/// </summary>
|
2025-10-16 22:35:31 -04:00
|
|
|
public static List<Element<LogCompression>> LogCompressions => Element<LogCompression>.GenerateElements();
|
2025-10-07 18:07:46 -04:00
|
|
|
|
2024-04-16 23:11:09 +09:00
|
|
|
/// <summary>
|
|
|
|
|
/// Current list of supported Redumper read methods
|
|
|
|
|
/// </summary>
|
2025-10-16 22:35:31 -04:00
|
|
|
public static List<Element<RedumperReadMethod>> RedumperReadMethods => Element<RedumperReadMethod>.GenerateElements();
|
2024-04-16 23:11:09 +09:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Current list of supported Redumper sector orders
|
|
|
|
|
/// </summary>
|
2025-10-16 22:35:31 -04:00
|
|
|
public static List<Element<RedumperSectorOrder>> RedumperSectorOrders => Element<RedumperSectorOrder>.GenerateElements();
|
2024-04-16 23:11:09 +09:00
|
|
|
|
2025-05-31 01:40:22 +09:00
|
|
|
/// <summary>
|
|
|
|
|
/// Current list of supported Redumper drive types
|
|
|
|
|
/// </summary>
|
2025-10-16 22:35:31 -04:00
|
|
|
public static List<Element<RedumperDriveType>> RedumperDriveTypes => Element<RedumperDriveType>.GenerateElements();
|
2025-05-31 01:40:22 +09:00
|
|
|
|
2021-08-04 14:17:53 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Current list of supported system profiles
|
|
|
|
|
/// </summary>
|
2024-11-21 11:55:00 -05:00
|
|
|
public static List<RedumpSystemComboBoxItem> Systems => RedumpSystemComboBoxItem.GenerateElements();
|
2021-08-04 14:17:53 -07:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2023-11-23 03:37:00 -05:00
|
|
|
/// <summary>
|
|
|
|
|
/// Constructor for pure view model
|
|
|
|
|
/// </summary>
|
|
|
|
|
public OptionsViewModel()
|
|
|
|
|
{
|
2026-02-07 15:11:46 -05:00
|
|
|
Options = new Options();
|
2023-11-23 03:37:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructor for in-code
|
|
|
|
|
/// </summary>
|
2026-02-07 15:11:46 -05:00
|
|
|
public OptionsViewModel(Options baseOptions)
|
2023-11-23 03:37:00 -05:00
|
|
|
{
|
2026-02-07 15:11:46 -05:00
|
|
|
Options = new Options(baseOptions);
|
2023-11-23 03:37:00 -05:00
|
|
|
}
|
|
|
|
|
|
2021-08-04 14:17:53 -07:00
|
|
|
#region Population
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-04-16 23:11:09 +09:00
|
|
|
/// Get a complete list of supported internal programs
|
2021-08-04 14:17:53 -07:00
|
|
|
/// </summary>
|
|
|
|
|
private static List<Element<InternalProgram>> PopulateInternalPrograms()
|
|
|
|
|
{
|
2026-01-27 16:16:34 -05:00
|
|
|
var internalPrograms = new List<InternalProgram>
|
|
|
|
|
{
|
|
|
|
|
InternalProgram.Redumper,
|
|
|
|
|
InternalProgram.DiscImageCreator,
|
|
|
|
|
InternalProgram.Aaru,
|
|
|
|
|
// InternalProgram.Dreamdump,
|
|
|
|
|
};
|
2024-11-12 22:18:08 -05:00
|
|
|
return internalPrograms.ConvertAll(ip => new Element<InternalProgram>(ip));
|
2021-08-04 14:17:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region UI Commands
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-11-03 21:59:22 -05:00
|
|
|
/// Get the human-readable result for a Redump login result
|
2021-08-04 14:17:53 -07:00
|
|
|
/// </summary>
|
2024-11-03 21:59:22 -05:00
|
|
|
public static string GetRedumpLoginResult(bool? success)
|
2021-08-04 14:17:53 -07:00
|
|
|
{
|
2024-11-03 21:59:22 -05:00
|
|
|
return success switch
|
2024-10-18 13:04:53 -04:00
|
|
|
{
|
|
|
|
|
true => "Redump username and password accepted!",
|
|
|
|
|
false => "Redump username and password denied!",
|
|
|
|
|
null => "An error occurred validating your credentials!",
|
|
|
|
|
};
|
2021-08-04 14:17:53 -07:00
|
|
|
}
|
|
|
|
|
|
2024-04-16 23:11:09 +09:00
|
|
|
/// <summary>
|
|
|
|
|
/// Reset Redumper non-redump options (Read Method, Sector Order, Drive Type)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void NonRedumpModeUnChecked()
|
|
|
|
|
{
|
2026-02-07 13:23:57 -05:00
|
|
|
Options.Dumping.Redumper.ReadMethod = RedumperReadMethod.NONE;
|
|
|
|
|
Options.Dumping.Redumper.SectorOrder = RedumperSectorOrder.NONE;
|
|
|
|
|
Options.Dumping.Redumper.DriveType = RedumperDriveType.NONE;
|
2024-04-16 23:11:09 +09:00
|
|
|
TriggerPropertyChanged(nameof(Options));
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-09 20:54:52 -04:00
|
|
|
#endregion
|
2023-10-18 02:59:41 -04:00
|
|
|
|
|
|
|
|
#region Property Updates
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Trigger a property changed event
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void TriggerPropertyChanged(string propertyName)
|
|
|
|
|
{
|
|
|
|
|
// If the property change event is initialized
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2021-08-04 14:17:53 -07:00
|
|
|
}
|
|
|
|
|
}
|