using Avalonia.Controls; using Remotely.Desktop.Shared.Reactive; using Microsoft.Extensions.Logging; using System.Windows.Input; using Remotely.Desktop.Shared.Services; namespace Remotely.Desktop.UI.ViewModels; public interface IPromptForAccessWindowViewModel : IBrandedViewModelBase { string OrganizationName { get; set; } bool PromptResult { get; set; } string RequesterName { get; set; } string RequestMessage { get; } ICommand SetResultNo { get; } ICommand SetResultYes { get; } } public class PromptForAccessWindowViewModel : BrandedViewModelBase, IPromptForAccessWindowViewModel { public PromptForAccessWindowViewModel( string requesterName, string organizationName, IBrandingProvider brandingProvider, IUiDispatcher dispatcher, ILogger logger) : base(brandingProvider, dispatcher, logger) { if (!string.IsNullOrWhiteSpace(requesterName)) { RequesterName = requesterName; } if (!string.IsNullOrWhiteSpace(organizationName)) { OrganizationName = organizationName; } } public string OrganizationName { get => Get() ?? "your IT provider"; set { Set(value); NotifyPropertyChanged(nameof(RequestMessage)); } } public bool PromptResult { get; set; } public string RequesterName { get => Get() ?? "a technician"; set { Set(value); NotifyPropertyChanged(nameof(RequestMessage)); } } public string RequestMessage { get { return $"Would you like to allow {RequesterName} from {OrganizationName} to control your computer?"; } } public ICommand SetResultNo => new RelayCommand(window => { PromptResult = false; if (window is not null) { window.Close(); } }); public ICommand SetResultYes => new RelayCommand(window => { PromptResult = true; if (window is not null) { window.Close(); } }); }