Browse Source

More module localization

pull/333/head
Ionite 12 months ago
parent
commit
b136590c3c
No known key found for this signature in database
  1. 18
      StabilityMatrix.Avalonia/Languages/Resources.Designer.cs
  2. 6
      StabilityMatrix.Avalonia/Languages/Resources.resx
  3. 21
      StabilityMatrix.Avalonia/ViewModels/Inference/Modules/SaveImageModule.cs
  4. 43
      StabilityMatrix.Avalonia/ViewModels/Inference/SamplerCardViewModel.cs

18
StabilityMatrix.Avalonia/Languages/Resources.Designer.cs generated

@ -599,6 +599,15 @@ namespace StabilityMatrix.Avalonia.Languages {
}
}
/// <summary>
/// Looks up a localized string similar to Addons.
/// </summary>
public static string Label_Addons {
get {
return ResourceManager.GetString("Label_Addons", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Add Stability Matrix to the Start Menu.
/// </summary>
@ -1760,6 +1769,15 @@ namespace StabilityMatrix.Avalonia.Languages {
}
}
/// <summary>
/// Looks up a localized string similar to Save Intermediate Image.
/// </summary>
public static string Label_SaveIntermediateImage {
get {
return ResourceManager.GetString("Label_SaveIntermediateImage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Search....
/// </summary>

6
StabilityMatrix.Avalonia/Languages/Resources.resx

@ -858,4 +858,10 @@
<data name="Label_SystemInformation" xml:space="preserve">
<value>System Information</value>
</data>
<data name="Label_Addons" xml:space="preserve">
<value>Addons</value><comment>Inference Sampler Addons</comment>
</data>
<data name="Label_SaveIntermediateImage" xml:space="preserve">
<value>Save Intermediate Image</value><comment>Inference module step to save an intermediate image</comment>
</data>
</root>

21
StabilityMatrix.Avalonia/ViewModels/Inference/Modules/SaveImageModule.cs

@ -1,4 +1,5 @@
using StabilityMatrix.Avalonia.Models.Inference;
using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Models.Inference;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes;
@ -14,19 +15,21 @@ public class SaveImageModule : ModuleBase
public SaveImageModule(ServiceManager<ViewModelBase> vmFactory)
: base(vmFactory)
{
Title = "Save Intermediary Image";
Title = Resources.Label_SaveIntermediateImage;
}
/// <inheritdoc />
protected override void OnApplyStep(ModuleApplyStepEventArgs e)
{
var preview = e.Builder.Nodes.AddTypedNode(
new ComfyNodeBuilder.PreviewImage
{
Name = e.Builder.Nodes.GetUniqueName("SaveIntermediaryImage"),
Images = e.Builder.GetPrimaryAsImage()
}
);
var preview = e.Builder
.Nodes
.AddTypedNode(
new ComfyNodeBuilder.PreviewImage
{
Name = e.Builder.Nodes.GetUniqueName("SaveIntermediateImage"),
Images = e.Builder.GetPrimaryAsImage()
}
);
e.Builder.Connections.OutputNodes.Add(preview);
}

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

@ -1,10 +1,11 @@
using System;
using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.Models.Inference;
using StabilityMatrix.Avalonia.Services;
@ -21,10 +22,7 @@ namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(SamplerCard))]
[ManagedService]
[Transient]
public partial class SamplerCardViewModel
: LoadableViewModelBase,
IParametersLoadableState,
IComfyStep
public partial class SamplerCardViewModel : LoadableViewModelBase, IParametersLoadableState, IComfyStep
{
public const string ModuleKey = "Sampler";
@ -80,15 +78,12 @@ public partial class SamplerCardViewModel
private int TotalSteps => Steps + RefinerSteps;
public SamplerCardViewModel(
IInferenceClientManager clientManager,
ServiceManager<ViewModelBase> vmFactory
)
public SamplerCardViewModel(IInferenceClientManager clientManager, ServiceManager<ViewModelBase> vmFactory)
{
ClientManager = clientManager;
ModulesCardViewModel = vmFactory.Get<StackEditableCardViewModel>(modulesCard =>
{
modulesCard.Title = "Addons";
modulesCard.Title = Resources.Label_Addons;
modulesCard.AvailableModules = new[] { typeof(FreeUModule), typeof(ControlNetModule) };
modulesCard.InitializeDefaults();
});
@ -146,8 +141,7 @@ public partial class SamplerCardViewModel
var primaryLatent = e.Builder.GetPrimaryAsLatent(vae);
// Set primary sampler and scheduler
e.Builder.Connections.PrimarySampler =
SelectedSampler ?? throw new ValidationException("Sampler not selected");
e.Builder.Connections.PrimarySampler = SelectedSampler ?? throw new ValidationException("Sampler not selected");
e.Builder.Connections.PrimaryScheduler =
SelectedScheduler ?? throw new ValidationException("Scheduler not selected");
@ -159,9 +153,7 @@ public partial class SamplerCardViewModel
new ComfyNodeBuilder.KSampler
{
Name = "Sampler",
Model =
e.Builder.Connections.BaseModel
?? throw new ArgumentException("No BaseModel"),
Model = e.Builder.Connections.BaseModel ?? throw new ArgumentException("No BaseModel"),
Seed = e.Builder.Connections.Seed,
SamplerName = e.Builder.Connections.PrimarySampler?.Name!,
Scheduler = e.Builder.Connections.PrimaryScheduler?.Name!,
@ -183,9 +175,7 @@ public partial class SamplerCardViewModel
new ComfyNodeBuilder.KSamplerAdvanced
{
Name = "Sampler",
Model =
e.Builder.Connections.BaseModel
?? throw new ArgumentException("No BaseModel"),
Model = e.Builder.Connections.BaseModel ?? throw new ArgumentException("No BaseModel"),
AddNoise = true,
NoiseSeed = e.Builder.Connections.Seed,
Steps = TotalSteps,
@ -206,9 +196,7 @@ public partial class SamplerCardViewModel
new ComfyNodeBuilder.KSamplerAdvanced
{
Name = "Refiner_Sampler",
Model =
e.Builder.Connections.RefinerModel
?? throw new ArgumentException("No RefinerModel"),
Model = e.Builder.Connections.RefinerModel ?? throw new ArgumentException("No RefinerModel"),
AddNoise = false,
NoiseSeed = e.Builder.Connections.Seed,
Steps = TotalSteps,
@ -254,18 +242,11 @@ public partial class SamplerCardViewModel
if (
!string.IsNullOrEmpty(parameters.Sampler)
&& GenerationParametersConverter.TryGetSamplerScheduler(
parameters.Sampler,
out var samplerScheduler
)
&& GenerationParametersConverter.TryGetSamplerScheduler(parameters.Sampler, out var samplerScheduler)
)
{
SelectedSampler = ClientManager.Samplers.FirstOrDefault(
s => s == samplerScheduler.Sampler
);
SelectedScheduler = ClientManager.Schedulers.FirstOrDefault(
s => s == samplerScheduler.Scheduler
);
SelectedSampler = ClientManager.Samplers.FirstOrDefault(s => s == samplerScheduler.Sampler);
SelectedScheduler = ClientManager.Schedulers.FirstOrDefault(s => s == samplerScheduler.Scheduler);
}
}

Loading…
Cancel
Save