using Microsoft.AspNetCore.Components;
using WebWindowTest.Models;
namespace WebWindowTest.Compo
{
public partial class EditSplitDimensions
{
#region Public Properties
///
/// Split dimension corrente
///
[Parameter]
public SplitDimension CurrRec { get; set; } = null!;
///
/// Nome dello split dimension corrente
///
[Parameter]
public string Name { get; set; } = null!;
///
/// Indice dello split dimension
///
[Parameter]
public int Index { get; set; } = -1;
[Parameter]
public EventCallback EC_Update { get; set; }
#endregion Public Properties
#region Private Properties
///
/// Metodo per aggiornare la dimensione
///
private double CurrVal
{
get => CurrRec.dDimension;
set
{
if (CurrRec.dDimension != value)
{
CurrRec.dDimension = (double)Math.Round((decimal)value, CssDecimals());
var args = new DataUpdateSplitDimension()
{
currSplit = CurrRec,
index = Index
};
_ = EC_Update.InvokeAsync(args);
}
}
}
///
/// Metodo per aggiornare il tipo della dimensione
///
private int CurrType
{
get => CurrRec.SelMeasureTypeIndex;
set
{
if (CurrRec.SelMeasureTypeIndex != value)
{
CurrRec.SelMeasureTypeIndex = value;
var args = new DataUpdateSplitDimension()
{
currSplit = CurrRec,
index=Index,
noSvg = true
};
_ = EC_Update.InvokeAsync(args);
}
}
}
private string SplitDimCss()
{
if(CurrRec.Parent is Split)
{
Split s = (Split)CurrRec.Parent;
if (s.SelSplitShape.Equals(Json.WindowConst.SplitShapes.GRID))
return "";
else
return "col-md-12 col-lg-6";
}
return "";
}
///
/// Metodo per avere il numero di decimali da usare nella form-input
///
///
public int CssDecimals()
{
switch (CurrRec.MeasureType)
{
case Json.WindowConst.MeasureTypes.ABSOLUTE:
{
return 2;
}
case Json.WindowConst.MeasureTypes.PROPORTIONAL:
{
return 0;
}
case Json.WindowConst.MeasureTypes.PERCENTAGE:
{
return 1;
}
}
return 0;
}
#endregion Private Properties
}
///
/// Classe per aggiornare split dimension
///
public class DataUpdateSplitDimension
{
public SplitDimension currSplit { get; set; } = null!;
public int index { get; set; } = -1;
public bool noSvg { get; set; } = false;
}
}