Browse Source

Add EditableModule

pull/333/head
Ionite 1 year ago
parent
commit
1fc560dd9e
No known key found for this signature in database
  1. 57
      StabilityMatrix.Avalonia/Models/Inference/EditableModule.cs
  2. 16
      StabilityMatrix.Core/Models/Base/StringValue.cs

57
StabilityMatrix.Avalonia/Models/Inference/EditableModule.cs

@ -0,0 +1,57 @@
using System;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.Inference;
using StabilityMatrix.Core.Models.Base;
namespace StabilityMatrix.Avalonia.Models.Inference;
public record EditableModule : StringValue
{
public static readonly EditableModule FreeU =
new(
"FreeU",
builder =>
builder.Get<StackExpanderViewModel>(vm =>
{
vm.Title = "FreeU";
vm.AddCards(builder.Get<FreeUCardViewModel>());
})
);
public static readonly EditableModule HiresFix =
new(
"HiresFix",
builder =>
builder.Get<StackExpanderViewModel>(vm =>
{
vm.Title = "HiresFix";
vm.AddCards(
builder.Get<UpscalerCardViewModel>(),
builder.Get<SamplerCardViewModel>(vmSampler =>
{
vmSampler.IsDenoiseStrengthEnabled = true;
})
);
})
);
public static readonly EditableModule Upscaler =
new(
"Upscaler",
builder =>
builder.Get<StackExpanderViewModel>(vm =>
{
vm.Title = "Upscaler";
vm.AddCards(builder.Get<UpscalerCardViewModel>());
})
);
public Func<ServiceManager<ViewModelBase>, ViewModelBase> Build { get; }
private EditableModule(string value, Func<ServiceManager<ViewModelBase>, ViewModelBase> build)
: base(value)
{
Build = build;
}
}

16
StabilityMatrix.Core/Models/Base/StringValue.cs

@ -0,0 +1,16 @@
namespace StabilityMatrix.Core.Models.Base;
/// <summary>
/// Base class for a string value object
/// </summary>
/// <param name="Value">String value</param>
public abstract record StringValue(string Value)
{
/// <inheritdoc />
public override string ToString()
{
return Value;
}
public static implicit operator string(StringValue stringValue) => stringValue.ToString();
}
Loading…
Cancel
Save