feat(ui): complete Avalonia UI port with 7 main pages, tool settings & top MenuBar
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace ClawdDotNet.Desktop.ViewModels;
|
||||
|
||||
/// <summary>Eingabe eines Lizenzschlüssels. Siehe <c>AvaloniaLicensePrompt</c>.</summary>
|
||||
public sealed partial class LicenseViewModel : ViewModelBase
|
||||
{
|
||||
private readonly TaskCompletionSource<string?> _completion = new();
|
||||
|
||||
[ObservableProperty]
|
||||
private string _key;
|
||||
|
||||
public string HardwareId { get; }
|
||||
|
||||
/// <summary>Warum der bisherige Schlüssel nicht taugt; leer beim ersten Fragen.</summary>
|
||||
public string Problem { get; }
|
||||
|
||||
/// <summary>Der eingegebene Schlüssel, oder <c>null</c> bei Abbruch.</summary>
|
||||
public Task<string?> Result => _completion.Task;
|
||||
|
||||
public LicenseViewModel(string hardwareId, string? problem, string? currentKey)
|
||||
{
|
||||
HardwareId = hardwareId;
|
||||
Problem = problem ?? "";
|
||||
_key = currentKey ?? "";
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Confirm()
|
||||
{
|
||||
var value = Key.Trim();
|
||||
|
||||
// Leere Eingabe ist kein Abbruch — sonst schließt sich das Fenster, wenn jemand
|
||||
// versehentlich die Eingabetaste drückt.
|
||||
if (value.Length == 0) return;
|
||||
|
||||
_completion.TrySetResult(value);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Cancel() => _completion.TrySetResult(null);
|
||||
|
||||
/// <summary>Schließt der Benutzer das Fenster, gilt das als Abbruch.</summary>
|
||||
public void CancelIfPending() => _completion.TrySetResult(null);
|
||||
}
|
||||
Reference in New Issue
Block a user