XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEWarframe

【WinUI】基于Warframe游戏本体的公开服务器以及安装器

公开
关注 0 Fork 0 Star 0
UTF-8
using Microsoft.UI.Xaml.Controls;
using XFEExtension.NetCore.WinUIHelper.Implements.Services;
using XFEExtension.NetCore.WinUIHelper.Utilities;
using XFEWarframe.Admin.Interface.Services;
using XFEWarframe.Admin.Models;
using XFEWarframe.Admin.Views.Dialogs;

namespace XFEWarframe.Admin.Implements.Services;

public sealed class AdminDialogService : GlobalServiceBase, IAdminDialogService
{
    private IInteractionService Interaction => ServiceManager.GetGlobalService<IInteractionService>()!;

    public async Task<NewAccount?> CreateAccountAsync()
    {
        var dialog = new NewAccountDialog();
        return await Interaction.ShowAsync(dialog) == ContentDialogResult.Primary ? dialog.Result : null;
    }

    public async Task<ItemGrant?> GiveItemAsync(string name, IReadOnlyList<AccountRow> accounts)
    {
        if (accounts.Count == 0) throw new InvalidOperationException("请先创建玩家。");
        var dialog = new GiveItemDialog(name, accounts);
        return await Interaction.ShowAsync(dialog) == ContentDialogResult.Primary ? dialog.Result : null;
    }
}