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

XFEWarframe

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

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

namespace XFEWarframe.Player.ViewModels;

public partial class EditorPageViewModel
{
    private int PageSize => Account.EditingEnabled ? 40 : 100;
    private async Task ReadOnlyAsync(string? selectedKey = null)
    {
        if (!Account.IsLoggedIn) { Reset(); return; }
        var category = Category?.Key ?? "Suits";
        var account = Account.AccountId;
        var query = Query;
        var generation = selectionGeneration;
        var data = await AccountService.InventoryAsync(query, category, offset);
        if (query != Query || account != Account.AccountId || category != (Category?.Key ?? "Suits") || generation != selectionGeneration) return;
        version = null; CanSave = false; ImportVisibility = ExportVisibility = Visibility.Collapsed;
        QuestCreation = null; Actions.Clear(); BatchActions.Clear(); Fields = []; SelectedAction = BatchAction = null;
        ListVisibility = Visibility.Visible;
        Items.Clear(); foreach (var item in data.Items)
            Items.Add(new(item.Id.Length > 0 ? item.Id : item.Type, item.Name,
                UiText.Format("经验 {0:N0} · 数量 {1:N0}", item.Xp, item.Count), item.Tags, CanEdit: false));
        SelectedItem = Items.FirstOrDefault(x => x.Key == selectedKey) ?? Items.FirstOrDefault();
        if (SelectedItem is null) { SelectionLabel = PageTitle; Description = UiText.Translate("当前分类没有物品。"); }
        total = data.Total; CanPrevious = offset > 0; CanNext = offset + PageSize < total;
        PageLabel = UiText.Format("共 {0:N0} 项 · 第 {1} / {2} 页", total, offset / PageSize + 1, Math.Max(1, (total + PageSize - 1) / PageSize));
        OnPropertyChanged(nameof(ActionVisibility)); OnPropertyChanged(nameof(BatchVisibility));
    }
}