Ionite
1 year ago
1 changed files with 6 additions and 22 deletions
@ -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…
Reference in new issue