update x gestioen richeiste forme + svg corrette

This commit is contained in:
Samuele Locatelli
2025-10-23 12:38:45 +02:00
parent f3ad3e4ce4
commit 1ed1658195
7 changed files with 195 additions and 77 deletions
+1 -1
View File
@@ -81,7 +81,7 @@
<select class="form-select" id="FamilyHardware" @bind="@CurrItem.SelFamilyHardware">
@if (Sash.s_FamilyHardwareList == null || Sash.s_FamilyHardwareList.Count == 0)
{
<option value="000000">ERROR - Missing family HW List</option>
<option value="000000">CUSTOM</option>
}
else
{
+66 -58
View File
@@ -11,19 +11,6 @@ namespace WebWindowComplex.Models
{
public class Sash : Area
{
public event EventHandler<OnReqShapeEventArgs> OnReqShape = delegate { };
internal void OnReqShapePreview(string sJwd, int groupId)
{
OnReqShapeEventArgs e = new OnReqShapeEventArgs(sJwd, groupId);
EventHandler<OnReqShapeEventArgs> handler = OnReqShape;
if (handler != null)
{
handler(this, e);
}
}
#region Public Fields
// Lista hardware completa passata dal chiamante del componente
@@ -42,12 +29,14 @@ namespace WebWindowComplex.Models
#endregion Public Constructors
#region Public Events
public event EventHandler<OnReqShapeEventArgs> OnReqShape = delegate { };
#endregion Public Events
#region Public Properties
public string sSashShape
{
get => m_CurrShape;
}
public bool bIsMeasureGlass
{
get
@@ -452,6 +441,11 @@ namespace WebWindowComplex.Models
}
}
public string sSashShape
{
get => m_CurrShape;
}
#endregion Public Properties
#region Public Methods
@@ -491,32 +485,6 @@ namespace WebWindowComplex.Models
return newSash;
}
/// <summary>
/// Richiesta calcolo shape corrente
/// </summary>
public void ReqRefreshShape()
{
if (m_HardwareCompleteList != null && m_HardwareCompleteList.Count > 0)
{
m_HardwareList.Clear();
// reset shape corrente
m_CurrShape = "";
// chiamata evento calcolo shape: gruppo da calcolare
OnReqShapePreview(m_ParentWindow.sSerialized(), GroupId);
}
}
/// <summary>
/// Agfgiornamento HW List conseguente a ricezione nuiova Shape
/// </summary>
/// <param name="newShape"></param>
public void UpdateShape(string newShape)
{
m_CurrShape = newShape;
RefreshHardwareList();
}
/// <summary>
/// Update valori ammissibili x HW list
/// </summary>
@@ -543,7 +511,6 @@ namespace WebWindowComplex.Models
}
}
public void Remove()
{
ParentArea.AreaList.Remove(this);
@@ -553,6 +520,40 @@ namespace WebWindowComplex.Models
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
}
/// <summary>
/// Richiesta calcolo shape corrente
/// </summary>
public void ReqRefreshShape()
{
if (m_HardwareCompleteList != null && m_HardwareCompleteList.Count > 0)
{
m_HardwareList.Clear();
// reset shape corrente
m_CurrShape = "";
// chiamata evento calcolo shape: gruppo da calcolare
OnReqShapePreview(m_ParentWindow.sSerialized(), GroupId);
}
}
public void SetSelFamilyHardware(string sFamilyHw)
{
m_SelFamilyHardware = sFamilyHw;
ReqRefreshShape();
RefreshHardwareOptionList();
SetFirstHardware();
}
/// <summary>
/// Agfgiornamento HW List conseguente a ricezione nuiova Shape
/// </summary>
/// <param name="newShape"></param>
public void UpdateShape(string newShape)
{
m_CurrShape = newShape;
RefreshHardwareList();
}
#endregion Public Methods
#region Internal Methods
@@ -657,6 +658,16 @@ namespace WebWindowComplex.Models
}
}
internal void OnReqShapePreview(string sJwd, int groupId)
{
OnReqShapeEventArgs e = new OnReqShapeEventArgs(sJwd, groupId);
EventHandler<OnReqShapeEventArgs> handler = OnReqShape;
if (handler != null)
{
handler(this, e);
}
}
internal void RefreshHardwareOptionList()
{
m_HwdOptionList.Clear();
@@ -751,13 +762,6 @@ namespace WebWindowComplex.Models
m_SashType = SashType;
}
public void SetSelFamilyHardware(string sFamilyHw)
{
m_SelFamilyHardware = sFamilyHw;
ReqRefreshShape();
RefreshHardwareOptionList();
SetFirstHardware();
}
internal string SetSelFamilyHardwareFromIndex(string codHardware)
{
if (string.IsNullOrEmpty(m_SelFamilyHardware))
@@ -765,8 +769,8 @@ namespace WebWindowComplex.Models
var item = m_HardwareCompleteList
.Where(x => x.Id == codHardware)
.Select(x => x.FamilyName)
.ToList();
SelFamilyHardware = item.First();
.FirstOrDefault();
SelFamilyHardware = item ?? "";
}
return SelFamilyHardware;
}
@@ -779,18 +783,22 @@ namespace WebWindowComplex.Models
internal void SetSelHardwareFromId(string sId)
{
if (m_HardwareList.Count == 0)
SelHardware = m_HardwareCompleteList.FirstOrDefault(x => x.Id.Equals(sId)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0);
SelHardware = m_HardwareCompleteList.FirstOrDefault(x => x.Id.Equals(sId)) ?? new Hardware(CustomHwId, "", "", Enums.OpeningTypes.Null, "", 0, 0);
else
SelHardware = m_HardwareList.FirstOrDefault(x => x.Id.Equals(sId)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0);
SelHardware = m_HardwareList.FirstOrDefault(x => x.Id.Equals(sId)) ?? new Hardware(CustomHwId, "", "", Enums.OpeningTypes.Null, "", 0, 0);
if (SelHardware.Id == "")
SelHardware = m_HardwareList.First();
//SelFamilyHardware = m_SelHardware.FamilyName;
SelHardware = m_HardwareList.First();
}
#endregion Internal Methods
#region Private Fields
/// <summary>
/// Codice HW custom x gestione casi non risolvibili di selezione
/// </summary>
private const string CustomHwId = "000000";
private bool m_bIsMeasureGlass;
private bool m_bIsPercentage = true;
@@ -799,6 +807,7 @@ namespace WebWindowComplex.Models
private bool m_bSashBottomRail;
private string m_CurrShape = "";
private List<Hardware> m_HardwareList = new List<Hardware>();
private List<ParametriOpzioni> m_HwdOptionList = new List<ParametriOpzioni>();
@@ -816,7 +825,6 @@ namespace WebWindowComplex.Models
private List<SashDimension> m_SashList = new List<SashDimension>();
private SashTypes m_SashType;
private string m_SelFamilyHardware;
private string m_CurrShape = "";
private Hardware m_SelHardware;
private OrientationSash m_SelOrientationSashType;
+76 -11
View File
@@ -432,7 +432,7 @@ namespace WebWindowComplex
/// Richiesta update anteprima SVG
/// </summary>
/// <returns></returns>
protected async Task DoPreviewSvg()
protected async Task DoPreviewSvg(bool doForce = false)
{
if (m_CurrWindow != null)
{
@@ -442,7 +442,7 @@ namespace WebWindowComplex
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize());
#endif
// verifico variazione JWD
if (!prevJwd.Equals(CurrJwd))
if (!prevJwd.Equals(CurrJwd) || doForce)
{
prevJwd = CurrJwd;
Dictionary<string, string> Args = new Dictionary<string, string>();
@@ -482,9 +482,9 @@ namespace WebWindowComplex
/// <summary>
/// Richiesta Shape compatibile da JWD
/// </summary>
/// <param name="groupId">ID numerico del gruppo da valutare</param>
/// <param name="groupIdList">Lista degli ID numerici dei gruppi da valutare</param>
/// <returns></returns>
protected async Task DoReqShape(int groupId)
protected async Task DoReqShape(List<int> groupIdList)
{
if (m_CurrWindow != null)
{
@@ -501,7 +501,8 @@ namespace WebWindowComplex
Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}");
Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.SASHSHAPE}");
Args.Add("Jwd", CurrJwd);
Args.Add("GroupId", $"{groupId}");
string listGroupId = JsonConvert.SerializeObject(groupIdList);
Args.Add("GroupId", listGroupId);
await EC_DoUpdate.InvokeAsync(Args);
}
}
@@ -562,16 +563,51 @@ namespace WebWindowComplex
protected override async Task OnParametersSetAsync()
{
isLoading = true;
// SOLO SE sono presenti...
if (ListPayload.IsPopulated() && LiveData.IsValid())
{
bool updateSvg = false;
bool updRequested = false;
listErrPre = new Dictionary<string, string>();
listErrLink = new Dictionary<string, string>();
listWarnings = new Dictionary<string, string>();
// controllo elenchi BasePayload siano validi...
if (ListPayload.IsValid())
{
// SOLO SE modificato live data...
if (prevLiveData == null || !prevLiveData.Equals(LiveData))
{
updRequested = true;
prevLiveData = new LivePayload()
{
CurrJwd = LiveData.CurrJwd,
OptionsXml = LiveData.OptionsXml,
DictShape = LiveData.DictShape,
SvgPreview = LiveData.SvgPreview
};
m_SelSVG = LiveData.SvgPreview;
// Aggiornati parametri di ingresso selezionati
UpdateSelParameter();
JsonWindow WindowFromJson = new JsonWindow("", "", "", "");
// provo a deserializzare
try
{
WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(LiveData.CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
setCurrWindow(WindowFromJson);
//SOLO SE non sono in edit...
if (!editLock)
{
currStep = CompileStep.Tree;
}
}
// altrimenti errore!
catch (Exception ex)
{
listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}");
}
}
checkWarnings();
#if false
// controllo sia popolato anche per la componente LIVE
if (LiveData.IsValid())
{
@@ -632,14 +668,28 @@ namespace WebWindowComplex
}
}
updateSvg = true;
}
}
#endif
if (SashList.Count > 0)
{
currAnta = 0;
}
if (updateSvg)
if (updRequested)
{
await DoPreviewSvg();
// se mancasse dizionario forme chiamo quello
if (LiveData.DictShape.Count == 0)
{
List<int> reqList = SashList.Select(x => x.GroupId).ToList();
if (reqList.Count > 0)
{
await DoReqShape(reqList);
}
}
else
{
// chiedo SVG
await DoPreviewSvg(true);
}
}
}
else
@@ -674,6 +724,13 @@ namespace WebWindowComplex
}
if (SashList.Count > 0)
currAnta = 0;
// se ho i dizionari delle forme le aggiungo
if (LiveData.DictShape.Count > 0)
{
// ToDo....
// aggiorno SVG
}
}
/// <summary>
@@ -1203,10 +1260,14 @@ namespace WebWindowComplex
{
FrameWindow = newFrame;
// ciclo x ogni group della mia frame
List<int> reqList = SashList.Select(x => x.GroupId).ToList();
await DoReqShape(reqList);
#if false
foreach (var item in SashList)
{
await DoReqShape(item.GroupId);
}
}
#endif
}
/// <summary>
@@ -1216,7 +1277,11 @@ namespace WebWindowComplex
/// <returns></returns>
private async Task UpdateShape(int groupId)
{
await DoReqShape(groupId);
List<int> reqList = new List<int>() { groupId };
await DoReqShape(reqList);
#if false
await DoReqShape(groupId);
#endif
}
/// <summary>
+21 -1
View File
@@ -6,7 +6,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>2.7.10.2309</Version>
<Version>2.7.10.2312</Version>
<Authors>Annamaria Sassi</Authors>
<Company>Egalware</Company>
<Description>Componente gestione Configurazioni avanzate Window per LUX</Description>
@@ -61,6 +61,26 @@