Browse Source

Merge branch 'dev' into inference-modules

# Conflicts:
#	StabilityMatrix.Avalonia/App.axaml.cs
#	StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj
#	StabilityMatrix.Avalonia/ViewModels/Inference/StackExpanderViewModel.cs
#	StabilityMatrix.Core/StabilityMatrix.Core.csproj
pull/333/head
Ionite 1 year ago
parent
commit
0a2fd59c7f
No known key found for this signature in database
  1. 8
      StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj
  2. 8
      StabilityMatrix.Avalonia/Animations/BetterEntranceNavigationTransition.cs
  3. 1
      StabilityMatrix.Avalonia/Animations/ItemsRepeaterArrangeAnimation.cs
  4. 305
      StabilityMatrix.Avalonia/App.axaml.cs
  5. 2
      StabilityMatrix.Avalonia/Behaviors/TextEditorCompletionBehavior.cs
  6. 1
      StabilityMatrix.Avalonia/Behaviors/TextEditorToolTipBehavior.cs
  7. 1
      StabilityMatrix.Avalonia/Controls/AdvancedImageBox.axaml.cs
  8. 10
      StabilityMatrix.Avalonia/Controls/BatchSizeCard.axaml.cs
  9. 3
      StabilityMatrix.Avalonia/Controls/BetterContentDialog.cs
  10. 4
      StabilityMatrix.Avalonia/Controls/CodeCompletion/CompletionData.cs
  11. 4
      StabilityMatrix.Avalonia/Controls/CodeCompletion/CompletionIcons.cs
  12. 4
      StabilityMatrix.Avalonia/Controls/CodeCompletion/CompletionList.cs
  13. 2
      StabilityMatrix.Avalonia/Controls/CodeCompletion/CompletionWindow.axaml.cs
  14. 2
      StabilityMatrix.Avalonia/Controls/CodeCompletion/ICompletionData.cs
  15. 2
      StabilityMatrix.Avalonia/Controls/Dock/DockUserControlBase.cs
  16. 29
      StabilityMatrix.Avalonia/Controls/FASymbolIconSource.cs
  17. 2
      StabilityMatrix.Avalonia/Controls/FreeUCard.axaml.cs
  18. 2
      StabilityMatrix.Avalonia/Controls/ImageFolderCard.axaml.cs
  19. 6
      StabilityMatrix.Avalonia/Controls/ImageGalleryCard.axaml.cs
  20. 1
      StabilityMatrix.Avalonia/Controls/LineDashFrame.cs
  21. 10
      StabilityMatrix.Avalonia/Controls/ModelCard.axaml.cs
  22. 1
      StabilityMatrix.Avalonia/Controls/Paginator.axaml.cs
  23. 2
      StabilityMatrix.Avalonia/Controls/PromptCard.axaml.cs
  24. 2
      StabilityMatrix.Avalonia/Controls/RefreshBadge.axaml.cs
  25. 6
      StabilityMatrix.Avalonia/Controls/SamplerCard.axaml.cs
  26. 6
      StabilityMatrix.Avalonia/Controls/SeedCard.axaml.cs
  27. 5
      StabilityMatrix.Avalonia/Controls/SelectImageCard.axaml.cs
  28. 6
      StabilityMatrix.Avalonia/Controls/SharpenCard.axaml.cs
  29. 8
      StabilityMatrix.Avalonia/Controls/StackCard.axaml.cs
  30. 2
      StabilityMatrix.Avalonia/Controls/StackExpander.axaml.cs
  31. 5
      StabilityMatrix.Avalonia/Controls/UpscalerCard.axaml.cs
  32. 13
      StabilityMatrix.Avalonia/DesignData/DesignData.cs
  33. 3
      StabilityMatrix.Avalonia/DialogHelper.cs
  34. 1
      StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs
  35. 19
      StabilityMatrix.Avalonia/Helpers/TagCsvParser.cs
  36. 1
      StabilityMatrix.Avalonia/Helpers/TextEditorConfigs.cs
  37. 1
      StabilityMatrix.Avalonia/Models/Inference/FileNameFormat.cs
  38. 1
      StabilityMatrix.Avalonia/Models/Inference/FileNameFormatProvider.cs
  39. 1
      StabilityMatrix.Avalonia/Models/Inference/Prompt.cs
  40. 1
      StabilityMatrix.Avalonia/Models/Inference/StackExpanderModel.cs
  41. 3
      StabilityMatrix.Avalonia/Models/Inference/ViewState.cs
  42. 5
      StabilityMatrix.Avalonia/Models/SharedState.cs
  43. 3
      StabilityMatrix.Avalonia/Models/TagCompletion/CompletionProvider.cs
  44. 4
      StabilityMatrix.Avalonia/Models/TagCompletion/TextCompletionRequest.cs
  45. 2
      StabilityMatrix.Avalonia/Models/TagCompletion/TokenizerProvider.cs
  46. 1
      StabilityMatrix.Avalonia/Services/IInferenceClientManager.cs
  47. 3
      StabilityMatrix.Avalonia/Services/InferenceClientManager.cs
  48. 4
      StabilityMatrix.Avalonia/Services/NavigationService.cs
  49. 32
      StabilityMatrix.Avalonia/Services/NotificationService.cs
  50. 15
      StabilityMatrix.Avalonia/Services/ServiceManager.cs
  51. 34
      StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj
  52. 3
      StabilityMatrix.Avalonia/Styles/ThemeColors.cs
  53. 1
      StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs
  54. 1
      StabilityMatrix.Avalonia/ViewModels/Base/ProgressItemViewModelBase.cs
  55. 3
      StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CheckpointBrowserCardViewModel.cs
  56. 4
      StabilityMatrix.Avalonia/ViewModels/CheckpointBrowserViewModel.cs
  57. 3
      StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFile.cs
  58. 3
      StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFolder.cs
  59. 1
      StabilityMatrix.Avalonia/ViewModels/CheckpointsPageViewModel.cs
  60. 2
      StabilityMatrix.Avalonia/ViewModels/Dialogs/DownloadResourceViewModel.cs
  61. 2
      StabilityMatrix.Avalonia/ViewModels/Dialogs/EnvVarsViewModel.cs
  62. 6
      StabilityMatrix.Avalonia/ViewModels/Dialogs/ExceptionViewModel.cs
  63. 2
      StabilityMatrix.Avalonia/ViewModels/Dialogs/ImageViewerViewModel.cs
  64. 3
      StabilityMatrix.Avalonia/ViewModels/Dialogs/InferenceConnectionHelpViewModel.cs
  65. 3
      StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs
  66. 2
      StabilityMatrix.Avalonia/ViewModels/Dialogs/LaunchOptionsViewModel.cs
  67. 4
      StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs
  68. 2
      StabilityMatrix.Avalonia/ViewModels/Dialogs/PackageImportViewModel.cs
  69. 2
      StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectDataDirectoryViewModel.cs
  70. 8
      StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs
  71. 2
      StabilityMatrix.Avalonia/ViewModels/Dialogs/UpdateViewModel.cs
  72. 27
      StabilityMatrix.Avalonia/ViewModels/FirstLaunchSetupViewModel.cs
  73. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/BatchSizeCardViewModel.cs
  74. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/FreeUCardViewModel.cs
  75. 4
      StabilityMatrix.Avalonia/ViewModels/Inference/IImageGalleryComponent.cs
  76. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/ImageFolderCardViewModel.cs
  77. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/ImageGalleryCardViewModel.cs
  78. 5
      StabilityMatrix.Avalonia/ViewModels/Inference/InferenceImageUpscaleViewModel.cs
  79. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs
  80. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs
  81. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs
  82. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs
  83. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/SeedCardViewModel.cs
  84. 3
      StabilityMatrix.Avalonia/ViewModels/Inference/SelectImageCardViewModel.cs
  85. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/SharpenCardViewModel.cs
  86. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/StackCardViewModel.cs
  87. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/StackExpanderViewModel.cs
  88. 2
      StabilityMatrix.Avalonia/ViewModels/Inference/UpscalerCardViewModel.cs
  89. 3
      StabilityMatrix.Avalonia/ViewModels/InferenceViewModel.cs
  90. 1
      StabilityMatrix.Avalonia/ViewModels/LaunchPageViewModel.cs
  91. 131
      StabilityMatrix.Avalonia/ViewModels/NewCheckpointsPageViewModel.cs
  92. 3
      StabilityMatrix.Avalonia/ViewModels/OutputsPage/OutputImageViewModel.cs
  93. 4
      StabilityMatrix.Avalonia/ViewModels/OutputsPageViewModel.cs
  94. 3
      StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs
  95. 44
      StabilityMatrix.Avalonia/ViewModels/PackageManagerViewModel.cs
  96. 2
      StabilityMatrix.Avalonia/ViewModels/Progress/ProgressManagerViewModel.cs
  97. 60
      StabilityMatrix.Avalonia/ViewModels/RefreshBadgeViewModel.cs
  98. 9
      StabilityMatrix.Avalonia/ViewModels/Settings/InferenceSettingsViewModel.cs
  99. 8
      StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs
  100. 2
      StabilityMatrix.Avalonia/Views/CheckpointBrowserPage.axaml.cs
  101. Some files were not shown because too many files have changed in this diff Show More

8
StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj

@ -19,12 +19,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.4" /> <PackageReference Include="Avalonia" Version="11.0.5" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.4" /> <PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="NLog" Version="5.2.3" /> <PackageReference Include="NLog" Version="5.2.5" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

8
StabilityMatrix.Avalonia/Animations/BetterEntranceNavigationTransition.cs

@ -1,12 +1,10 @@
using System; using System;
using System.Threading; using System.Threading;
using AsyncAwaitBestPractices;
using Avalonia; using Avalonia;
using Avalonia.Animation; using Avalonia.Animation;
using Avalonia.Animation.Easings; using Avalonia.Animation.Easings;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.Styling; using Avalonia.Styling;
using FluentAvalonia.UI.Media.Animation;
namespace StabilityMatrix.Avalonia.Animations; namespace StabilityMatrix.Avalonia.Animations;
@ -23,7 +21,7 @@ public class BetterEntranceNavigationTransition : BaseTransitionInfo
/// Gets or sets the Vertical Offset used when animating /// Gets or sets the Vertical Offset used when animating
/// </summary> /// </summary>
public double FromVerticalOffset { get; set; } = 100; public double FromVerticalOffset { get; set; } = 100;
public override async void RunAnimation(Animatable ctrl, CancellationToken cancellationToken) public override async void RunAnimation(Animatable ctrl, CancellationToken cancellationToken)
{ {
var animation = new Animation var animation = new Animation
@ -36,7 +34,7 @@ public class BetterEntranceNavigationTransition : BaseTransitionInfo
Setters = Setters =
{ {
new Setter(Visual.OpacityProperty, 0.0), new Setter(Visual.OpacityProperty, 0.0),
new Setter(TranslateTransform.XProperty,FromHorizontalOffset), new Setter(TranslateTransform.XProperty, FromHorizontalOffset),
new Setter(TranslateTransform.YProperty, FromVerticalOffset) new Setter(TranslateTransform.YProperty, FromVerticalOffset)
}, },
Cue = new Cue(0d) Cue = new Cue(0d)
@ -46,7 +44,7 @@ public class BetterEntranceNavigationTransition : BaseTransitionInfo
Setters = Setters =
{ {
new Setter(Visual.OpacityProperty, 1d), new Setter(Visual.OpacityProperty, 1d),
new Setter(TranslateTransform.XProperty,0.0), new Setter(TranslateTransform.XProperty, 0.0),
new Setter(TranslateTransform.YProperty, 0.0) new Setter(TranslateTransform.YProperty, 0.0)
}, },
Cue = new Cue(1d) Cue = new Cue(1d)

1
StabilityMatrix.Avalonia/Animations/ItemsRepeaterArrangeAnimation.cs

@ -2,7 +2,6 @@
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Rendering.Composition; using Avalonia.Rendering.Composition;
using Avalonia.Rendering.Composition.Animations;
namespace StabilityMatrix.Avalonia.Animations; namespace StabilityMatrix.Avalonia.Animations;

305
StabilityMatrix.Avalonia/App.axaml.cs

@ -39,43 +39,25 @@ using Polly.Extensions.Http;
using Polly.Timeout; using Polly.Timeout;
using Refit; using Refit;
using Sentry; using Sentry;
using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.DesignData; using StabilityMatrix.Avalonia.DesignData;
using StabilityMatrix.Avalonia.Helpers; using StabilityMatrix.Avalonia.Helpers;
using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Models.TagCompletion;
using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels; using StabilityMatrix.Avalonia.ViewModels;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.CheckpointBrowser;
using StabilityMatrix.Avalonia.ViewModels.CheckpointManager;
using StabilityMatrix.Avalonia.ViewModels.Dialogs;
using StabilityMatrix.Avalonia.ViewModels.Inference;
using StabilityMatrix.Avalonia.ViewModels.Inference.Modules;
using StabilityMatrix.Avalonia.ViewModels.PackageManager;
using StabilityMatrix.Avalonia.ViewModels.Progress; using StabilityMatrix.Avalonia.ViewModels.Progress;
using StabilityMatrix.Avalonia.ViewModels.Settings;
using StabilityMatrix.Avalonia.Views; using StabilityMatrix.Avalonia.Views;
using StabilityMatrix.Avalonia.Views.Dialogs;
using StabilityMatrix.Avalonia.Views.Inference;
using StabilityMatrix.Avalonia.Views.Settings;
using StabilityMatrix.Core.Api; using StabilityMatrix.Core.Api;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Converters.Json; using StabilityMatrix.Core.Converters.Json;
using StabilityMatrix.Core.Database; using StabilityMatrix.Core.Database;
using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Helper.Cache;
using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models.Api; using StabilityMatrix.Core.Models.Api;
using StabilityMatrix.Core.Models.Configs; using StabilityMatrix.Core.Models.Configs;
using StabilityMatrix.Core.Models.FileInterfaces; using StabilityMatrix.Core.Models.FileInterfaces;
using StabilityMatrix.Core.Models.PackageModification;
using StabilityMatrix.Core.Models.Packages;
using StabilityMatrix.Core.Models.Settings; using StabilityMatrix.Core.Models.Settings;
using StabilityMatrix.Core.Python;
using StabilityMatrix.Core.Services; using StabilityMatrix.Core.Services;
using StabilityMatrix.Core.Updater;
using Application = Avalonia.Application; using Application = Avalonia.Application;
using DrawingColor = System.Drawing.Color; using DrawingColor = System.Drawing.Color;
using LogLevel = Microsoft.Extensions.Logging.LogLevel; using LogLevel = Microsoft.Extensions.Logging.LogLevel;
@ -250,19 +232,6 @@ public sealed class App : Application
internal static void ConfigurePageViewModels(IServiceCollection services) internal static void ConfigurePageViewModels(IServiceCollection services)
{ {
services
.AddSingleton<PackageManagerViewModel>()
.AddSingleton<SettingsViewModel>()
.AddSingleton<InferenceSettingsViewModel>()
.AddSingleton<CheckpointBrowserViewModel>()
.AddSingleton<CheckpointsPageViewModel>()
.AddSingleton<NewCheckpointsPageViewModel>()
.AddSingleton<LaunchPageViewModel>()
.AddSingleton<ProgressManagerViewModel>()
.AddSingleton<InferenceViewModel>()
.AddSingleton<ProgressManagerViewModel>()
.AddSingleton<OutputsPageViewModel>();
services.AddSingleton<MainWindowViewModel>( services.AddSingleton<MainWindowViewModel>(
provider => provider =>
new MainWindowViewModel( new MainWindowViewModel(
@ -290,205 +259,103 @@ public sealed class App : Application
services.AddSingleton<IDisposable>(p => p.GetRequiredService<LaunchPageViewModel>()); services.AddSingleton<IDisposable>(p => p.GetRequiredService<LaunchPageViewModel>());
} }
internal static void ConfigureDialogViewModels(IServiceCollection services) internal static void ConfigureDialogViewModels(
IServiceCollection services,
Type[] exportedTypes
)
{ {
// Dialog view models (transient)
services.AddTransient<InstallerViewModel>();
services.AddTransient<OneClickInstallViewModel>();
services.AddTransient<SelectModelVersionViewModel>();
services.AddTransient<SelectDataDirectoryViewModel>();
services.AddTransient<LaunchOptionsViewModel>();
services.AddTransient<ExceptionViewModel>();
services.AddTransient<EnvVarsViewModel>();
services.AddTransient<ImageViewerViewModel>();
services.AddTransient<PackageImportViewModel>();
services.AddTransient<InferenceConnectionHelpViewModel>();
services.AddTransient<DownloadResourceViewModel>();
// Dialog view models (singleton)
services.AddSingleton<FirstLaunchSetupViewModel>();
services.AddSingleton<UpdateViewModel>();
// Other transients (usually sub view models)
services.AddTransient<CheckpointFolder>();
services.AddTransient<CheckpointFile>();
services.AddTransient<InferenceTextToImageViewModel>();
services.AddTransient<InferenceImageUpscaleViewModel>();
services.AddTransient<CheckpointBrowserCardViewModel>();
services.AddTransient<PackageCardViewModel>();
// Global progress
services.AddSingleton<ProgressManagerViewModel>();
// Controls
services.AddTransient<RefreshBadgeViewModel>();
// Inference controls
services.AddTransient<SeedCardViewModel>();
services.AddTransient<SamplerCardViewModel>();
services.AddTransient<UpscalerCardViewModel>();
services.AddTransient<ImageGalleryCardViewModel>();
services.AddTransient<ImageFolderCardViewModel>();
services.AddTransient<PromptCardViewModel>();
services.AddTransient<StackCardViewModel>();
services.AddTransient<StackEditableCardViewModel>();
services.AddTransient<StackExpanderViewModel>();
services.AddTransient<ModelCardViewModel>();
services.AddTransient<BatchSizeCardViewModel>();
services.AddTransient<SelectImageCardViewModel>();
services.AddTransient<SharpenCardViewModel>();
services.AddTransient<FreeUCardViewModel>();
services.AddTransient<ControlNetCardViewModel>();
// Inference modules
services.AddTransient<UpscalerModule>();
services.AddTransient<HiresFixModule>();
services.AddTransient<ControlNetModule>();
services.AddTransient<SaveImageModule>();
// Dialog factory // Dialog factory
services.AddSingleton<ServiceManager<ViewModelBase>>( services.AddSingleton<ServiceManager<ViewModelBase>>(provider =>
provider => {
new ServiceManager<ViewModelBase>() var serviceManager = new ServiceManager<ViewModelBase>();
.Register(provider.GetRequiredService<InstallerViewModel>)
.Register(provider.GetRequiredService<OneClickInstallViewModel>) var serviceManagedTypes = exportedTypes
.Register(provider.GetRequiredService<SelectModelVersionViewModel>) .Select(
.Register(provider.GetRequiredService<SelectDataDirectoryViewModel>) t =>
.Register(provider.GetRequiredService<LaunchOptionsViewModel>) new
.Register(provider.GetRequiredService<UpdateViewModel>) {
.Register(provider.GetRequiredService<CheckpointBrowserCardViewModel>) t,
.Register(provider.GetRequiredService<CheckpointFolder>) attributes = t.GetCustomAttributes(
.Register(provider.GetRequiredService<CheckpointFile>) typeof(ManagedServiceAttribute),
.Register(provider.GetRequiredService<PackageCardViewModel>) true
.Register(provider.GetRequiredService<RefreshBadgeViewModel>) )
.Register(provider.GetRequiredService<ExceptionViewModel>) }
.Register(provider.GetRequiredService<EnvVarsViewModel>) )
.Register(provider.GetRequiredService<ProgressManagerViewModel>) .Where(t1 => t1.attributes is { Length: > 0 })
.Register(provider.GetRequiredService<InferenceTextToImageViewModel>) .Select(t1 => t1.t)
.Register(provider.GetRequiredService<InferenceImageUpscaleViewModel>) .ToList();
.Register(provider.GetRequiredService<SeedCardViewModel>)
.Register(provider.GetRequiredService<SamplerCardViewModel>)
.Register(provider.GetRequiredService<ImageGalleryCardViewModel>)
.Register(provider.GetRequiredService<ImageFolderCardViewModel>)
.Register(provider.GetRequiredService<PromptCardViewModel>)
.Register(provider.GetRequiredService<StackCardViewModel>)
.Register(provider.GetRequiredService<StackEditableCardViewModel>)
.Register(provider.GetRequiredService<StackExpanderViewModel>)
.Register(provider.GetRequiredService<UpscalerCardViewModel>)
.Register(provider.GetRequiredService<ModelCardViewModel>)
.Register(provider.GetRequiredService<BatchSizeCardViewModel>)
.Register(provider.GetRequiredService<ImageViewerViewModel>)
.Register(provider.GetRequiredService<FirstLaunchSetupViewModel>)
.Register(provider.GetRequiredService<PackageImportViewModel>)
.Register(provider.GetRequiredService<SelectImageCardViewModel>)
.Register(provider.GetRequiredService<InferenceConnectionHelpViewModel>)
.Register(provider.GetRequiredService<SharpenCardViewModel>)
.Register(provider.GetRequiredService<DownloadResourceViewModel>)
.Register(provider.GetRequiredService<FreeUCardViewModel>)
.Register(provider.GetRequiredService<ControlNetCardViewModel>)
.Register(provider.GetRequiredService<UpscalerModule>)
.Register(provider.GetRequiredService<HiresFixModule>)
.Register(provider.GetRequiredService<ControlNetModule>)
.Register(provider.GetRequiredService<SaveImageModule>)
);
}
internal static void ConfigureViews(IServiceCollection services) foreach (var type in serviceManagedTypes)
{ {
// Pages ViewModelBase? GetInstance() => provider.GetRequiredService(type) as ViewModelBase;
services.AddSingleton<CheckpointsPage>(); serviceManager.Register(type, GetInstance);
services.AddSingleton<LaunchPageView>(); }
services.AddSingleton<PackageManagerPage>();
services.AddSingleton<SettingsPage>();
services.AddSingleton<InferenceSettingsPage>();
services.AddSingleton<CheckpointBrowserPage>();
services.AddSingleton<ProgressManagerPage>();
services.AddSingleton<InferencePage>();
services.AddSingleton<NewCheckpointsPage>();
services.AddSingleton<OutputsPage>();
// Inference tabs
services.AddTransient<InferenceTextToImageView>();
services.AddTransient<InferenceImageUpscaleView>();
// Inference controls
services.AddTransient<ImageGalleryCard>();
services.AddTransient<ImageFolderCard>();
services.AddTransient<SeedCard>();
services.AddTransient<SamplerCard>();
services.AddTransient<PromptCard>();
services.AddTransient<StackCard>();
services.AddTransient<StackEditableCard>();
services.AddTransient<StackExpander>();
services.AddTransient<UpscalerCard>();
services.AddTransient<ModelCard>();
services.AddTransient<BatchSizeCard>();
services.AddTransient<SelectImageCard>();
services.AddTransient<SharpenCard>();
services.AddTransient<FreeUCard>();
services.AddTransient<ControlNetCard>();
// Dialogs
services.AddTransient<SelectDataDirectoryDialog>();
services.AddTransient<LaunchOptionsDialog>();
services.AddTransient<UpdateDialog>();
services.AddTransient<ExceptionDialog>();
services.AddTransient<EnvVarsDialog>();
services.AddTransient<ImageViewerDialog>();
services.AddTransient<PackageImportDialog>();
services.AddTransient<InferenceConnectionHelpDialog>();
services.AddTransient<DownloadResourceDialog>();
// Controls
services.AddTransient<RefreshBadge>();
// Windows
services.AddSingleton<MainWindow>();
services.AddSingleton<FirstLaunchSetupWindow>();
}
internal static void ConfigurePackages(IServiceCollection services) return serviceManager;
{ });
services.AddSingleton<BasePackage, A3WebUI>();
services.AddSingleton<BasePackage, StableDiffusionUx>();
services.AddSingleton<BasePackage, StableDiffusionDirectMl>();
services.AddSingleton<BasePackage, Fooocus>();
services.AddSingleton<BasePackage, InvokeAI>();
services.AddSingleton<BasePackage, ComfyUI>();
services.AddSingleton<BasePackage, VladAutomatic>();
services.AddSingleton<BasePackage, VoltaML>();
services.AddSingleton<BasePackage, FooocusMre>();
} }
private static IServiceCollection ConfigureServices() internal static IServiceCollection ConfigureServices()
{ {
var services = new ServiceCollection(); var services = new ServiceCollection();
services.AddMemoryCache(); services.AddMemoryCache();
var exportedTypes = AppDomain.CurrentDomain
.GetAssemblies()
.Where(a => a.FullName?.StartsWith("StabilityMatrix") == true)
.SelectMany(a => a.GetExportedTypes())
.ToArray();
var transientTypes = exportedTypes
.Select(
t => new { t, attributes = t.GetCustomAttributes(typeof(TransientAttribute), true) }
)
.Where(
t1 =>
t1.attributes is { Length: > 0 }
&& !t1.t.Name.Contains("Mock", StringComparison.OrdinalIgnoreCase)
)
.Select(t1 => new { Type = t1.t, Attribute = (TransientAttribute)t1.attributes[0] });
foreach (var typePair in transientTypes)
{
if (typePair.Attribute.InterfaceType is null)
{
services.AddTransient(typePair.Type);
}
else
{
services.AddTransient(typePair.Attribute.InterfaceType, typePair.Type);
}
}
var singletonTypes = exportedTypes
.Select(
t => new { t, attributes = t.GetCustomAttributes(typeof(SingletonAttribute), true) }
)
.Where(
t1 =>
t1.attributes is { Length: > 0 }
&& !t1.t.Name.Contains("Mock", StringComparison.OrdinalIgnoreCase)
)
.Select(t1 => new { Type = t1.t, Attribute = (SingletonAttribute)t1.attributes[0] });
foreach (var typePair in singletonTypes)
{
if (typePair.Attribute.InterfaceType is null)
{
services.AddSingleton(typePair.Type);
}
else
{
services.AddSingleton(typePair.Attribute.InterfaceType, typePair.Type);
}
}
ConfigurePageViewModels(services); ConfigurePageViewModels(services);
ConfigureDialogViewModels(services); ConfigureDialogViewModels(services, exportedTypes);
ConfigurePackages(services);
// Other services // Other services
services.AddSingleton<ISettingsManager, SettingsManager>();
services.AddSingleton<ISharedFolders, SharedFolders>();
services.AddSingleton<SharedState>();
services.AddSingleton<ModelFinder>();
services.AddSingleton<IPackageFactory, PackageFactory>();
services.AddSingleton<IDownloadService, DownloadService>();
services.AddSingleton<IGithubApiCache, GithubApiCache>();
services.AddSingleton<INotificationService, NotificationService>();
services.AddSingleton<IPyRunner, PyRunner>();
services.AddSingleton<IUpdateHelper, UpdateHelper>();
services.AddSingleton<INavigationService, NavigationService>();
services.AddSingleton<IInferenceClientManager, InferenceClientManager>();
services.AddSingleton<ICompletionProvider, CompletionProvider>();
services.AddSingleton<ITokenizerProvider, TokenizerProvider>();
services.AddSingleton<IModelIndexService, ModelIndexService>();
services.AddTransient<IPackageModificationRunner, PackageModificationRunner>();
services.AddSingleton<IImageIndexService, ImageIndexService>();
services.AddSingleton<ITrackedDownloadService, TrackedDownloadService>(); services.AddSingleton<ITrackedDownloadService, TrackedDownloadService>();
services.AddSingleton<IDisposable>( services.AddSingleton<IDisposable>(
provider => (IDisposable)provider.GetRequiredService<ITrackedDownloadService>() provider => (IDisposable)provider.GetRequiredService<ITrackedDownloadService>()
@ -516,8 +383,6 @@ public sealed class App : Application
services.AddSingleton<IPrerequisiteHelper, UnixPrerequisiteHelper>(); services.AddSingleton<IPrerequisiteHelper, UnixPrerequisiteHelper>();
} }
ConfigureViews(services);
if (Design.IsDesignMode) if (Design.IsDesignMode)
{ {
services.AddSingleton<ILiteDbContext, MockLiteDbContext>(); services.AddSingleton<ILiteDbContext, MockLiteDbContext>();

2
StabilityMatrix.Avalonia/Behaviors/TextEditorCompletionBehavior.cs

@ -2,9 +2,7 @@ using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Avalonia; using Avalonia;
using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Threading; using Avalonia.Threading;
using Avalonia.Xaml.Interactivity; using Avalonia.Xaml.Interactivity;

1
StabilityMatrix.Avalonia/Behaviors/TextEditorToolTipBehavior.cs

@ -3,7 +3,6 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Presenters;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.Xaml.Interactivity; using Avalonia.Xaml.Interactivity;

1
StabilityMatrix.Avalonia/Controls/AdvancedImageBox.axaml.cs

@ -22,7 +22,6 @@ using AsyncAwaitBestPractices;
using AsyncImageLoader; using AsyncImageLoader;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Presenters; using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using Avalonia.Input; using Avalonia.Input;

10
StabilityMatrix.Avalonia/Controls/BatchSizeCard.axaml.cs

@ -1,9 +1,7 @@
using Avalonia; using Avalonia.Controls.Primitives;
using Avalonia.Controls; using StabilityMatrix.Core.Attributes;
using Avalonia.Controls.Primitives;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
public class BatchSizeCard : TemplatedControl [Transient]
{ public class BatchSizeCard : TemplatedControl { }
}

3
StabilityMatrix.Avalonia/Controls/BetterContentDialog.cs

@ -1,6 +1,5 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Reflection; using System.Reflection;
using AsyncAwaitBestPractices; using AsyncAwaitBestPractices;
using Avalonia; using Avalonia;
@ -11,8 +10,6 @@ using Avalonia.Interactivity;
using Avalonia.Threading; using Avalonia.Threading;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.Dialogs;
using Brushes = Avalonia.Media.Brushes;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;

4
StabilityMatrix.Avalonia/Controls/CodeCompletion/CompletionData.cs

@ -1,9 +1,5 @@
using System; using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Controls;
using Avalonia.Controls.Documents; using Avalonia.Controls.Documents;
using Avalonia.Media;
using AvaloniaEdit.Document; using AvaloniaEdit.Document;
using AvaloniaEdit.Editing; using AvaloniaEdit.Editing;
using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models;

4
StabilityMatrix.Avalonia/Controls/CodeCompletion/CompletionIcons.cs

@ -1,6 +1,4 @@
using System; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Projektanker.Icons.Avalonia;
using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Models.TagCompletion; using StabilityMatrix.Avalonia.Models.TagCompletion;
using StabilityMatrix.Avalonia.Styles; using StabilityMatrix.Avalonia.Styles;

4
StabilityMatrix.Avalonia/Controls/CodeCompletion/CompletionList.cs

@ -20,10 +20,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
@ -31,8 +29,6 @@ using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Markup.Xaml.Templates; using Avalonia.Markup.Xaml.Templates;
using AvaloniaEdit.Utils; using AvaloniaEdit.Utils;
using StabilityMatrix.Avalonia.Models.TagCompletion;
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper;
namespace StabilityMatrix.Avalonia.Controls.CodeCompletion; namespace StabilityMatrix.Avalonia.Controls.CodeCompletion;

2
StabilityMatrix.Avalonia/Controls/CodeCompletion/CompletionWindow.axaml.cs

@ -18,8 +18,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Threading.Tasks;
using AsyncAwaitBestPractices;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;

2
StabilityMatrix.Avalonia/Controls/CodeCompletion/ICompletionData.cs

@ -19,10 +19,8 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Avalonia.Controls.Documents; using Avalonia.Controls.Documents;
using Avalonia.Media;
using AvaloniaEdit.Document; using AvaloniaEdit.Document;
using AvaloniaEdit.Editing; using AvaloniaEdit.Editing;
using FluentAvalonia.UI.Controls;
using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models;
namespace StabilityMatrix.Avalonia.Controls.CodeCompletion; namespace StabilityMatrix.Avalonia.Controls.CodeCompletion;

2
StabilityMatrix.Avalonia/Controls/Dock/DockUserControlBase.cs

@ -1,5 +1,4 @@
using System; using System;
using System.Text.Json;
using System.Text.Json.Nodes; using System.Text.Json.Nodes;
using System.Threading.Tasks; using System.Threading.Tasks;
using Avalonia; using Avalonia;
@ -9,7 +8,6 @@ using Avalonia.Controls.Primitives;
using Avalonia.Threading; using Avalonia.Threading;
using Dock.Avalonia.Controls; using Dock.Avalonia.Controls;
using Dock.Model; using Dock.Model;
using Dock.Model.Avalonia.Json;
using Dock.Model.Core; using Dock.Model.Core;
using Dock.Serializer; using Dock.Serializer;
using StabilityMatrix.Avalonia.Models.Inference; using StabilityMatrix.Avalonia.Models.Inference;

29
StabilityMatrix.Avalonia/Controls/FASymbolIconSource.cs

@ -15,12 +15,14 @@ namespace StabilityMatrix.Avalonia.Controls;
[SuppressMessage("ReSharper", "PropertyCanBeMadeInitOnly.Global")] [SuppressMessage("ReSharper", "PropertyCanBeMadeInitOnly.Global")]
public class FASymbolIconSource : PathIconSource public class FASymbolIconSource : PathIconSource
{ {
public static readonly StyledProperty<string> SymbolProperty = public static readonly StyledProperty<string> SymbolProperty = AvaloniaProperty.Register<
AvaloniaProperty.Register<FASymbolIconSource, string>(nameof(Symbol)); FASymbolIconSource,
string
public static readonly StyledProperty<double> FontSizeProperty = TextElement.FontSizeProperty.AddOwner<FASymbolIconSource>(); >(nameof(Symbol));
public static readonly StyledProperty<double> FontSizeProperty =
TextElement.FontSizeProperty.AddOwner<FASymbolIconSource>();
public FASymbolIconSource() public FASymbolIconSource()
{ {
Stretch = Stretch.None; Stretch = Stretch.None;
@ -52,11 +54,11 @@ public class FASymbolIconSource : PathIconSource
private void InvalidateData() private void InvalidateData()
{ {
var path = IconProvider.Current.GetIconPath(Symbol); var path = IconProvider.Current.GetIcon(Symbol).Path;
var geometry = Geometry.Parse(path); var geometry = Geometry.Parse(path);
var scale = FontSize / 20; var scale = FontSize / 20;
Data = geometry; Data = geometry;
// TODO: Scaling not working // TODO: Scaling not working
Data.Transform = new ScaleTransform(scale, scale); Data.Transform = new ScaleTransform(scale, scale);
@ -74,14 +76,15 @@ public class FASymbolIconSourceConverter : TypeConverter
return base.CanConvertFrom(context, sourceType); return base.CanConvertFrom(context, sourceType);
} }
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value) public override object? ConvertFrom(
ITypeDescriptorContext? context,
CultureInfo? culture,
object value
)
{ {
return value switch return value switch
{ {
string val => new FASymbolIconSource string val => new FASymbolIconSource { Symbol = val, },
{
Symbol = val,
},
_ => base.ConvertFrom(context, culture, value) _ => base.ConvertFrom(context, culture, value)
}; };
} }

2
StabilityMatrix.Avalonia/Controls/FreeUCard.axaml.cs

@ -1,5 +1,7 @@
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
[Transient]
public class FreeUCard : TemplatedControl { } public class FreeUCard : TemplatedControl { }

2
StabilityMatrix.Avalonia/Controls/ImageFolderCard.axaml.cs

@ -1,7 +1,9 @@
using Avalonia.Input; using Avalonia.Input;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
[Transient]
public class ImageFolderCard : DropTargetTemplatedControlBase public class ImageFolderCard : DropTargetTemplatedControlBase
{ {
/// <inheritdoc /> /// <inheritdoc />

6
StabilityMatrix.Avalonia/Controls/ImageGalleryCard.axaml.cs

@ -1,7 +1,7 @@
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
public class ImageGalleryCard : TemplatedControl [Transient]
{ public class ImageGalleryCard : TemplatedControl { }
}

1
StabilityMatrix.Avalonia/Controls/LineDashFrame.cs

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Avalonia; using Avalonia;
using Avalonia.Controls;
using Avalonia.Media; using Avalonia.Media;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;

10
StabilityMatrix.Avalonia/Controls/ModelCard.axaml.cs

@ -1,9 +1,7 @@
using Avalonia; using Avalonia.Controls.Primitives;
using Avalonia.Controls; using StabilityMatrix.Core.Attributes;
using Avalonia.Controls.Primitives;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
public class ModelCard : TemplatedControl [Transient]
{ public class ModelCard : TemplatedControl { }
}

1
StabilityMatrix.Avalonia/Controls/Paginator.axaml.cs

@ -2,7 +2,6 @@
using System.Windows.Input; using System.Windows.Input;
using Avalonia; using Avalonia;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using AvaloniaEdit.Utils;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;

2
StabilityMatrix.Avalonia/Controls/PromptCard.axaml.cs

@ -6,9 +6,11 @@ using AvaloniaEdit;
using AvaloniaEdit.Editing; using AvaloniaEdit.Editing;
using AvaloniaEdit.Utils; using AvaloniaEdit.Utils;
using StabilityMatrix.Avalonia.Helpers; using StabilityMatrix.Avalonia.Helpers;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
[Transient]
public class PromptCard : TemplatedControl public class PromptCard : TemplatedControl
{ {
/// <inheritdoc /> /// <inheritdoc />

2
StabilityMatrix.Avalonia/Controls/RefreshBadge.axaml.cs

@ -1,7 +1,9 @@
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
[Transient]
public partial class RefreshBadge : UserControlBase public partial class RefreshBadge : UserControlBase
{ {
public RefreshBadge() public RefreshBadge()

6
StabilityMatrix.Avalonia/Controls/SamplerCard.axaml.cs

@ -1,7 +1,7 @@
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
public class SamplerCard : TemplatedControl [Transient]
{ public class SamplerCard : TemplatedControl { }
}

6
StabilityMatrix.Avalonia/Controls/SeedCard.axaml.cs

@ -1,7 +1,7 @@
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
public class SeedCard : TemplatedControl [Transient]
{ public class SeedCard : TemplatedControl { }
}

5
StabilityMatrix.Avalonia/Controls/SelectImageCard.axaml.cs

@ -1,3 +1,6 @@
namespace StabilityMatrix.Avalonia.Controls; using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Controls;
[Transient]
public class SelectImageCard : DropTargetTemplatedControlBase { } public class SelectImageCard : DropTargetTemplatedControlBase { }

6
StabilityMatrix.Avalonia/Controls/SharpenCard.axaml.cs

@ -1,7 +1,7 @@
using Avalonia; using Avalonia.Controls.Primitives;
using Avalonia.Controls; using StabilityMatrix.Core.Attributes;
using Avalonia.Controls.Primitives;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
[Transient]
public class SharpenCard : TemplatedControl { } public class SharpenCard : TemplatedControl { }

8
StabilityMatrix.Avalonia/Controls/StackCard.axaml.cs

@ -1,14 +1,18 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Avalonia; using Avalonia;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[Transient]
public class StackCard : TemplatedControl public class StackCard : TemplatedControl
{ {
public static readonly StyledProperty<int> SpacingProperty = AvaloniaProperty.Register<StackCard, int>( public static readonly StyledProperty<int> SpacingProperty = AvaloniaProperty.Register<
"Spacing", 8); StackCard,
int
>("Spacing", 8);
public int Spacing public int Spacing
{ {

2
StabilityMatrix.Avalonia/Controls/StackExpander.axaml.cs

@ -1,8 +1,10 @@
using Avalonia; using Avalonia;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
[Transient]
public class StackExpander : TemplatedControl public class StackExpander : TemplatedControl
{ {
public static readonly StyledProperty<int> SpacingProperty = AvaloniaProperty.Register< public static readonly StyledProperty<int> SpacingProperty = AvaloniaProperty.Register<

5
StabilityMatrix.Avalonia/Controls/UpscalerCard.axaml.cs

@ -1,13 +1,14 @@
using System; using AsyncAwaitBestPractices;
using AsyncAwaitBestPractices;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using StabilityMatrix.Avalonia.ViewModels.Inference; using StabilityMatrix.Avalonia.ViewModels.Inference;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Models.Api.Comfy; using StabilityMatrix.Core.Models.Api.Comfy;
namespace StabilityMatrix.Avalonia.Controls; namespace StabilityMatrix.Avalonia.Controls;
[Transient]
public class UpscalerCard : TemplatedControl public class UpscalerCard : TemplatedControl
{ {
/// <inheritdoc /> /// <inheritdoc />

13
StabilityMatrix.Avalonia/DesignData/DesignData.cs

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
@ -9,7 +8,6 @@ using System.Text;
using AvaloniaEdit.Utils; using AvaloniaEdit.Utils;
using DynamicData.Binding; using DynamicData.Binding;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Controls.CodeCompletion; using StabilityMatrix.Avalonia.Controls.CodeCompletion;
using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Models.TagCompletion; using StabilityMatrix.Avalonia.Models.TagCompletion;
@ -57,7 +55,7 @@ public static class DesignData
if (isInitialized) if (isInitialized)
throw new InvalidOperationException("DesignData is already initialized."); throw new InvalidOperationException("DesignData is already initialized.");
var services = new ServiceCollection(); var services = App.ConfigureServices();
var activePackageId = Guid.NewGuid(); var activePackageId = Guid.NewGuid();
services.AddSingleton<ISettingsManager, MockSettingsManager>( services.AddSingleton<ISettingsManager, MockSettingsManager>(
@ -121,8 +119,7 @@ public static class DesignData
.AddSingleton<ICompletionProvider, MockCompletionProvider>() .AddSingleton<ICompletionProvider, MockCompletionProvider>()
.AddSingleton<IModelIndexService, MockModelIndexService>() .AddSingleton<IModelIndexService, MockModelIndexService>()
.AddSingleton<IImageIndexService, MockImageIndexService>() .AddSingleton<IImageIndexService, MockImageIndexService>()
.AddSingleton<ITrackedDownloadService, MockTrackedDownloadService>() .AddSingleton<ITrackedDownloadService, MockTrackedDownloadService>();
.AddSingleton<IPackageModificationRunner, PackageModificationRunner>();
// Placeholder services that nobody should need during design time // Placeholder services that nobody should need during design time
services services
@ -133,12 +130,6 @@ public static class DesignData
.AddSingleton<ITokenizerProvider>(_ => null!) .AddSingleton<ITokenizerProvider>(_ => null!)
.AddSingleton<IPrerequisiteHelper>(_ => null!); .AddSingleton<IPrerequisiteHelper>(_ => null!);
// Using some default service implementations from App
App.ConfigurePackages(services);
App.ConfigurePageViewModels(services);
App.ConfigureDialogViewModels(services);
App.ConfigureViews(services);
// Override Launch page with mock // Override Launch page with mock
services.Remove(ServiceDescriptor.Singleton<LaunchPageViewModel, LaunchPageViewModel>()); services.Remove(ServiceDescriptor.Singleton<LaunchPageViewModel, LaunchPageViewModel>());
services.AddSingleton<LaunchPageViewModel, MockLaunchPageViewModel>(); services.AddSingleton<LaunchPageViewModel, MockLaunchPageViewModel>();

3
StabilityMatrix.Avalonia/DialogHelper.cs

@ -14,11 +14,9 @@ using Avalonia.Media;
using Avalonia.Threading; using Avalonia.Threading;
using AvaloniaEdit; using AvaloniaEdit;
using AvaloniaEdit.TextMate; using AvaloniaEdit.TextMate;
using CommunityToolkit.Mvvm.ComponentModel.__Internals;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using Markdown.Avalonia; using Markdown.Avalonia;
using Markdown.Avalonia.SyntaxHigh.Extensions;
using NLog; using NLog;
using Refit; using Refit;
using StabilityMatrix.Avalonia.Controls; using StabilityMatrix.Avalonia.Controls;
@ -26,7 +24,6 @@ using StabilityMatrix.Avalonia.Helpers;
using StabilityMatrix.Core.Exceptions; using StabilityMatrix.Core.Exceptions;
using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.Database;
using StabilityMatrix.Core.Services; using StabilityMatrix.Core.Services;
using TextMateSharp.Grammars; using TextMateSharp.Grammars;
using Process = FuzzySharp.Process; using Process = FuzzySharp.Process;

1
StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs

@ -3,7 +3,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using Avalonia;
using Force.Crc32; using Force.Crc32;
using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models;

19
StabilityMatrix.Avalonia/Helpers/TagCsvParser.cs

@ -1,24 +1,21 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.Common;
using System.Globalization;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using StabilityMatrix.Avalonia.Models.TagCompletion; using StabilityMatrix.Avalonia.Models.TagCompletion;
using Sylvan.Data.Csv; using Sylvan.Data.Csv;
using Sylvan; using Sylvan;
using Sylvan.Data;
namespace StabilityMatrix.Avalonia.Helpers; namespace StabilityMatrix.Avalonia.Helpers;
public class TagCsvParser public class TagCsvParser
{ {
private readonly Stream stream; private readonly Stream stream;
public TagCsvParser(Stream stream) public TagCsvParser(Stream stream)
{ {
this.stream = stream; this.stream = stream;
} }
public async IAsyncEnumerable<TagCsvEntry> ParseAsync() public async IAsyncEnumerable<TagCsvEntry> ParseAsync()
{ {
var pool = new StringPool(); var pool = new StringPool();
@ -27,10 +24,10 @@ public class TagCsvParser
StringFactory = pool.GetString, StringFactory = pool.GetString,
HasHeaders = false, HasHeaders = false,
}; };
using var textReader = new StreamReader(stream); using var textReader = new StreamReader(stream);
await using var dataReader = await CsvDataReader.CreateAsync(textReader, options); await using var dataReader = await CsvDataReader.CreateAsync(textReader, options);
while (await dataReader.ReadAsync()) while (await dataReader.ReadAsync())
{ {
var entry = new TagCsvEntry var entry = new TagCsvEntry
@ -42,7 +39,7 @@ public class TagCsvParser
}; };
yield return entry; yield return entry;
} }
/*var dataBinderOptions = new DataBinderOptions /*var dataBinderOptions = new DataBinderOptions
{ {
BindingMode = DataBindingMode.Any BindingMode = DataBindingMode.Any
@ -54,17 +51,17 @@ public class TagCsvParser
public async Task<Dictionary<string, TagCsvEntry>> GetDictionaryAsync() public async Task<Dictionary<string, TagCsvEntry>> GetDictionaryAsync()
{ {
var dict = new Dictionary<string, TagCsvEntry>(); var dict = new Dictionary<string, TagCsvEntry>();
await foreach (var entry in ParseAsync()) await foreach (var entry in ParseAsync())
{ {
if (entry.Name is null || entry.Type is null) if (entry.Name is null || entry.Type is null)
{ {
continue; continue;
} }
dict.Add(entry.Name, entry); dict.Add(entry.Name, entry);
} }
return dict; return dict;
} }
} }

1
StabilityMatrix.Avalonia/Helpers/TextEditorConfigs.cs

@ -1,5 +1,4 @@
using System.IO; using System.IO;
using System.Reflection;
using Avalonia.Media; using Avalonia.Media;
using AvaloniaEdit; using AvaloniaEdit;
using AvaloniaEdit.TextMate; using AvaloniaEdit.TextMate;

1
StabilityMatrix.Avalonia/Models/Inference/FileNameFormat.cs

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;

1
StabilityMatrix.Avalonia/Models/Inference/FileNameFormatProvider.cs

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;

1
StabilityMatrix.Avalonia/Models/Inference/Prompt.cs

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;

1
StabilityMatrix.Avalonia/Models/Inference/StackExpanderModel.cs

@ -1,5 +1,4 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using StabilityMatrix.Avalonia.ViewModels.Inference;
namespace StabilityMatrix.Avalonia.Models.Inference; namespace StabilityMatrix.Avalonia.Models.Inference;

3
StabilityMatrix.Avalonia/Models/Inference/ViewState.cs

@ -1,5 +1,4 @@
using System.Text.Json.Nodes; using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
namespace StabilityMatrix.Avalonia.Models.Inference; namespace StabilityMatrix.Avalonia.Models.Inference;

5
StabilityMatrix.Avalonia/Models/SharedState.cs

@ -1,14 +1,17 @@
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Models; namespace StabilityMatrix.Avalonia.Models;
/// <summary> /// <summary>
/// Singleton DI service for observable shared UI state. /// Singleton DI service for observable shared UI state.
/// </summary> /// </summary>
[Singleton]
public partial class SharedState : ObservableObject public partial class SharedState : ObservableObject
{ {
/// <summary> /// <summary>
/// Whether debug mode enabled from settings page version tap. /// Whether debug mode enabled from settings page version tap.
/// </summary> /// </summary>
[ObservableProperty] private bool isDebugMode; [ObservableProperty]
private bool isDebugMode;
} }

3
StabilityMatrix.Avalonia/Models/TagCompletion/CompletionProvider.cs

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -16,6 +15,7 @@ using NLog;
using StabilityMatrix.Avalonia.Controls.CodeCompletion; using StabilityMatrix.Avalonia.Controls.CodeCompletion;
using StabilityMatrix.Avalonia.Helpers; using StabilityMatrix.Avalonia.Helpers;
using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models;
@ -26,6 +26,7 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.Models.TagCompletion; namespace StabilityMatrix.Avalonia.Models.TagCompletion;
[Singleton(typeof(ICompletionProvider))]
public partial class CompletionProvider : ICompletionProvider public partial class CompletionProvider : ICompletionProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

4
StabilityMatrix.Avalonia/Models/TagCompletion/TextCompletionRequest.cs

@ -1,6 +1,4 @@
using System.Collections.Generic; using StabilityMatrix.Core.Models.Tokens;
using AvaloniaEdit.Document;
using StabilityMatrix.Core.Models.Tokens;
namespace StabilityMatrix.Avalonia.Models.TagCompletion; namespace StabilityMatrix.Avalonia.Models.TagCompletion;

2
StabilityMatrix.Avalonia/Models/TagCompletion/TokenizerProvider.cs

@ -1,10 +1,12 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using StabilityMatrix.Avalonia.Extensions; using StabilityMatrix.Avalonia.Extensions;
using StabilityMatrix.Core.Attributes;
using TextMateSharp.Grammars; using TextMateSharp.Grammars;
using TextMateSharp.Registry; using TextMateSharp.Registry;
namespace StabilityMatrix.Avalonia.Models.TagCompletion; namespace StabilityMatrix.Avalonia.Models.TagCompletion;
[Singleton(typeof(ITokenizerProvider))]
public class TokenizerProvider : ITokenizerProvider public class TokenizerProvider : ITokenizerProvider
{ {
private readonly Registry registry = new(new RegistryOptions(ThemeName.DarkPlus)); private readonly Registry registry = new(new RegistryOptions(ThemeName.DarkPlus));

1
StabilityMatrix.Avalonia/Services/IInferenceClientManager.cs

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Threading; using System.Threading;

3
StabilityMatrix.Avalonia/Services/InferenceClientManager.cs

@ -1,6 +1,5 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -14,6 +13,7 @@ using SkiaSharp;
using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Models.TagCompletion; using StabilityMatrix.Avalonia.Models.TagCompletion;
using StabilityMatrix.Core.Api; using StabilityMatrix.Core.Api;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Inference; using StabilityMatrix.Core.Inference;
using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models;
@ -28,6 +28,7 @@ namespace StabilityMatrix.Avalonia.Services;
/// Manager for the current inference client /// Manager for the current inference client
/// Has observable shared properties for shared info like model names /// Has observable shared properties for shared info like model names
/// </summary> /// </summary>
[Singleton(typeof(IInferenceClientManager))]
public partial class InferenceClientManager : ObservableObject, IInferenceClientManager public partial class InferenceClientManager : ObservableObject, IInferenceClientManager
{ {
private readonly ILogger<InferenceClientManager> logger; private readonly ILogger<InferenceClientManager> logger;

4
StabilityMatrix.Avalonia/Services/NavigationService.cs

@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using FluentAvalonia.UI.Media.Animation; using FluentAvalonia.UI.Media.Animation;
@ -8,10 +6,12 @@ using FluentAvalonia.UI.Navigation;
using StabilityMatrix.Avalonia.Animations; using StabilityMatrix.Avalonia.Animations;
using StabilityMatrix.Avalonia.ViewModels; using StabilityMatrix.Avalonia.ViewModels;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Services; using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.Services; namespace StabilityMatrix.Avalonia.Services;
[Singleton(typeof(INavigationService))]
public class NavigationService : INavigationService public class NavigationService : INavigationService
{ {
private Frame? _frame; private Frame? _frame;

32
StabilityMatrix.Avalonia/Services/NotificationService.cs

@ -3,20 +3,24 @@ using System.Threading.Tasks;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Notifications; using Avalonia.Controls.Notifications;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models;
namespace StabilityMatrix.Avalonia.Services; namespace StabilityMatrix.Avalonia.Services;
[Singleton(typeof(INotificationService))]
public class NotificationService : INotificationService public class NotificationService : INotificationService
{ {
private WindowNotificationManager? notificationManager; private WindowNotificationManager? notificationManager;
public void Initialize( public void Initialize(
Visual? visual, Visual? visual,
NotificationPosition position = NotificationPosition.BottomRight, NotificationPosition position = NotificationPosition.BottomRight,
int maxItems = 4) int maxItems = 4
)
{ {
if (notificationManager is not null) return; if (notificationManager is not null)
return;
notificationManager = new WindowNotificationManager(TopLevel.GetTopLevel(visual)) notificationManager = new WindowNotificationManager(TopLevel.GetTopLevel(visual))
{ {
Position = position, Position = position,
@ -30,28 +34,31 @@ public class NotificationService : INotificationService
} }
public void Show( public void Show(
string title, string title,
string message, string message,
NotificationType appearance = NotificationType.Information, NotificationType appearance = NotificationType.Information,
TimeSpan? expiration = null) TimeSpan? expiration = null
)
{ {
Show(new Notification(title, message, appearance, expiration)); Show(new Notification(title, message, appearance, expiration));
} }
public void ShowPersistent( public void ShowPersistent(
string title, string title,
string message, string message,
NotificationType appearance = NotificationType.Information) NotificationType appearance = NotificationType.Information
)
{ {
Show(new Notification(title, message, appearance, TimeSpan.Zero)); Show(new Notification(title, message, appearance, TimeSpan.Zero));
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task<TaskResult<T>> TryAsync<T>( public async Task<TaskResult<T>> TryAsync<T>(
Task<T> task, Task<T> task,
string title = "Error", string title = "Error",
string? message = null, string? message = null,
NotificationType appearance = NotificationType.Error) NotificationType appearance = NotificationType.Error
)
{ {
try try
{ {
@ -63,13 +70,14 @@ public class NotificationService : INotificationService
return TaskResult<T>.FromException(e); return TaskResult<T>.FromException(e);
} }
} }
/// <inheritdoc /> /// <inheritdoc />
public async Task<TaskResult<bool>> TryAsync( public async Task<TaskResult<bool>> TryAsync(
Task task, Task task,
string title = "Error", string title = "Error",
string? message = null, string? message = null,
NotificationType appearance = NotificationType.Error) NotificationType appearance = NotificationType.Error
)
{ {
try try
{ {

15
StabilityMatrix.Avalonia/Services/ServiceManager.cs

@ -256,4 +256,19 @@ public class ServiceManager<T>
return new BetterContentDialog { Content = view }; return new BetterContentDialog { Content = view };
} }
public void Register(Type type, Func<T> providerFunc)
{
lock (providers)
{
if (instances.ContainsKey(type) || providers.ContainsKey(type))
{
throw new ArgumentException(
$"Service of type {type} is already registered for {typeof(T)}"
);
}
providers[type] = providerFunc;
}
}
} }

34
StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj

@ -23,48 +23,48 @@
<PackageReference Include="AutoComplete.Net" Version="1.2211.2014.42"/> <PackageReference Include="AutoComplete.Net" Version="1.2211.2014.42"/>
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.1" /> <PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.1" />
<PackageReference Include="Avalonia.Controls.PanAndZoom" Version="11.0.0" /> <PackageReference Include="Avalonia.Controls.PanAndZoom" Version="11.0.0" />
<PackageReference Include="Avalonia" Version="11.0.4" /> <PackageReference Include="Avalonia" Version="11.0.5" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.4" /> <PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.4" /> <PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.5" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.4" /> <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.5" />
<PackageReference Include="Avalonia.HtmlRenderer" Version="11.0.0" /> <PackageReference Include="Avalonia.HtmlRenderer" Version="11.0.0" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.2" /> <PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.2" />
<PackageReference Include="AvaloniaEdit.TextMate" Version="11.0.0" /> <PackageReference Include="AvaloniaEdit.TextMate" Version="11.0.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="CSharpDiscriminatedUnion" Version="2.0.1" /> <PackageReference Include="CSharpDiscriminatedUnion" Version="2.0.1" />
<PackageReference Include="DiscordRichPresence" Version="1.2.1.24" /> <PackageReference Include="DiscordRichPresence" Version="1.2.1.24" />
<PackageReference Include="Dock.Avalonia" Version="11.0.0.2" /> <PackageReference Include="Dock.Avalonia" Version="11.0.0.2" />
<PackageReference Include="Dock.Model.Avalonia" Version="11.0.0.2" /> <PackageReference Include="Dock.Model.Avalonia" Version="11.0.0.2" />
<PackageReference Include="Dock.Serializer" Version="11.0.0.2" /> <PackageReference Include="Dock.Serializer" Version="11.0.0.2" />
<PackageReference Include="DynamicData" Version="7.14.2" /> <PackageReference Include="DynamicData" Version="8.1.1" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.4" /> <PackageReference Include="FluentAvaloniaUI" Version="2.0.4" />
<PackageReference Include="FluentIcons.Avalonia" Version="1.1.217" /> <PackageReference Include="FluentIcons.Avalonia" Version="1.1.220" />
<PackageReference Include="FluentIcons.FluentAvalonia" Version="1.1.217" /> <PackageReference Include="FluentIcons.FluentAvalonia" Version="1.1.220" />
<PackageReference Include="FuzzySharp" Version="2.0.2" /> <PackageReference Include="FuzzySharp" Version="2.0.2" />
<PackageReference Include="Markdown.Avalonia" Version="11.0.0" /> <PackageReference Include="Markdown.Avalonia" Version="11.0.2" />
<PackageReference Include="MetadataExtractor" Version="2.8.1" /> <PackageReference Include="MetadataExtractor" Version="2.8.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.8" /> <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.12" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" /> <PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="NLog" Version="5.2.3" /> <PackageReference Include="NLog" Version="5.2.5" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.2" /> <PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
<PackageReference Include="Polly" Version="7.2.4" /> <PackageReference Include="Polly" Version="8.0.0" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" /> <PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageReference Include="Polly.Extensions.Http" Version="3.0.0" /> <PackageReference Include="Polly.Extensions.Http" Version="3.0.0" />
<PackageReference Include="Projektanker.Icons.Avalonia.FontAwesome" Version="6.6.0" /> <PackageReference Include="Projektanker.Icons.Avalonia.FontAwesome" Version="8.3.0" />
<PackageReference Include="RockLib.Reflection.Optimized" Version="2.0.0" /> <PackageReference Include="RockLib.Reflection.Optimized" Version="2.0.0" />
<PackageReference Include="Sentry" Version="3.33.1" /> <PackageReference Include="Sentry" Version="3.40.1" />
<PackageReference Include="Sentry.NLog" Version="3.33.1" /> <PackageReference Include="Sentry.NLog" Version="3.40.1" />
<PackageReference Include="SpacedGrid-Avalonia" Version="11.0.0" /> <PackageReference Include="SpacedGrid-Avalonia" Version="11.0.0" />
<PackageReference Include="Sylvan.Common" Version="0.4.2" /> <PackageReference Include="Sylvan.Common" Version="0.4.2" />
<PackageReference Include="Sylvan.Data" Version="0.2.12" /> <PackageReference Include="Sylvan.Data" Version="0.2.12" />
<PackageReference Include="Sylvan.Data.Csv" Version="1.3.3" /> <PackageReference Include="Sylvan.Data.Csv" Version="1.3.3" />
<PackageReference Include="TextMateSharp.Grammars" Version="1.0.55" /> <PackageReference Include="TextMateSharp.Grammars" Version="1.0.56" />
</ItemGroup> </ItemGroup>

3
StabilityMatrix.Avalonia/Styles/ThemeColors.cs

@ -1,5 +1,4 @@
using Avalonia; using Avalonia.Media;
using Avalonia.Media;
namespace StabilityMatrix.Avalonia.Styles; namespace StabilityMatrix.Avalonia.Styles;

1
StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs

@ -9,7 +9,6 @@ using AsyncAwaitBestPractices;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Notifications; using Avalonia.Controls.Notifications;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
using Avalonia.Threading; using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;

1
StabilityMatrix.Avalonia/ViewModels/Base/ProgressItemViewModelBase.cs

@ -1,5 +1,4 @@
using System; using System;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
namespace StabilityMatrix.Avalonia.ViewModels.Base; namespace StabilityMatrix.Avalonia.ViewModels.Base;

3
StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CheckpointBrowserCardViewModel.cs

@ -17,6 +17,7 @@ using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.Dialogs; using StabilityMatrix.Avalonia.ViewModels.Dialogs;
using StabilityMatrix.Avalonia.Views.Dialogs; using StabilityMatrix.Avalonia.Views.Dialogs;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.Api; using StabilityMatrix.Core.Models.Api;
@ -27,6 +28,8 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.CheckpointBrowser; namespace StabilityMatrix.Avalonia.ViewModels.CheckpointBrowser;
[ManagedService]
[Transient]
public partial class CheckpointBrowserCardViewModel : Base.ProgressViewModel public partial class CheckpointBrowserCardViewModel : Base.ProgressViewModel
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

4
StabilityMatrix.Avalonia/ViewModels/CheckpointBrowserViewModel.cs

@ -5,16 +5,13 @@ using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Reactive;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsyncAwaitBestPractices; using AsyncAwaitBestPractices;
using Avalonia.Collections; using Avalonia.Collections;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Notifications; using Avalonia.Controls.Notifications;
using AvaloniaEdit.Utils;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
@ -42,6 +39,7 @@ using SymbolIconSource = FluentIcons.FluentAvalonia.SymbolIconSource;
namespace StabilityMatrix.Avalonia.ViewModels; namespace StabilityMatrix.Avalonia.ViewModels;
[View(typeof(CheckpointBrowserPage))] [View(typeof(CheckpointBrowserPage))]
[Singleton]
public partial class CheckpointBrowserViewModel : PageViewModelBase public partial class CheckpointBrowserViewModel : PageViewModelBase
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

3
StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFile.cs

@ -10,6 +10,7 @@ using CommunityToolkit.Mvvm.Input;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using NLog; using NLog;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models;
@ -19,6 +20,8 @@ using StabilityMatrix.Core.Processes;
namespace StabilityMatrix.Avalonia.ViewModels.CheckpointManager; namespace StabilityMatrix.Avalonia.ViewModels.CheckpointManager;
[ManagedService]
[Transient]
public partial class CheckpointFile : ViewModelBase public partial class CheckpointFile : ViewModelBase
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

3
StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFolder.cs

@ -17,6 +17,7 @@ using DynamicData.Binding;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models;
@ -27,6 +28,8 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.CheckpointManager; namespace StabilityMatrix.Avalonia.ViewModels.CheckpointManager;
[ManagedService]
[Transient]
public partial class CheckpointFolder : ViewModelBase public partial class CheckpointFolder : ViewModelBase
{ {
private readonly ISettingsManager settingsManager; private readonly ISettingsManager settingsManager;

1
StabilityMatrix.Avalonia/ViewModels/CheckpointsPageViewModel.cs

@ -24,6 +24,7 @@ using SymbolIconSource = FluentIcons.FluentAvalonia.SymbolIconSource;
namespace StabilityMatrix.Avalonia.ViewModels; namespace StabilityMatrix.Avalonia.ViewModels;
[View(typeof(CheckpointsPage))] [View(typeof(CheckpointsPage))]
[Singleton]
public partial class CheckpointsPageViewModel : PageViewModelBase public partial class CheckpointsPageViewModel : PageViewModelBase
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

2
StabilityMatrix.Avalonia/ViewModels/Dialogs/DownloadResourceViewModel.cs

@ -16,6 +16,8 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[View(typeof(DownloadResourceDialog))] [View(typeof(DownloadResourceDialog))]
[ManagedService]
[Transient]
public partial class DownloadResourceViewModel : ContentDialogViewModelBase public partial class DownloadResourceViewModel : ContentDialogViewModelBase
{ {
private readonly IDownloadService downloadService; private readonly IDownloadService downloadService;

2
StabilityMatrix.Avalonia/ViewModels/Dialogs/EnvVarsViewModel.cs

@ -12,6 +12,8 @@ using StabilityMatrix.Core.Models;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[View(typeof(EnvVarsViewModel))] [View(typeof(EnvVarsViewModel))]
[ManagedService]
[Transient]
public partial class EnvVarsViewModel : ContentDialogViewModelBase public partial class EnvVarsViewModel : ContentDialogViewModelBase
{ {
[ObservableProperty] [ObservableProperty]

6
StabilityMatrix.Avalonia/ViewModels/Dialogs/ExceptionViewModel.cs

@ -6,11 +6,13 @@ using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[View(typeof(ExceptionDialog))] [View(typeof(ExceptionDialog))]
[ManagedService]
[Transient]
public partial class ExceptionViewModel : ViewModelBase public partial class ExceptionViewModel : ViewModelBase
{ {
public Exception? Exception { get; set; } public Exception? Exception { get; set; }
public string? Message => Exception?.Message; public string? Message => Exception?.Message;
public string? ExceptionType => Exception?.GetType().Name ?? ""; public string? ExceptionType => Exception?.GetType().Name ?? "";
} }

2
StabilityMatrix.Avalonia/ViewModels/Dialogs/ImageViewerViewModel.cs

@ -21,6 +21,8 @@ using Size = StabilityMatrix.Core.Helper.Size;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[View(typeof(ImageViewerDialog))] [View(typeof(ImageViewerDialog))]
[ManagedService]
[Transient]
public partial class ImageViewerViewModel : ContentDialogViewModelBase public partial class ImageViewerViewModel : ContentDialogViewModelBase
{ {
[ObservableProperty] [ObservableProperty]

3
StabilityMatrix.Avalonia/ViewModels/Dialogs/InferenceConnectionHelpViewModel.cs

@ -6,7 +6,6 @@ using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using StabilityMatrix.Avalonia.Animations;
using StabilityMatrix.Avalonia.Controls; using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.Services;
@ -23,6 +22,8 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[View(typeof(InferenceConnectionHelpDialog))] [View(typeof(InferenceConnectionHelpDialog))]
[ManagedService]
[Transient]
public partial class InferenceConnectionHelpViewModel : ContentDialogViewModelBase public partial class InferenceConnectionHelpViewModel : ContentDialogViewModelBase
{ {
private readonly ISettingsManager settingsManager; private readonly ISettingsManager settingsManager;

3
StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs

@ -19,6 +19,7 @@ using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Helper.Factory; using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models;
@ -31,6 +32,8 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[ManagedService]
[Transient]
public partial class InstallerViewModel : ContentDialogViewModelBase public partial class InstallerViewModel : ContentDialogViewModelBase
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

2
StabilityMatrix.Avalonia/ViewModels/Dialogs/LaunchOptionsViewModel.cs

@ -17,6 +17,8 @@ using StabilityMatrix.Core.Models;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[View(typeof(LaunchOptionsDialog))] [View(typeof(LaunchOptionsDialog))]
[ManagedService]
[Transient]
public partial class LaunchOptionsViewModel : ContentDialogViewModelBase public partial class LaunchOptionsViewModel : ContentDialogViewModelBase
{ {
private readonly ILogger<LaunchOptionsViewModel> logger; private readonly ILogger<LaunchOptionsViewModel> logger;

4
StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs

@ -10,17 +10,19 @@ using Microsoft.Extensions.Logging;
using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Helper.Factory; using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.PackageModification; using StabilityMatrix.Core.Models.PackageModification;
using StabilityMatrix.Core.Models.Packages; using StabilityMatrix.Core.Models.Packages;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Python; using StabilityMatrix.Core.Python;
using StabilityMatrix.Core.Services; using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[ManagedService]
[Transient]
public partial class OneClickInstallViewModel : ContentDialogViewModelBase public partial class OneClickInstallViewModel : ContentDialogViewModelBase
{ {
private readonly ISettingsManager settingsManager; private readonly ISettingsManager settingsManager;

2
StabilityMatrix.Avalonia/ViewModels/Dialogs/PackageImportViewModel.cs

@ -23,6 +23,8 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[View(typeof(PackageImportDialog))] [View(typeof(PackageImportDialog))]
[ManagedService]
[Transient]
public partial class PackageImportViewModel : ContentDialogViewModelBase public partial class PackageImportViewModel : ContentDialogViewModelBase
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

2
StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectDataDirectoryViewModel.cs

@ -19,6 +19,8 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[View(typeof(SelectDataDirectoryDialog))] [View(typeof(SelectDataDirectoryDialog))]
[ManagedService]
[Transient]
public partial class SelectDataDirectoryViewModel : ContentDialogViewModelBase public partial class SelectDataDirectoryViewModel : ContentDialogViewModelBase
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

8
StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs

@ -1,19 +1,19 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using Avalonia.Media.Imaging; using Avalonia.Media.Imaging;
using Avalonia.Platform;
using Avalonia.Threading; using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Services; using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[ManagedService]
[Transient]
public partial class SelectModelVersionViewModel : ContentDialogViewModelBase public partial class SelectModelVersionViewModel : ContentDialogViewModelBase
{ {
private readonly ISettingsManager settingsManager; private readonly ISettingsManager settingsManager;

2
StabilityMatrix.Avalonia/ViewModels/Dialogs/UpdateViewModel.cs

@ -22,6 +22,8 @@ using StabilityMatrix.Core.Updater;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs; namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[View(typeof(UpdateDialog))] [View(typeof(UpdateDialog))]
[ManagedService]
[Singleton]
public partial class UpdateViewModel : ContentDialogViewModelBase public partial class UpdateViewModel : ContentDialogViewModelBase
{ {
private readonly ISettingsManager settingsManager; private readonly ISettingsManager settingsManager;

27
StabilityMatrix.Avalonia/ViewModels/FirstLaunchSetupViewModel.cs

@ -11,6 +11,8 @@ using StabilityMatrix.Core.Helper;
namespace StabilityMatrix.Avalonia.ViewModels; namespace StabilityMatrix.Avalonia.ViewModels;
[View(typeof(FirstLaunchSetupWindow))] [View(typeof(FirstLaunchSetupWindow))]
[ManagedService]
[Singleton]
public partial class FirstLaunchSetupViewModel : ViewModelBase public partial class FirstLaunchSetupViewModel : ViewModelBase
{ {
[ObservableProperty] [ObservableProperty]
@ -20,14 +22,17 @@ public partial class FirstLaunchSetupViewModel : ViewModelBase
private string gpuInfoText = string.Empty; private string gpuInfoText = string.Empty;
[ObservableProperty] [ObservableProperty]
private RefreshBadgeViewModel checkHardwareBadge = new() private RefreshBadgeViewModel checkHardwareBadge =
{ new()
WorkingToolTipText = "We're checking some hardware specifications to determine compatibility.", {
SuccessToolTipText = "Everything looks good!", WorkingToolTipText =
FailToolTipText = "We recommend a GPU with CUDA support for the best experience. " + "We're checking some hardware specifications to determine compatibility.",
"You can continue without one, but some packages may not work, and inference may be slower.", SuccessToolTipText = "Everything looks good!",
FailColorBrush = ThemeColors.ThemeYellow, FailToolTipText =
}; "We recommend a GPU with CUDA support for the best experience. "
+ "You can continue without one, but some packages may not work, and inference may be slower.",
FailColorBrush = ThemeColors.ThemeYellow,
};
public FirstLaunchSetupViewModel() public FirstLaunchSetupViewModel()
{ {
@ -43,14 +48,16 @@ public partial class FirstLaunchSetupViewModel : ViewModelBase
gpuInfo = await Task.Run(() => HardwareHelper.IterGpuInfo().ToArray()); gpuInfo = await Task.Run(() => HardwareHelper.IterGpuInfo().ToArray());
} }
// First Nvidia GPU // First Nvidia GPU
var activeGpu = gpuInfo.FirstOrDefault(gpu => gpu.Name?.ToLowerInvariant().Contains("nvidia") ?? false); var activeGpu = gpuInfo.FirstOrDefault(
gpu => gpu.Name?.ToLowerInvariant().Contains("nvidia") ?? false
);
var isNvidia = activeGpu is not null; var isNvidia = activeGpu is not null;
// Otherwise first GPU // Otherwise first GPU
activeGpu ??= gpuInfo.FirstOrDefault(); activeGpu ??= gpuInfo.FirstOrDefault();
GpuInfoText = activeGpu is null GpuInfoText = activeGpu is null
? "No GPU detected" ? "No GPU detected"
: $"{activeGpu.Name} ({Size.FormatBytes(activeGpu.MemoryBytes)})"; : $"{activeGpu.Name} ({Size.FormatBytes(activeGpu.MemoryBytes)})";
return isNvidia; return isNvidia;
} }

2
StabilityMatrix.Avalonia/ViewModels/Inference/BatchSizeCardViewModel.cs

@ -6,6 +6,8 @@ using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(BatchSizeCard))] [View(typeof(BatchSizeCard))]
[ManagedService]
[Transient]
public partial class BatchSizeCardViewModel : LoadableViewModelBase public partial class BatchSizeCardViewModel : LoadableViewModelBase
{ {
[ObservableProperty] [ObservableProperty]

2
StabilityMatrix.Avalonia/ViewModels/Inference/FreeUCardViewModel.cs

@ -7,6 +7,8 @@ using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(FreeUCard))] [View(typeof(FreeUCard))]
[ManagedService]
[Transient]
public partial class FreeUCardViewModel : LoadableViewModelBase public partial class FreeUCardViewModel : LoadableViewModelBase
{ {
public const string ModuleKey = "FreeU"; public const string ModuleKey = "FreeU";

4
StabilityMatrix.Avalonia/ViewModels/Inference/IImageGalleryComponent.cs

@ -1,6 +1,4 @@
using System.Collections.Generic; using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;

2
StabilityMatrix.Avalonia/ViewModels/Inference/ImageFolderCardViewModel.cs

@ -32,6 +32,8 @@ using SortDirection = DynamicData.Binding.SortDirection;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(ImageFolderCard))] [View(typeof(ImageFolderCard))]
[ManagedService]
[Transient]
public partial class ImageFolderCardViewModel : ViewModelBase public partial class ImageFolderCardViewModel : ViewModelBase
{ {
private readonly ILogger<ImageFolderCardViewModel> logger; private readonly ILogger<ImageFolderCardViewModel> logger;

2
StabilityMatrix.Avalonia/ViewModels/Inference/ImageGalleryCardViewModel.cs

@ -23,6 +23,8 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(ImageGalleryCard))] [View(typeof(ImageGalleryCard))]
[ManagedService]
[Transient]
public partial class ImageGalleryCardViewModel : ViewModelBase public partial class ImageGalleryCardViewModel : ViewModelBase
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

5
StabilityMatrix.Avalonia/ViewModels/Inference/InferenceImageUpscaleViewModel.cs

@ -1,13 +1,10 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsyncAwaitBestPractices; using AsyncAwaitBestPractices;
using Avalonia.Controls.Shapes;
using Avalonia.Threading;
using DynamicData.Binding; using DynamicData.Binding;
using NLog; using NLog;
using StabilityMatrix.Avalonia.Extensions; using StabilityMatrix.Avalonia.Extensions;
@ -29,6 +26,8 @@ namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(InferenceImageUpscaleView), persistent: true)] [View(typeof(InferenceImageUpscaleView), persistent: true)]
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
[ManagedService]
[Transient]
public class InferenceImageUpscaleViewModel : InferenceGenerationViewModelBase public class InferenceImageUpscaleViewModel : InferenceGenerationViewModelBase
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

2
StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs

@ -30,6 +30,8 @@ using InferenceTextToImageView = StabilityMatrix.Avalonia.Views.Inference.Infere
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(InferenceTextToImageView), persistent: true)] [View(typeof(InferenceTextToImageView), persistent: true)]
[ManagedService]
[Transient]
public class InferenceTextToImageViewModel public class InferenceTextToImageViewModel
: InferenceGenerationViewModelBase, : InferenceGenerationViewModelBase,
IParametersLoadableState IParametersLoadableState

2
StabilityMatrix.Avalonia/ViewModels/Inference/ModelCardViewModel.cs

@ -12,6 +12,8 @@ using StabilityMatrix.Core.Models;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(ModelCard))] [View(typeof(ModelCard))]
[ManagedService]
[Transient]
public partial class ModelCardViewModel : LoadableViewModelBase, IParametersLoadableState public partial class ModelCardViewModel : LoadableViewModelBase, IParametersLoadableState
{ {
[ObservableProperty] [ObservableProperty]

2
StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs

@ -21,6 +21,8 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(PromptCard))] [View(typeof(PromptCard))]
[ManagedService]
[Transient]
public partial class PromptCardViewModel : LoadableViewModelBase, IParametersLoadableState public partial class PromptCardViewModel : LoadableViewModelBase, IParametersLoadableState
{ {
private readonly IModelIndexService modelIndexService; private readonly IModelIndexService modelIndexService;

2
StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs

@ -14,6 +14,8 @@ using StabilityMatrix.Core.Models.Api.Comfy;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(SamplerCard))] [View(typeof(SamplerCard))]
[ManagedService]
[Transient]
public partial class SamplerCardViewModel : LoadableViewModelBase, IParametersLoadableState public partial class SamplerCardViewModel : LoadableViewModelBase, IParametersLoadableState
{ {
public const string ModuleKey = "Sampler"; public const string ModuleKey = "Sampler";

2
StabilityMatrix.Avalonia/ViewModels/Inference/SeedCardViewModel.cs

@ -10,6 +10,8 @@ using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(SeedCard))] [View(typeof(SeedCard))]
[ManagedService]
[Transient]
public partial class SeedCardViewModel : LoadableViewModelBase public partial class SeedCardViewModel : LoadableViewModelBase
{ {
[ObservableProperty, NotifyPropertyChangedFor(nameof(RandomizeButtonToolTip))] [ObservableProperty, NotifyPropertyChangedFor(nameof(RandomizeButtonToolTip))]

3
StabilityMatrix.Avalonia/ViewModels/Inference/SelectImageCardViewModel.cs

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Text.Json;
using System.Linq; using System.Linq;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Media; using Avalonia.Media;
@ -19,6 +18,8 @@ using StabilityMatrix.Core.Models.Database;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(SelectImageCard))] [View(typeof(SelectImageCard))]
[ManagedService]
[Transient]
public partial class SelectImageCardViewModel : ViewModelBase, IDropTarget public partial class SelectImageCardViewModel : ViewModelBase, IDropTarget
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

2
StabilityMatrix.Avalonia/ViewModels/Inference/SharpenCardViewModel.cs

@ -7,6 +7,8 @@ using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(SharpenCard))] [View(typeof(SharpenCard))]
[ManagedService]
[Transient]
public partial class SharpenCardViewModel : LoadableViewModelBase public partial class SharpenCardViewModel : LoadableViewModelBase
{ {
[Range(1, 31)] [Range(1, 31)]

2
StabilityMatrix.Avalonia/ViewModels/Inference/StackCardViewModel.cs

@ -10,6 +10,8 @@ using StabilityMatrix.Core.Extensions;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(StackCard))] [View(typeof(StackCard))]
[ManagedService]
[Transient]
public class StackCardViewModel : StackViewModelBase public class StackCardViewModel : StackViewModelBase
{ {
/// <inheritdoc /> /// <inheritdoc />

2
StabilityMatrix.Avalonia/ViewModels/Inference/StackExpanderViewModel.cs

@ -13,6 +13,8 @@ using StabilityMatrix.Core.Extensions;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(StackExpander))] [View(typeof(StackExpander))]
[ManagedService]
[Transient]
public partial class StackExpanderViewModel : StackViewModelBase public partial class StackExpanderViewModel : StackViewModelBase
{ {
public const string ModuleKey = "StackExpander"; public const string ModuleKey = "StackExpander";

2
StabilityMatrix.Avalonia/ViewModels/Inference/UpscalerCardViewModel.cs

@ -20,6 +20,8 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.Inference; namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(UpscalerCard))] [View(typeof(UpscalerCard))]
[ManagedService]
[Transient]
public partial class UpscalerCardViewModel : LoadableViewModelBase public partial class UpscalerCardViewModel : LoadableViewModelBase
{ {
public const string ModuleKey = "Upscaler"; public const string ModuleKey = "Upscaler";

3
StabilityMatrix.Avalonia/ViewModels/InferenceViewModel.cs

@ -9,7 +9,6 @@ using System.Threading.Tasks;
using AsyncAwaitBestPractices; using AsyncAwaitBestPractices;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Notifications; using Avalonia.Controls.Notifications;
using Avalonia.Controls.Shapes;
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
using Avalonia.Threading; using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
@ -23,7 +22,6 @@ using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.Dialogs; using StabilityMatrix.Avalonia.ViewModels.Dialogs;
using StabilityMatrix.Avalonia.ViewModels.Inference; using StabilityMatrix.Avalonia.ViewModels.Inference;
using StabilityMatrix.Avalonia.Views; using StabilityMatrix.Avalonia.Views;
using StabilityMatrix.Core.Api;
using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Database; using StabilityMatrix.Core.Database;
using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Extensions;
@ -43,6 +41,7 @@ namespace StabilityMatrix.Avalonia.ViewModels;
[Preload] [Preload]
[View(typeof(InferencePage))] [View(typeof(InferencePage))]
[Singleton]
public partial class InferenceViewModel : PageViewModelBase public partial class InferenceViewModel : PageViewModelBase
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

1
StabilityMatrix.Avalonia/ViewModels/LaunchPageViewModel.cs

@ -40,6 +40,7 @@ using SymbolIconSource = FluentIcons.FluentAvalonia.SymbolIconSource;
namespace StabilityMatrix.Avalonia.ViewModels; namespace StabilityMatrix.Avalonia.ViewModels;
[View(typeof(LaunchPageView))] [View(typeof(LaunchPageView))]
[Singleton]
public partial class LaunchPageViewModel : PageViewModelBase, IDisposable, IAsyncDisposable public partial class LaunchPageViewModel : PageViewModelBase, IDisposable, IAsyncDisposable
{ {
private readonly ILogger<LaunchPageViewModel> logger; private readonly ILogger<LaunchPageViewModel> logger;

131
StabilityMatrix.Avalonia/ViewModels/NewCheckpointsPageViewModel.cs

@ -2,14 +2,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsyncAwaitBestPractices; using AsyncAwaitBestPractices;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Notifications; using Avalonia.Controls.Notifications;
using AvaloniaEdit.Utils;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -35,6 +33,7 @@ using SymbolIconSource = FluentIcons.FluentAvalonia.SymbolIconSource;
namespace StabilityMatrix.Avalonia.ViewModels; namespace StabilityMatrix.Avalonia.ViewModels;
[View(typeof(NewCheckpointsPage))] [View(typeof(NewCheckpointsPage))]
[Singleton]
public partial class NewCheckpointsPageViewModel : PageViewModelBase public partial class NewCheckpointsPageViewModel : PageViewModelBase
{ {
private readonly ILogger<NewCheckpointsPageViewModel> logger; private readonly ILogger<NewCheckpointsPageViewModel> logger;
@ -44,12 +43,17 @@ public partial class NewCheckpointsPageViewModel : PageViewModelBase
private readonly ServiceManager<ViewModelBase> dialogFactory; private readonly ServiceManager<ViewModelBase> dialogFactory;
private readonly INotificationService notificationService; private readonly INotificationService notificationService;
public override string Title => "Checkpoint Manager"; public override string Title => "Checkpoint Manager";
public override IconSource IconSource => new SymbolIconSource public override IconSource IconSource =>
{Symbol = Symbol.Cellular5g, IsFilled = true}; new SymbolIconSource { Symbol = Symbol.Cellular5g, IsFilled = true };
public NewCheckpointsPageViewModel(ILogger<NewCheckpointsPageViewModel> logger, public NewCheckpointsPageViewModel(
ISettingsManager settingsManager, ILiteDbContext liteDbContext, ICivitApi civitApi, ILogger<NewCheckpointsPageViewModel> logger,
ServiceManager<ViewModelBase> dialogFactory, INotificationService notificationService) ISettingsManager settingsManager,
ILiteDbContext liteDbContext,
ICivitApi civitApi,
ServiceManager<ViewModelBase> dialogFactory,
INotificationService notificationService
)
{ {
this.logger = logger; this.logger = logger;
this.settingsManager = settingsManager; this.settingsManager = settingsManager;
@ -63,23 +67,27 @@ public partial class NewCheckpointsPageViewModel : PageViewModelBase
[NotifyPropertyChangedFor(nameof(ConnectedCheckpoints))] [NotifyPropertyChangedFor(nameof(ConnectedCheckpoints))]
[NotifyPropertyChangedFor(nameof(NonConnectedCheckpoints))] [NotifyPropertyChangedFor(nameof(NonConnectedCheckpoints))]
private ObservableCollection<CheckpointFile> allCheckpoints = new(); private ObservableCollection<CheckpointFile> allCheckpoints = new();
[ObservableProperty] [ObservableProperty]
private ObservableCollection<CivitModel> civitModels = new(); private ObservableCollection<CivitModel> civitModels = new();
public ObservableCollection<CheckpointFile> ConnectedCheckpoints => new( public ObservableCollection<CheckpointFile> ConnectedCheckpoints =>
AllCheckpoints.Where(x => x.IsConnectedModel) new(
.OrderBy(x => x.ConnectedModel!.ModelName) AllCheckpoints
.ThenBy(x => x.ModelType) .Where(x => x.IsConnectedModel)
.GroupBy(x => x.ConnectedModel!.ModelId) .OrderBy(x => x.ConnectedModel!.ModelName)
.Select(x => x.First())); .ThenBy(x => x.ModelType)
.GroupBy(x => x.ConnectedModel!.ModelId)
.Select(x => x.First())
);
public ObservableCollection<CheckpointFile> NonConnectedCheckpoints => new( public ObservableCollection<CheckpointFile> NonConnectedCheckpoints =>
AllCheckpoints.Where(x => !x.IsConnectedModel).OrderBy(x => x.ModelType)); new(AllCheckpoints.Where(x => !x.IsConnectedModel).OrderBy(x => x.ModelType));
public override async Task OnLoadedAsync() public override async Task OnLoadedAsync()
{ {
if (Design.IsDesignMode) return; if (Design.IsDesignMode)
return;
var files = CheckpointFile.GetAllCheckpointFiles(settingsManager.ModelsDirectory); var files = CheckpointFile.GetAllCheckpointFiles(settingsManager.ModelsDirectory);
AllCheckpoints = new ObservableCollection<CheckpointFile>(files); AllCheckpoints = new ObservableCollection<CheckpointFile>(files);
@ -89,17 +97,17 @@ public partial class NewCheckpointsPageViewModel : PageViewModelBase
{ {
CommaSeparatedModelIds = string.Join(',', connectedModelIds) CommaSeparatedModelIds = string.Join(',', connectedModelIds)
}; };
// See if query is cached // See if query is cached
var cachedQuery = await liteDbContext.CivitModelQueryCache var cachedQuery = await liteDbContext.CivitModelQueryCache
.IncludeAll() .IncludeAll()
.FindByIdAsync(ObjectHash.GetMd5Guid(modelRequest)); .FindByIdAsync(ObjectHash.GetMd5Guid(modelRequest));
// If cached, update model cards // If cached, update model cards
if (cachedQuery is not null) if (cachedQuery is not null)
{ {
CivitModels = new ObservableCollection<CivitModel>(cachedQuery.Items); CivitModels = new ObservableCollection<CivitModel>(cachedQuery.Items);
// Start remote query (background mode) // Start remote query (background mode)
// Skip when last query was less than 2 min ago // Skip when last query was less than 2 min ago
var timeSinceCache = DateTimeOffset.UtcNow - cachedQuery.InsertedAt; var timeSinceCache = DateTimeOffset.UtcNow - cachedQuery.InsertedAt;
@ -113,24 +121,34 @@ public partial class NewCheckpointsPageViewModel : PageViewModelBase
await CivitQuery(modelRequest); await CivitQuery(modelRequest);
} }
} }
public async Task ShowVersionDialog(int modelId) public async Task ShowVersionDialog(int modelId)
{ {
var model = CivitModels.FirstOrDefault(m => m.Id == modelId); var model = CivitModels.FirstOrDefault(m => m.Id == modelId);
if (model == null) if (model == null)
{ {
notificationService.Show(new Notification("Model has no versions available", notificationService.Show(
"This model has no versions available for download", NotificationType.Warning)); new Notification(
"Model has no versions available",
"This model has no versions available for download",
NotificationType.Warning
)
);
return; return;
} }
var versions = model.ModelVersions; var versions = model.ModelVersions;
if (versions is null || versions.Count == 0) if (versions is null || versions.Count == 0)
{ {
notificationService.Show(new Notification("Model has no versions available", notificationService.Show(
"This model has no versions available for download", NotificationType.Warning)); new Notification(
"Model has no versions available",
"This model has no versions available for download",
NotificationType.Warning
)
);
return; return;
} }
var dialog = new BetterContentDialog var dialog = new BetterContentDialog
{ {
Title = model.Name, Title = model.Name,
@ -139,19 +157,21 @@ public partial class NewCheckpointsPageViewModel : PageViewModelBase
IsFooterVisible = false, IsFooterVisible = false,
MaxDialogWidth = 750, MaxDialogWidth = 750,
}; };
var viewModel = dialogFactory.Get<SelectModelVersionViewModel>(); var viewModel = dialogFactory.Get<SelectModelVersionViewModel>();
viewModel.Dialog = dialog; viewModel.Dialog = dialog;
viewModel.Versions = versions.Select(version => viewModel.Versions = versions
new ModelVersionViewModel( .Select(
settingsManager.Settings.InstalledModelHashes ?? new HashSet<string>(), version)) version =>
new ModelVersionViewModel(
settingsManager.Settings.InstalledModelHashes ?? new HashSet<string>(),
version
)
)
.ToImmutableArray(); .ToImmutableArray();
viewModel.SelectedVersionViewModel = viewModel.Versions[0]; viewModel.SelectedVersionViewModel = viewModel.Versions[0];
dialog.Content = new SelectModelVersionDialog dialog.Content = new SelectModelVersionDialog { DataContext = viewModel };
{
DataContext = viewModel
};
var result = await dialog.ShowAsync(); var result = await dialog.ShowAsync();
@ -171,8 +191,10 @@ public partial class NewCheckpointsPageViewModel : PageViewModelBase
var modelResponse = await civitApi.GetModels(request); var modelResponse = await civitApi.GetModels(request);
var models = modelResponse.Items; var models = modelResponse.Items;
// Filter out unknown model types and archived/taken-down models // Filter out unknown model types and archived/taken-down models
models = models.Where(m => m.Type.ConvertTo<SharedFolderType>() > 0) models = models
.Where(m => m.Mode == null).ToList(); .Where(m => m.Type.ConvertTo<SharedFolderType>() > 0)
.Where(m => m.Mode == null)
.ToList();
// Database update calls will invoke `OnModelsUpdated` // Database update calls will invoke `OnModelsUpdated`
// Add to database // Add to database
@ -186,7 +208,8 @@ public partial class NewCheckpointsPageViewModel : PageViewModelBase
Request = request, Request = request,
Items = models, Items = models,
Metadata = modelResponse.Metadata Metadata = modelResponse.Metadata
}); }
);
if (cacheNew) if (cacheNew)
{ {
@ -195,26 +218,42 @@ public partial class NewCheckpointsPageViewModel : PageViewModelBase
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {
notificationService.Show(new Notification("Request to CivitAI timed out", notificationService.Show(
"Could not check for checkpoint updates. Please try again later.")); new Notification(
"Request to CivitAI timed out",
"Could not check for checkpoint updates. Please try again later."
)
);
logger.LogWarning($"CivitAI query timed out ({request})"); logger.LogWarning($"CivitAI query timed out ({request})");
} }
catch (HttpRequestException e) catch (HttpRequestException e)
{ {
notificationService.Show(new Notification("CivitAI can't be reached right now", notificationService.Show(
"Could not check for checkpoint updates. Please try again later.")); new Notification(
"CivitAI can't be reached right now",
"Could not check for checkpoint updates. Please try again later."
)
);
logger.LogWarning(e, $"CivitAI query HttpRequestException ({request})"); logger.LogWarning(e, $"CivitAI query HttpRequestException ({request})");
} }
catch (ApiException e) catch (ApiException e)
{ {
notificationService.Show(new Notification("CivitAI can't be reached right now", notificationService.Show(
"Could not check for checkpoint updates. Please try again later.")); new Notification(
"CivitAI can't be reached right now",
"Could not check for checkpoint updates. Please try again later."
)
);
logger.LogWarning(e, $"CivitAI query ApiException ({request})"); logger.LogWarning(e, $"CivitAI query ApiException ({request})");
} }
catch (Exception e) catch (Exception e)
{ {
notificationService.Show(new Notification("CivitAI can't be reached right now", notificationService.Show(
$"Unknown exception during CivitAI query: {e.GetType().Name}")); new Notification(
"CivitAI can't be reached right now",
$"Unknown exception during CivitAI query: {e.GetType().Name}"
)
);
logger.LogError(e, $"CivitAI query unknown exception ({request})"); logger.LogError(e, $"CivitAI query unknown exception ({request})");
} }
} }

3
StabilityMatrix.Avalonia/ViewModels/OutputsPage/OutputImageViewModel.cs

@ -1,5 +1,4 @@
using System; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Models.Database; using StabilityMatrix.Core.Models.Database;

4
StabilityMatrix.Avalonia/ViewModels/OutputsPageViewModel.cs

@ -5,11 +5,9 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsyncAwaitBestPractices; using AsyncAwaitBestPractices;
using AsyncImageLoader; using AsyncImageLoader;
using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Threading; using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
@ -24,7 +22,6 @@ using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.Dialogs; using StabilityMatrix.Avalonia.ViewModels.Dialogs;
using StabilityMatrix.Avalonia.ViewModels.Inference;
using StabilityMatrix.Avalonia.ViewModels.OutputsPage; using StabilityMatrix.Avalonia.ViewModels.OutputsPage;
using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper;
@ -40,6 +37,7 @@ using SymbolIconSource = FluentIcons.FluentAvalonia.SymbolIconSource;
namespace StabilityMatrix.Avalonia.ViewModels; namespace StabilityMatrix.Avalonia.ViewModels;
[View(typeof(Views.OutputsPage))] [View(typeof(Views.OutputsPage))]
[Singleton]
public partial class OutputsPageViewModel : PageViewModelBase public partial class OutputsPageViewModel : PageViewModelBase
{ {
private readonly ISettingsManager settingsManager; private readonly ISettingsManager settingsManager;

3
StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs

@ -14,6 +14,7 @@ using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.Dialogs; using StabilityMatrix.Avalonia.ViewModels.Dialogs;
using StabilityMatrix.Avalonia.Views.Dialogs; using StabilityMatrix.Avalonia.Views.Dialogs;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Helper.Factory; using StabilityMatrix.Core.Helper.Factory;
@ -26,6 +27,8 @@ using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels.PackageManager; namespace StabilityMatrix.Avalonia.ViewModels.PackageManager;
[ManagedService]
[Transient]
public partial class PackageCardViewModel : ProgressViewModel public partial class PackageCardViewModel : ProgressViewModel
{ {
private readonly ILogger<PackageCardViewModel> logger; private readonly ILogger<PackageCardViewModel> logger;

44
StabilityMatrix.Avalonia/ViewModels/PackageManagerViewModel.cs

@ -8,9 +8,11 @@ using AsyncAwaitBestPractices;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Notifications; using Avalonia.Controls.Notifications;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using Avalonia.Threading;
using DynamicData; using DynamicData;
using DynamicData.Binding; using DynamicData.Binding;
using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Controls;
using Microsoft.Extensions.Logging;
using StabilityMatrix.Avalonia.Controls; using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
@ -20,7 +22,6 @@ using StabilityMatrix.Avalonia.Views;
using StabilityMatrix.Avalonia.Views.Dialogs; using StabilityMatrix.Avalonia.Views.Dialogs;
using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models; using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.FileInterfaces; using StabilityMatrix.Core.Models.FileInterfaces;
using StabilityMatrix.Core.Models.PackageModification; using StabilityMatrix.Core.Models.PackageModification;
@ -36,12 +37,13 @@ namespace StabilityMatrix.Avalonia.ViewModels;
/// </summary> /// </summary>
[View(typeof(PackageManagerPage))] [View(typeof(PackageManagerPage))]
[Singleton]
public partial class PackageManagerViewModel : PageViewModelBase public partial class PackageManagerViewModel : PageViewModelBase
{ {
private readonly ISettingsManager settingsManager; private readonly ISettingsManager settingsManager;
private readonly IPackageFactory packageFactory;
private readonly ServiceManager<ViewModelBase> dialogFactory; private readonly ServiceManager<ViewModelBase> dialogFactory;
private readonly INotificationService notificationService; private readonly INotificationService notificationService;
private readonly ILogger<PackageManagerViewModel> logger;
public override string Title => "Packages"; public override string Title => "Packages";
public override IconSource IconSource => public override IconSource IconSource =>
@ -63,17 +65,19 @@ public partial class PackageManagerViewModel : PageViewModelBase
public IObservableCollection<PackageCardViewModel> PackageCards { get; } = public IObservableCollection<PackageCardViewModel> PackageCards { get; } =
new ObservableCollectionExtended<PackageCardViewModel>(); new ObservableCollectionExtended<PackageCardViewModel>();
private DispatcherTimer timer;
public PackageManagerViewModel( public PackageManagerViewModel(
ISettingsManager settingsManager, ISettingsManager settingsManager,
IPackageFactory packageFactory,
ServiceManager<ViewModelBase> dialogFactory, ServiceManager<ViewModelBase> dialogFactory,
INotificationService notificationService INotificationService notificationService,
ILogger<PackageManagerViewModel> logger
) )
{ {
this.settingsManager = settingsManager; this.settingsManager = settingsManager;
this.packageFactory = packageFactory;
this.dialogFactory = dialogFactory; this.dialogFactory = dialogFactory;
this.notificationService = notificationService; this.notificationService = notificationService;
this.logger = logger;
EventManager.Instance.InstalledPackagesChanged += OnInstalledPackagesChanged; EventManager.Instance.InstalledPackagesChanged += OnInstalledPackagesChanged;
@ -94,6 +98,9 @@ public partial class PackageManagerViewModel : PageViewModelBase
) )
.Bind(PackageCards) .Bind(PackageCards)
.Subscribe(); .Subscribe();
timer = new DispatcherTimer { Interval = TimeSpan.FromMinutes(15), IsEnabled = true };
timer.Tick += async (_, _) => await CheckPackagesForUpdates();
} }
public void SetPackages(IEnumerable<InstalledPackage> packages) public void SetPackages(IEnumerable<InstalledPackage> packages)
@ -118,6 +125,14 @@ public partial class PackageManagerViewModel : PageViewModelBase
var currentUnknown = await Task.Run(IndexUnknownPackages); var currentUnknown = await Task.Run(IndexUnknownPackages);
unknownInstalledPackages.Edit(s => s.Load(currentUnknown)); unknownInstalledPackages.Edit(s => s.Load(currentUnknown));
timer.Start();
}
public override void OnUnloaded()
{
timer.Stop();
base.OnUnloaded();
} }
public async Task ShowInstallDialog(BasePackage? selectedPackage = null) public async Task ShowInstallDialog(BasePackage? selectedPackage = null)
@ -159,6 +174,25 @@ public partial class PackageManagerViewModel : PageViewModelBase
} }
} }
private async Task CheckPackagesForUpdates()
{
foreach (var package in PackageCards)
{
try
{
await package.OnLoadedAsync();
}
catch (Exception e)
{
logger.LogError(
e,
"Failed to check for updates for {Package}",
package?.Package?.PackageName
);
}
}
}
private IEnumerable<UnknownInstalledPackage> IndexUnknownPackages() private IEnumerable<UnknownInstalledPackage> IndexUnknownPackages()
{ {
var packageDir = new DirectoryPath(settingsManager.LibraryDir).JoinDir("Packages"); var packageDir = new DirectoryPath(settingsManager.LibraryDir).JoinDir("Packages");

2
StabilityMatrix.Avalonia/ViewModels/Progress/ProgressManagerViewModel.cs

@ -22,6 +22,8 @@ using SymbolIconSource = FluentIcons.FluentAvalonia.SymbolIconSource;
namespace StabilityMatrix.Avalonia.ViewModels.Progress; namespace StabilityMatrix.Avalonia.ViewModels.Progress;
[View(typeof(ProgressManagerPage))] [View(typeof(ProgressManagerPage))]
[ManagedService]
[Singleton]
public partial class ProgressManagerViewModel : PageViewModelBase public partial class ProgressManagerViewModel : PageViewModelBase
{ {
private readonly INotificationService notificationService; private readonly INotificationService notificationService;

60
StabilityMatrix.Avalonia/ViewModels/RefreshBadgeViewModel.cs

@ -16,10 +16,12 @@ namespace StabilityMatrix.Avalonia.ViewModels;
[View(typeof(RefreshBadge))] [View(typeof(RefreshBadge))]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[ManagedService]
[Transient]
public partial class RefreshBadgeViewModel : ViewModelBase public partial class RefreshBadgeViewModel : ViewModelBase
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public string WorkingToolTipText { get; set; } = "Loading..."; public string WorkingToolTipText { get; set; } = "Loading...";
public string SuccessToolTipText { get; set; } = "Success"; public string SuccessToolTipText { get; set; } = "Success";
public string InactiveToolTipText { get; set; } = ""; public string InactiveToolTipText { get; set; } = "";
@ -32,7 +34,7 @@ public partial class RefreshBadgeViewModel : ViewModelBase
public IBrush SuccessColorBrush { get; set; } = ThemeColors.ThemeGreen; public IBrush SuccessColorBrush { get; set; } = ThemeColors.ThemeGreen;
public IBrush InactiveColorBrush { get; set; } = ThemeColors.ThemeYellow; public IBrush InactiveColorBrush { get; set; } = ThemeColors.ThemeYellow;
public IBrush FailColorBrush { get; set; } = ThemeColors.ThemeYellow; public IBrush FailColorBrush { get; set; } = ThemeColors.ThemeYellow;
public Func<Task<bool>>? RefreshFunc { get; set; } public Func<Task<bool>>? RefreshFunc { get; set; }
[ObservableProperty] [ObservableProperty]
@ -41,7 +43,7 @@ public partial class RefreshBadgeViewModel : ViewModelBase
[NotifyPropertyChangedFor(nameof(CurrentToolTip))] [NotifyPropertyChangedFor(nameof(CurrentToolTip))]
[NotifyPropertyChangedFor(nameof(Icon))] [NotifyPropertyChangedFor(nameof(Icon))]
private ProgressState state; private ProgressState state;
public bool IsWorking => State == ProgressState.Working; public bool IsWorking => State == ProgressState.Working;
/*public ControlAppearance Appearance => State switch /*public ControlAppearance Appearance => State switch
@ -51,36 +53,40 @@ public partial class RefreshBadgeViewModel : ViewModelBase
ProgressState.Failed => ControlAppearance.Danger, ProgressState.Failed => ControlAppearance.Danger,
_ => ControlAppearance.Secondary _ => ControlAppearance.Secondary
};*/ };*/
public IBrush ColorBrush => State switch
{
ProgressState.Success => SuccessColorBrush,
ProgressState.Inactive => InactiveColorBrush,
ProgressState.Failed => FailColorBrush,
_ => Brushes.Gray
};
public string CurrentToolTip => State switch public IBrush ColorBrush =>
{ State switch
ProgressState.Working => WorkingToolTipText, {
ProgressState.Success => SuccessToolTipText, ProgressState.Success => SuccessColorBrush,
ProgressState.Inactive => InactiveToolTipText, ProgressState.Inactive => InactiveColorBrush,
ProgressState.Failed => FailToolTipText, ProgressState.Failed => FailColorBrush,
_ => "" _ => Brushes.Gray
}; };
public Symbol Icon => State switch public string CurrentToolTip =>
{ State switch
ProgressState.Success => SuccessIcon, {
ProgressState.Failed => FailIcon, ProgressState.Working => WorkingToolTipText,
_ => InactiveIcon ProgressState.Success => SuccessToolTipText,
}; ProgressState.Inactive => InactiveToolTipText,
ProgressState.Failed => FailToolTipText,
_ => ""
};
public Symbol Icon =>
State switch
{
ProgressState.Success => SuccessIcon,
ProgressState.Failed => FailIcon,
_ => InactiveIcon
};
[RelayCommand] [RelayCommand]
private async Task Refresh() private async Task Refresh()
{ {
Logger.Info("Running refresh command..."); Logger.Info("Running refresh command...");
if (RefreshFunc == null) return; if (RefreshFunc == null)
return;
State = ProgressState.Working; State = ProgressState.Working;
try try

9
StabilityMatrix.Avalonia/ViewModels/Settings/InferenceSettingsViewModel.cs

@ -1,12 +1,9 @@
using CommunityToolkit.Mvvm.ComponentModel; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.Views.Settings; using StabilityMatrix.Avalonia.Views.Settings;
using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.ViewModels.Settings; namespace StabilityMatrix.Avalonia.ViewModels.Settings;
[View(typeof(InferenceSettingsPage))] [View(typeof(InferenceSettingsPage))]
public partial class InferenceSettingsViewModel : ViewModelBase [Singleton]
{ public partial class InferenceSettingsViewModel : ViewModelBase { }
}

8
StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs

@ -13,7 +13,6 @@ using System.Reflection;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsyncAwaitBestPractices;
using Avalonia; using Avalonia;
using Avalonia.Controls.Notifications; using Avalonia.Controls.Notifications;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
@ -53,6 +52,7 @@ using SymbolIconSource = FluentIcons.FluentAvalonia.SymbolIconSource;
namespace StabilityMatrix.Avalonia.ViewModels; namespace StabilityMatrix.Avalonia.ViewModels;
[View(typeof(SettingsPage))] [View(typeof(SettingsPage))]
[Singleton]
public partial class SettingsViewModel : PageViewModelBase public partial class SettingsViewModel : PageViewModelBase
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
@ -229,7 +229,7 @@ public partial class SettingsViewModel : PageViewModelBase
.Subscribe(formatProperty => .Subscribe(formatProperty =>
{ {
var provider = FileNameFormatProvider.GetSample(); var provider = FileNameFormatProvider.GetSample();
var template = formatProperty.Value; var template = formatProperty.Value ?? string.Empty;
if ( if (
!string.IsNullOrEmpty(template) !string.IsNullOrEmpty(template)
@ -282,11 +282,11 @@ public partial class SettingsViewModel : PageViewModelBase
} }
public static ValidationResult ValidateOutputImageFileNameFormat( public static ValidationResult ValidateOutputImageFileNameFormat(
string format, string? format,
ValidationContext context ValidationContext context
) )
{ {
return FileNameFormatProvider.GetSample().Validate(format); return FileNameFormatProvider.GetSample().Validate(format ?? string.Empty);
} }
partial void OnSelectedThemeChanged(string? value) partial void OnSelectedThemeChanged(string? value)

2
StabilityMatrix.Avalonia/Views/CheckpointBrowserPage.axaml.cs

@ -1,8 +1,10 @@
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using StabilityMatrix.Avalonia.Controls; using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.Views; namespace StabilityMatrix.Avalonia.Views;
[Singleton]
public partial class CheckpointBrowserPage : UserControlBase public partial class CheckpointBrowserPage : UserControlBase
{ {
public CheckpointBrowserPage() public CheckpointBrowserPage()

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save