Skip to content

Commit 617627a

Browse files
authored
Merge pull request #85 from LykosAI/main
2 parents 830905d + a999f5e commit 617627a

18 files changed

+529
-161
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to Stability Matrix will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.0.0.html).
77

8+
## v2.3.2
9+
### Added
10+
- Added warning for exFAT / FAT32 drives when selecting a data directory
11+
### Fixed
12+
- Automatic1111 and ComfyUI should now install the correct version of pytorch for AMD GPUs
13+
- Fixed "Call from invalid thread" exceptions preventing download completion notifications from showing
14+
- Fixed model preview image downloading with incorrect name
15+
### Changed
16+
- Redesigned "Select Model Version" dialog to include model description and all preview images
17+
818
## v2.3.1
919
### Fixed
1020
- Fixed Auto update not appearing in some regions due to date formatting issues

StabilityMatrix.Avalonia/Controls/BetterImage.cs

+44-19
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
using Avalonia;
1+
using System;
2+
using Avalonia;
23
using Avalonia.Automation;
34
using Avalonia.Automation.Peers;
45
using Avalonia.Controls;
56
using Avalonia.Controls.Automation.Peers;
7+
using Avalonia.Layout;
68
using Avalonia.Media;
79
using Avalonia.Metadata;
810

@@ -77,25 +79,48 @@ public sealed override void Render(DrawingContext context)
7779
{
7880
var source = Source;
7981

80-
if (source != null && Bounds.Width > 0 && Bounds.Height > 0)
82+
if (source == null || Bounds is not {Width: > 0, Height: > 0}) return;
83+
84+
var viewPort = new Rect(Bounds.Size);
85+
var sourceSize = source.Size;
86+
87+
var scale = Stretch.CalculateScaling(Bounds.Size, sourceSize, StretchDirection);
88+
var scaledSize = sourceSize * scale;
89+
90+
// Calculate starting points for dest
91+
var destX = HorizontalAlignment switch
8192
{
82-
Rect viewPort = new Rect(Bounds.Size);
83-
Size sourceSize = source.Size;
84-
85-
Vector scale = Stretch.CalculateScaling(Bounds.Size, sourceSize, StretchDirection);
86-
Size scaledSize = sourceSize * scale;
87-
Rect destRect = viewPort
88-
.CenterRect(new Rect(scaledSize))
89-
.WithX(0)
90-
.WithY(0)
91-
.Intersect(viewPort);
92-
Rect sourceRect = new Rect(sourceSize)
93-
.CenterRect(new Rect(destRect.Size / scale))
94-
.WithX(0)
95-
.WithY(0);
96-
97-
context.DrawImage(source, sourceRect, destRect);
98-
}
93+
HorizontalAlignment.Left => 0,
94+
HorizontalAlignment.Center => (int) (viewPort.Width - scaledSize.Width) / 2,
95+
HorizontalAlignment.Right => (int) (viewPort.Width - scaledSize.Width),
96+
// Stretch is default, use center
97+
HorizontalAlignment.Stretch => (int) (viewPort.Width - scaledSize.Width) / 2,
98+
_ => throw new ArgumentException(nameof(HorizontalAlignment))
99+
};
100+
101+
var destRect = viewPort
102+
.CenterRect(new Rect(scaledSize))
103+
.WithX(destX)
104+
.WithY(0)
105+
.Intersect(viewPort);
106+
var destRectUnscaledSize = destRect.Size / scale;
107+
108+
var sourceX = HorizontalAlignment switch
109+
{
110+
HorizontalAlignment.Left => 0,
111+
HorizontalAlignment.Center => (int) (sourceSize - destRectUnscaledSize).Width / 2,
112+
HorizontalAlignment.Right => (int) (sourceSize - destRectUnscaledSize).Width,
113+
// Stretch is default, use center
114+
HorizontalAlignment.Stretch => (int) (sourceSize - destRectUnscaledSize).Width / 2,
115+
_ => throw new ArgumentException(nameof(HorizontalAlignment))
116+
};
117+
118+
var sourceRect = new Rect(sourceSize)
119+
.CenterRect(new Rect(destRect.Size / scale))
120+
.WithX(sourceX)
121+
.WithY(0);
122+
123+
context.DrawImage(source, sourceRect, destRect);
99124
}
100125

101126
/// <summary>

StabilityMatrix.Avalonia/DesignData/DesignData.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@ public static PackageManagerViewModel PackageManagerViewModel
327327
new()
328328
{
329329
Name = "BB95 Furry Mix",
330-
Description = "v1.0.0",
330+
Description = @"Introducing SnoutMix
331+
A Mix of non-Furry and Furry models such as Furtastic and BB95Furry to create a great variety of anthro AI generation options, but bringing out more detail, still giving a lot of freedom to customise the human aspects, and having great backgrounds, with a focus on something more realistic. Works well with realistic character loras.
332+
The gallery images are often inpainted, but you will get something very similar if copying their data directly. They are inpainted using the same model, therefore all results are possible without anything custom/hidden-away. Controlnet Tiled is applied to enhance them further afterwards. Gallery images were made with same model but before it was renamed",
331333
BaseModel = "SD 1.5",
332334
Files = new List<CivitFile>
333335
{
@@ -365,6 +367,8 @@ public static PackageManagerViewModel PackageManagerViewModel
365367

366368
// Sample data for dialogs
367369
vm.Versions = new List<ModelVersionViewModel> {sampleViewModel};
370+
vm.Title = sampleCivitVersions[0].Name;
371+
vm.Description = sampleCivitVersions[0].Description;
368372
vm.SelectedVersionViewModel = sampleViewModel;
369373
});
370374

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using AsyncImageLoader;
4+
using Avalonia.Media.Imaging;
5+
using StabilityMatrix.Core.Models.FileInterfaces;
6+
7+
namespace StabilityMatrix.Avalonia.Models;
8+
9+
public record ImageSource : IDisposable
10+
{
11+
/// <summary>
12+
/// Local file path
13+
/// </summary>
14+
public FilePath? LocalFile { get; init; }
15+
16+
/// <summary>
17+
/// Remote URL
18+
/// </summary>
19+
public Uri? RemoteUrl { get; init; }
20+
21+
/// <summary>
22+
/// Bitmap
23+
/// </summary>
24+
public Bitmap? Bitmap { get; init; }
25+
26+
public ImageSource(FilePath localFile)
27+
{
28+
LocalFile = localFile;
29+
}
30+
31+
public ImageSource(Uri remoteUrl)
32+
{
33+
RemoteUrl = remoteUrl;
34+
}
35+
36+
public Task<Bitmap?> BitmapAsync => GetBitmapAsync();
37+
38+
/// <summary>
39+
/// Get the bitmap
40+
/// </summary>
41+
public async Task<Bitmap?> GetBitmapAsync()
42+
{
43+
if (Bitmap is not null) return Bitmap;
44+
45+
var loader = ImageLoader.AsyncImageLoader;
46+
47+
// Use local file path if available, otherwise remote URL
48+
var path = LocalFile?.FullPath ?? RemoteUrl?.ToString();
49+
50+
if (path is null) return null;
51+
52+
// Load the image
53+
return await loader.ProvideImageAsync(path).ConfigureAwait(false);
54+
}
55+
56+
/// <summary>
57+
/// Clears the cached bitmap
58+
/// </summary>
59+
protected virtual void Dispose(bool disposing)
60+
{
61+
if (!disposing) return;
62+
63+
Bitmap?.Dispose();
64+
}
65+
66+
/// <inheritdoc />
67+
public void Dispose()
68+
{
69+
Dispose(true);
70+
GC.SuppressFinalize(this);
71+
}
72+
73+
/// <inheritdoc />
74+
public override string ToString()
75+
{
76+
return LocalFile?.FullPath ?? RemoteUrl?.ToString() ?? "";
77+
}
78+
79+
/// <summary>
80+
/// Implicit conversion to string for async image loader.
81+
/// Resolves with the local file path if available, otherwise the remote URL.
82+
/// Otherwise returns null.
83+
/// </summary>
84+
public static implicit operator string(ImageSource imageSource) => imageSource.ToString();
85+
}

StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<ApplicationManifest>app.manifest</ApplicationManifest>
99
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
1010
<ApplicationIcon>./Assets/Icon.ico</ApplicationIcon>
11-
<Version>2.3.0-dev.1</Version>
11+
<Version>2.3.2-dev.1</Version>
1212
<InformationalVersion>$(Version)</InformationalVersion>
1313
<EnableWindowsTargeting>true</EnableWindowsTargeting>
1414
</PropertyGroup>
@@ -21,6 +21,7 @@
2121
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.2" />
2222
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
2323
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.2" />
24+
<PackageReference Include="Avalonia.HtmlRenderer" Version="11.0.0" />
2425
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0.1" />
2526
<PackageReference Include="AvaloniaEdit.TextMate" Version="11.0.0" />
2627
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />

0 commit comments

Comments
 (0)