564 lines
19 KiB
C#
564 lines
19 KiB
C#
using Egw.Window.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using WebWindowComplex.Models;
|
|
using static WebWindowComplex.Json.WindowConst;
|
|
using static WebWindowComplex.LayoutConst;
|
|
|
|
namespace WebWindowComplex.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>
|
|
/// Livello di accesso (utente base)
|
|
/// </summary>
|
|
[CascadingParameter(Name = "User")]
|
|
public bool User { get; set; } = false!;
|
|
|
|
/// <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 opzioni hardware
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<Sash> EC_ReqOptionHw { 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>
|
|
/// Evento per richiesta profili degli Element
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<Sash> EC_ReqElement { get; set; }
|
|
|
|
/// <summary>
|
|
/// Lista di sash
|
|
/// </summary>
|
|
[CascadingParameter(Name = "SashGroupList")]
|
|
public List<Sash> SashGroupList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Lista di sash dimension in stato edit
|
|
/// </summary>
|
|
[CascadingParameter(Name = "SashDimEditList")]
|
|
public List<int> SashDimEditList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Frame corrente
|
|
/// </summary>
|
|
[Parameter]
|
|
public Frame FrameWindow { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Evento per salvare stato edit singole ante
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<List<int>> EC_EditSashDim { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
currSashDimEdit = SashDimEditList;
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Private Fields
|
|
|
|
private bool editMode = false;
|
|
private List<int> currSashDimEdit = new List<int>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
/// <summary>
|
|
/// Selezione quantità di ante
|
|
/// </summary>
|
|
private int SashQty
|
|
{
|
|
get => CurrSashGroup.nSashQty;
|
|
set
|
|
{
|
|
if (CurrSashGroup.nSashQty != value)
|
|
{
|
|
CurrSashGroup.nSashQty = value;
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetHwOpt });
|
|
var args = new DataUpdateSash()
|
|
{
|
|
currSash = CurrSashGroup,
|
|
svgNoHw = true
|
|
};
|
|
_ = EC_UpdateSashGroup.InvokeAsync(args);
|
|
_ = EC_ReqElement.InvokeAsync(CurrSashGroup);
|
|
if (CurrSashGroup.SelHardware.Id != "000000")
|
|
_ = EC_ReqOptionHw.InvokeAsync(CurrSashGroup);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezione quantit� bottom rail
|
|
/// </summary>
|
|
private int SashBottomRailQty
|
|
{
|
|
get => CurrSashGroup.SashBottomRailQty;
|
|
set
|
|
{
|
|
if (CurrSashGroup.SashBottomRailQty != value)
|
|
{
|
|
CurrSashGroup.SashBottomRailQty = value;
|
|
if (CurrSashGroup.SashBottomRailQty > 0)
|
|
CurrSashGroup.SashBottomRail = true;
|
|
else
|
|
CurrSashGroup.SashBottomRail = false;
|
|
var args = new DataUpdateSash()
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
_ = EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezione tipo di orientamento della sash
|
|
/// </summary>
|
|
private int OrientationSashTypeIndex
|
|
{
|
|
get => CurrSashGroup.SelOrientationSashTypeIndex;
|
|
set
|
|
{
|
|
if (CurrSashGroup.SelOrientationSashTypeIndex != value)
|
|
{
|
|
CurrSashGroup.SelOrientationSashTypeIndex = value;
|
|
var args = new DataUpdateSash()
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
_ = EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezione famiglia hardware
|
|
/// </summary>
|
|
private string FamilyHardware
|
|
{
|
|
get => CurrSashGroup.SelFamilyHardware;
|
|
set
|
|
{
|
|
if (CurrSashGroup.SelFamilyHardware != value)
|
|
{
|
|
CurrSashGroup.SelFamilyHardware = value;
|
|
var args = new DataUpdateSash()
|
|
{
|
|
currSash = CurrSashGroup,
|
|
svgNoHw = true
|
|
};
|
|
_ = EC_UpdateSashGroup.InvokeAsync(args);
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetHwOpt });
|
|
_ = EC_ReqOptionHw.InvokeAsync(CurrSashGroup);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezione hardware
|
|
/// </summary>
|
|
private string SelHwType
|
|
{
|
|
get => CurrSashGroup.SelHardwareFromId;
|
|
set
|
|
{
|
|
if (CurrSashGroup.SelHardwareFromId != value)
|
|
{
|
|
CurrSashGroup.SelHardwareFromId = value;
|
|
var args = new DataUpdateSash
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
_ = EC_UpdateSashGroup.InvokeAsync(args);
|
|
_ = EC_ReqOptionHw.InvokeAsync(CurrSashGroup);
|
|
}
|
|
}
|
|
}
|
|
|
|
private MeasureTypes MeasureType
|
|
{
|
|
get
|
|
{
|
|
MeasureTypes type = CurrSashGroup.SashList.First().SelMeasureType;
|
|
for (int i = 1; i < CurrSashGroup.SashList.Count; i++)
|
|
{
|
|
if (CurrSashGroup.SashList.ElementAt(i).SelMeasureType != type)
|
|
return MeasureTypes.NULL;
|
|
}
|
|
return type;
|
|
}
|
|
set
|
|
{
|
|
for (int i = 0; i < CurrSashGroup.SashList.Count; i++)
|
|
{
|
|
CurrSashGroup.SashList.ElementAt(i).SelMeasureTypeIndex = (int)value;
|
|
}
|
|
var args = new DataUpdateSash
|
|
{
|
|
currSash = CurrSashGroup,
|
|
noSvg = true
|
|
};
|
|
_ = EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
private int ChangeType
|
|
{
|
|
get
|
|
{
|
|
return CurrSashGroup.bIsDimensionLight ? 1 : 0;
|
|
}
|
|
set
|
|
{
|
|
if (value == 1)
|
|
CurrSashGroup.bIsDimensionLight = true;
|
|
else
|
|
CurrSashGroup.bIsDimensionLight = false;
|
|
foreach (var CurrSashDim in CurrSashGroup.SashList)
|
|
{
|
|
if (CurrSashDim.SelMeasureType is MeasureTypes.ABSOLUTE)
|
|
{
|
|
if (CurrSashGroup.bIsDimensionLight)
|
|
{
|
|
CurrSashDim.SetDimensionLight(CurrSashDim.dDimension -
|
|
CurrSashDim.ElementDimensionList.ElementAt(1).dDimension -
|
|
CurrSashDim.ElementDimensionList.Last().dDimension);
|
|
}
|
|
else
|
|
{
|
|
CurrSashDim.SetDimensionLight(CurrSashDim.dDimension +
|
|
CurrSashDim.ElementDimensionList.ElementAt(1).dDimension +
|
|
CurrSashDim.ElementDimensionList.Last().dDimension);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Metodo per rimuovere area corrente
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task RemoveArea()
|
|
{
|
|
CurrSashGroup.Remove();
|
|
if (FrameWindow.SelThreshold.Name.Contains("Threshold") && SashGroupList.IndexOf(CurrSashGroup) == 0)
|
|
{
|
|
Threshold? updThreshold = FrameWindow.ThresholdList.FirstOrDefault(x => x.Name != "Threshold");
|
|
if (updThreshold != null)
|
|
FrameWindow.SelThresholdFromName = updThreshold.Name;
|
|
}
|
|
var args = new DataUpdateFrame()
|
|
{
|
|
currFrame = FrameWindow,
|
|
groupIdDelete = CurrSashGroup.GroupId
|
|
};
|
|
// richiesta reset dict shape
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape });
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDimElem });
|
|
await EC_UpdateFrame.InvokeAsync(args);
|
|
await EC_ReqClose.InvokeAsync(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per cambiare dimensione solo luce
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private Task ChangeTypeDimension(bool type)
|
|
{
|
|
if (CurrSashGroup.bIsDimensionLight != type)
|
|
{
|
|
CurrSashGroup.bIsDimensionLight = type;
|
|
foreach (var CurrSashDim in CurrSashGroup.SashList)
|
|
{
|
|
if (CurrSashDim.SelMeasureType is MeasureTypes.ABSOLUTE)
|
|
{
|
|
if (CurrSashGroup.bIsDimensionLight)
|
|
{
|
|
CurrSashDim.SetDimensionLight(CurrSashDim.dDimension -
|
|
CurrSashDim.ElementDimensionList.ElementAt(1).dDimension -
|
|
CurrSashDim.ElementDimensionList.Last().dDimension);
|
|
}
|
|
else
|
|
{
|
|
CurrSashDim.SetDimensionLight(CurrSashDim.dDimension +
|
|
CurrSashDim.ElementDimensionList.ElementAt(1).dDimension +
|
|
CurrSashDim.ElementDimensionList.Last().dDimension);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
DataUpdateSash args = new DataUpdateSash()
|
|
{
|
|
currSash = CurrSashGroup,
|
|
noSvg = false
|
|
};
|
|
return EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per scegliere tipo di misura
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
//protected Task SetMeasureType(MeasureTypes type)
|
|
//{
|
|
// //isOpen = !isOpen;
|
|
// for (int i = 0; i < CurrSashGroup.SashList.Count; i++)
|
|
// {
|
|
// CurrSashGroup.SashList.ElementAt(i).SelMeasureTypeIndex = (int)type;
|
|
// }
|
|
// var args = new DataUpdateSash
|
|
// {
|
|
// currSash = CurrSashGroup,
|
|
// noSvg = true
|
|
// };
|
|
// return EC_UpdateSashGroup.InvokeAsync(args);
|
|
//}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare la sash dimension
|
|
/// </summary>
|
|
/// <param name="updateSD"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdateSashDimension(SashDimension updateSD)
|
|
{
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
var currRec = CurrSashGroup.SashList.First(x => x.nSashId == updateSD.nSashId);
|
|
if (currRec != null)
|
|
{
|
|
currRec = updateSD;
|
|
var args = new DataUpdateSash
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
await EC_ReqElement.InvokeAsync(CurrSashGroup);
|
|
await EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare sash group
|
|
/// </summary>
|
|
/// <param name="updateS"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdateSash(DataUpdateProfile updateS)
|
|
{
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
if (updateS != null)
|
|
{
|
|
CurrSashGroup = updateS.sash;
|
|
var args = new DataUpdateSash
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
if (updateS.reqProfile)
|
|
await EC_ReqElement.InvokeAsync(CurrSashGroup);
|
|
await EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare sash group
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdateBottomRail(DataBottomRail updRec)
|
|
{
|
|
if (updRec.sash != null)
|
|
{
|
|
CurrSashGroup = updRec.sash;
|
|
var args = new DataUpdateSash
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
await EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare bottom rail
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdateBottomRail(ElementDimension updRec)
|
|
{
|
|
var currRec = CurrSashGroup.BottomRailElemDimList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
|
|
if (currRec != null)
|
|
{
|
|
currRec = updRec;
|
|
var args = new DataUpdateSash
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
await EC_UpdateSashGroup.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per resettare dizionario richiesto
|
|
/// </summary>
|
|
/// <param name="args"></param>
|
|
/// <returns></returns>
|
|
private Task ResetDict(DataUpdateRes args)
|
|
{
|
|
return EC_ReqResetDict.InvokeAsync(args);
|
|
}
|
|
|
|
private void EditView(DataChangeMode args)
|
|
{
|
|
//editMode = args.Edit;
|
|
if(args.IndexSashEdit != -1)
|
|
currSashDimEdit.Add(args.IndexSashEdit);
|
|
if (args.IndexSashClose != -1)
|
|
currSashDimEdit.Remove(args.IndexSashClose);
|
|
_ = EC_EditSashDim.InvokeAsync(currSashDimEdit);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sollevo evento per tornare alla pagina Tree
|
|
/// </summary>
|
|
private void ReqClose()
|
|
{
|
|
_ = EC_ReqClose.InvokeAsync(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento opzioni hardware
|
|
/// </summary>
|
|
/// <param name="argsHw"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdateOpt(DataUpdateHwOption argsHw)
|
|
{
|
|
AGBOptionCombo AGBOptCombo = argsHw.AGBOptCombo;
|
|
AGBOptionText AGBOptText = argsHw.AGBOptText;
|
|
if (AGBOptCombo != null)
|
|
{
|
|
// cerco il record
|
|
var currRec = CurrSashGroup.HwOptionList.FirstOrDefault(x => x.sName == AGBOptCombo.sName && x.sDescription == AGBOptCombo.sDescription);
|
|
currRec = AGBOptCombo;
|
|
}
|
|
else if(AGBOptText != null)
|
|
{
|
|
// cerco il record
|
|
var currRec = CurrSashGroup.HwOptionList.FirstOrDefault(x => x.sName == AGBOptText.sName && x.sDescription == AGBOptText.sDescription);
|
|
currRec = AGBOptText;
|
|
}
|
|
if(AGBOptCombo != null || AGBOptText != null)
|
|
{
|
|
var args = new DataUpdateSash
|
|
{
|
|
currSash = CurrSashGroup
|
|
};
|
|
await EC_UpdateSashGroup.InvokeAsync(args);
|
|
await EC_ReqOptionHw.InvokeAsync(CurrSashGroup);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Prima chiamata hw option list
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private Task FirstHwOptionList()
|
|
{
|
|
var args = new DataUpdateSash { currSash = CurrSashGroup };
|
|
return EC_ReqFirstOptionHw.InvokeAsync(CurrSashGroup);
|
|
}
|
|
|
|
//private bool isOpen = false;
|
|
//private void ToggleDropdown()
|
|
//{
|
|
// isOpen = !isOpen;
|
|
//}
|
|
|
|
private string AreaSashCss(int i)
|
|
{
|
|
if (i == 0)
|
|
return "row mt-4";
|
|
else
|
|
return "row mt-2";
|
|
}
|
|
|
|
private string MeasureTypeCss(MeasureTypes type)
|
|
{
|
|
for (int i = 0; i < CurrSashGroup.SashList.Count; i++)
|
|
{
|
|
if (!CurrSashGroup.SashList.ElementAt(i).MeasureType.Equals(type))
|
|
return "dropdown-item";
|
|
}
|
|
return "dropdown-item fw-bold";
|
|
}
|
|
private string TypeDimensionCss(bool type)
|
|
{
|
|
if(CurrSashGroup.bIsDimensionLight && type)
|
|
return "dropdown-item fw-bold";
|
|
else if(!CurrSashGroup.bIsDimensionLight && !type)
|
|
return "dropdown-item fw-bold";
|
|
return "dropdown-item";
|
|
}
|
|
#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;
|
|
}
|
|
} |