using System; using System.Collections.Generic; using System.Collections.ObjectModel; using AvaloniaEdit.Utils; using Microsoft.Extensions.DependencyInjection; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels; using StabilityMatrix.Avalonia.ViewModels.Dialogs; using StabilityMatrix.Core.Api; using StabilityMatrix.Core.Database; using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper.Cache; using StabilityMatrix.Core.Helper.Factory; using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models.Api; using StabilityMatrix.Core.Models.Packages; using StabilityMatrix.Core.Python; using StabilityMatrix.Core.Services; namespace StabilityMatrix.Avalonia.DesignData; public static class DesignData { private static IServiceProvider Services { get; } static DesignData() { var services = new ServiceCollection(); var activePackageId = new Guid(); services.AddSingleton(_ => new MockSettingsManager { Settings = { InstalledPackages = new List { new() { Id = activePackageId, DisplayName = "My Installed Package", PackageName = "stable-diffusion-webui", PackageVersion = "v1.0.0", LibraryPath = "Packages\\example-webui", LastUpdateCheck = DateTimeOffset.Now } }, ActiveInstalledPackage = activePackageId } }); // General services services.AddLogging(); services.AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton(); // Placeholder services that nobody should need during design time services .AddSingleton(_ => null!) .AddSingleton(_ => null!) .AddSingleton(_ => null!) .AddSingleton(_ => null!) .AddSingleton(_ => null!); // Using some default service implementations from App App.ConfigurePackages(services); App.ConfigurePageViewModels(services); App.ConfigureDialogViewModels(services); App.ConfigureViews(services); Services = services.BuildServiceProvider(); var dialogFactory = Services.GetRequiredService>(); var settingsManager = Services.GetRequiredService(); var downloadService = Services.GetRequiredService(); var modelFinder = Services.GetRequiredService(); var notificationService = Services.GetRequiredService(); // Main window MainWindowViewModel = new MainWindowViewModel(settingsManager, dialogFactory) { Pages = new List { LaunchPageViewModel, PackageManagerViewModel, CheckpointBrowserViewModel }, FooterPages = new List { SettingsViewModel } }; // Sample data var sampleCivitVersions = new List { new() { Name = "BB95 Furry Mix", Description = "v1.0.0", } }; // Sample data for dialogs SelectModelVersionViewModel.Versions = sampleCivitVersions; SelectModelVersionViewModel.SelectedVersion = sampleCivitVersions[0]; // Checkpoints page CheckpointsPageViewModel.CheckpointFolders = new ObservableCollection { new(settingsManager, downloadService, modelFinder) { Title = "Lora", DirectoryPath = "Packages/lora", CheckpointFiles = new ObservableCollection { new() { FilePath = "~/Models/Lora/electricity-light.safetensors", Title = "Auroral Background", ConnectedModel = new ConnectedModelInfo { VersionName = "Lightning Auroral", BaseModel = "SD 1.5", ModelName = "Auroral Background", ModelType = CivitModelType.LORA, FileMetadata = new CivitFileMetadata { Format = CivitModelFormat.SafeTensor, Fp = CivitModelFpType.fp16, Size = CivitModelSize.pruned, } } }, new() { FilePath = "~/Models/Lora/model.safetensors", Title = "Some model" }, } }, new(settingsManager, downloadService, modelFinder) { Title = "VAE", DirectoryPath = "Packages/VAE", CheckpointFiles = new ObservableCollection { new() { FilePath = "~/Models/VAE/vae_v2.pt", Title = "VAE v2", } } } }; CheckpointBrowserViewModel.ModelCards = new ObservableCollection { new(new CivitModel { Name = "BB95 Furry Mix", Description = "A furry mix of BB95", }, downloadService, settingsManager, dialogFactory, notificationService) }; } public static MainWindowViewModel MainWindowViewModel { get; } public static LaunchPageViewModel LaunchPageViewModel => Services.GetRequiredService(); public static PackageManagerViewModel PackageManagerViewModel => Services.GetRequiredService(); public static CheckpointsPageViewModel CheckpointsPageViewModel => Services.GetRequiredService(); public static SettingsViewModel SettingsViewModel => Services.GetRequiredService(); public static CheckpointBrowserViewModel CheckpointBrowserViewModel => Services.GetRequiredService(); public static SelectModelVersionViewModel SelectModelVersionViewModel => Services.GetRequiredService(); public static OneClickInstallViewModel OneClickInstallViewModel => Services.GetRequiredService(); public static InstallerViewModel InstallerViewModel => Services.GetRequiredService(); }