Browse Source

added description to SelectModelVersionDialog

pull/109/head
JT 1 year ago
parent
commit
4759480aaa
  1. 6
      StabilityMatrix.Avalonia/DesignData/DesignData.cs
  2. 1
      StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj
  3. 26
      StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CheckpointBrowserCardViewModel.cs
  4. 2
      StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs
  5. 31
      StabilityMatrix.Avalonia/Views/Dialogs/SelectModelVersionDialog.axaml

6
StabilityMatrix.Avalonia/DesignData/DesignData.cs

@ -325,7 +325,9 @@ public static class DesignData
new()
{
Name = "BB95 Furry Mix",
Description = "v1.0.0",
Description = @"Introducing SnoutMix
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.
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",
BaseModel = "SD 1.5",
Files = new List<CivitFile>
{
@ -363,6 +365,8 @@ public static class DesignData
// Sample data for dialogs
vm.Versions = new List<ModelVersionViewModel> {sampleViewModel};
vm.Title = sampleCivitVersions[0].Name;
vm.Description = sampleCivitVersions[0].Description;
vm.SelectedVersionViewModel = sampleViewModel;
});

1
StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj

@ -21,6 +21,7 @@
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.2" />
<!--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.2" />
<PackageReference Include="Avalonia.HtmlRenderer" Version="11.0.0" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0.1" />
<PackageReference Include="AvaloniaEdit.TextMate" Version="11.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />

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

@ -5,6 +5,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
@ -170,10 +171,15 @@ public partial class CheckpointBrowserCardViewModel : Base.ProgressViewModel
IsSecondaryButtonEnabled = false,
IsFooterVisible = false,
MaxDialogWidth = 750,
MaxDialogHeight = 850,
};
var prunedDescription = PruneDescription(model);
var viewModel = dialogFactory.Get<SelectModelVersionViewModel>();
viewModel.Dialog = dialog;
viewModel.Title = model.Name;
viewModel.Description = prunedDescription;
viewModel.Versions = versions.Select(version =>
new ModelVersionViewModel(
settingsManager.Settings.InstalledModelHashes ?? new HashSet<string>(), version))
@ -199,6 +205,23 @@ public partial class CheckpointBrowserCardViewModel : Base.ProgressViewModel
await DoImport(model, selectedVersion, selectedFile);
}
private static string PruneDescription(CivitModel model)
{
var prunedDescription =
model.Description
.Replace("<br/>", $"{Environment.NewLine}{Environment.NewLine}")
.Replace("<br />", $"{Environment.NewLine}{Environment.NewLine}")
.Replace("</p>", $"{Environment.NewLine}{Environment.NewLine}")
.Replace("</h1>", $"{Environment.NewLine}{Environment.NewLine}")
.Replace("</h2>", $"{Environment.NewLine}{Environment.NewLine}")
.Replace("</h3>", $"{Environment.NewLine}{Environment.NewLine}")
.Replace("</h4>", $"{Environment.NewLine}{Environment.NewLine}")
.Replace("</h5>", $"{Environment.NewLine}{Environment.NewLine}")
.Replace("</h6>", $"{Environment.NewLine}{Environment.NewLine}");
prunedDescription = HtmlRegex().Replace(prunedDescription, string.Empty);
return prunedDescription;
}
private static async Task<FilePath> SaveCmInfo(
CivitModel model,
CivitModelVersion modelVersion,
@ -354,4 +377,7 @@ public partial class CheckpointBrowserCardViewModel : Base.ProgressViewModel
IsImporting = false;
});
}
[GeneratedRegex("<[^>]+>")]
private static partial Regex HtmlRegex();
}

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

@ -18,6 +18,8 @@ public partial class SelectModelVersionViewModel : ContentDialogViewModelBase
public required ContentDialog Dialog { get; set; }
public required IReadOnlyList<ModelVersionViewModel> Versions { get; set; }
public required string Description { get; set; }
public required string Title { get; set; }
[ObservableProperty] private Bitmap? previewImage;
[ObservableProperty] private ModelVersionViewModel? selectedVersionViewModel;

31
StabilityMatrix.Avalonia/Views/Dialogs/SelectModelVersionDialog.axaml

@ -6,7 +6,7 @@
xmlns:api="clr-namespace:StabilityMatrix.Core.Models.Api;assembly=StabilityMatrix.Core"
xmlns:dialogs="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Dialogs"
xmlns:designData="clr-namespace:StabilityMatrix.Avalonia.DesignData"
mc:Ignorable="d" d:DesignWidth="700" d:DesignHeight="450"
mc:Ignorable="d" d:DesignWidth="700" d:DesignHeight="850"
x:DataType="dialogs:SelectModelVersionViewModel"
xmlns:icons="https://github.com/projektanker/icons.avalonia"
xmlns:fluentAvalonia="clr-namespace:FluentIcons.FluentAvalonia;assembly=FluentIcons.FluentAvalonia"
@ -19,16 +19,29 @@
RowDefinitions="*,Auto"
ColumnDefinitions="*,Auto,*">
<controls:BetterImage Grid.Column="0" Grid.Row="0" Margin="8"
VerticalAlignment="Top"
MaxHeight="400"
HorizontalAlignment="Left"
Source="{Binding PreviewImage}" />
<Grid Grid.Row="0"
Grid.Column="0"
RowDefinitions="Auto, Auto">
<controls:BetterImage
Margin="8"
VerticalAlignment="Top"
MaxHeight="400"
HorizontalAlignment="Left"
Source="{Binding PreviewImage}" />
<Expander Grid.Row="1"
Header="Model Description"
ExpandDirection="Up"
Margin="16, 8">
<TextBlock Text="{Binding Description}"
TextWrapping="Wrap"
Margin="8"/>
</Expander>
</Grid>
<ListBox Grid.Row="0" Grid.Column="1"
Margin="8"
MaxHeight="450"
MaxHeight="400"
VerticalAlignment="Top"
ItemsSource="{Binding Versions}"
SelectedItem="{Binding SelectedVersionViewModel}">
<ListBox.ItemTemplate>
@ -78,7 +91,7 @@
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type dialogs:CivitFileViewModel}">
<Grid RowDefinitions="Auto, Auto" ColumnDefinitions="Auto, *"
Margin="-4,0,0,0">
Margin="0,4,0,4">
<fluentAvalonia:SymbolIcon Grid.Row="0" Grid.RowSpan="2"
Grid.Column="0"
Margin="0, 0, 8, 0"

Loading…
Cancel
Save