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

XFEWarframe

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

公开
关注 0 Fork 0 Star 0
UTF-8
using Microsoft.UI.Xaml.Controls;
using XFEWarframe.Admin.Models;
using XFEWarframe.Desktop.Editing;

namespace XFEWarframe.Admin.Views.Dialogs;

public sealed partial class GiveItemDialog : ContentDialog
{
    public GiveItemDialog(string name, IReadOnlyList<AccountRow> accounts)
    {
        InitializeComponent();
        Title = "添加 " + name;
        Suggestions.SetCandidates(AccountInput, accounts);
        Suggestions.SetSelectedItem(AccountInput, accounts.FirstOrDefault());
    }
    public ItemGrant Result => new((Suggestions.GetSelectedItem(AccountInput) as AccountRow ?? throw new InvalidOperationException("请选择玩家。")).Id, (int)CountInput.Value);
    private void Validate(ContentDialog sender, ContentDialogButtonClickEventArgs args)
    {
        if (Suggestions.GetSelectedItem(AccountInput) is null || !double.IsFinite(CountInput.Value) || CountInput.Value != Math.Truncate(CountInput.Value) || CountInput.Value is < 1 or > 100)
        {
            args.Cancel = true;
            ValidationText.Text = "请选择玩家,并输入 1 到 100 之间的整数数量。";
        }
    }
}