Files
Annamaria Sassi e0bb0ddb20 Correzioni
2026-02-19 17:15:28 +01:00

150 lines
4.2 KiB
C#

using Microsoft.AspNetCore.Components;
using WebWindowComplex.Models;
namespace WebWindowComplex.Compo
{
public partial class EditSplitDimensions
{
#region Public Properties
/// <summary>
/// Split dimension corrente
/// </summary>
[Parameter]
public SplitDimension CurrRec { get; set; } = null!;
/// <summary>
/// Nome dello split dimension corrente
/// </summary>
[Parameter]
public string Name { get; set; } = null!;
/// <summary>
/// Indice dello split dimension
/// </summary>
[Parameter]
public int Index { get; set; } = -1;
[Parameter]
public EventCallback<DataUpdateSplitDimension> EC_Update { get; set; }
#endregion Public Properties
#region Private Properties
/// <summary>
/// Metodo per aggiornare la dimensione
/// </summary>
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);
}
}
}
/// <summary>
/// Metodo per aggiornare il tipo della dimensione
/// </summary>
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)
{
if (split.SelSplitShape.Equals(Json.WindowConst.SplitShapes.GRID))
return "";
else
return "col-md-12 col-lg-6";
}
return "";
}
/// <summary>
/// Metodo per avere il numero di decimali da usare nella form-input
/// </summary>
/// <returns></returns>
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;
}
/// <summary>
/// Metodo per avere il lo step da usare nella form-input
/// </summary>
/// <returns></returns>
public double CssStepNumber()
{
switch (CurrRec.MeasureType)
{
case Json.WindowConst.MeasureTypes.ABSOLUTE:
{
return 0.5;
}
case Json.WindowConst.MeasureTypes.PROPORTIONAL:
{
return 1;
}
case Json.WindowConst.MeasureTypes.PERCENTAGE:
{
return 0.5;
}
}
return 0;
}
#endregion Private Properties
}
/// <summary>
/// Classe per aggiornare split dimension
/// </summary>
public class DataUpdateSplitDimension
{
public SplitDimension currSplit { get; set; } = null!;
public int index { get; set; } = -1;
public bool noSvg { get; set; } = false;
}
}