Multi-Platform Package Manager for Stable Diffusion
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

49 lines
1.3 KiB

using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
using FluentAvalonia.UI.Controls;
using FluentAvalonia.UI.Navigation;
using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.ViewModels;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Models.Packages;
namespace StabilityMatrix.Avalonia.Views;
[Singleton]
public partial class PackageManagerPage : UserControlBase
{
public PackageManagerPage()
{
InitializeComponent();
AddHandler(Frame.NavigatedToEvent, OnNavigatedTo, RoutingStrategies.Direct);
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
/// <summary>
/// Handle navigation events to this page
/// </summary>
private void OnNavigatedTo(object? sender, NavigationEventArgs args)
{
if (args.Parameter is PackageManagerNavigationOptions { OpenInstallerDialog: true } options)
{
var vm = (PackageManagerViewModel)DataContext!;
Dispatcher.UIThread.Invoke(() =>
{
vm.ShowInstallDialog(options.InstallerSelectedPackage);
});
}
}
public record PackageManagerNavigationOptions
{
public bool OpenInstallerDialog { get; init; }
public BasePackage? InstallerSelectedPackage { get; init; }
}
}