Remotely/Desktop.Linux/Services/RemoteControlAccessServiceLinux.cs

42 lines
1.3 KiB
C#

using Avalonia.Threading;
using Remotely.Desktop.Core.Interfaces;
using Remotely.Desktop.Linux.ViewModels;
using Remotely.Desktop.Linux.Views;
using Remotely.Shared.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Remotely.Desktop.Linux.Services
{
public class RemoteControlAccessServiceLinux : IRemoteControlAccessService
{
public async Task<bool> PromptForAccess(string requesterName, string organizationName)
{
var result = await Dispatcher.UIThread.InvokeAsync(async () =>
{
var promptWindow = new PromptForAccessWindow();
var viewModel = promptWindow.DataContext as PromptForAccessWindowViewModel;
if (!string.IsNullOrWhiteSpace(requesterName))
{
viewModel.RequesterName = requesterName;
}
if (!string.IsNullOrWhiteSpace(organizationName))
{
viewModel.OrganizationName = organizationName;
}
promptWindow.Show();
await TaskHelper.DelayUntilAsync(() => !promptWindow.IsVisible, TimeSpan.MaxValue);
return viewModel.PromptResult;
});
return result;
}
}
}