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