Files
WotBlitzStatisticsBlazor/WotBlitzStatisticsPro.Blazor/Pages/PlayerInfoTanksTreeBase.cs
T

76 lines
2.1 KiB
C#

using MediatR;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WotBlitzStatisticsPro.Blazor.GraphQl;
using WotBlitzStatisticsPro.Blazor.Model;
using WotBlitzStatisticsPro.Blazor.Services;
namespace WotBlitzStatisticsPro.Blazor.Pages
{
public class PlayerInfoTanksTreeBase: ComponentBase
{
[Parameter]
public IEnumerable<ITank> TanksList { get; set; }
[Inject]
public IStringLocalizer<App> Localize { get; set; }
[Inject]
public IMediator Mediator { get; set; }
[Inject]
public IMediaQueriesService MediaQueriesService { get; set; }
[Inject]
public ISvgHelper SvgHelper { get; set; }
[Inject]
public IGraphQlBackendService GraphQlBackendService { get; set; }
[Inject]
public INotificationsService Notifications { get; set; }
public IReadOnlyList<IDictionary_Vehicles> VehiclesLibrary { get; set; }
public int FrameHeigth { get; set; }
public int CardWidth { get; } = 200;
public int CardHeigth { get; } = 120;
public string FrameStyle
{
get
{
return $"min-height: {FrameHeigth}px; overflow-y: auto; overflow-x: auto;";
}
}
protected async override Task OnInitializedAsync()
{
var screenHeight = await MediaQueriesService.WindowHeight();
// TODO: Move it to the Nation selector handler
try
{
string nationId = "germany";
VehiclesLibrary = await GraphQlBackendService.GetVehiclesByNation(nationId);
}
catch (System.Exception e)
{
Notifications.ReportError("Can not get data from backend", e.Message);
}
FrameHeigth = screenHeight - 390;
}
public int GetTextWidth(string text, string fontFace, int fontSize)
{
return SvgHelper.CalculateTextBlockSize(text, fontFace, fontSize).Width;
}
}
}