2023-10-07 22:48:43 -04:00
|
|
|
|
using System.Collections.Generic;
|
2021-08-04 14:17:53 -07:00
|
|
|
|
using System.Linq;
|
2022-07-26 13:47:19 -07:00
|
|
|
|
using System.Threading.Tasks;
|
2021-09-29 11:48:37 -07:00
|
|
|
|
using MPF.Core.Data;
|
2023-10-07 01:30:11 -04:00
|
|
|
|
using MPF.Core.UI.ComboBoxItems;
|
2023-09-05 00:08:09 -04:00
|
|
|
|
using SabreTools.RedumpLib.Web;
|
2021-08-04 14:17:53 -07:00
|
|
|
|
|
2023-10-07 23:37:01 -04:00
|
|
|
|
namespace MPF.Core.UI.ViewModels
|
2021-08-04 14:17:53 -07:00
|
|
|
|
{
|
|
|
|
|
|
public class OptionsViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Current set of options
|
|
|
|
|
|
/// </summary>
|
2021-12-21 20:49:35 -08: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
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Lists
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// List of available internal programs
|
|
|
|
|
|
/// </summary>
|
2021-12-21 20:49:35 -08:00
|
|
|
|
public List<Element<InternalProgram>> InternalPrograms => PopulateInternalPrograms();
|
2021-08-04 14:17:53 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Current list of supported system profiles
|
|
|
|
|
|
/// </summary>
|
2021-12-21 20:49:35 -08:00
|
|
|
|
public List<RedumpSystemComboBoxItem> Systems => RedumpSystemComboBoxItem.GenerateElements().ToList();
|
2021-08-04 14:17:53 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Constructor
|
|
|
|
|
|
/// </summary>
|
2023-10-07 11:47:24 -04:00
|
|
|
|
public OptionsViewModel(Options baseOptions)
|
2021-08-04 14:17:53 -07:00
|
|
|
|
{
|
2023-09-25 21:11:14 -04:00
|
|
|
|
Options = new Options(baseOptions);
|
2021-08-04 14:17:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region Population
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Get a complete list of supported internal programs
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private static List<Element<InternalProgram>> PopulateInternalPrograms()
|
|
|
|
|
|
{
|
2023-09-07 10:36:33 -04:00
|
|
|
|
var internalPrograms = new List<InternalProgram> { InternalProgram.DiscImageCreator, InternalProgram.Aaru, InternalProgram.Redumper };
|
2021-08-04 14:17:53 -07:00
|
|
|
|
return internalPrograms.Select(ip => new Element<InternalProgram>(ip)).ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region UI Commands
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Test Redump login credentials
|
|
|
|
|
|
/// </summary>
|
2023-09-25 15:09:21 -04:00
|
|
|
|
#if NET48
|
2023-10-07 22:48:43 -04:00
|
|
|
|
public (bool?, string) TestRedumpLogin(string username, string password)
|
2022-07-26 13:47:19 -07:00
|
|
|
|
#else
|
2023-10-07 23:37:01 -04:00
|
|
|
|
public async Task<(bool?, string?)> TestRedumpLogin(string username, string password)
|
2022-07-26 13:47:19 -07:00
|
|
|
|
#endif
|
2021-08-04 14:17:53 -07:00
|
|
|
|
{
|
2023-09-25 15:09:21 -04:00
|
|
|
|
#if NET48
|
2023-10-07 22:40:51 -04:00
|
|
|
|
return RedumpWebClient.ValidateCredentials(username, password);
|
2022-07-26 13:47:19 -07:00
|
|
|
|
#else
|
2023-10-07 22:40:51 -04:00
|
|
|
|
return await RedumpHttpClient.ValidateCredentials(username, password);
|
2022-07-26 13:47:19 -07:00
|
|
|
|
#endif
|
2021-08-04 14:17:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-09 20:54:52 -04:00
|
|
|
|
#endregion
|
2021-08-04 14:17:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|