Browse Source

moved most everything out of the old project

pull/55/head
JT 1 year ago
parent
commit
99a7067482
  1. 4
      StabilityMatrix.Avalonia/Controls/UserControlBase.cs
  2. 5
      StabilityMatrix.Avalonia/DesignData/DesignData.cs
  3. 1
      StabilityMatrix.Avalonia/DesignData/MockNotificationService.cs
  4. 1
      StabilityMatrix.Avalonia/Services/INotificationService.cs
  5. 6
      StabilityMatrix.Avalonia/Services/NotificationService.cs
  6. 73
      StabilityMatrix.Avalonia/ViewModels/CheckpointFile.cs
  7. 7
      StabilityMatrix.Avalonia/ViewModels/CheckpointFolder.cs
  8. 4
      StabilityMatrix.Avalonia/ViewModels/LaunchPageViewModel.cs
  9. 1
      StabilityMatrix.Avalonia/ViewModels/MainWindowViewModel.cs
  10. 2
      StabilityMatrix.Avalonia/ViewModels/PackageManagerViewModel.cs
  11. 6
      StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs
  12. 26
      StabilityMatrix.Avalonia/Views/LaunchPageView.axaml
  13. 2
      StabilityMatrix.Avalonia/Views/SettingsPage.axaml
  14. 6
      StabilityMatrix.Core/Api/A3WebApiManager.cs
  15. 6
      StabilityMatrix.Core/Api/IA3WebApi.cs
  16. 2
      StabilityMatrix.Core/Api/IA3WebApiManager.cs
  17. 5
      StabilityMatrix.Core/Api/ICivitApi.cs
  18. 6
      StabilityMatrix.Core/Database/CivitModelQueryCacheEntry.cs
  19. 7
      StabilityMatrix.Core/Database/ILiteDbContext.cs
  20. 9
      StabilityMatrix.Core/Database/LiteDbContext.cs
  21. 24
      StabilityMatrix.Core/Helper/ArchiveHelper.cs
  22. 2
      StabilityMatrix.Core/Helper/ISharedFolders.cs
  23. 10
      StabilityMatrix.Core/Helper/ModelFinder.cs
  24. 24
      StabilityMatrix.Core/Helper/PrerequisiteHelper.cs
  25. 7
      StabilityMatrix.Core/Helper/SharedFolders.cs
  26. 7
      StabilityMatrix.Core/Models/ConnectedModelInfo.cs
  27. 35
      StabilityMatrix.Core/Models/GlobalUserSecrets.cs
  28. 7
      StabilityMatrix.Core/Services/SettingsManager.cs
  29. 6
      StabilityMatrix.Core/StabilityMatrix.Core.csproj
  30. 6
      StabilityMatrix.Core/Updater/IUpdateHelper.cs
  31. 5
      StabilityMatrix.Core/Updater/SignatureChecker.cs
  32. 19
      StabilityMatrix.Core/Updater/UpdateHelper.cs
  33. 1
      StabilityMatrix.Tests/Helper/EventManagerTests.cs
  34. 2
      StabilityMatrix.Tests/Models/SharedFoldersTests.cs
  35. 3
      StabilityMatrix.Tests/ReparsePoints/JunctionTests.cs
  36. 7
      StabilityMatrix/App.xaml.cs
  37. 1
      StabilityMatrix/CheckpointManagerPage.xaml
  38. 4
      StabilityMatrix/DesignData/MockCheckpointFolder.cs
  39. 4
      StabilityMatrix/StabilityMatrix.csproj
  40. 1
      StabilityMatrix/TextToImagePage.xaml
  41. 2
      StabilityMatrix/ViewModels/CheckpointBrowserCardViewModel.cs
  42. 5
      StabilityMatrix/ViewModels/CheckpointBrowserViewModel.cs
  43. 2
      StabilityMatrix/ViewModels/CheckpointManagerViewModel.cs
  44. 2
      StabilityMatrix/ViewModels/DataDirectoryMigrationViewModel.cs
  45. 2
      StabilityMatrix/ViewModels/InstallerViewModel.cs
  46. 2
      StabilityMatrix/ViewModels/LaunchViewModel.cs
  47. 5
      StabilityMatrix/ViewModels/MainWindowViewModel.cs
  48. 1
      StabilityMatrix/ViewModels/OneClickInstallViewModel.cs
  49. 4
      StabilityMatrix/ViewModels/SettingsViewModel.cs
  50. 3
      StabilityMatrix/ViewModels/TextToImageViewModel.cs
  51. 2
      StabilityMatrix/ViewModels/UpdateWindowViewModel.cs

4
StabilityMatrix.Avalonia/Controls/UserControlBase.cs

@ -1,8 +1,6 @@
using System;
using AsyncAwaitBestPractices;
using AsyncAwaitBestPractices;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using StabilityMatrix.Avalonia.ViewModels;
namespace StabilityMatrix.Avalonia.Controls;

5
StabilityMatrix.Avalonia/DesignData/DesignData.cs

@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using AvaloniaEdit.Utils;
using Microsoft.Extensions.Logging;
using NLog;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels;
using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models;

1
StabilityMatrix.Avalonia/DesignData/MockNotificationService.cs

@ -1,7 +1,6 @@
using Avalonia;
using Avalonia.Controls.Notifications;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels;
namespace StabilityMatrix.Avalonia.DesignData;

1
StabilityMatrix.Avalonia/Services/INotificationService.cs

@ -1,6 +1,5 @@
using Avalonia;
using Avalonia.Controls.Notifications;
using StabilityMatrix.Avalonia.ViewModels;
namespace StabilityMatrix.Avalonia.Services;

6
StabilityMatrix.Avalonia/Services/NotificationService.cs

@ -1,10 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Avalonia;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using FluentAvalonia.UI.Controls;
using StabilityMatrix.Avalonia.ViewModels;
namespace StabilityMatrix.Avalonia.Services;

73
StabilityMatrix/Models/CheckpointFile.cs → StabilityMatrix.Avalonia/ViewModels/CheckpointFile.cs

@ -5,24 +5,24 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using AsyncAwaitBestPractices;
using Avalonia.Media.Imaging;
using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using NLog;
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.FileInterfaces;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Processes;
using StabilityMatrix.Helper;
namespace StabilityMatrix.Models;
namespace StabilityMatrix.Avalonia.ViewModels;
public partial class CheckpointFile : ObservableObject
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IDialogFactory dialogFactory;
// Event for when this file is deleted
public event EventHandler<CheckpointFile>? Deleted;
@ -41,7 +41,7 @@ public partial class CheckpointFile : ObservableObject
private string title = string.Empty;
public string? PreviewImagePath { get; set; }
public BitmapImage? PreviewImage { get; set; }
public Bitmap? PreviewImage { get; set; }
public bool IsPreviewImageLoaded => PreviewImage != null;
[ObservableProperty]
@ -50,18 +50,13 @@ public partial class CheckpointFile : ObservableObject
[ObservableProperty] private bool isLoading;
public string FileName => Path.GetFileName(FilePath);
public string FileName => Path.GetFileName((string?) FilePath);
public ObservableCollection<string> Badges { get; set; } = new();
private static readonly string[] SupportedCheckpointExtensions = { ".safetensors", ".pt", ".ckpt", ".pth", "bin" };
private static readonly string[] SupportedImageExtensions = { ".png", ".jpg", ".jpeg" };
private static readonly string[] SupportedMetadataExtensions = { ".json" };
public CheckpointFile(IDialogFactory dialogFactory)
{
this.dialogFactory = dialogFactory;
}
partial void OnConnectedModelChanged(ConnectedModelInfo? value)
{
@ -111,25 +106,27 @@ public partial class CheckpointFile : ObservableObject
[RelayCommand]
private async Task RenameAsync()
{
var responses = await dialogFactory.ShowTextEntryDialog("Rename Model", new []
{
("File Name", FileName)
});
var name = responses?.FirstOrDefault();
if (name == null) return;
// TODO: Fix with new dialogs
// Rename file in OS
try
{
var newFilePath = Path.Combine(Path.GetDirectoryName(FilePath) ?? "", name);
File.Move(FilePath, newFilePath);
FilePath = newFilePath;
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
// var responses = await dialogFactory.ShowTextEntryDialog("Rename Model", new []
// {
// ("File Name", FileName)
// });
// var name = responses?.FirstOrDefault();
// if (name == null) return;
//
// // Rename file in OS
// try
// {
// var newFilePath = Path.Combine(Path.GetDirectoryName((string?) FilePath) ?? "", name);
// File.Move(FilePath, newFilePath);
// FilePath = newFilePath;
// }
// catch (Exception e)
// {
// Console.WriteLine(e);
// throw;
// }
}
[RelayCommand]
@ -143,14 +140,10 @@ public partial class CheckpointFile : ObservableObject
{
if (PreviewImagePath == null) return;
var bytes = await File.ReadAllBytesAsync(PreviewImagePath);
await Application.Current.Dispatcher.InvokeAsync(() =>
await Dispatcher.UIThread.InvokeAsync(() =>
{
var bitmap = new BitmapImage();
using var ms = new MemoryStream(bytes);
bitmap.BeginInit();
bitmap.StreamSource = ms;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
var bitmap = new Bitmap(ms);
PreviewImage = bitmap;
});
}
@ -162,7 +155,7 @@ public partial class CheckpointFile : ObservableObject
/// - {filename}.preview.{image-extensions} (preview image)
/// - {filename}.cm-info.json (connected model info)
/// </summary>
public static IEnumerable<CheckpointFile> FromDirectoryIndex(IDialogFactory dialogFactory, string directory, SearchOption searchOption = SearchOption.TopDirectoryOnly)
public static IEnumerable<CheckpointFile> FromDirectoryIndex(string directory, SearchOption searchOption = SearchOption.TopDirectoryOnly)
{
// Get all files with supported extensions
var allExtensions = SupportedCheckpointExtensions
@ -174,7 +167,7 @@ public partial class CheckpointFile : ObservableObject
foreach (var file in files.Keys.Where(k => SupportedCheckpointExtensions.Contains(Path.GetExtension(k))))
{
var checkpointFile = new CheckpointFile(dialogFactory)
var checkpointFile = new CheckpointFile()
{
Title = Path.GetFileNameWithoutExtension(file),
FilePath = Path.Combine(directory, file),
@ -211,11 +204,11 @@ public partial class CheckpointFile : ObservableObject
/// <summary>
/// Index with progress reporting.
/// </summary>
public static IEnumerable<CheckpointFile> FromDirectoryIndex(IDialogFactory dialogFactory, string directory, IProgress<ProgressReport> progress,
public static IEnumerable<CheckpointFile> FromDirectoryIndex(string directory, IProgress<ProgressReport> progress,
SearchOption searchOption = SearchOption.TopDirectoryOnly)
{
var current = 0ul;
foreach (var checkpointFile in FromDirectoryIndex(dialogFactory, directory, searchOption))
foreach (var checkpointFile in FromDirectoryIndex(directory, searchOption))
{
current++;
progress.Report(new ProgressReport(current, "Indexing", checkpointFile.FileName));

7
StabilityMatrix/Models/CheckpointFolder.cs → StabilityMatrix.Avalonia/ViewModels/CheckpointFolder.cs

@ -6,7 +6,6 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using StabilityMatrix.Core.Extensions;
@ -15,10 +14,8 @@ using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.FileInterfaces;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Helper;
using StabilityMatrix.ViewModels;
namespace StabilityMatrix.Models;
namespace StabilityMatrix.Avalonia.ViewModels;
public partial class CheckpointFolder : ObservableObject
{
@ -38,7 +35,7 @@ public partial class CheckpointFolder : ObservableObject
/// Custom title for UI.
/// </summary>
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(FolderType))]
[NotifyPropertyChangedFor(nameof(Models.CheckpointFolder.FolderType))]
[NotifyPropertyChangedFor(nameof(TitleWithFilesCount))]
private string title = string.Empty;

4
StabilityMatrix.Avalonia/ViewModels/LaunchPageViewModel.cs

@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Threading;
using AvaloniaEdit.Document;
using CommunityToolkit.Mvvm.ComponentModel;

1
StabilityMatrix.Avalonia/ViewModels/MainWindowViewModel.cs

@ -3,7 +3,6 @@ using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Avalonia.Views;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Models.Settings;
namespace StabilityMatrix.Avalonia.ViewModels;

2
StabilityMatrix.Avalonia/ViewModels/PackageManagerViewModel.cs

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
@ -10,7 +9,6 @@ using StabilityMatrix.Avalonia.Views;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.Packages;
using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Avalonia.ViewModels;

6
StabilityMatrix.Avalonia/ViewModels/SettingsViewModel.cs

@ -1,6 +1,4 @@
using System;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using Avalonia.Controls.Notifications;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@ -32,6 +30,8 @@ public partial class SettingsViewModel : PageViewModelBase
public SettingsViewModel(INotificationService notificationService)
{
this.notificationService = notificationService;
SelectedTheme = AvailableThemes[1];
}
[RelayCommand]

26
StabilityMatrix.Avalonia/Views/LaunchPageView.axaml

@ -104,11 +104,7 @@
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<!--<SelectableTextBlock
Margin="24,16"
Text="Console output here."
Grid.Row="1">
</SelectableTextBlock>-->
<avaloniaEdit:TextEditor
x:Name="Console"
Document="{Binding ConsoleDocument}"
@ -120,18 +116,16 @@
LineNumbersForeground="DarkSlateGray"
VerticalScrollBarVisibility="Auto"
FontFamily="Cascadia Code,Consolas,Menlo,Monospace" />
<!--<terminal:Terminal Grid.Row="1"
Margin="24,8,26,10"
Background="{DynamicResource ControlFillColorDisabledBrush}"
IsReadOnly="True"
AutoScroll="True"
FontFamily="Consolas"
ItemHeight="22"
Foreground="White"
BorderThickness="0"
VerticalScrollBarVisibility="Auto"
ItemsSource="{Binding ConsoleHistory, Mode=OneWay}"/>-->
<Expander IsExpanded="True" Grid.Row="1" Header="Header Stuff" Margin="16">
<Expander.Styles>
<Style Selector="Expander /template/ ToggleButton#PART_toggle">
<Setter Property="IsVisible" Value="False"/>
</Style>
</Expander.Styles>
<TextBlock Text="Hello World"></TextBlock>
</Expander>
<!--Command="{Binding LaunchWebUiCommand}"-->
<!--Visibility="{Binding ShowWebUiButton, Converter={StaticResource BoolToVisConverter}}"-->
<Button

2
StabilityMatrix.Avalonia/Views/SettingsPage.axaml

@ -22,7 +22,7 @@
ItemsSource="{Binding AvailableThemes}"
SelectedItem="{Binding SelectedTheme}"
Margin="8"
Width="500" />
MinWidth="100"/>
</ui:SettingsExpander.Footer>
</ui:SettingsExpander>

6
StabilityMatrix/Api/A3WebApiManager.cs → StabilityMatrix.Core/Api/A3WebApiManager.cs

@ -1,9 +1,7 @@
using System;
using System.Net.Http;
using Refit;
using Refit;
using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Api;
namespace StabilityMatrix.Core.Api;
public class A3WebApiManager : IA3WebApiManager
{

6
StabilityMatrix/Api/IA3WebApi.cs → StabilityMatrix.Core/Api/IA3WebApi.cs

@ -1,9 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
using Refit;
using Refit;
using StabilityMatrix.Core.Models.Api;
namespace StabilityMatrix.Api;
namespace StabilityMatrix.Core.Api;
[Headers("User-Agent: StabilityMatrix")]
public interface IA3WebApi

2
StabilityMatrix/Api/IA3WebApiManager.cs → StabilityMatrix.Core/Api/IA3WebApiManager.cs

@ -1,6 +1,6 @@
using Refit;
namespace StabilityMatrix.Api;
namespace StabilityMatrix.Core.Api;
public interface IA3WebApiManager
{

5
StabilityMatrix/Api/ICivitApi.cs → StabilityMatrix.Core/Api/ICivitApi.cs

@ -1,8 +1,7 @@
using System.Threading.Tasks;
using Refit;
using Refit;
using StabilityMatrix.Core.Models.Api;
namespace StabilityMatrix.Api;
namespace StabilityMatrix.Core.Api;
public interface ICivitApi
{

6
StabilityMatrix/Database/CivitModelQueryCacheEntry.cs → StabilityMatrix.Core/Database/CivitModelQueryCacheEntry.cs

@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using LiteDB;
using LiteDB;
using StabilityMatrix.Core.Models.Api;
namespace StabilityMatrix.Database;
namespace StabilityMatrix.Core.Database;
/// <summary>
/// Cache entry for the result of a Civit model query response

7
StabilityMatrix/Database/ILiteDbContext.cs → StabilityMatrix.Core/Database/ILiteDbContext.cs

@ -1,10 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System;
using LiteDB.Async;
using LiteDB.Async;
using StabilityMatrix.Core.Models.Api;
namespace StabilityMatrix.Database;
namespace StabilityMatrix.Core.Database;
public interface ILiteDbContext : IDisposable
{

9
StabilityMatrix/Database/LiteDbContext.cs → StabilityMatrix.Core/Database/LiteDbContext.cs

@ -1,16 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using LiteDB.Async;
using LiteDB.Async;
using Microsoft.Extensions.Options;
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Models.Api;
using StabilityMatrix.Core.Models.Configs;
using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Database;
namespace StabilityMatrix.Core.Database;
public class LiteDbContext : ILiteDbContext
{

24
StabilityMatrix/Helper/ArchiveHelper.cs → StabilityMatrix.Core/Helper/ArchiveHelper.cs

@ -1,18 +1,15 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using NLog;
using SharpCompress.Common;
using SharpCompress.Readers;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Processes;
using Timer = System.Timers.Timer;
namespace StabilityMatrix.Helper;
namespace StabilityMatrix.Core.Helper;
public record struct ArchiveInfo(ulong Size, ulong CompressedSize);
@ -23,7 +20,10 @@ public static class ArchiveHelper
// HomeDir is set by ISettingsManager.TryFindLibrary()
public static string HomeDir { get; set; } = string.Empty;
public static string SevenZipPath => Path.Combine(HomeDir, "Assets", "7za.exe");
public static string SevenZipPath => RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? Path.Combine(HomeDir, "Assets", "7za.exe")
: throw new NotImplementedException("need to implement 7z path for non-windows");
private static readonly Regex Regex7ZOutput = new(@"(?<=Size:\s*)\d+|(?<=Compressed:\s*)\d+");
private static readonly Regex Regex7ZProgressDigits = new(@"(?<=\s*)\d+(?=%)");
@ -125,15 +125,15 @@ public static class ArchiveHelper
// Create an DispatchTimer that monitors the progress of the extraction
var progressMonitor = progress switch {
null => null,
_ => new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(36) }
_ => new Timer(TimeSpan.FromMilliseconds(36))
};
if (progressMonitor != null)
{
progressMonitor.Tick += (sender, args) =>
progressMonitor.Elapsed += (_, _) =>
{
// Ignore 0 counts
if (count == 0) return;
Application.Current.Dispatcher.Invoke(() => progress!.Report(new ProgressReport(count, total, message: "Extracting")));
progress!.Report(new ProgressReport(count, total, message: "Extracting"));
};
}

2
StabilityMatrix/Models/ISharedFolders.cs → StabilityMatrix.Core/Helper/ISharedFolders.cs

@ -1,7 +1,7 @@
using StabilityMatrix.Core.Models.FileInterfaces;
using StabilityMatrix.Core.Models.Packages;
namespace StabilityMatrix.Models;
namespace StabilityMatrix.Core.Helper;
public interface ISharedFolders
{

10
StabilityMatrix/Helper/ModelFinder.cs → StabilityMatrix.Core/Helper/ModelFinder.cs

@ -1,12 +1,10 @@
using System.Linq;
using System.Threading.Tasks;
using NLog;
using NLog;
using Refit;
using StabilityMatrix.Api;
using StabilityMatrix.Core.Api;
using StabilityMatrix.Core.Database;
using StabilityMatrix.Core.Models.Api;
using StabilityMatrix.Database;
namespace StabilityMatrix.Helper;
namespace StabilityMatrix.Core.Helper;
// return Model, ModelVersion, ModelFile
public record struct ModelSearchResult(CivitModel Model, CivitModelVersion ModelVersion, CivitFile ModelFile);

24
StabilityMatrix.Core/Helper/PrerequisiteHelper.cs

@ -209,8 +209,7 @@ public class PrerequisiteHelper : IPrerequisiteHelper
}
// Unzip python
// TODO: Update when ArchiveHelper is implemented
// await ArchiveHelper.Extract7Z(PythonDownloadPath, PythonDir);
await ArchiveHelper.Extract7Z(PythonDownloadPath, PythonDir);
try
{
@ -218,8 +217,7 @@ public class PrerequisiteHelper : IPrerequisiteHelper
await ExtractAllEmbeddedResources("StabilityMatrix.Assets.venv", PythonDir);
// Add venv to python's library zip
// TODO: Update when ArchiveHelper is implemented
//await ArchiveHelper.AddToArchive7Z(PythonLibraryZipPath, VenvTempDir);
await ArchiveHelper.AddToArchive7Z(PythonLibraryZipPath, VenvTempDir);
}
finally
{
@ -348,16 +346,14 @@ public class PrerequisiteHelper : IPrerequisiteHelper
private async Task UnzipGit(IProgress<ProgressReport>? progress = null)
{
// TODO: Update when ArchiveHelper is implemented
// if (progress == null)
// {
// await ArchiveHelper.Extract7Z(PortableGitDownloadPath, PortableGitInstallDir);
// }
// else
// {
// await ArchiveHelper.Extract7Z(PortableGitDownloadPath, PortableGitInstallDir, progress);
// }
if (progress == null)
{
await ArchiveHelper.Extract7Z(PortableGitDownloadPath, PortableGitInstallDir);
}
else
{
await ArchiveHelper.Extract7Z(PortableGitDownloadPath, PortableGitInstallDir, progress);
}
logger.LogInformation("Extracted Git");

7
StabilityMatrix/Models/SharedFolders.cs → StabilityMatrix.Core/Helper/SharedFolders.cs

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using NLog;
using NLog;
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models;
@ -10,7 +7,7 @@ using StabilityMatrix.Core.Models.Packages;
using StabilityMatrix.Core.ReparsePoints;
using StabilityMatrix.Core.Services;
namespace StabilityMatrix.Models;
namespace StabilityMatrix.Core.Helper;
public class SharedFolders : ISharedFolders
{

7
StabilityMatrix/Models/ConnectedModelInfo.cs → StabilityMatrix.Core/Models/ConnectedModelInfo.cs

@ -1,11 +1,8 @@
using System;
using System.IO;
using System.Text.Json;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using StabilityMatrix.Core.Models.Api;
namespace StabilityMatrix.Models;
namespace StabilityMatrix.Core.Models;
public class ConnectedModelInfo
{

35
StabilityMatrix/Models/GlobalUserSecrets.cs → StabilityMatrix.Core/Models/GlobalUserSecrets.cs

@ -1,17 +1,12 @@
using System;
using System.Collections.Generic;
using System.DirectoryServices;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;
using System.Security.Principal;
using System.Text.Json;
using System.Text.Json.Serialization;
using StabilityMatrix.Core.Models;
using DeviceId;
using StabilityMatrix.Core.Models.FileInterfaces;
namespace StabilityMatrix.Models;
namespace StabilityMatrix.Core.Models;
internal record struct KeyInfo(byte[] Key, byte[] Salt, int Iterations);
@ -30,17 +25,29 @@ public class GlobalUserSecrets
public Dictionary<string, string> PatreonCookies { get; set; } = new();
private static SecurityIdentifier? GetComputerSid()
private static string? GetComputerSid()
{
var id = new DirectoryEntry($"WinNT://{Environment.MachineName},Computer")
.Children.Cast<DirectoryEntry>().First().InvokeGet("objectSID");
return id is not byte[] bytes ? null :
new SecurityIdentifier(bytes, 0).AccountDomainSid;
var deviceId = new DeviceIdBuilder()
.AddMachineName()
.AddOsVersion()
.OnWindows(windows => windows
.AddProcessorId()
.AddMotherboardSerialNumber()
.AddSystemDriveSerialNumber())
.OnLinux(linux => linux
.AddMotherboardSerialNumber()
.AddSystemDriveSerialNumber())
.OnMac(mac => mac
.AddSystemDriveSerialNumber()
.AddPlatformSerialNumber())
.ToString();
return deviceId;
}
private static SecureString GetComputerKeyPhrase()
{
var keySource = GetComputerSid()?.ToString();
var keySource = GetComputerSid();
// If no sid, use username as fallback
keySource ??= Environment.UserName;

7
StabilityMatrix.Core/Services/SettingsManager.cs

@ -193,11 +193,8 @@ public class SettingsManager : ISettingsManager
private void SetStaticLibraryPaths()
{
GlobalConfig.LibraryDir = LibraryDir;
// TODO: update this when ArchiveHelper is implemented
//ArchiveHelper.HomeDir = LibraryDir;
PyRunner.HomeDir = LibraryDir;
ArchiveHelper.HomeDir = LibraryDir;
PyRunner.HomeDir = LibraryDir;
}
/// <summary>

6
StabilityMatrix.Core/StabilityMatrix.Core.csproj

@ -9,12 +9,18 @@
<ItemGroup>
<PackageReference Include="AsyncAwaitBestPractices" Version="6.0.6" />
<PackageReference Include="Blake3" Version="0.5.1" />
<PackageReference Include="DeviceId" Version="6.3.0" />
<PackageReference Include="DeviceId.Linux" Version="6.3.0" />
<PackageReference Include="DeviceId.Mac" Version="6.2.0" />
<PackageReference Include="DeviceId.Windows" Version="6.2.0" />
<PackageReference Include="DeviceId.Windows.Wmi" Version="6.2.1" />
<PackageReference Include="LiteDB" Version="5.0.16" />
<PackageReference Include="LiteDB.Async" Version="0.1.6" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
<PackageReference Include="NLog" Version="5.2.2" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.2" />
<PackageReference Include="NSec.Cryptography" Version="22.4.0" />
<PackageReference Include="Octokit" Version="7.0.1" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageReference Include="pythonnet" Version="3.0.1" />

6
StabilityMatrix/Updater/IUpdateHelper.cs → StabilityMatrix.Core/Updater/IUpdateHelper.cs

@ -1,9 +1,7 @@
using System;
using System.Threading.Tasks;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Models.Update;
namespace StabilityMatrix.Updater;
namespace StabilityMatrix.Core.Updater;
public interface IUpdateHelper
{

5
StabilityMatrix/Updater/SignatureChecker.cs → StabilityMatrix.Core/Updater/SignatureChecker.cs

@ -1,8 +1,7 @@
using System;
using System.Text;
using System.Text;
using NSec.Cryptography;
namespace StabilityMatrix.Updater;
namespace StabilityMatrix.Core.Updater;
public class SignatureChecker
{

19
StabilityMatrix/Updater/UpdateHelper.cs → StabilityMatrix.Core/Updater/UpdateHelper.cs

@ -1,10 +1,5 @@
using System;
using System.IO;
using System.Net.Http;
using System.Reflection;
using System.Reflection;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Threading;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using StabilityMatrix.Core.Extensions;
@ -13,9 +8,8 @@ using StabilityMatrix.Core.Models.Configs;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Models.Update;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Helper;
namespace StabilityMatrix.Updater;
namespace StabilityMatrix.Core.Updater;
public class UpdateHelper : IUpdateHelper
{
@ -23,7 +17,7 @@ public class UpdateHelper : IUpdateHelper
private readonly IHttpClientFactory httpClientFactory;
private readonly IDownloadService downloadService;
private readonly DebugOptions debugOptions;
private readonly DispatcherTimer timer = new();
private readonly System.Timers.Timer timer = new(TimeSpan.FromMinutes(5));
private string UpdateManifestUrl => debugOptions.UpdateManifestUrl ??
"https://cdn.lykos.ai/update.json";
@ -41,14 +35,13 @@ public class UpdateHelper : IUpdateHelper
this.httpClientFactory = httpClientFactory;
this.downloadService = downloadService;
this.debugOptions = debugOptions.Value;
timer.Interval = TimeSpan.FromMinutes(5);
timer.Tick += async (_, _) => { await CheckForUpdate(); };
timer.Elapsed += async (_, _) => { await CheckForUpdate(); };
}
public async Task StartCheckingForUpdates()
{
timer.IsEnabled = true;
timer.Enabled = true;
timer.Start();
await CheckForUpdate();
}

1
StabilityMatrix.Tests/Helper/EventManagerTests.cs

@ -1,5 +1,4 @@
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Helper;
namespace StabilityMatrix.Tests.Helper;

2
StabilityMatrix.Tests/Models/SharedFoldersTests.cs

@ -1,6 +1,6 @@
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Models;
using StabilityMatrix.Models;
namespace StabilityMatrix.Tests.Models;

3
StabilityMatrix.Tests/ReparsePoints/JunctionTests.cs

@ -1,5 +1,4 @@
using Microsoft.VisualBasic;
using StabilityMatrix.Core.ReparsePoints;
using StabilityMatrix.Core.ReparsePoints;
namespace StabilityMatrix.Tests.ReparsePoints;

7
StabilityMatrix/App.xaml.cs

@ -26,7 +26,8 @@ using Polly.Extensions.Http;
using Polly.Timeout;
using Refit;
using Sentry;
using StabilityMatrix.Api;
using StabilityMatrix.Core.Api;
using StabilityMatrix.Core.Database;
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Helper.Cache;
using StabilityMatrix.Core.Helper.Factory;
@ -34,11 +35,9 @@ using StabilityMatrix.Core.Models.Configs;
using StabilityMatrix.Core.Models.Packages;
using StabilityMatrix.Core.Python;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Database;
using StabilityMatrix.Core.Updater;
using StabilityMatrix.Helper;
using StabilityMatrix.Models;
using StabilityMatrix.Services;
using StabilityMatrix.Updater;
using StabilityMatrix.ViewModels;
using Wpf.Ui.Contracts;
using Wpf.Ui.Services;

1
StabilityMatrix/CheckpointManagerPage.xaml

@ -16,7 +16,6 @@
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:ci="clr-namespace:StabilityMatrix.Interactions"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:StabilityMatrix.Models"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:viewModels="clr-namespace:StabilityMatrix.ViewModels"

4
StabilityMatrix/DesignData/MockCheckpointFolder.cs

@ -1,6 +1,4 @@
using StabilityMatrix.Models;
namespace StabilityMatrix.DesignData;
namespace StabilityMatrix.DesignData;
public class MockCheckpointFolder : CheckpointFolder
{

4
StabilityMatrix/StabilityMatrix.csproj

@ -110,5 +110,9 @@
<ItemGroup>
<ProjectReference Include="..\StabilityMatrix.Core\StabilityMatrix.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>
</Project>

1
StabilityMatrix/TextToImagePage.xaml

@ -14,7 +14,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StabilityMatrix"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:StabilityMatrix.Models"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:viewModels="clr-namespace:StabilityMatrix.ViewModels"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

2
StabilityMatrix/ViewModels/CheckpointBrowserCardViewModel.cs

@ -6,6 +6,7 @@ using System.Net.Http;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using AsyncAwaitBestPractices;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@ -20,7 +21,6 @@ using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Processes;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Helper;
using StabilityMatrix.Models;
using Wpf.Ui.Controls;
using Wpf.Ui.Controls.ContentDialogControl;

5
StabilityMatrix/ViewModels/CheckpointBrowserViewModel.cs

@ -11,16 +11,15 @@ using NLog;
using System.Diagnostics;
using System.Net.Http;
using System.Windows.Data;
using StabilityMatrix.Api;
using StabilityMatrix.Core.Api;
using StabilityMatrix.Core.Database;
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.Api;
using StabilityMatrix.Core.Models.Settings;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Database;
using StabilityMatrix.Helper;
using StabilityMatrix.Models;
using ApiException = Refit.ApiException;
namespace StabilityMatrix.ViewModels;

2
StabilityMatrix/ViewModels/CheckpointManagerViewModel.cs

@ -7,9 +7,9 @@ using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using NLog;
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Helper;
using StabilityMatrix.Models;
namespace StabilityMatrix.ViewModels;

2
StabilityMatrix/ViewModels/DataDirectoryMigrationViewModel.cs

@ -10,8 +10,6 @@ using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models.FileInterfaces;
using StabilityMatrix.Core.Python;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Helper;
using StabilityMatrix.Models;
namespace StabilityMatrix.ViewModels;

2
StabilityMatrix/ViewModels/InstallerViewModel.cs

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using AsyncAwaitBestPractices;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@ -19,7 +20,6 @@ using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Processes;
using StabilityMatrix.Core.Python;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Models;
using StabilityMatrix.Services;
using Wpf.Ui.Contracts;
using Wpf.Ui.Controls;

2
StabilityMatrix/ViewModels/LaunchViewModel.cs

@ -3,6 +3,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using AsyncAwaitBestPractices;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
@ -16,7 +17,6 @@ using StabilityMatrix.Core.Processes;
using StabilityMatrix.Core.Python;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Helper;
using StabilityMatrix.Models;
using Wpf.Ui.Contracts;
using Wpf.Ui.Controls.ContentDialogControl;
using EventManager = StabilityMatrix.Core.Helper.EventManager;

5
StabilityMatrix/ViewModels/MainWindowViewModel.cs

@ -4,20 +4,19 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Threading;
using System.Windows.Shell;
using System.Windows.Threading;
using AsyncAwaitBestPractices;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.Options;
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Models.Configs;
using StabilityMatrix.Core.Models.Update;
using StabilityMatrix.Core.Processes;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Core.Updater;
using StabilityMatrix.Helper;
using StabilityMatrix.Services;
using StabilityMatrix.Updater;
using Wpf.Ui.Appearance;
using Wpf.Ui.Controls.ContentDialogControl;
using Wpf.Ui.Controls.Window;

1
StabilityMatrix/ViewModels/OneClickInstallViewModel.cs

@ -11,7 +11,6 @@ using StabilityMatrix.Core.Models.Packages;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Python;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Models;
using EventManager = StabilityMatrix.Core.Helper.EventManager;
namespace StabilityMatrix.ViewModels;

4
StabilityMatrix/ViewModels/SettingsViewModel.cs

@ -19,14 +19,14 @@ using Microsoft.Extensions.Logging;
using Ookii.Dialogs.Wpf;
using Polly.Timeout;
using Refit;
using StabilityMatrix.Api;
using StabilityMatrix.Core.Api;
using StabilityMatrix.Core.Database;
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Python;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Database;
using StabilityMatrix.Helper;
using Wpf.Ui.Appearance;
using Wpf.Ui.Contracts;

3
StabilityMatrix/ViewModels/TextToImageViewModel.cs

@ -8,13 +8,12 @@ using System.Windows.Media.Imaging;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.Logging;
using StabilityMatrix.Api;
using StabilityMatrix.Core.Api;
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.Api;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Helper;
using StabilityMatrix.Models;
using StabilityMatrix.Services;
namespace StabilityMatrix.ViewModels;

2
StabilityMatrix/ViewModels/UpdateWindowViewModel.cs

@ -9,7 +9,7 @@ using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Models.Update;
using StabilityMatrix.Core.Services;
using StabilityMatrix.Updater;
using StabilityMatrix.Core.Updater;
namespace StabilityMatrix.ViewModels;

Loading…
Cancel
Save