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

72 lines
2.2 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-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-21 13:20:59 +02:00
//[Obsolete("Just temporary. In the future, add this into tankTree DTO")]
//public ElementDimensions[] BattlesTextSize { get; set; }
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()
{
2022-07-20 18:37:42 +02:00
//var screenWidth = await MediaQueriesService.WindowWidth();
2022-07-20 17:41:30 +02:00
var screenHeight = await MediaQueriesService.WindowHeight();
2022-07-20 18:37:42 +02:00
//FrameWidth = Convert.ToInt32(((decimal)screenWidth) * 0.94m);
2022-07-20 17:41:30 +02:00
FrameHeigth = screenHeight - 390;
2022-07-21 13:20:59 +02:00
// TODO: This is temporary
//var dd = new List<ElementDimensions>();
//var tt = TanksList.ToArray();
//for (int i = 0; i < 3; i++)
//{
// var d = await SvgHelper.CalculateTextBlockSizeAsync(tt[i].Battles.ToString("N0"), "Segoe UI", 12);
// dd.Add(d);
//}
//BattlesTextSize = dd.ToArray();
//---
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
}
}