Files
webwindowconfigurator/WebWindowComplex/Compo/CardSplit.razor.cs
T

149 lines
4.6 KiB
C#

using Microsoft.AspNetCore.Components;
using WebWindowComplex.Models;
namespace WebWindowComplex.Compo
{
public partial class CardSplit
{
/// <summary>
/// Indice del fill corrente rispetto alla lista fill
/// </summary>
[Parameter]
public int CurrIndex { get; set; } = 0;
/// <summary>
/// Fill corrente rispetto alla lista fill
/// </summary>
[Parameter]
public Split CurrItem { get; set; } = null!;
/// <summary>
/// Lista di sash
/// </summary>
[Parameter]
public List<Sash> SashList { get; set; } = null!;
/// <summary>
/// Lista di split
/// </summary>
[Parameter]
public List<Split> SplitList { get; set; } = null!;
/// <summary>
/// Evento per scambiare le aree di uno split
/// </summary>
[Parameter]
public EventCallback<Area> EC_SwapTwoAree { get; set; }
/// <summary>
/// Evento per rimuovere split
/// </summary>
[Parameter]
public EventCallback<Area> EC_RemoveArea { get; set; }
/// <summary>
/// Evento per cambiare nel caso di split a griglia se inizia con lo split verticale
/// </summary>
[Parameter]
public EventCallback<DataChangeStartVert> EC_ChangeStartVert { get; set; }
/// <summary>
/// Evento per richiedere reset dizionario Shape
/// </summary>
[Parameter]
public EventCallback<bool> EC_ReqResetDictShape { get; set; }
/// <summary>
/// Evento per tornare nella pagine Tree
/// </summary>
[Parameter]
public EventCallback<bool> EC_ReqClose { get; set; }
/// <summary>
/// Sollevo evento per scambiare le aree di uno split
/// </summary>
/// <param name="item"> split corrente </param>
/// <returns></returns>
protected async Task SwapTwoAree(Split item)
{
// richiesta reset dict shape
_ = EC_ReqResetDictShape.InvokeAsync(true);
await EC_SwapTwoAree.InvokeAsync(item);
}
/// <summary>
/// Sollevo evento per rimuovere split
/// </summary>
/// <param name="item"> split corrente </param>
/// <returns></returns>
protected async Task RemoveArea(Split item)
{
// richiesta reset dict shape
await EC_ReqResetDictShape.InvokeAsync(true);
await EC_RemoveArea.InvokeAsync(item);
}
/// <summary>
/// Sollevo evento per rimuovere split
/// </summary>
/// <param name="item"> split corrente </param>
/// <returns></returns>
protected async Task ChangeStartVert(ChangeEventArgs e, Split item)
{
var Args = new DataChangeStartVert
{
eventArg = e,
currItem = item,
};
await EC_ChangeStartVert.InvokeAsync(Args);
}
/// <summary>
/// Metodo per determinare la descrizione del parent dello split corrente
/// </summary>
/// <param name="currSplit"> split corrente </param>
/// <returns></returns>
protected string descParentSplit(Split currSplit)
{
if ((currSplit.ParentArea is Splitted || currSplit.ParentArea is Sash) && SashList.Count > 0)
{
for (int j = 0; j < SashList.Count; j++)
{
if (SashList[j].Equals(currSplit.ParentArea))
{
return "Sash " + (j + 1);
}
else if (SashList[j].Equals(currSplit.ParentArea.ParentArea))
{
for (int k = 0; k < SashList[j].AreaList.Count; k++)
{
if (SashList[j].AreaList[k].AreaList[0].Equals(currSplit))
{
return "Sash group " + (j + 1) + " - sash " + (k + 1);
}
}
}
}
}
else
{
return "Frame";
}
return "";
}
/// <summary>
/// Sollevo evento per tornare alla pagina Tree
/// </summary>
private void ReqClose()
{
_ = EC_ReqClose.InvokeAsync(true);
}
}
public class DataChangeStartVert
{
public ChangeEventArgs eventArg { get; set; } = null!;
public Split currItem { get; set; }
}
}