Files
gpw_next/GPW.CORE.Comp/CalendarWeek.razor.cs
T
2023-01-19 12:59:48 +01:00

99 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using GPW.CORE.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
namespace GPW.CORE.Comp
{
public partial class CalendarWeek
{
/// <summary>
/// Evento selezione data valida (= entro il periodo selezionato)
/// </summary>
[Parameter]
public EventCallback<DateTime> DateSelected { get; set; }
/// <summary>
/// Evento richiesta modifica settimana
/// </summary>
[Parameter]
public EventCallback<int> WeekChanged { get; set; }
/// <summary>
/// Css titolo
/// default: color: red
/// </summary>
[Parameter]
public string HeadStyle { get; set; } = "color: #AAFF00";
/// <summary>
/// Periodo da mostrare (tipicamente 1 settimana)
/// </summary>
[Parameter]
public List<DateTime> DateList { get; set; } = new List<DateTime>();
[Parameter]
public int StartHour { get; set; } = 8;
[Parameter]
public int EndHour { get; set; } = 20;
/// <summary>
/// Altezza di ogni blocco ora da mostrare
/// </summary>
[Parameter]
public int HeightHour { get; set; } = 20;
protected DateTime DtRif
{
get
{
DateTime answ = DateTime.Today;
if (DateList != null && DateList.Count > 0)
{
answ = DateList[0];
}
return answ;
}
}
protected override async Task OnParametersSetAsync()
{
HourSlot = new List<int>();
for (int i = StartHour; i <= EndHour; i++)
{
HourSlot.Add(i);
}
await InvokeAsync(StateHasChanged);
}
protected List<int> HourSlot = new List<int>();
protected int calcColSpan
{
get => DateList.Count + 1;
}
/// <summary>
/// GetIso8601WeekOfYear
/// </summary>
/// <param name="DtReq"></param>
/// <returns></returns>
protected int weekNum(DateTime DtReq)
{
int wNum = WeekData.GetIso8601WeekOfYear(DtReq);
return wNum;
}
/// <summary>
/// Richiesta cambio sett di riferimento --> riporta evento
/// </summary>
/// <param name="delta"></param>
/// <returns></returns>
protected async Task changeWeek(int delta)
{
await WeekChanged.InvokeAsync(delta);
}
}
}