Browse Source

Use default json state load for PromptCard

pull/165/head
Ionite 1 year ago
parent
commit
6d49b9197c
No known key found for this signature in database
  1. 28
      StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs

28
StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs

@ -1,33 +1,17 @@
using System.Text.Json.Nodes;
using AvaloniaEdit.Document;
using AvaloniaEdit.Document;
using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Models.Inference;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(PromptCard))]
public class PromptCardViewModel : LoadableViewModelBase
public partial class PromptCardViewModel : LoadableViewModelBase
{
public TextDocument PromptDocument { get; } = new();
public TextDocument NegativePromptDocument { get; } = new();
/// <inheritdoc />
public override void LoadStateFromJsonObject(JsonObject state)
{
var model = DeserializeModel<PromptCardModel>(state);
PromptDocument.Text = model.Prompt ?? "";
NegativePromptDocument.Text = model.NegativePrompt ?? "";
}
/// <inheritdoc />
public override JsonObject SaveStateToJsonObject()
{
return SerializeModel(new PromptCardModel
{
Prompt = PromptDocument.Text,
NegativePrompt = NegativePromptDocument.Text
});
}
[ObservableProperty] private int editorFontSize = 14;
[ObservableProperty] private string editorFontFamily = "Consolas";
}

Loading…
Cancel
Save