54 lines
1.3 KiB
C#
Raw Normal View History

2023-05-11 23:11:39 -04:00
using Avalonia;
using ReactiveUI;
2023-05-14 22:35:06 -04:00
using Serilog;
using SPTInstaller.Interfaces;
2023-05-11 23:11:39 -04:00
using System.Windows.Input;
namespace SPTInstaller.ViewModels;
public class MessageViewModel : ViewModelBase
2023-05-11 23:11:39 -04:00
{
private bool _HasErrors;
public bool HasErrors
2023-05-11 23:11:39 -04:00
{
get => _HasErrors;
set => this.RaiseAndSetIfChanged(ref _HasErrors, value);
}
private string _Message;
public string Message
{
get => _Message;
set => this.RaiseAndSetIfChanged(ref _Message, value);
}
2023-07-30 16:15:52 -04:00
private bool _showCloseButton;
public bool ShowCloseButton
{
get => _showCloseButton;
set => this.RaiseAndSetIfChanged(ref _showCloseButton, value);
}
public ICommand CloseCommand { get; set; } = ReactiveCommand.Create(() =>
{
if (Application.Current.ApplicationLifetime is Avalonia.Controls.ApplicationLifetimes.IClassicDesktopStyleApplicationLifetime desktopApp)
2023-05-11 23:11:39 -04:00
{
desktopApp.MainWindow.Close();
2023-05-11 23:11:39 -04:00
}
});
2023-05-11 23:11:39 -04:00
2023-07-30 16:15:52 -04:00
public MessageViewModel(IScreen Host, IResult result, bool showCloseButton = true) : base(Host)
{
2023-07-30 16:15:52 -04:00
ShowCloseButton = showCloseButton;
Message = result.Message;
2023-05-11 23:11:39 -04:00
if(result.Succeeded)
2023-05-11 23:11:39 -04:00
{
Log.Information(Message);
return;
2023-05-11 23:11:39 -04:00
}
HasErrors = true;
Log.Error(Message);
2023-05-11 23:11:39 -04:00
}
}