245 lines
7.0 KiB
C#
245 lines
7.0 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using WebWindowTest.Models;
|
|
using static WebWindowTest.Json.WindowConst;
|
|
using static WebWindowTest.LayoutConst;
|
|
|
|
namespace WebWindowTest.Compo
|
|
{
|
|
public partial class CardSashGroup
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Sash corrente rispetto alla lista Sash
|
|
/// </summary>
|
|
[CascadingParameter(Name = "CurrSashGroup")]
|
|
public Sash CurrSashGroup { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Evento per cambiare tutti i fill
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateFrame> EC_UpdateFrame { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per tornare nella pagine Tree
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<bool> EC_ReqClose { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per richiedere reset dizionario Shape
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateRes> EC_ReqResetDict { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per richiedere per la prima volta opzioni hardware
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<Sash> EC_ReqFirstOptionHw { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per segnalare aggiornamento
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateSash> EC_UpdateSashGroup { get; set; }
|
|
|
|
/// <summary>
|
|
/// Lista di sash
|
|
/// </summary>
|
|
[CascadingParameter(Name = "SashList")]
|
|
public List<Sash> SashList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Frame corrente
|
|
/// </summary>
|
|
[Parameter]
|
|
public Frame FrameWindow { get; set; } = null!;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Selezione quantità di ante
|
|
/// </summary>
|
|
protected int SashQty
|
|
{
|
|
get => CurrSashGroup.nSashQty;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezione quantità bottom rail
|
|
/// </summary>
|
|
protected int SashBottomRailQty
|
|
{
|
|
get => CurrSashGroup.SashBottomRailQty;
|
|
set
|
|
{
|
|
if (CurrSashGroup.SashBottomRailQty != value)
|
|
{
|
|
CurrSashGroup.SashBottomRailQty = value;
|
|
if (CurrSashGroup.SashBottomRailQty > 0)
|
|
CurrSashGroup.SetSashBottomRail(true);
|
|
else
|
|
CurrSashGroup.SetSashBottomRail(false);
|
|
var args = new DataUpdateSash()
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
_ = EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezione tipo di orientamento della sash
|
|
/// </summary>
|
|
protected int OrientationSashTypeIndex
|
|
{
|
|
get => CurrSashGroup.SelOrientationSashTypeIndex;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezione famiglia hardware
|
|
/// </summary>
|
|
protected string FamilyHardware
|
|
{
|
|
get => CurrSashGroup.SelFamilyHardware;
|
|
}
|
|
|
|
protected string SelHwType
|
|
{
|
|
get => CurrSashGroup.GetHardwareDescription;
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// Metodo per scegliere tipo di misura
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
protected async Task SetMeasureType(MeasureTypes type)
|
|
{
|
|
isOpen = !isOpen;
|
|
for(int i = 0; i < CurrSashGroup.SashList.Count; i++)
|
|
{
|
|
CurrSashGroup.SashList.ElementAt(i).SetSelMeasureType(type, i);
|
|
}
|
|
var args = new DataUpdateSash
|
|
{
|
|
currSash = CurrSashGroup,
|
|
noSvg = true
|
|
};
|
|
await EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare la sash dimension
|
|
/// </summary>
|
|
/// <param name="updateSD"></param>
|
|
/// <returns></returns>
|
|
protected async Task UpdateSashDimension(SashDimension updateSD)
|
|
{
|
|
var currRec = CurrSashGroup.SashList.First(x => x.nSashId == updateSD.nSashId);
|
|
if(currRec != null)
|
|
{
|
|
currRec = updateSD;
|
|
var args = new DataUpdateSash
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
await EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare sash
|
|
/// </summary>
|
|
/// <param name="updateS"></param>
|
|
/// <returns></returns>
|
|
protected async Task UpdateSash(Sash updateS)
|
|
{
|
|
if (updateS != null)
|
|
{
|
|
CurrSashGroup = updateS;
|
|
var args = new DataUpdateSash
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
await EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Methods
|
|
|
|
private bool editMode = false;
|
|
private List<int> currSashDimEdit = new List<int>();
|
|
private void EditView(DataChangeMode args)
|
|
{
|
|
editMode = args.Edit;
|
|
if(args.IndexSashEdit != -1)
|
|
currSashDimEdit.Add(args.IndexSashEdit);
|
|
if (args.IndexSashClose != -1)
|
|
currSashDimEdit.Remove(args.IndexSashClose);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sollevo evento per tornare alla pagina Tree
|
|
/// </summary>
|
|
private void ReqClose()
|
|
{
|
|
_ = EC_ReqClose.InvokeAsync(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Prima chiamata hw option list
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
/// <returns></returns>
|
|
private async Task FirstHwOptionList()
|
|
{
|
|
var args = new DataUpdateSash
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
//await EC_UpdatePreview.InvokeAsync(args);
|
|
await EC_ReqFirstOptionHw.InvokeAsync(CurrSashGroup);
|
|
}
|
|
|
|
private string ButtonMeasureCss(MeasureTypes type)
|
|
{
|
|
foreach(var item in CurrSashGroup.SashList)
|
|
{
|
|
if (!item.SelMeasureType.Equals(type))
|
|
return "btn btn-outline-secondary btn-sm";
|
|
}
|
|
return "btn btn-secondary btn-sm";
|
|
}
|
|
|
|
private bool isOpen = false;
|
|
private void ToggleDropdown()
|
|
{
|
|
isOpen = !isOpen;
|
|
}
|
|
#endregion Private Methods
|
|
}
|
|
|
|
public class DataUpdateSash
|
|
{
|
|
public Sash currSash { get; set; } = null!;
|
|
public bool svgNoHw { get; set; } = false;
|
|
public bool noSvg { get; set; } = false;
|
|
}
|
|
|
|
public class DataUpdateRes
|
|
{
|
|
public DataAction req { get; set; } = DataAction.None;
|
|
}
|
|
} |