52bdaec430
- Aggiunto reset shape nell'aggiunta sashGroup - Tolta chiamatareset dict nel cambiare shape split
2007 lines
81 KiB
C#
2007 lines
81 KiB
C#
using Egw.Window.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Newtonsoft.Json;
|
|
using NLog;
|
|
using WebWindowComplex.Compo;
|
|
using WebWindowComplex.DTO;
|
|
using WebWindowComplex.Json;
|
|
using WebWindowComplex.Models;
|
|
using static WebWindowComplex.Json.WindowConst;
|
|
using static WebWindowComplex.LayoutConst;
|
|
|
|
namespace WebWindowComplex
|
|
{
|
|
public partial class TableComp : IDisposable
|
|
{
|
|
#region Public Enums
|
|
|
|
public enum DataReq
|
|
{
|
|
/// <summary>
|
|
/// Nessuna richiesta
|
|
/// </summary>
|
|
None = 0,
|
|
|
|
/// <summary>
|
|
/// Richiesta hardware opzioni
|
|
/// </summary>
|
|
ReqHwOpt,
|
|
|
|
/// <summary>
|
|
/// Richiesta svg senza hw
|
|
/// </summary>
|
|
ReqSvgNoHw,
|
|
|
|
/// <summary>
|
|
/// Richiesta svg con hw
|
|
/// </summary>
|
|
ReqSvgWithHw,
|
|
|
|
/// <summary>
|
|
/// Richiesta shape sash group
|
|
/// </summary>
|
|
ReqShape,
|
|
|
|
/// <summary>
|
|
/// Richiesta element
|
|
/// </summary>
|
|
ReqElement
|
|
}
|
|
|
|
#endregion Public Enums
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Livello di accesso (utente base)
|
|
/// </summary>
|
|
[Parameter]
|
|
public bool baseUser { get; set; } = false!;
|
|
|
|
/// <summary>
|
|
/// Classe override css x SVG (x rescale)
|
|
/// </summary>
|
|
[Parameter]
|
|
public string CssSvg { get; set; } = "responsive-svg";
|
|
|
|
/// <summary>
|
|
/// Richiesta azione al parent
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataAction> EC_ActionReq { get; set; }
|
|
|
|
/// <summary>
|
|
/// Richiesta update da JWD (SVG, calcoli vari...)
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<Dictionary<string, string>> EC_DoUpdate { get; set; }
|
|
|
|
/// <summary>
|
|
/// Richiesta chiusura JWD (+ refresh)
|
|
/// se torna true --> richiesta salvataggio
|
|
/// se torna false --> richiesta revert
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataSave> EC_OnClose { get; set; }
|
|
|
|
/// <summary>
|
|
/// Sollevo evento errore validazione con una lista di errori rilevati
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<Dictionary<string, string>> EC_ValidError { get; set; }
|
|
|
|
/// <summary>
|
|
/// Elenco anagrafiche di base
|
|
/// </summary>
|
|
[Parameter]
|
|
public BaseListPayload ListPayload { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Dati live controllo (JWD, SVG, ...)
|
|
/// </summary>
|
|
[Parameter]
|
|
public LivePayload LiveData { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Preselezione valori
|
|
/// </summary>
|
|
[Parameter]
|
|
public SelectPayload? SelectionData { get; set; } = null;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
if (m_CurrWindow != null)
|
|
{
|
|
m_CurrWindow = null;
|
|
}
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (forceSvgUpdate && prevReq != (int)DataReq.ReqSvgNoHw && prevReq != (int)DataReq.ReqElement)
|
|
{
|
|
firstDisplay = false;
|
|
forceSvgUpdate = false;
|
|
// preview SVG senza HW
|
|
if(prevReq != (int)DataReq.ReqSvgWithHw)
|
|
await DoPreviewSvg(true, true);
|
|
if (LiveData.ProfElementList.Count == 0)
|
|
await UpdateElement(FrameWindow);
|
|
}
|
|
isRendered = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Primo init componente
|
|
/// </summary>
|
|
protected override void OnInitialized()
|
|
{
|
|
// reset editLock...
|
|
editLock = false;
|
|
listErrPre = new Dictionary<string, string>();
|
|
listErrLink = new Dictionary<string, string>();
|
|
listWarnings = new Dictionary<string, string>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gestione update post ricezione parametri da controllo chiamante
|
|
/// </summary>
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
isLoading = true;
|
|
// SOLO SE sono presenti...
|
|
listErrLink = new Dictionary<string, string>();
|
|
okParams = ListPayload.IsPopulated();
|
|
okJwd = LiveData.IsValid();
|
|
if (okParams && okJwd)
|
|
{
|
|
bool updRequested = false;
|
|
listErrPre = new Dictionary<string, string>();
|
|
listWarnings = new Dictionary<string, string>();
|
|
// controllo elenchi BasePayload siano validi...
|
|
if (ListPayload.IsValid())
|
|
{
|
|
bool calculateSvg = false;
|
|
// SOLO SE modificato live data...
|
|
if (prevLiveData == null || !prevLiveData.Equals(LiveData))
|
|
{
|
|
bool needDeser = prevLiveData == null || !prevLiveData.JwdEqual(LiveData);
|
|
calculateSvg = prevLiveData == null || !prevLiveData.DictShape.Equals(LiveData.DictShape);
|
|
updRequested = true;
|
|
prevLiveData = new LivePayload()
|
|
{
|
|
CurrJwd = LiveData.CurrJwd,
|
|
DictOptionsXml = LiveData.DictOptionsXml,
|
|
DictShape = LiveData.DictShape,
|
|
SvgPreview = LiveData.SvgPreview,
|
|
ProfElementList = LiveData.ProfElementList
|
|
};
|
|
// Aggiornati parametri di ingresso selezionati
|
|
UpdateSelParameter();
|
|
// provo a deserializzare SE necessario
|
|
if (needDeser)
|
|
{
|
|
JsonWindow WindowFromJson = new JsonWindow("", "", "", "");
|
|
try
|
|
{
|
|
WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(LiveData.CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
|
|
if (WindowFromJson == null || WindowFromJson.AreaList == null || WindowFromJson.AreaList.Count == 0)
|
|
{
|
|
WindowFromJson = BuildWindowDefault();
|
|
Log.Info("Ricostruito jwd");
|
|
}
|
|
UpdateInputList(WindowFromJson);
|
|
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}");
|
|
Log.Error($"Errore nel deserializzare jwd: {ex.Message}");
|
|
// costruisco una finestra base
|
|
WindowFromJson = BuildWindowDefault();
|
|
await DoPreviewSvg(false);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// usando m_currWindow (preesistente) impostare i parametri...
|
|
UpdateDict();
|
|
}
|
|
}
|
|
if (m_CurrWindow != null && m_CurrWindow.AreaList != null && m_CurrWindow.AreaList.Count > 0)
|
|
{
|
|
checkWarnings();
|
|
if (SashGroupList.Count > 0)
|
|
currAntaIndex = 0;
|
|
if (updRequested)
|
|
{
|
|
// se mancasse dizionario forme chiamo quello
|
|
if (LiveData.DictShape.Count == 0 && listErrLink.Count == 0 && !waitShape)
|
|
{
|
|
waitShape = true;
|
|
if (firstDisplay && isRendered && prevReq!=(int)DataReq.ReqSvgNoHw)
|
|
{
|
|
firstDisplay = false;
|
|
// preview SVG senza HW
|
|
await DoPreviewSvg(true, true);
|
|
if (LiveData.ProfElementList.Count == 0)
|
|
await UpdateElement(FrameWindow);
|
|
}
|
|
else
|
|
{
|
|
forceSvgUpdate = true;
|
|
}
|
|
List<int> reqList = SashGroupList.Select(x => x.GroupId).ToList();
|
|
if (reqList.Count > 0)
|
|
{
|
|
await DoReqShape(reqList);
|
|
}
|
|
}
|
|
else if (LiveData.DictShape.Count > 0 && calculateSvg)
|
|
{
|
|
await DoPreviewSvg();
|
|
}
|
|
else
|
|
{
|
|
if(prevReq != (int)DataReq.ReqSvgWithHw && SashGroupList.Count > 0)
|
|
await DoPreviewSvg();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
JsonWindow WindowFromJson = new JsonWindow("", "", "", "");
|
|
WindowFromJson = BuildWindowDefault();
|
|
await DoPreviewSvg(true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
checkErrorPre();
|
|
}
|
|
}
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private bool waitShape = false;
|
|
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
private int currAntaIndex = 0;
|
|
|
|
private int currFillIndex = -1;
|
|
|
|
private List<string> currLoading = new List<string>();
|
|
|
|
private int currSashIndex = -1;
|
|
|
|
private int currSplitIndex = -1;
|
|
|
|
private CompileStep currStep;
|
|
|
|
private bool editLock = false;
|
|
|
|
private bool firstDisplay = true;
|
|
|
|
private bool forceSvgUpdate = false;
|
|
|
|
private bool groupIdOK = false;
|
|
|
|
/// <summary>
|
|
/// Booleana fase loading
|
|
/// </summary>
|
|
private bool isLoading = false;
|
|
|
|
private bool isRendered = false;
|
|
|
|
/// <summary>
|
|
/// ELenco errori di coerenza/link dati (vanno risolti per disegnare/procedere)
|
|
/// </summary>
|
|
private Dictionary<string, string> listErrLink = new Dictionary<string, string>();
|
|
|
|
/// <summary>
|
|
/// Elenco errori preliminari (mancano elementi di base di validazione modello dati))
|
|
/// </summary>
|
|
private Dictionary<string, string> listErrPre = new Dictionary<string, string>();
|
|
|
|
/// <summary>
|
|
/// Elenco warnings non bloccanti
|
|
/// </summary>
|
|
private Dictionary<string, string> listWarnings = new Dictionary<string, string>();
|
|
|
|
private List<Fill> m_FillList = new List<Fill>();
|
|
|
|
private Frame? m_Frame;
|
|
|
|
private List<ItemTable> m_ItemTableList = new List<ItemTable>();
|
|
|
|
private int m_maxCol = 0;
|
|
|
|
private int m_maxRow = 0;
|
|
|
|
private List<Sash> m_SashList = new List<Sash>();
|
|
|
|
private List<Split> m_SplitList = new List<Split>();
|
|
|
|
private List<Splitted> m_SplittedList = new List<Splitted>();
|
|
|
|
private bool okJwd = false;
|
|
|
|
private bool okParams = false;
|
|
|
|
/// <summary>
|
|
/// Dati live precedenti x comparazione
|
|
/// </summary>
|
|
private LivePayload? prevLiveData = null;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private Dictionary<int, int> Child { get; set; } = new Dictionary<int, int>();
|
|
|
|
private List<Fill> FillList
|
|
{
|
|
get => m_FillList;
|
|
}
|
|
|
|
private Frame FrameWindow
|
|
{
|
|
get => m_Frame!;
|
|
set => m_Frame = value;
|
|
}
|
|
|
|
private List<ItemTable> ItemTableList
|
|
{
|
|
get => m_ItemTableList;
|
|
}
|
|
|
|
private Window? m_CurrWindow { get; set; } = null;
|
|
|
|
private Window? m_PreviousWindow { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Componente SVG da mostrare
|
|
/// </summary>
|
|
private MarkupString outSvg
|
|
{
|
|
get
|
|
{
|
|
// aggiunta gestione classe svg per posizionamento con costraints
|
|
var newSvg = LiveData.SvgPreview.Replace("<svg", $"<svg class=\"{CssSvg}\"");
|
|
return (MarkupString)newSvg;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Salvataggio JWD precedente x evitare loop su update (aggiornato dopo chiamate redis)
|
|
/// </summary>
|
|
private string prevJwd { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Salvataggio tipo di domanda precedente
|
|
/// </summary>
|
|
private int prevReq { get; set; } = 0;
|
|
|
|
private int reqHwOpt { get; set; } = 0;
|
|
|
|
private Dictionary<int, bool> RowCollapsed { get; set; } = new Dictionary<int, bool>();
|
|
|
|
private List<Sash> SashGroupList
|
|
{
|
|
get => m_SashList;
|
|
}
|
|
|
|
private string SelColorMaterial { get; set; } = "";
|
|
|
|
private string SelFamilyHardware { get; set; } = "";
|
|
|
|
private string SelGlass { get; set; } = "";
|
|
|
|
private string SelMaterial { get; set; } = ""!;
|
|
|
|
private string SelProfile { get; set; } = "";
|
|
|
|
private List<Split> SplitList
|
|
{
|
|
get => m_SplitList;
|
|
}
|
|
|
|
private List<Splitted> SplittedList
|
|
{
|
|
get => m_SplittedList;
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Metodo per andare allo step successivo
|
|
/// </summary>
|
|
/// <param name="newStep"> step successivo </param>
|
|
private void AdvStep(CompileStep newStep)
|
|
{
|
|
currStep = newStep;
|
|
currSashIndex = -1;
|
|
currFillIndex = -1;
|
|
currSplitIndex = -1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per ottenere lista di tutti i groupId appartenenti alla window
|
|
/// </summary>
|
|
/// <param name="node"> Area da aggiungere alla lista groupId </param>
|
|
/// <param name="groupIdList"> Lista group id </param>
|
|
private void AllGroupIdList(Area node, List<int> groupIdList)
|
|
{
|
|
if (node != null)
|
|
{
|
|
groupIdList.Add(node.GroupId);
|
|
foreach (var item in node.AreaList)
|
|
{
|
|
AllGroupIdList(item, groupIdList);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per costruire una finestra con vetro fisso
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private JsonWindow BuildWindowDefault()
|
|
{
|
|
// Costruisco window e setto i parametri
|
|
Window window = new Window();
|
|
window.sProfilePath = "Profilo78";
|
|
window.sMaterial = "Pino";
|
|
window.sGlass = "Vetro BE 2S 4T/16/4T";
|
|
window.sColorMaterial = "Wood";
|
|
// Costruisco frame e setto i parametri
|
|
Frame frame = new Frame(null, window);
|
|
frame.SetGroupId(1);
|
|
frame.SetAreaType(AreaTypes.FRAME);
|
|
frame.SetSelShape(Shapes.RECTANGLE);
|
|
frame.SetSelThresholdFromName("Bottom");
|
|
frame.SetBottomRail(false);
|
|
frame.SetBottomRailQty(0);
|
|
window.AreaList.Add(frame);
|
|
List<FrameDimension> DimensionList = new List<FrameDimension>
|
|
{
|
|
new FrameDimension(frame, 1, "Width", 800, false),
|
|
new FrameDimension(frame, 1, "Height", 1200, true)
|
|
};
|
|
List<Joint> JointList = new List<Joint>
|
|
{
|
|
new Joint(frame, 1, Joints.FULL_H),
|
|
new Joint(frame, 2, Joints.FULL_H),
|
|
new Joint(frame, 3, Joints.FULL_H),
|
|
new Joint(frame, 4, Joints.FULL_H)
|
|
};
|
|
frame.JointList = JointList;
|
|
frame.DimensionList = DimensionList;
|
|
// Costruisco fill e setto i parametri
|
|
Fill fill = new Fill(frame, window);
|
|
fill.AreaType = AreaTypes.FILL;
|
|
fill.SelFillType = FillTypes.GLASS;
|
|
fill.GroupId = 2;
|
|
frame.AreaList.Add(fill);
|
|
JsonWindow jsonWindow = window.Serialize();
|
|
string jwd = JsonConvert.SerializeObject(jsonWindow);
|
|
return JsonConvert.DeserializeObject<JsonWindow>(jwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Calcola bottone per tutti i Fill
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string buttonFillCss(FillTypes reqFillTypes)
|
|
{
|
|
foreach (var fill in FillList)
|
|
{
|
|
if (!fill.FillType.Equals(reqFillTypes))
|
|
return "btn btn-outline-secondary btn-sm";
|
|
}
|
|
return "btn btn-secondary btn-sm";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per cambiare tutti i Fill e richiedere aggiornamento SVG
|
|
/// </summary>
|
|
/// <param name="reqFillType"> tipo di fill richiesto </param>
|
|
/// <returns></returns>
|
|
private Task ChangeAllFill(FillTypes reqFillType)
|
|
{
|
|
updateAllFill(FrameWindow, reqFillType);
|
|
return DoPreviewSvg();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifica errori prelimionari per mostrare dove sia il problema
|
|
/// </summary>
|
|
private void checkErrorPre()
|
|
{
|
|
// verifico 1:1 le liste e indico cosa manca
|
|
if (ListPayload.Hardware == null || ListPayload.Hardware.Count == 0)
|
|
{
|
|
listErrPre.Add("Hardware", "Missing Hardware List!");
|
|
Log.Warn("Missing Hardware List");
|
|
}
|
|
else
|
|
{
|
|
if (ListPayload.FamilyHardware == null || ListPayload.FamilyHardware.Count == 0)
|
|
{
|
|
listErrPre.Add("FamilyHardware", "Missing Family HW List!");
|
|
Log.Warn(" Missing Family HW List");
|
|
}
|
|
}
|
|
if (ListPayload.Glass == null || ListPayload.Glass.Count == 0)
|
|
{
|
|
listErrPre.Add("Glass", "Missing Glass List!");
|
|
Log.Warn(" Missing Glass List");
|
|
}
|
|
if (ListPayload.Material == null || ListPayload.Material.Count == 0)
|
|
{
|
|
listErrPre.Add("Material", "Missing Material List!");
|
|
Log.Warn(" Missing Material List");
|
|
}
|
|
if (ListPayload.ColorMaterial == null || ListPayload.ColorMaterial.Count == 0)
|
|
{
|
|
listErrPre.Add("ColorMaterial", "Missing ColorMaterial List!");
|
|
Log.Warn("Missing ColorMaterial List");
|
|
}
|
|
if (ListPayload.ProfileList == null || ListPayload.ProfileList.Count == 0)
|
|
{
|
|
listErrPre.Add("Profile", "Missing Profile data!");
|
|
Log.Warn("Missing Profile data");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per controllare che non ci siano duplicati di GroupId
|
|
/// </summary>
|
|
/// <param name="window"></param>
|
|
/// <returns></returns>
|
|
private bool CheckGroupId(Window window)
|
|
{
|
|
List<int> groupIdList = new List<int>();
|
|
AllGroupIdList(window.AreaList.First(), groupIdList);
|
|
var duplicati = groupIdList.GroupBy(x => x)
|
|
.Where(g => g.Count() > 1)
|
|
.Select(g => g.Key)
|
|
.ToList();
|
|
return duplicati.Count > 0 ? false : true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifica warning minori (es coerenza colori...)
|
|
/// </summary>
|
|
private void checkWarnings()
|
|
{
|
|
// verifico 1:1 le liste e i valori siano coerenti...
|
|
if (ListPayload.ColorMaterial != null && ListPayload.ColorMaterial.Count > 0)
|
|
{
|
|
if (m_CurrWindow != null)
|
|
{
|
|
if (ListPayload.ColorMaterial == null || !ListPayload.ColorMaterial.Contains(m_CurrWindow.sColorMaterial))
|
|
{
|
|
listWarnings.Add("ColorMaterial", $"Missing Color: {m_CurrWindow.sColorMaterial}");
|
|
}
|
|
if (ListPayload.Glass == null || !ListPayload.Glass.Contains(m_CurrWindow.sGlass))
|
|
{
|
|
listWarnings.Add("Glass", $"Missing Glass: {m_CurrWindow.sGlass}");
|
|
}
|
|
if (ListPayload.Material == null || !ListPayload.Material.Contains(m_CurrWindow.sMaterial))
|
|
{
|
|
listWarnings.Add("Material", $"Missing Material: {m_CurrWindow.sMaterial}");
|
|
}
|
|
if (ListPayload.ProfileList == null || !ListPayload.ProfileList.Any(x => x.ProfileName.Contains(m_CurrWindow.sProfilePath)))
|
|
{
|
|
listWarnings.Add("Profile", $"Missing Profile: {m_CurrWindow.sProfilePath}");
|
|
}
|
|
if (!groupIdOK)
|
|
{
|
|
listWarnings.Add("GroupId", "JWD not correct!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare il valore collassato degli elementi della gerarchia
|
|
/// </summary>
|
|
/// <param name="Args"></param>
|
|
private void CollapsedRowTree(Dictionary<int, bool> Args)
|
|
{
|
|
foreach (var item in Args)
|
|
{
|
|
RowCollapsed[item.Key] = Args[item.Key] ? true : false;
|
|
if (m_ItemTableList.FirstOrDefault(x => x.Row == item.Key) != null)
|
|
{
|
|
Child[item.Key] = m_ItemTableList.FirstOrDefault(x => x.Row == item.Key)!.NumChild;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per riempire la lista ItemTable in modo da poter rappresentarla come tabella
|
|
/// </summary>
|
|
/// <param name="node"> Area da classificare </param>
|
|
/// <param name="row"> numero di riga </param>
|
|
/// <param name="col"> numero di colonna </param>
|
|
/// <param name="maxRow"> numero di riga massimo </param>
|
|
/// <param name="maxCol"> numero di colonna massimo </param>
|
|
private void CreateElementTable(Area node, int row, int col, int maxRow, int maxCol)
|
|
{
|
|
if (node != null)
|
|
{
|
|
switch (node.AreaType)
|
|
{
|
|
case AreaTypes.FRAME:
|
|
{
|
|
if (node.AreaList.Count >= 1)
|
|
ItemTableList.Add(new ItemTable(AreaTypes.FRAME, "FR", row, col, -1, node.AreaList.Count));
|
|
else
|
|
ItemTableList.Add(new ItemTable(AreaTypes.FRAME, "FR", row, col, -1, 0));
|
|
row++;
|
|
col++;
|
|
maxRow++;
|
|
maxCol++;
|
|
break;
|
|
}
|
|
case AreaTypes.SASH:
|
|
{
|
|
string nWIndow;
|
|
// Se ha fratelli
|
|
if ((node.ParentArea.ParentArea != null && node.ParentArea.ParentArea.AreaList.Count > 1) ||
|
|
(node.ParentArea != null && node.ParentArea.AreaList.Count > 1))
|
|
{
|
|
for (int i = 0; i < SashGroupList.Count; i++)
|
|
{
|
|
if (SashGroupList[i].Equals(node))
|
|
{
|
|
nWIndow = SashGroupList.Count == 1 ? "" : $"{i + 1}";
|
|
// Se il nodo ha figli, salvo il numero nell'oggetto
|
|
if (node.AreaList.Count >= 1)
|
|
ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SG" + nWIndow, maxRow, col, i, node.AreaList.Count));
|
|
else
|
|
ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SG" + nWIndow, maxRow, col, i, 0));
|
|
}
|
|
}
|
|
maxCol++;
|
|
}
|
|
else
|
|
{
|
|
// Se il nodo ha figli, salvo il numero nell'oggetto
|
|
if (node.AreaList.Count >= 1)
|
|
ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SG", row, col, 0, node.AreaList.Count));
|
|
else
|
|
ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SG", row, col, 0, 0));
|
|
maxCol++;
|
|
}
|
|
row++;
|
|
col++;
|
|
maxRow++;
|
|
break;
|
|
}
|
|
case AreaTypes.FILL:
|
|
{
|
|
if ((node.ParentArea.AreaList.Count > 1 && node.ParentArea.AreaList.First().Equals(node)) ||
|
|
(node.ParentArea.ParentArea != null && node.ParentArea.ParentArea.AreaList.Count > 1 && node.ParentArea.ParentArea.AreaList.First().AreaList.First().Equals(node)))
|
|
maxCol++;
|
|
string nFill;
|
|
for (int i = 0; i < FillList.Count; i++)
|
|
{
|
|
if (FillList[i].Equals(node))
|
|
{
|
|
nFill = FillList.Count == 1 ? "" : $"{i + 1}";
|
|
if (node.AreaList.Count == 0)
|
|
ItemTableList.Add(new ItemTable(AreaTypes.FILL, "FL" + nFill, maxRow, col, i, 0));
|
|
else
|
|
ItemTableList.Add(new ItemTable(AreaTypes.FILL, "FL" + nFill, maxRow, col, i, node.AreaList.Count));
|
|
break;
|
|
}
|
|
}
|
|
row++;
|
|
col++;
|
|
maxRow++;
|
|
break;
|
|
}
|
|
case AreaTypes.SPLIT:
|
|
{
|
|
// Se il nodo ha fratelli o cugini
|
|
if (node.ParentArea.AreaList.Count > 1 || (node.ParentArea.ParentArea != null && node.ParentArea.ParentArea.AreaList.Count > 1))
|
|
{
|
|
if (node.ParentArea.AreaList.First().Equals(node) || node.ParentArea.ParentArea.AreaList.First().Equals(node))
|
|
maxCol++;
|
|
for (int i = 0; i < SplitList.Count; i++)
|
|
{
|
|
if (SplitList[i].Equals(node))
|
|
{
|
|
string nSplit = SplitList.Count == 1 ? "" : $"{i + 1}";
|
|
if (node.AreaList.Count >= 1)
|
|
ItemTableList.Add(new ItemTable(AreaTypes.SPLIT, "SP" + nSplit, maxRow, col, i, node.AreaList.Count));
|
|
else
|
|
ItemTableList.Add(new ItemTable(AreaTypes.SPLIT, "SP" + nSplit, maxRow, col, i, 0));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < SplitList.Count; i++)
|
|
{
|
|
if (SplitList[i].Equals(node))
|
|
{
|
|
string nSplit = SplitList.Count == 1 ? "" : $"{i + 1}";
|
|
if (node.AreaList.Count >= 1)
|
|
ItemTableList.Add(new ItemTable(AreaTypes.SPLIT, "SP" + nSplit, row, col, i, node.AreaList.Count));
|
|
else
|
|
ItemTableList.Add(new ItemTable(AreaTypes.SPLIT, "SP" + nSplit, row, col, i, 0));
|
|
maxCol++;
|
|
}
|
|
}
|
|
}
|
|
row++;
|
|
col++;
|
|
maxRow++;
|
|
break;
|
|
}
|
|
case AreaTypes.SPLITTED:
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
foreach (var item in node.AreaList)
|
|
{
|
|
if (maxRow < m_maxRow)
|
|
CreateElementTable(item, row, col, m_maxRow, maxCol);
|
|
else
|
|
CreateElementTable(item, row, col, maxRow, maxCol);
|
|
}
|
|
}
|
|
if (maxCol > m_maxCol)
|
|
{
|
|
m_maxCol = maxCol;
|
|
}
|
|
if (maxRow > m_maxRow)
|
|
{
|
|
m_maxRow = maxRow;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per riempire le liste Sash, Split, Splitted e Fill
|
|
/// </summary>
|
|
/// <param name="node"> Area da classificare </param>
|
|
/// <param name="IntoSash"> Parametro per sapere se si è dentro un'anta </param>
|
|
private void CreateWindowsList(Area node, bool IntoSash)
|
|
{
|
|
if (node != null)
|
|
{
|
|
if (node.ParentArea is Sash || IntoSash == true)
|
|
IntoSash = true;
|
|
switch (node.AreaType)
|
|
{
|
|
case AreaTypes.FRAME:
|
|
{
|
|
FrameWindow = (Frame)node;
|
|
break;
|
|
}
|
|
case AreaTypes.SASH:
|
|
{
|
|
m_SashList.Add((Sash)node);
|
|
break;
|
|
}
|
|
case AreaTypes.FILL:
|
|
{
|
|
m_FillList.Add((Fill)node);
|
|
break;
|
|
}
|
|
case AreaTypes.SPLIT:
|
|
{
|
|
m_SplitList.Add((Split)node);
|
|
break;
|
|
}
|
|
case AreaTypes.SPLITTED:
|
|
{
|
|
if (node.ParentArea is Split && !IntoSash && node.AreaList.First() is Fill)
|
|
{
|
|
m_SplittedList.Add((Splitted)node);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
foreach (var item in node.AreaList)
|
|
{
|
|
CreateWindowsList(item, IntoSash);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Calcola CSS warning
|
|
/// </summary>
|
|
/// <param name="fKey"></param>
|
|
/// <returns></returns>
|
|
private string cssValid(string fKey)
|
|
{
|
|
return listWarnings.ContainsKey(fKey) ? "border border-danger" : "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Richiesta chiusura SENZA salvataggio (= restore prev)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task DoClose()
|
|
{
|
|
editLock = false;
|
|
Log.Info("Richiesta Chiusura");
|
|
//return EC_OnClose.InvokeAsync(false);
|
|
if (m_CurrWindow != null)
|
|
{
|
|
#if DEBUG
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented);
|
|
#else
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize());
|
|
#endif
|
|
//manca salvataggio JWD
|
|
DataSave dataSave = new DataSave()
|
|
{
|
|
currJwd = CurrJwd,
|
|
ForceSave = false,
|
|
};
|
|
await EC_OnClose.InvokeAsync(dataSave);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Richiesta update anteprima SVG
|
|
/// </summary>
|
|
/// <param name="doForce">Forza richiesta anche con JWD invariato</param>
|
|
/// <param name="hideHw">Nasconde hw (def. false) poiché senza è piu rapido</param>
|
|
/// <returns></returns>
|
|
private async Task DoPreviewSvg(bool doForce = false, bool hideHw = false)
|
|
{
|
|
if (m_CurrWindow != null)
|
|
{
|
|
#if DEBUG
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(false), Formatting.Indented);
|
|
var CalcJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(hideHw), Formatting.Indented);
|
|
#else
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(false));
|
|
var CalcJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(hideHw));
|
|
#endif
|
|
// verifico variazione JWD
|
|
if (!prevJwd.Equals(CurrJwd) || doForce || (prevReq != (int)DataReq.ReqSvgWithHw && prevReq != (int)DataReq.ReqSvgNoHw))
|
|
{
|
|
string stringLog = "Richiesta svg " + (hideHw ? "senza" : "con") + " hw";
|
|
Log.Info(stringLog);
|
|
prevJwd = CurrJwd;
|
|
prevReq = hideHw ? (int)DataReq.ReqSvgNoHw : (int)DataReq.ReqSvgWithHw;
|
|
Dictionary<string, string> Args = new Dictionary<string, string>();
|
|
Args.Add("Mode", $"{(int)Enums.QuestionModes.PREVIEW}");
|
|
Args.Add("SerializedData", CalcJwd);
|
|
await EC_DoUpdate.InvokeAsync(Args);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Richiesta Profili Element da JWD
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task DoReqElement(List<int> groupIdList)
|
|
{
|
|
if (m_CurrWindow != null)
|
|
{
|
|
#if DEBUG
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented);
|
|
#else
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize());
|
|
#endif
|
|
// verifico variazione JWD
|
|
if (!prevJwd.Equals(CurrJwd) || prevReq != (int)DataReq.ReqElement)
|
|
{
|
|
Log.Info("Richiesta profili elementi");
|
|
prevJwd = CurrJwd;
|
|
prevReq = (int)DataReq.ReqElement;
|
|
Dictionary<string, string> Args = new Dictionary<string, string>();
|
|
Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}");
|
|
Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.PROFILEDATAFROMAREA}");
|
|
Args.Add("SerializedData", CurrJwd);
|
|
string listGroupId = JsonConvert.SerializeObject(groupIdList);
|
|
Args.Add("GroupId", listGroupId);
|
|
await EC_DoUpdate.InvokeAsync(Args);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Richiesta calcolo Options HW
|
|
/// </summary>
|
|
/// <param name="groupIdList">Lista degli ID numerici dei gruppi da valutare</param>
|
|
/// <returns></returns>
|
|
private async Task DoReqOptHardware(List<int> groupIdList, bool isFirst = false)
|
|
{
|
|
if (m_CurrWindow != null)
|
|
{
|
|
loadListAdd("LoadHwOpt");
|
|
#if DEBUG
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented);
|
|
#else
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize());
|
|
#endif
|
|
// verifico variazione JWD
|
|
if (!prevJwd.Equals(CurrJwd) || isFirst || prevReq != (int)DataReq.ReqHwOpt)
|
|
{
|
|
Log.Info("Richiesta Hardware option");
|
|
prevJwd = CurrJwd;
|
|
prevReq = (int)DataReq.ReqHwOpt;
|
|
Dictionary<string, string> Args = new Dictionary<string, string>();
|
|
Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}");
|
|
Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.HARDWAREOPTIONS}");
|
|
Args.Add("SerializedData", CurrJwd);
|
|
string listGroupId = JsonConvert.SerializeObject(groupIdList);
|
|
Args.Add("GroupId", listGroupId);
|
|
await EC_DoUpdate.InvokeAsync(Args);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Richiesta Shape compatibile da JWD
|
|
/// </summary>
|
|
/// <param name="groupIdList">Lista degli ID numerici dei gruppi da valutare</param>
|
|
/// <returns></returns>
|
|
private async Task DoReqShape(List<int> groupIdList)
|
|
{
|
|
if (m_CurrWindow != null)
|
|
{
|
|
#if DEBUG
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented);
|
|
#else
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize());
|
|
#endif
|
|
// verifico variazione JWD
|
|
if (!prevJwd.Equals(CurrJwd) || prevReq != (int)DataReq.ReqShape)
|
|
//if (!prevLiveData.CurrJwd.Equals(CurrJwd))
|
|
{
|
|
Log.Info("Richiesta shape");
|
|
prevJwd = CurrJwd;
|
|
prevReq = (int)DataReq.ReqShape;
|
|
Dictionary<string, string> Args = new Dictionary<string, string>();
|
|
Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}");
|
|
Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.SASHSHAPE}");
|
|
Args.Add("SerializedData", CurrJwd);
|
|
string listGroupId = JsonConvert.SerializeObject(groupIdList);
|
|
Args.Add("GroupId", listGroupId);
|
|
await EC_DoUpdate.InvokeAsync(Args);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo di reset
|
|
/// </summary>
|
|
private Task DoReset()
|
|
{
|
|
Log.Info("Richiesta reset");
|
|
return Task.CompletedTask;
|
|
// Da fare
|
|
}
|
|
|
|
/// <summary>
|
|
/// Richiesta chiusura con salvataggio
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private Task DoSave()
|
|
{
|
|
editLock = false;
|
|
Log.Info("Richiesta Salvataggio");
|
|
//return EC_OnClose.InvokeAsync(false);
|
|
if (m_CurrWindow != null)
|
|
{
|
|
#if DEBUG
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented);
|
|
#else
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize());
|
|
#endif
|
|
//manca salvataggio JWD
|
|
DataSave dataSave = new DataSave()
|
|
{
|
|
currJwd = CurrJwd,
|
|
ForceSave = true,
|
|
};
|
|
return EC_OnClose.InvokeAsync(dataSave);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Helper aggiunta elemento a lista caricamento (per caricamento opzioni hw)
|
|
/// </summary>
|
|
/// <param name="loadCode"></param>
|
|
private void loadListAdd(string loadCode)
|
|
{
|
|
if (!currLoading.Contains(loadCode))
|
|
{
|
|
currLoading.Add(loadCode);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Helper rimozione elemento a lista caricamento
|
|
/// </summary>
|
|
/// <param name="loadCode"></param>
|
|
private void loadListRem(string loadCode)
|
|
{
|
|
if (currLoading.Contains(loadCode))
|
|
{
|
|
currLoading.Remove(loadCode);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per cambiare step
|
|
/// </summary>
|
|
/// <param name="newStep"> step successivo </param>
|
|
private void NextStep(CompileStep newStep, int Index = 1)
|
|
{
|
|
editLock = true;
|
|
currStep = newStep;
|
|
switch (newStep)
|
|
{
|
|
case CompileStep.Sash:
|
|
{
|
|
currSashIndex = Index;
|
|
currFillIndex = -1;
|
|
currSplitIndex = -1;
|
|
break;
|
|
}
|
|
case CompileStep.Fill:
|
|
{
|
|
currFillIndex = Index;
|
|
currSashIndex = -1;
|
|
currSplitIndex = -1;
|
|
break;
|
|
}
|
|
case CompileStep.Split:
|
|
{
|
|
currSplitIndex = Index;
|
|
currSashIndex = -1;
|
|
currFillIndex = -1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per cambiare step
|
|
/// </summary>
|
|
/// <param name="Args"></param>
|
|
private void NextStepArgs(DataNextStep Args)
|
|
{
|
|
CompileStep newStep = Args.currCompileStep;
|
|
int Index = Args.index;
|
|
NextStep(newStep, Index);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rimozione area da frame corrente
|
|
/// </summary>
|
|
/// <param name="remove"> oggetto da rimuovere </param>
|
|
/// <returns></returns>
|
|
private async Task RemoveArea(DataNextStep remove)
|
|
{
|
|
if (remove.currCompileStep is CompileStep.Sash)
|
|
{
|
|
SashGroupList.ElementAt(remove.index).Remove();
|
|
if (FrameWindow.SelThreshold.Name.Contains("Threshold") && remove.index == 0)
|
|
{
|
|
Threshold? updThreshold = FrameWindow.ThresholdList.FirstOrDefault(x => x.Name != "Threshold");
|
|
if (updThreshold != null)
|
|
FrameWindow.SelThresholdFromName = updThreshold.Name;
|
|
}
|
|
SashGroupList.RemoveAt(remove.index);
|
|
}
|
|
else if (remove.currCompileStep is CompileStep.Split)
|
|
{
|
|
SplitList.ElementAt(remove.index).Remove();
|
|
SplitList.RemoveAt(remove.index);
|
|
}
|
|
await EC_ActionReq.InvokeAsync(DataAction.ResetDimElem);
|
|
await DoPreviewSvg();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Richiesta opzioni hardware per la prima volta
|
|
/// </summary>
|
|
/// <param name="newSash"> nuovo frame </param>
|
|
/// <returns></returns>
|
|
private async Task ReqFirstOptionHw(Sash newSash)
|
|
{
|
|
if (newSash != null)
|
|
{
|
|
// cerco il record
|
|
var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId);
|
|
// lo aggiorno
|
|
currRec = newSash;
|
|
// resetto hw list
|
|
await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt);
|
|
// richiesta calcolo opzioni hardware per la singola sash group
|
|
List<int> reqList = SashGroupList.Select(x => x.GroupId).ToList();
|
|
// chiamo con gruppo della nuova sash
|
|
await DoReqOptHardware(reqList);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lista completa dei group id per le richieste
|
|
/// </summary>
|
|
/// <param name="node"> nodo da controllare </param>
|
|
/// <param name="groupId"> Lista groupId </param>
|
|
private void ReqGroupIdList(Area node, List<int> groupId)
|
|
{
|
|
if (node.AreaList == null)
|
|
return;
|
|
if (node is Sash || node is Split)
|
|
groupId.Add(node.GroupId);
|
|
foreach (var child in node.AreaList)
|
|
ReqGroupIdList(child, groupId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Richiesta reset dizionario Shape con action
|
|
/// </summary>
|
|
/// <param name="args"></param>
|
|
private Task ReqResetDict(DataUpdateRes args)
|
|
{
|
|
return EC_ActionReq.InvokeAsync(args.req);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ritorno step Tree
|
|
/// </summary>
|
|
/// <param name="args"></param>
|
|
private void ReturnTree(bool args)
|
|
{
|
|
AdvStep(CompileStep.Tree);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per cercare un area precisa partendo da GroupId
|
|
/// </summary>
|
|
/// <param name="currentArea"> Area che si sta analizzando </param>
|
|
/// <param name="idSearch"> Id Area che si sta cercando </param>
|
|
/// <returns></returns>
|
|
private Area? SearchAreaFromGroupId(Area currentArea, int idSearch)
|
|
{
|
|
if (currentArea.GroupId == idSearch)
|
|
{
|
|
return currentArea;
|
|
}
|
|
foreach (Area child in currentArea.AreaList)
|
|
{
|
|
Area? found = SearchAreaFromGroupId(child, idSearch);
|
|
if (found != null)
|
|
return found;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per costruire oggetti della Window
|
|
/// </summary>
|
|
/// <param name="WindowFromJson"></param>
|
|
private void setCurrWindow(JsonWindow WindowFromJson)
|
|
{
|
|
if (m_CurrWindow != null)
|
|
{
|
|
m_CurrWindow = null;
|
|
}
|
|
m_CurrWindow = WindowFromJson.Deserialize();
|
|
groupIdOK = CheckGroupId(m_CurrWindow);
|
|
if (groupIdOK)
|
|
{
|
|
FrameWindow = m_CurrWindow.AreaList[0];
|
|
if (m_PreviousWindow != null)
|
|
{
|
|
for (int i = 0; i < 2; i++)
|
|
m_CurrWindow.AreaList.First().DimensionList[i].dDimension = m_PreviousWindow.AreaList.First().DimensionList[i].dDimension;
|
|
if (m_CurrWindow.AreaList.First().Shape == Shapes.TRIANGLE)
|
|
{
|
|
for (int i = 0; i < 2; i++)
|
|
m_CurrWindow.AreaList.First().JointList[i].SelJointType = m_PreviousWindow.AreaList.First().JointList[i].SelJointType;
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
m_CurrWindow.AreaList.First().JointList[i].SelJointType = m_PreviousWindow.AreaList.First().JointList[i].SelJointType;
|
|
}
|
|
}
|
|
if (m_CurrWindow != null)
|
|
{
|
|
// Aggiornamento liste sash, split, splitted, fill e itemTable
|
|
UpdateLists();
|
|
}
|
|
if (SashGroupList.Count > 0)
|
|
currAntaIndex = 0;
|
|
// Aggiorno window con dati shape e hw option
|
|
UpdateDict();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per calcolare overlap per gli elementi delle ante
|
|
/// </summary>
|
|
/// <param name="sash"> sash group </param>
|
|
/// <param name="anta"> anta </param>
|
|
/// <param name="indexAnta"> indice anta </param>
|
|
/// <param name="elemList"> lista elementi </param>
|
|
private void SetOverlapSash(Sash sash, SashDimension anta, int indexAnta, List<ElementDimension> elemList)
|
|
{
|
|
string overlapNameBottom = "";
|
|
string overlapNameTop = "";
|
|
string overlapNameSx = "";
|
|
string overlapNameDx = "";
|
|
elemList = anta.ElementDimensionList;
|
|
List<ElementDimension> elemOld = elemList;
|
|
foreach (var elem in sash.BottomRailElemDimList)
|
|
{
|
|
elem.SetOverlapElement(Window.m_ParameterList.GetValueOrDefault("Sash_BottomRail_Overlap"));
|
|
}
|
|
if (sash.ParentArea is Frame || (sash.ParentArea.ParentArea is Split split && split.nSplitQtyHoriz == 0))
|
|
{
|
|
Frame frame = sash.ParentWindow.AreaList.First();
|
|
if (frame.SelThreshold.Name.Contains("Threshold"))
|
|
overlapNameBottom = "Sash_Threshold";
|
|
else
|
|
overlapNameBottom = "Sash_Bottom";
|
|
overlapNameTop = "Sash_Top";
|
|
if (sash.ParentArea is Frame)
|
|
{
|
|
if (sash.SashList.Count == 1)
|
|
{
|
|
overlapNameDx = "Sash_Top";
|
|
overlapNameSx = "Sash_Top";
|
|
}
|
|
else
|
|
{
|
|
if (indexAnta == 0)
|
|
{
|
|
overlapNameDx = string.Join("_", elemList.ElementAt(1).sName.Split('_').Skip(1));
|
|
overlapNameSx = "Sash_Top";
|
|
}
|
|
else if (indexAnta == sash.SashList.Count - 1)
|
|
{
|
|
overlapNameDx = "Sash_Top";
|
|
overlapNameSx = string.Join("_", elemList.Last().sName.Split('_').Skip(1));
|
|
}
|
|
else
|
|
{
|
|
overlapNameDx = string.Join("_", elemList.ElementAt(1).sName.Split('_').Skip(1));
|
|
overlapNameSx = string.Join("_", elemList.Last().sName.Split('_').Skip(1));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Split s = (Split)sash.ParentArea.ParentArea;
|
|
int indexAreaSplit = s.AreaList.IndexOf(sash.ParentArea);
|
|
int indexSplit = indexAreaSplit == 0 ? 0 : indexAreaSplit - 1;
|
|
if (indexAreaSplit == 0)
|
|
{
|
|
if (sash.SashList.Count == 1)
|
|
{
|
|
if (s.ElemDimVertList.ElementAt(indexSplit).sName.Contains("Mixed"))
|
|
overlapNameDx = "Mixed_Split_Top";
|
|
else
|
|
overlapNameDx = "Sash_Vertical";
|
|
overlapNameSx = "Sash_Top";
|
|
}
|
|
else
|
|
{
|
|
if (indexAnta == 0)
|
|
{
|
|
overlapNameDx = string.Join("_", elemList.ElementAt(1).sName.Split('_').Skip(1));
|
|
overlapNameSx = "Sash_Top";
|
|
}
|
|
else if (indexAnta == sash.SashList.Count - 1)
|
|
{
|
|
if (s.ElemDimVertList.ElementAt(indexSplit).sName.Contains("Mixed"))
|
|
overlapNameDx = "Mixed_Split_Top";
|
|
else
|
|
overlapNameDx = "Sash_Vertical";
|
|
overlapNameSx = string.Join("_", elemList.Last().sName.Split('_').Skip(1));
|
|
}
|
|
else
|
|
{
|
|
overlapNameDx = string.Join("_", elemList.ElementAt(1).sName.Split('_').Skip(1));
|
|
overlapNameSx = string.Join("_", elemList.Last().sName.Split('_').Skip(1));
|
|
}
|
|
}
|
|
}
|
|
else if (indexAreaSplit == s.AreaList.Count() - 1)
|
|
{
|
|
if (sash.SashList.Count == 1)
|
|
{
|
|
if (s.ElemDimVertList.ElementAt(indexSplit).sName.Contains("Mixed"))
|
|
overlapNameSx = "Mixed_Split_Top";
|
|
else
|
|
overlapNameSx = "Sash_Vertical";
|
|
overlapNameDx = "Sash_Top";
|
|
}
|
|
else
|
|
{
|
|
if (indexAnta == 0)
|
|
{
|
|
overlapNameDx = string.Join("_", elemList.ElementAt(1).sName.Split('_').Skip(1));
|
|
if (s.ElemDimVertList.ElementAt(indexSplit).sName.Contains("Mixed"))
|
|
overlapNameSx = "Mixed_Split_Top";
|
|
else
|
|
overlapNameSx = "Sash_Vertical";
|
|
}
|
|
else if (indexAnta == sash.SashList.Count - 1)
|
|
{
|
|
overlapNameDx = "Sash_Top";
|
|
overlapNameSx = string.Join("_", elemList.Last().sName.Split('_').Skip(1));
|
|
}
|
|
else
|
|
{
|
|
overlapNameDx = string.Join("_", elemList.ElementAt(1).sName.Split('_').Skip(1));
|
|
overlapNameSx = string.Join("_", elemList.Last().sName.Split('_').Skip(1));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (sash.SashList.Count == 1)
|
|
{
|
|
if (s.ElemDimVertList.ElementAt(indexSplit).sName.Contains("Mixed"))
|
|
overlapNameDx = "Mixed_Split_Top";
|
|
else
|
|
overlapNameDx = "Sash_Vertical_Top";
|
|
if (s.ElemDimVertList.ElementAt(indexSplit).sName.Contains("Mixed"))
|
|
overlapNameSx = "Mixed_Split_Top";
|
|
else
|
|
overlapNameSx = "Sash_Vertical";
|
|
}
|
|
else
|
|
{
|
|
if (indexAnta == 0)
|
|
{
|
|
overlapNameDx = string.Join("_", elemList.ElementAt(1).sName.Split('_').Skip(1));
|
|
if (s.ElemDimVertList.ElementAt(indexSplit).sName.Contains("Mixed"))
|
|
overlapNameSx = "Mixed_Split_Top";
|
|
else
|
|
overlapNameSx = "Sash_Vertical";
|
|
}
|
|
else if (indexAnta == sash.SashList.Count - 1)
|
|
{
|
|
if (s.ElemDimVertList.ElementAt(indexSplit).sName.Contains("Mixed"))
|
|
overlapNameDx = "Mixed_Split_Top";
|
|
else
|
|
overlapNameDx = "Sash_Vertical";
|
|
overlapNameSx = string.Join("_", elemList.Last().sName.Split('_').Skip(1));
|
|
}
|
|
else
|
|
{
|
|
overlapNameDx = string.Join("_", elemList.ElementAt(1).sName.Split('_').Skip(1));
|
|
overlapNameSx = string.Join("_", elemList.Last().sName.Split('_').Skip(1));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (sash.ParentArea.ParentArea is Split s && s.nSplitQtyHoriz > 0)
|
|
{
|
|
int indexAreaSplit = s.AreaList.IndexOf(sash.ParentArea);
|
|
int indexSplit = indexAreaSplit == 0 ? 0 : indexAreaSplit - 1;
|
|
if (indexAreaSplit == 0)
|
|
{
|
|
overlapNameBottom = "Sash_Bottom";
|
|
overlapNameTop = "Mixed_Split_Top";
|
|
}
|
|
else if (indexAreaSplit == s.AreaList.Count() - 1)
|
|
{
|
|
if (s.ElemDimHorizList.ElementAt(indexSplit).sName.Contains("Mixed"))
|
|
overlapNameBottom = "Mixed_Split_Bottom";
|
|
else
|
|
overlapNameBottom = "Sash_Horizontal_Bottom";
|
|
overlapNameTop = "Sash_Top";
|
|
}
|
|
else
|
|
{
|
|
if (s.ElemDimHorizList.ElementAt(indexSplit).sName.Contains("Mixed"))
|
|
overlapNameBottom = "Mixed_Split_Bottom";
|
|
else
|
|
overlapNameBottom = "Sash_Horizontal_Bottom";
|
|
if (s.ElemDimHorizList.ElementAt(indexSplit).sName.Contains("Mixed"))
|
|
overlapNameTop = "Mixed_Split_Top";
|
|
else
|
|
overlapNameTop = "Sash_Horizontal_Top";
|
|
}
|
|
if (sash.SashList.Count == 1)
|
|
{
|
|
overlapNameDx = "Sash_Top";
|
|
overlapNameSx = "Sash_Top";
|
|
}
|
|
else
|
|
{
|
|
if (indexAnta == 0)
|
|
{
|
|
overlapNameDx = string.Join("_", elemList.ElementAt(1).sName.Split('_').Skip(1));
|
|
overlapNameSx = "Sash_Top";
|
|
}
|
|
else if (indexAnta == sash.SashList.Count - 1)
|
|
{
|
|
overlapNameDx = "Sash_Top";
|
|
overlapNameSx = string.Join("_", elemList.Last().sName.Split('_').Skip(1));
|
|
}
|
|
else
|
|
{
|
|
overlapNameDx = string.Join("_", elemList.ElementAt(1).sName.Split('_').Skip(1));
|
|
overlapNameSx = string.Join("_", elemList.Last().sName.Split('_').Skip(1));
|
|
}
|
|
}
|
|
}
|
|
elemList.First().SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapNameBottom + "_Overlap"));
|
|
elemList.ElementAt(1).SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapNameDx + "_Overlap"));
|
|
for (int elem = 2; elem <= elemList.Count - 2; elem++)
|
|
elemList.ElementAt(elem).SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapNameTop + "_Overlap"));
|
|
elemList.Last().SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapNameSx + "_Overlap"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Calcola il css del tab selezionato
|
|
/// </summary>
|
|
/// <param name="testStep"> Step </param>
|
|
/// <returns></returns>
|
|
private string tabNavCss(CompileStep testStep, int Index = -1)
|
|
{
|
|
if (testStep == CompileStep.Sash)
|
|
{
|
|
if ((currSashIndex == 0 && Index == 0) || (currSashIndex == 1 && Index == 1))
|
|
return "nav-link active fw-bold";
|
|
else
|
|
return "nav-link text-dark";
|
|
}
|
|
else if (testStep == CompileStep.Fill)
|
|
{
|
|
if ((currFillIndex == 0 && Index == 0) || (currFillIndex == 1 && Index == 1))
|
|
return "nav-link active fw-bold";
|
|
else
|
|
return "nav-link text-dark";
|
|
}
|
|
else if (testStep == CompileStep.Split)
|
|
{
|
|
if ((currSplitIndex == 0 && Index == 0) || (currSplitIndex == 1 && Index == 1))
|
|
return "nav-link active fw-bold";
|
|
else
|
|
return "nav-link text-dark";
|
|
}
|
|
return (testStep == currStep) ? "nav-link active fw-bold" : "nav-link text-dark";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare tutti i Fill al nuovo tipo
|
|
/// </summary>
|
|
/// <param name="area"> area corrente</param>
|
|
/// <param name="type"> tipo a cui aggiornare</param>
|
|
private void updateAllFill(Area area, FillTypes type)
|
|
{
|
|
if (area.AreaType.Equals(AreaTypes.FILL))
|
|
{
|
|
Fill fill = (Fill)area;
|
|
fill.SetSelFillType(type);
|
|
return;
|
|
}
|
|
foreach (Area child in area.AreaList)
|
|
{
|
|
updateAllFill(child, type);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento dei dati con informazioni ricevute dai dizionari
|
|
/// </summary>
|
|
private void UpdateDict()
|
|
{
|
|
// se ho i dizionari delle forme le aggiungo
|
|
if (LiveData.DictShape.Count > 0)
|
|
{
|
|
waitShape = false;
|
|
// Inserisco le forme ricevuto nei sash group
|
|
foreach (var item in LiveData.DictShape)
|
|
{
|
|
Sash? sashFromGroupId = SashGroupList.FirstOrDefault(x => x.GroupId == item.Key);
|
|
if (sashFromGroupId != null)
|
|
{
|
|
sashFromGroupId.SashShape = item.Value;
|
|
sashFromGroupId.UpdateShape(item.Value);
|
|
}
|
|
}
|
|
if (prevReq == (int)DataReq.ReqShape)
|
|
{
|
|
if (reqHwOpt > 0)
|
|
{
|
|
List<int> reqList = SashGroupList.Select(x => x.GroupId).ToList();
|
|
if (reqList.Count > 0)
|
|
{
|
|
_ = DoReqOptHardware(reqList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// se ho le opzioni hw le aggiungo
|
|
if (LiveData.DictOptionsXml.Count > 0)
|
|
{
|
|
loadListRem("LoadHwOpt");
|
|
foreach (var item in SashGroupList)
|
|
{
|
|
if (LiveData.DictOptionsXml.ContainsKey(item.GroupId))
|
|
{
|
|
item.SetHardwareOption(LiveData.DictOptionsXml[item.GroupId]);
|
|
}
|
|
}
|
|
}
|
|
if (LiveData.ProfElementList.Count > 0)
|
|
{
|
|
// Inserisco i profili ricevuti nei rispettivi Element
|
|
foreach (var item in LiveData.ProfElementList)
|
|
{
|
|
UpdateProfileElement(item.Profiles, item.GroupId, item.EntId);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento Element
|
|
/// </summary>
|
|
/// <param name="newFrame"> nuovo frame </param>
|
|
/// <returns></returns>
|
|
private async Task UpdateElement(Frame newFrame)
|
|
{
|
|
if (newFrame != null)
|
|
{
|
|
// richiedo update element del frame
|
|
List<int> reqList = new List<int>();
|
|
reqList.Add(FrameWindow.GroupId);
|
|
// Aggiorno le liste sash, split
|
|
m_FillList = new List<Fill>();
|
|
m_SashList = new List<Sash>();
|
|
m_SplitList = new List<Split>();
|
|
m_SplittedList = new List<Splitted>();
|
|
CreateWindowsList((m_CurrWindow!).AreaList.First(), false);
|
|
ReqGroupIdList(FrameWindow, reqList);
|
|
await DoReqElement(reqList);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento Element a causa di un cambiamento nel frame
|
|
/// </summary>
|
|
/// <param name="newFrame"> nuovo frame </param>
|
|
/// <returns></returns>
|
|
private async Task UpdateElementFrame(Frame newFrame)
|
|
{
|
|
if (newFrame != null)
|
|
{
|
|
// cerco il record
|
|
var currRec = m_CurrWindow?.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId);
|
|
// lo aggiorno
|
|
currRec = newFrame;
|
|
// richiedo update element del frame
|
|
await UpdateElement(FrameWindow);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento Element a causa di un cambiamento nella sash
|
|
/// </summary>
|
|
/// <param name="newSash"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdateElementSash(Sash newSash)
|
|
{
|
|
if (newSash != null)
|
|
{
|
|
Sash currRec = (Sash)SearchAreaFromGroupId(FrameWindow, newSash.GroupId)!;
|
|
currRec = newSash;
|
|
await UpdateElement(FrameWindow);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento Element a causa di un cambiamento nello split
|
|
/// </summary>
|
|
/// <param name="newSash"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdateElementSplit(Split newSplit)
|
|
{
|
|
if (newSplit != null)
|
|
{
|
|
Split currRec = (Split)SearchAreaFromGroupId(FrameWindow, newSplit.GroupId)!;
|
|
currRec = newSplit;
|
|
await UpdateElement(FrameWindow);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento opzioni dato nuovo frame
|
|
/// </summary>
|
|
/// <param name="newFrame"> nuovo frame </param>
|
|
/// <returns></returns>
|
|
private async Task UpdateHwOptionsFrame(Frame newFrame)
|
|
{
|
|
if (newFrame != null)
|
|
{
|
|
// cerco il record
|
|
var currRec = m_CurrWindow?.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId);
|
|
// lo aggiorno
|
|
currRec = newFrame;
|
|
// resetto hw lst
|
|
await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt);
|
|
reqHwOpt++;
|
|
if (prevReq == (int)DataReq.ReqShape)
|
|
{
|
|
// richiesta calcolo opzioni hardware per la singola sash group
|
|
List<int> reqList = SashGroupList.Select(x => x.GroupId).ToList();
|
|
// chiamo con gruppo della nuova sash
|
|
await DoReqOptHardware(reqList);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento opzioni data nuova sash group
|
|
/// </summary>
|
|
/// <param name="newSash"> nuovo frame </param>
|
|
/// <returns></returns>
|
|
private async Task UpdateHwOptionsSash(Sash newSash)
|
|
{
|
|
if (newSash != null)
|
|
{
|
|
// cerco il record
|
|
var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId);
|
|
// lo aggiorno
|
|
currRec = newSash;
|
|
// resetto hw list
|
|
await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt);
|
|
// richiesta calcolo opzioni hardware per la singola sash group
|
|
List<int> reqList = SashGroupList.Select(x => x.GroupId).ToList();
|
|
await DoReqOptHardware(reqList);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per settare i paramteri di ingresso selezionati
|
|
/// </summary>
|
|
private void UpdateInputList(JsonWindow WindowFromJson)
|
|
{
|
|
string profile = WindowFromJson.ProfilePath;
|
|
Window.m_ParameterList = ListPayload.ProfileList?.FirstOrDefault(x => x.ProfileName.Equals(profile))?.ParameterDict ?? new();
|
|
Frame.m_AllThresholdList = ListPayload.ProfileList?.FirstOrDefault(x => x.ProfileName.Equals(profile))?.ThresholdList ?? new();
|
|
Sash.m_HardwareCompleteList = ListPayload.Hardware;
|
|
Sash.s_FamilyHardwareList = ListPayload.FamilyHardware;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo che resetta le liste (sash, split, splitted, fill e itemTable) e le crea nuovamente
|
|
/// </summary>
|
|
private void UpdateLists()
|
|
{
|
|
m_maxCol = 0;
|
|
m_maxRow = 0;
|
|
m_FillList = new List<Fill>();
|
|
m_SashList = new List<Sash>();
|
|
m_SplitList = new List<Split>();
|
|
m_SplittedList = new List<Splitted>();
|
|
m_ItemTableList = new List<ItemTable>();
|
|
CreateWindowsList((m_CurrWindow!).AreaList.First(), false);
|
|
CreateElementTable(m_CurrWindow.AreaList.First(), 1, 1, 1, 1);
|
|
foreach (var item in ItemTableList)
|
|
{
|
|
if (item.NumChild > 3)
|
|
{
|
|
if (!RowCollapsed.ContainsKey(item.Row))
|
|
{
|
|
RowCollapsed.Add(item.Row, false);
|
|
Child.Add(item.Row, item.NumChild);
|
|
}
|
|
}
|
|
else if (RowCollapsed.ContainsKey(item.Row))
|
|
{
|
|
RowCollapsed.Remove(item.Row);
|
|
Child.Remove(item.Row);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento Fill
|
|
/// </summary>
|
|
/// <param name="newFill"> Fill da aggiornare</param>
|
|
/// <returns></returns>
|
|
private async Task UpdatePreviewFill(Fill newFill)
|
|
{
|
|
if (newFill != null)
|
|
{
|
|
// cerco il record
|
|
var currRec = (Fill?)SearchAreaFromGroupId(FrameWindow, newFill.GroupId);
|
|
// lo aggiorno
|
|
if (currRec != null)
|
|
{
|
|
currRec = newFill;
|
|
await DoPreviewSvg();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento Frame
|
|
/// </summary>
|
|
/// <param name="newFrame"> nuovo frame</param>
|
|
/// <returns></returns>
|
|
private async Task UpdatePreviewFrame(DataUpdateFrame args)
|
|
{
|
|
Frame newFrame = args.currFrame;
|
|
bool forceSvgNoHw = args.svgNoHw;
|
|
if (args.groupIdDelete != -1)
|
|
RowCollapsed.Remove(args.groupIdDelete);
|
|
if (newFrame != null)
|
|
{
|
|
// richiedo update shape
|
|
List<int> reqList = SashGroupList.Select(x => x.GroupId).ToList();
|
|
if (args.reqShape)
|
|
await DoReqShape(reqList);
|
|
// cerco il record
|
|
var currRec = m_CurrWindow?.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId);
|
|
// lo aggiorno
|
|
currRec = newFrame;
|
|
if (forceSvgNoHw)
|
|
await DoPreviewSvg(true, true);
|
|
else
|
|
await DoPreviewSvg();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare valori della sezione General
|
|
/// </summary>
|
|
/// <param name="args"></param>
|
|
private void UpdatePreviewGeneral(DataUpdateGeneral args)
|
|
{
|
|
string Color = args.Color;
|
|
string Glass = args.Glass;
|
|
string Material = args.Material;
|
|
string Profile = args.Profile;
|
|
if (m_CurrWindow != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(Color))
|
|
m_CurrWindow.sColorMaterial = Color;
|
|
else if (!string.IsNullOrEmpty(Glass))
|
|
m_CurrWindow.sGlass = Glass;
|
|
else if (!string.IsNullOrEmpty(Material))
|
|
m_CurrWindow.sMaterial = Material;
|
|
else if (!string.IsNullOrEmpty(Profile))
|
|
m_CurrWindow.sProfilePath = Profile;
|
|
_ = DoPreviewSvg();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento opzioni dato update sash
|
|
/// </summary>
|
|
/// <param name="newSash"> nuova sash </param>
|
|
/// <returns></returns>
|
|
private async Task UpdatePreviewSashGroup(DataUpdateSash args)
|
|
{
|
|
Sash newSash = args.currSash;
|
|
bool svgNoHw = args.svgNoHw;
|
|
bool noSvg = args.noSvg;
|
|
Sash? item = (Sash?)SearchAreaFromGroupId(FrameWindow, newSash.GroupId);
|
|
if (!noSvg && newSash != null && item != null)
|
|
{
|
|
item = newSash;
|
|
if (svgNoHw)
|
|
await DoPreviewSvg(true, true);
|
|
else
|
|
await DoPreviewSvg();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento Frame
|
|
/// </summary>
|
|
/// <param name="newFrame"> nuovo frame </param>
|
|
/// <returns></returns>
|
|
private async Task UpdatePreviewSplit(DataUpdateSplit args)
|
|
{
|
|
Split newSplit = args.currSplit;
|
|
bool forceSvgNoHw = args.svgNoHw;
|
|
bool noSvg = args.noSvg;
|
|
if (newSplit != null)
|
|
{
|
|
// cerco il record
|
|
var currRec = SearchAreaFromGroupId(FrameWindow, newSplit.GroupId);
|
|
// lo aggiorno
|
|
currRec = newSplit;
|
|
if (!noSvg)
|
|
{
|
|
if (forceSvgNoHw)
|
|
await DoPreviewSvg(true, true);
|
|
else
|
|
await DoPreviewSvg();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare Splitted
|
|
/// </summary>
|
|
/// <param name="currSplitted"> Splitted da aggiornare </param>
|
|
/// <returns></returns>
|
|
private async Task UpdatePreviewSplitted(Splitted currSplitted)
|
|
{
|
|
if (currSplitted != null)
|
|
{
|
|
var item = SearchAreaFromGroupId(FrameWindow, currSplitted.GroupId);
|
|
item = currSplitted;
|
|
// ricalcolo liste
|
|
UpdateLists();
|
|
// richiedo update shape
|
|
List<int> reqList = SashGroupList.Select(x => x.GroupId).ToList();
|
|
//await DoPreviewSvg();
|
|
await UpdateElement(FrameWindow);
|
|
await DoReqShape(reqList);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare i nomi dei profili degli elementi
|
|
/// </summary>
|
|
/// <param name="profileNameList"> Lista dei profili </param>
|
|
/// <param name="GroupIdSearch"> Id Area che si sta cercando </param>
|
|
/// <param name="EntityIdSearch"> Id dell'anta o dello split (se -1 non usare) </param>
|
|
/// <returns></returns>
|
|
private void UpdateProfileElement(List<string> profileNameList, int GroupIdSearch, int EntityIdSearch)
|
|
{
|
|
// Cerco area corrispondente al GroupId
|
|
Area? found = SearchAreaFromGroupId(FrameWindow, GroupIdSearch);
|
|
List<ElementDimension> elemList = new List<ElementDimension>();
|
|
if (found != null)
|
|
{
|
|
switch (found.AreaType)
|
|
{
|
|
case AreaTypes.FRAME:
|
|
{
|
|
Frame frame = (Frame)found;
|
|
for (int index = frame.ElementDimensionList.Count; index < profileNameList.Count; index++)
|
|
{
|
|
double valStd = Window.m_ParameterList.GetValueOrDefault(profileNameList.ElementAt(index) + "_DimStd");
|
|
frame.ElementDimensionList.Add(new ElementDimension(frame, index + 1, valStd));
|
|
}
|
|
for (int i = 0; i < frame.ElementDimensionList.Count; i++)
|
|
{
|
|
frame.ElementDimensionList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i));
|
|
}
|
|
for (int index = profileNameList.Count; index < frame.ElementDimensionList.Count; index++)
|
|
frame.ElementDimensionList.RemoveAt(index);
|
|
elemList = frame.ElementDimensionList;
|
|
foreach (var item in elemList)
|
|
{
|
|
string overlapName = string.Join("_", item.sName.Split('_').Skip(1));
|
|
item.SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapName + "_Overlap"));
|
|
}
|
|
foreach (var elem in frame.BottomRailElemDimList)
|
|
{
|
|
elem.SetOverlapElement(Window.m_ParameterList.GetValueOrDefault("Frame_BottomRail_Overlap"));
|
|
}
|
|
break;
|
|
}
|
|
case AreaTypes.SASH:
|
|
{
|
|
Sash sash = (Sash)found;
|
|
SashDimension anta = sash.SashList.ElementAt(EntityIdSearch - 1);
|
|
for (int index = anta.ElementDimensionList.Count; index < profileNameList.Count; index++)
|
|
{
|
|
double valStd = Window.m_ParameterList.GetValueOrDefault(profileNameList.ElementAt(index) + "_DimStd");
|
|
anta.ElementDimensionList.Add(new ElementDimension(sash, index + 1, valStd));
|
|
}
|
|
int numElemDelete = anta.ElementDimensionList.Count - profileNameList.Count;
|
|
for (int i = 0; i < numElemDelete; i++)
|
|
{
|
|
anta.ElementDimensionList.RemoveAt(anta.ElementDimensionList.Count - 1);
|
|
}
|
|
for (int index = profileNameList.Count; index < anta.ElementDimensionList.Count; index++)
|
|
anta.ElementDimensionList.RemoveAt(index);
|
|
for (int i = 0; i < anta.ElementDimensionList.Count; i++)
|
|
{
|
|
anta.ElementDimensionList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i));
|
|
}
|
|
SetOverlapSash(sash, anta, EntityIdSearch - 1, elemList);
|
|
break;
|
|
}
|
|
case AreaTypes.SPLIT:
|
|
{
|
|
Split split = (Split)found;
|
|
List<SplitElementDimension> SpElemList = split.searchElemFromSubArea(EntityIdSearch);
|
|
for (int i = 0; i < SpElemList.Count; i++)
|
|
{
|
|
SpElemList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i));
|
|
SpElemList.ElementAt(i).SetMinDimension(Window.m_ParameterList.GetValueOrDefault(SpElemList.ElementAt(i).sName + "_DimMin"));
|
|
SpElemList.ElementAt(i).SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(SpElemList.ElementAt(i).sName + "_DimMax"));
|
|
if (SpElemList.ElementAt(i).dDimension > SpElemList.ElementAt(i).dMaxDim)
|
|
{
|
|
SpElemList.ElementAt(i).SetDimension(SpElemList.ElementAt(i).dMaxDim);
|
|
Frame frame = split.ParentWindow.AreaList.First();
|
|
if (frame != null)
|
|
{
|
|
frame.SearchAreaList(frame, frame.AvailWidthArea(), "Width");
|
|
frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height");
|
|
}
|
|
}
|
|
else if (SpElemList.ElementAt(i).dDimension < SpElemList.ElementAt(i).dMinDim)
|
|
{
|
|
SpElemList.ElementAt(i).SetDimension(SpElemList.ElementAt(i).dMinDim);
|
|
Frame frame = split.ParentWindow.AreaList.First();
|
|
if (frame != null)
|
|
{
|
|
frame.SearchAreaList(frame, frame.AvailWidthArea(), "Width");
|
|
frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height");
|
|
}
|
|
}
|
|
string overlapName = string.Join("_", SpElemList.ElementAt(i).sName.Split('_').Skip(1));
|
|
SpElemList.ElementAt(i).SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapName + "_Overlap"));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
foreach (var item in elemList)
|
|
{
|
|
item.SetMinDimension(Window.m_ParameterList.GetValueOrDefault(item.sName + "_DimMin"));
|
|
item.SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(item.sName + "_DimMax"));
|
|
if (item.dDimension > item.dMaxDim)
|
|
item.SetDimension(item.dMaxDim);
|
|
else if (item.dMaxDim < item.dMinDim)
|
|
item.SetDimension(item.dMinDim);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per settare i parmateri di ingresso selezionati
|
|
/// </summary>
|
|
private void UpdateSelParameter()
|
|
{
|
|
if (SelectionData != null && SelectionData.IsValid())
|
|
{
|
|
SelFamilyHardware = SelectionData.FamilyHardware ?? "";
|
|
SelColorMaterial = SelectionData.ColorMaterial ?? "";
|
|
SelMaterial = SelectionData.Material ?? "";
|
|
SelGlass = SelectionData.Glass ?? "";
|
|
SelProfile = SelectionData.Profile ?? "";
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |