127 lines
3.5 KiB
C#
127 lines
3.5 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using WebWindowTest.Models;
|
|
|
|
namespace WebWindowTest.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 s = (Split)CurrRec.Parent;
|
|
if (s.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;
|
|
}
|
|
|
|
#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;
|
|
}
|
|
} |