using Avalonia.Controls; using System.Windows.Input; using Remotely.Desktop.Shared.Reactive; using Remotely.Desktop.Shared.Abstractions; using Microsoft.Extensions.Logging; using Remotely.Desktop.UI.Controls.Dialogs; using Desktop.Shared.Services; namespace Remotely.Desktop.UI.ViewModels; public interface IMessageBoxViewModel : IBrandedViewModelBase { bool AreYesNoButtonsVisible { get; set; } string Caption { get; set; } bool IsOkButtonVisible { get; set; } string Message { get; set; } ICommand NoCommand { get; } ICommand OKCommand { get; } MessageBoxResult Result { get; set; } ICommand YesCommand { get; } } public class MessageBoxViewModel : BrandedViewModelBase, IMessageBoxViewModel { public MessageBoxViewModel (IBrandingProvider brandingProvider, IUiDispatcher dispatcher, ILogger logger) : base(brandingProvider, dispatcher, logger) { } public bool AreYesNoButtonsVisible { get => Get(); set => Set(value); } public string Caption { get => Get() ?? string.Empty; set => Set(value); } public bool IsOkButtonVisible { get => Get(); set => Set(value); } public string Message { get => Get() ?? string.Empty; set => Set(value); } public ICommand NoCommand => new RelayCommand(window => { Result = MessageBoxResult.No; window?.Close(); }); public ICommand OKCommand => new RelayCommand(window => { Result = MessageBoxResult.OK; window?.Close(); }); public MessageBoxResult Result { get; set; } = MessageBoxResult.Cancel; public ICommand YesCommand => new RelayCommand(window => { Result = MessageBoxResult.Yes; window?.Close(); }); }