|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Collections.ObjectModel; |
|
|
|
|
using System.Diagnostics; |
|
|
|
|
using System.Linq; |
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel; |
|
|
|
|
using StabilityMatrix.Helper; |
|
|
|
|
using StabilityMatrix.Models; |
|
|
|
|
|
|
|
|
|
namespace StabilityMatrix.ViewModels; |
|
|
|
@ -14,29 +15,44 @@ public partial class LaunchOptionsDialogViewModel : ObservableObject
|
|
|
|
|
[ObservableProperty] |
|
|
|
|
private BasePackage? selectedPackage; |
|
|
|
|
|
|
|
|
|
public void OnLoad() |
|
|
|
|
/// <summary> |
|
|
|
|
/// Export the current cards options to a list of strings |
|
|
|
|
/// </summary> |
|
|
|
|
public List<string> AsLaunchArgs() |
|
|
|
|
{ |
|
|
|
|
Debug.WriteLine("In LaunchOptions OnLoad"); |
|
|
|
|
// Populate Cards using the selected package |
|
|
|
|
Cards.Clear(); |
|
|
|
|
return ( |
|
|
|
|
from card in Cards from option in card.Options |
|
|
|
|
where option.Selected select option.Name).ToList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var package = SelectedPackage; |
|
|
|
|
if (package == null) |
|
|
|
|
{ |
|
|
|
|
Debug.WriteLine($"selectedPackage is null"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
var definitions = package.LaunchOptions; |
|
|
|
|
if (definitions == null) |
|
|
|
|
/// <summary> |
|
|
|
|
/// Create cards using definitions |
|
|
|
|
/// </summary> |
|
|
|
|
public void CardsFromDefinitions(List<LaunchOptionDefinition> definitions) |
|
|
|
|
{ |
|
|
|
|
foreach (var definition in definitions) |
|
|
|
|
{ |
|
|
|
|
Debug.WriteLine($"definitions is null"); |
|
|
|
|
return; |
|
|
|
|
Cards.Add(new LaunchOptionCard(definition)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach (var definition in definitions) |
|
|
|
|
/// <summary> |
|
|
|
|
/// Import the current cards options from a list of strings |
|
|
|
|
/// </summary> |
|
|
|
|
public void LoadFromLaunchArgs(IEnumerable<string> launchArgs) |
|
|
|
|
{ |
|
|
|
|
var launchArgsSet = new HashSet<string>(launchArgs); |
|
|
|
|
foreach (var card in Cards) |
|
|
|
|
{ |
|
|
|
|
Cards.Add(new LaunchOptionCard(definition)); |
|
|
|
|
foreach (var option in card.Options) |
|
|
|
|
{ |
|
|
|
|
option.Selected = launchArgsSet.Contains(option.Name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Debug.WriteLine($"Cards: {Cards.Count}"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void OnLoad() |
|
|
|
|
{ |
|
|
|
|
Debug.WriteLine("In LaunchOptions OnLoad"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|