83cf80a289
- Modifiche interfaccia - Correzioni varie
484 lines
17 KiB
C#
484 lines
17 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Newtonsoft.Json.Linq;
|
|
using WebWindowComplex.Models;
|
|
using static WebWindowComplex.Json.WindowConst;
|
|
using static WebWindowComplex.LayoutConst;
|
|
|
|
namespace WebWindowComplex.Compo
|
|
{
|
|
public partial class CardInglesina
|
|
{
|
|
|
|
/// <summary>
|
|
/// Inglesina corrente
|
|
/// </summary>
|
|
[Parameter]
|
|
public Inglesina CurrInglesina { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Lista di sash
|
|
/// </summary>
|
|
[Parameter]
|
|
public List<Sash> SashGroupList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Lista di inglesine
|
|
/// </summary>
|
|
[Parameter]
|
|
public List<Inglesina> InglesinaList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Frame
|
|
/// </summary>
|
|
[Parameter]
|
|
public Frame FrameWindow { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Livello di accesso (utente base)
|
|
/// </summary>
|
|
[CascadingParameter(Name = "User")]
|
|
public bool BaseUser { get; set; } = false!;
|
|
|
|
/// <summary>
|
|
/// Evento per richiedere reset dizionario
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateRes> EC_ReqResetDict { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per aggiornare Inglesina
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateInglesina> EC_UpdateInglesina { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per aggiornare Frame
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateFrame> EC_UpdateFrame { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per richiesta profili degli Element
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<Inglesina> EC_ReqElement { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per tornare nella pagine Tree
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<bool> EC_ReqClose { get; set; }
|
|
|
|
/// <summary>
|
|
/// Vocabolario con traduzione lingua corrente
|
|
/// </summary>
|
|
[CascadingParameter(Name = "Vocabulary")]
|
|
public Dictionary<string, string> Vocabulary { get; set; } = null!;
|
|
|
|
#region Protected Properties
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
InglesinaDict = Vocabulary.Where(x => x.Key.Contains("CWIng_")).ToDictionary(x => x.Key, y => y.Value);
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Private Fields
|
|
|
|
private Dictionary<string, string> InglesinaDict = new();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
/// <summary>
|
|
/// Proprietà per selezionare shape Inglesina
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private int InglesinaShapeIndex
|
|
{
|
|
get => CurrInglesina.SelSplitShapeIndex;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Proprietà per selezionare shape Inglesina
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private int SideIndex
|
|
{
|
|
get => CurrInglesina.SelSideIndex;
|
|
set
|
|
{
|
|
if (CurrInglesina.SelSideIndex != value)
|
|
{
|
|
CurrInglesina.SelSideIndex = value;
|
|
var args = new DataUpdateInglesina()
|
|
{
|
|
currInglesina = CurrInglesina
|
|
};
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
_ = EC_ReqElement.InvokeAsync(CurrInglesina);
|
|
_ = EC_UpdateInglesina.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Proprietà per selezionare numero di Inglesina verticali
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private int InglesinaQtyVert
|
|
{
|
|
get => CurrInglesina.nSplitQtyVert;
|
|
set
|
|
{
|
|
if (CurrInglesina.nSplitQtyVert != value)
|
|
{
|
|
CurrInglesina.nSplitQtyVert = value;
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDimElem });
|
|
var args = new DataUpdateInglesina()
|
|
{
|
|
currInglesina = CurrInglesina
|
|
};
|
|
_ = EC_ReqElement.InvokeAsync(CurrInglesina);
|
|
_ = EC_UpdateInglesina.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Proprietà per selezionare numero di Inglesina verticali
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private int InglesinaQtyHoriz
|
|
{
|
|
get => CurrInglesina.nSplitQtyHoriz;
|
|
set
|
|
{
|
|
if (CurrInglesina.nSplitQtyHoriz != value)
|
|
{
|
|
CurrInglesina.nSplitQtyHoriz = value;
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
var args = new DataUpdateInglesina()
|
|
{
|
|
currInglesina = CurrInglesina
|
|
};
|
|
_ = EC_ReqElement.InvokeAsync(CurrInglesina);
|
|
_ = EC_UpdateInglesina.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|
|
|
|
private MeasureTypes MeasureType
|
|
{
|
|
get
|
|
{
|
|
MeasureTypes type = MeasureTypes.NULL;
|
|
if (CurrInglesina.SplitVertList.Count > 0)
|
|
type = CurrInglesina.SplitVertList.First().SelMeasureType;
|
|
else
|
|
type = CurrInglesina.SplitHorizList.First().SelMeasureType;
|
|
for (int i = 1; i < CurrInglesina.SplitVertList.Count; i++)
|
|
{
|
|
if (CurrInglesina.SplitVertList.ElementAt(i).SelMeasureType != type)
|
|
return MeasureTypes.NULL;
|
|
}
|
|
for (int i = 1; i < CurrInglesina.SplitHorizList.Count; i++)
|
|
{
|
|
if (CurrInglesina.SplitHorizList.ElementAt(i).SelMeasureType != type)
|
|
return MeasureTypes.NULL;
|
|
}
|
|
return type;
|
|
}
|
|
set
|
|
{
|
|
foreach (var item in CurrInglesina.SplitVertList)
|
|
{
|
|
item.SelMeasureTypeIndex = (int)value;
|
|
//item.SetSelMeasureType(value);
|
|
}
|
|
foreach (var item in CurrInglesina.SplitHorizList)
|
|
{
|
|
item.SelMeasureTypeIndex = (int)value;
|
|
//item.SetSelMeasureType(value);
|
|
}
|
|
var args = new DataUpdateInglesina()
|
|
{
|
|
currInglesina = CurrInglesina,
|
|
noSvg = true
|
|
};
|
|
_ = EC_UpdateInglesina.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Metodo per path immagine forma
|
|
/// </summary>
|
|
/// <param name="fileName"></param>
|
|
/// <returns></returns>
|
|
private string GetImageShapePath(string fileName) => $"_content/Egw.Lux.WebWindowComplex/icone/split/shape/{fileName}.svg";
|
|
|
|
/// <summary>
|
|
/// Metodo per rimuovere Inglesina
|
|
/// </summary>
|
|
/// <param name="item"> Inglesina corrente </param>
|
|
/// <returns></returns>
|
|
private async Task RemoveArea()
|
|
{
|
|
CurrInglesina.Remove();
|
|
var args = new DataUpdateFrame()
|
|
{
|
|
currFrame = FrameWindow
|
|
};
|
|
// richiesta reset dict shape
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape });
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape });
|
|
await EC_UpdateFrame.InvokeAsync(args);
|
|
await EC_ReqClose.InvokeAsync(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per cercare l'anta in cui è l'inglesina
|
|
/// </summary>
|
|
/// <param name="area"></param>
|
|
/// <returns></returns>
|
|
private bool SearchSash(Area area)
|
|
{
|
|
if (area is Sash)
|
|
return true;
|
|
foreach (var item in area.AreaList)
|
|
return SearchSash(item);
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per selezionare la forma dell'inglesina
|
|
/// </summary>
|
|
/// <param name="newShapeIndex"></param>
|
|
/// <returns></returns>
|
|
private async Task SelShapeInglesina(int newShapeIndex)
|
|
{
|
|
if (CurrInglesina.SelSplitShapeIndex != newShapeIndex)
|
|
{
|
|
CurrInglesina.SelSplitShapeIndex = newShapeIndex;
|
|
var args = new DataUpdateInglesina()
|
|
{
|
|
currInglesina = CurrInglesina
|
|
};
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
if (!(CurrInglesina.ParentArea.ParentArea is Sash))
|
|
{
|
|
// Se la shape selezionata è grid o custom, richiede reset shape
|
|
if (newShapeIndex == (int)SplitShapes.GRID || newShapeIndex == (int)SplitShapes.CUSTOM)
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape });
|
|
if (SearchSash(CurrInglesina))
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetHwOpt });
|
|
}
|
|
await EC_ReqElement.InvokeAsync(CurrInglesina);
|
|
await EC_UpdateInglesina.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento element
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdateElement(SplitElementDimension updRec)
|
|
{
|
|
if (updRec != null)
|
|
{
|
|
SplitElementDimension? currRec = new SplitElementDimension(updRec.ParentArea, 0, 0, -1);
|
|
if (updRec.nSubArea != 0)
|
|
{
|
|
List<SplitElementDimension> ElemIndexList = new List<SplitElementDimension>();
|
|
if (CurrInglesina.bSplitStartVert)
|
|
ElemIndexList = CurrInglesina.ElemDimHorizList
|
|
.Where(x => x.nSubArea != updRec.nSubArea && x.nIndex == updRec.nIndex)
|
|
.ToList();
|
|
else
|
|
ElemIndexList = CurrInglesina.ElemDimVertList
|
|
.Where(x => x.nSubArea == updRec.nSubArea && x.nIndex == updRec.nIndex)
|
|
.ToList();
|
|
foreach (var item in ElemIndexList)
|
|
{
|
|
item.SetDimension(updRec.dDimension);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (CurrInglesina.bSplitStartVert)
|
|
currRec = CurrInglesina.ElemDimVertList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
|
|
else
|
|
currRec = CurrInglesina.ElemDimHorizList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
|
|
// lo aggiorno
|
|
currRec = updRec;
|
|
}
|
|
var args = new DataUpdateInglesina()
|
|
{
|
|
currInglesina = CurrInglesina
|
|
};
|
|
await EC_UpdateInglesina.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare la dimensione dell'3Inglesina
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdateDimension(DataUpdateSplitDimension updRec)
|
|
{
|
|
SplitDimension currSplitDim = updRec.currSplit;
|
|
SplitDimension currRec = new SplitDimension(0, MeasureTypes.NULL, false, updRec.currSplit.Parent, false);
|
|
// cerco il record
|
|
if (currSplitDim.bIsVertListDim)
|
|
currRec = CurrInglesina.SplitVertList.ElementAt(updRec.index);
|
|
else
|
|
currRec = CurrInglesina.SplitHorizList.ElementAt(updRec.index);
|
|
// lo aggiorno
|
|
if (currSplitDim != null)
|
|
{
|
|
currRec = currSplitDim;
|
|
var args = new DataUpdateInglesina()
|
|
{
|
|
currInglesina = CurrInglesina,
|
|
noSvg = updRec.noSvg
|
|
};
|
|
//await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape });
|
|
await EC_UpdateInglesina.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per cambiare la dimensione principale
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
/// <returns></returns>
|
|
private async Task ChangeStartVert(ChangeEventArgs e)
|
|
{
|
|
foreach (Split s in InglesinaList)
|
|
{
|
|
if (s.Equals(CurrInglesina) && e.Value != null)
|
|
{
|
|
s.bSplitStartVert = (bool)e.Value;
|
|
//s.SetSplitStartVert((bool)e.Value);
|
|
}
|
|
}
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDimElem });
|
|
var args = new DataUpdateInglesina()
|
|
{
|
|
currInglesina = CurrInglesina
|
|
};
|
|
await EC_ReqElement.InvokeAsync(CurrInglesina);
|
|
await EC_UpdateInglesina.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per determinare la descrizione del parent dello Inglesina corrente
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string descParentInglesina()
|
|
{
|
|
if ((CurrInglesina.ParentArea.ParentArea is Splitted || CurrInglesina.ParentArea.ParentArea.ParentArea is Sash) && SashGroupList.Count > 0)
|
|
{
|
|
for (int j = 0; j < SashGroupList.Count; j++)
|
|
{
|
|
if (SashGroupList[j].Equals(CurrInglesina.ParentArea.ParentArea))
|
|
{
|
|
return Traduci("CWIng_Sash") + " " + (j + 1);
|
|
}
|
|
else if (SashGroupList[j].Equals(CurrInglesina.ParentArea.ParentArea.ParentArea))
|
|
{
|
|
for (int k = 0; k < SashGroupList[j].AreaList.Count; k++)
|
|
{
|
|
if (SashGroupList[j].AreaList[k].AreaList[0].AreaList.Count > 0 && SashGroupList[j].AreaList[k].AreaList[0].AreaList[0].Equals(CurrInglesina))
|
|
{
|
|
return Traduci("CWIng_SashGroup") + " " + (j + 1) + " - " + Traduci("CWIng_Sash") + " " + (k + 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return "Frame";
|
|
}
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sollevo evento per tornare alla pagina Tree
|
|
/// </summary>
|
|
private void ReqClose()
|
|
{
|
|
_ = EC_ReqClose.InvokeAsync(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per lista degli elementi orizzontali
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private List<SplitElementDimension> horizList()
|
|
{
|
|
int subAreaMin = CurrInglesina.ElemDimHorizList.Min(x => x.nSubArea);
|
|
return CurrInglesina.ElemDimHorizList.Where(x => x.nSubArea == subAreaMin).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per lista degli elementi verticali
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private List<SplitElementDimension> vertList()
|
|
{
|
|
int subAreaMin = CurrInglesina.ElemDimVertList.Min(x => x.nSubArea);
|
|
return CurrInglesina.ElemDimVertList.Where(x => x.nSubArea == subAreaMin).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per la visualizzazione dei pulsanti shape
|
|
/// </summary>
|
|
/// <param name="index"></param>
|
|
/// <returns></returns>
|
|
private string ButtonShapeCss(int index)
|
|
{
|
|
string ans = "";
|
|
if (InglesinaShapeIndex == index)
|
|
ans = "active";
|
|
return ans;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per traduzione in lingua corrente
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
private string Traduci(string lemma)
|
|
{
|
|
string ans = lemma;
|
|
if (InglesinaDict != null && InglesinaDict.ContainsKey(lemma))
|
|
{
|
|
ans = InglesinaDict.GetValueOrDefault(lemma) ?? "";
|
|
}
|
|
return ans;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe per raggruppare oggetti che servono per aggiornare Inglesina
|
|
/// </summary>
|
|
public class DataUpdateInglesina
|
|
{
|
|
public Inglesina currInglesina { get; set; } = null!;
|
|
public bool svgNoHw { get; set; } = false;
|
|
public bool noSvg { get; set; } = false;
|
|
}
|
|
} |