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

75 lines
2.1 KiB
C#
Raw Normal View History

2022-07-20 12:19:35 +02:00
using MediatR;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
2022-07-20 17:41:30 +02:00
using System;
2022-07-20 12:19:35 +02:00
using System.Collections.Generic;
2022-07-21 13:20:59 +02:00
using System.Linq;
2022-07-20 17:41:30 +02:00
using System.Threading.Tasks;
2022-07-20 12:19:35 +02:00
using WotBlitzStatisticsPro.Blazor.GraphQl;
2022-07-21 13:20:59 +02:00
using WotBlitzStatisticsPro.Blazor.Model;
2022-07-20 17:41:30 +02:00
using WotBlitzStatisticsPro.Blazor.Services;
2022-07-20 12:19:35 +02:00
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; }
2022-07-20 17:41:30 +02:00
[Inject]
public IMediaQueriesService MediaQueriesService { get; set; }
2022-07-21 13:20:59 +02:00
[Inject]
public ISvgHelper SvgHelper { get; set; }
2022-07-22 12:51:31 +02:00
[Inject]
public IGraphQlBackendService GraphQlBackendService { get; set; }
[Inject]
public INotificationsService Notifications { get; set; }
public IReadOnlyList<IDictionary_Vehicles> VehiclesLibrary { get; set; }
2022-07-20 17:41:30 +02:00
public int FrameHeigth { get; set; }
2022-07-20 18:37:42 +02:00
public int CardWidth { get; } = 200;
public int CardHeigth { get; } = 120;
2022-07-20 17:41:30 +02:00
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();
2022-07-22 12:51:31 +02:00
// 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);
}
2022-08-06 13:01:32 +02:00
FrameHeigth = screenHeight + 390;
2022-07-20 17:41:30 +02:00
}
2022-07-21 13:20:59 +02:00
public int GetTextWidth(string text, string fontFace, int fontSize)
{
return SvgHelper.CalculateTextBlockSize(text, fontFace, fontSize).Width;
}
2022-07-20 12:19:35 +02:00
}
}