38 lines
942 B
C#
38 lines
942 B
C#
using System.Windows;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using Livia.Models;
|
|
using Livia.Views.Utility;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Livia.ViewModels;
|
|
|
|
internal class ValidateSerialKeyWindowViewModel(
|
|
ILogger logger,
|
|
ISerialKeyManager serialKeyManager,
|
|
IWarningSystem warningSystem)
|
|
: ObservableObject
|
|
{
|
|
public ISerialKeyManager SerialKeyManager { get; } = serialKeyManager;
|
|
|
|
public void CopyHardwareId()
|
|
{
|
|
try
|
|
{
|
|
Clipboard.SetText(SerialKeyManager.HardwareId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
logger.LogError(e, "Error copying hardware id to clipboard");
|
|
}
|
|
}
|
|
|
|
public bool Validate()
|
|
{
|
|
bool success = SerialKeyManager.Validate();
|
|
if (!success)
|
|
{
|
|
warningSystem.ShowDialog(WarningWindowKind.Warning, true, "ValidateSerialKeyFailed");
|
|
}
|
|
return success;
|
|
}
|
|
} |