55935e6809
- Cambiato bottoni Joints in CardFrame
458 lines
16 KiB
C#
458 lines
16 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 CardSplit
|
|
{
|
|
|
|
/// <summary>
|
|
/// Split corrente rispetto alla lista split
|
|
/// </summary>
|
|
[Parameter]
|
|
public Split CurrSplit { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Lista di sash
|
|
/// </summary>
|
|
[Parameter]
|
|
public List<Sash> SashGroupList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Lista di split
|
|
/// </summary>
|
|
[Parameter]
|
|
public List<Split> SplitList { 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 User { get; set; } = false!;
|
|
|
|
/// <summary>
|
|
/// Evento per richiedere reset dizionario
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateRes> EC_ReqResetDict { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per aggiornare Split
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateSplit> EC_UpdateSplit { 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<Split> EC_ReqElement { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per tornare nella pagine Tree
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<bool> EC_ReqClose { get; set; }
|
|
|
|
/// <summary>
|
|
/// Metodo per scambiare le aree di uno split (solo se si hanno due aree)
|
|
/// </summary>
|
|
/// <param name="item"> split corrente </param>
|
|
/// <returns></returns>
|
|
protected async Task SwapTwoAree()
|
|
{
|
|
CurrSplit.SwapAree();
|
|
var args = new DataUpdateSplit(){
|
|
currSplit = CurrSplit,
|
|
svgNoHw = true
|
|
};
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape });
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDimElem });
|
|
await EC_ReqElement.InvokeAsync(CurrSplit);
|
|
await EC_UpdateSplit.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per rimuovere split
|
|
/// </summary>
|
|
/// <param name="item"> split corrente </param>
|
|
/// <returns></returns>
|
|
protected async Task RemoveArea()
|
|
{
|
|
CurrSplit.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.ResetDimElem });
|
|
await EC_UpdateFrame.InvokeAsync(args);
|
|
await EC_ReqClose.InvokeAsync(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Proprietà per selezionare shape split
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected int SplitShapeIndex
|
|
{
|
|
get => CurrSplit.SelSplitShapeIndex;
|
|
set
|
|
{
|
|
if (CurrSplit.SelSplitShapeIndex != value)
|
|
{
|
|
CurrSplit.SelSplitShapeIndex = value;
|
|
var args = new DataUpdateSplit()
|
|
{
|
|
currSplit = CurrSplit
|
|
};
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
if(!(CurrSplit.ParentArea.ParentArea is Sash))
|
|
{
|
|
// Se la shape selezionata è grid o custom, richiede reset shape
|
|
if (value == (int)SplitShapes.GRID || value == (int)SplitShapes.CUSTOM)
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape });
|
|
if (SearchSash(CurrSplit))
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetHwOpt });
|
|
}
|
|
_ = EC_ReqElement.InvokeAsync(CurrSplit);
|
|
_ = EC_UpdateSplit.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool SearchSash(Area area)
|
|
{
|
|
if (area is Sash)
|
|
return true;
|
|
foreach (var item in area.AreaList)
|
|
return SearchSash(item);
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Proprietà per selezionare numero di split verticali
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected int SplitQtyVert
|
|
{
|
|
get => CurrSplit.nSplitQtyVert;
|
|
set
|
|
{
|
|
if (CurrSplit.nSplitQtyVert != value)
|
|
{
|
|
CurrSplit.nSplitQtyVert = value;
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDimElem });
|
|
var args = new DataUpdateSplit()
|
|
{
|
|
currSplit = CurrSplit
|
|
};
|
|
_ = EC_ReqElement.InvokeAsync(CurrSplit);
|
|
_ = EC_UpdateSplit.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Proprietà per selezionare numero di split verticali
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected int SplitQtyHoriz
|
|
{
|
|
get => CurrSplit.nSplitQtyHoriz;
|
|
set
|
|
{
|
|
if (CurrSplit.nSplitQtyHoriz != value)
|
|
{
|
|
CurrSplit.nSplitQtyHoriz = value;
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
var args = new DataUpdateSplit()
|
|
{
|
|
currSplit = CurrSplit
|
|
};
|
|
_ = EC_ReqElement.InvokeAsync(CurrSplit);
|
|
_ = EC_UpdateSplit.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 (CurrSplit.bSplitStartVert)
|
|
ElemIndexList = CurrSplit.ElemDimHorizList
|
|
.Where(x => x.nSubArea != updRec.nSubArea && x.nIndex == updRec.nIndex)
|
|
.ToList();
|
|
else
|
|
ElemIndexList = CurrSplit.ElemDimVertList
|
|
.Where(x => x.nSubArea == updRec.nSubArea && x.nIndex == updRec.nIndex)
|
|
.ToList();
|
|
foreach (var item in ElemIndexList)
|
|
{
|
|
item.SetDimension(updRec.dDimension);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(CurrSplit.bSplitStartVert)
|
|
currRec = CurrSplit.ElemDimVertList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
|
|
else
|
|
currRec = CurrSplit.ElemDimHorizList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
|
|
// lo aggiorno
|
|
currRec = updRec;
|
|
}
|
|
var args = new DataUpdateSplit()
|
|
{
|
|
currSplit = CurrSplit,
|
|
svgNoHw = false
|
|
};
|
|
await EC_UpdateSplit.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiornare la dimensione dello split
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
/// <returns></returns>
|
|
protected 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 = CurrSplit.SplitVertList.ElementAt(updRec.index);
|
|
else
|
|
currRec = CurrSplit.SplitHorizList.ElementAt(updRec.index);
|
|
// lo aggiorno
|
|
if (currSplitDim != null)
|
|
{
|
|
currRec = currSplitDim;
|
|
var args = new DataUpdateSplit()
|
|
{
|
|
currSplit = CurrSplit,
|
|
noSvg = updRec.noSvg
|
|
};
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape });
|
|
await EC_UpdateSplit.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
//protected async Task UpdateSplit(DataUpdateSplit updRec)
|
|
//{
|
|
// if (updRec.currSplit != null)
|
|
// {
|
|
// CurrSplit = updRec.currSplit;
|
|
// var args = new DataUpdateSplit()
|
|
// {
|
|
// currSplit = CurrSplit,
|
|
// noSvg = updRec.noSvg
|
|
// };
|
|
// //await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape });
|
|
// await EC_UpdateSplit.InvokeAsync(args);
|
|
// }
|
|
//}
|
|
|
|
/// <summary>
|
|
/// Metodo per cambiare la dimensione principale
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
/// <returns></returns>
|
|
protected async Task ChangeStartVert(ChangeEventArgs e)
|
|
{
|
|
foreach (Split s in SplitList)
|
|
{
|
|
if (s.Equals(CurrSplit) && 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 DataUpdateSplit()
|
|
{
|
|
currSplit = CurrSplit
|
|
};
|
|
await EC_ReqElement.InvokeAsync(CurrSplit);
|
|
await EC_UpdateSplit.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per determinare la descrizione del parent dello split corrente
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected string descParentSplit()
|
|
{
|
|
if ((CurrSplit.ParentArea is Splitted || CurrSplit.ParentArea is Sash) && SashGroupList.Count > 0)
|
|
{
|
|
for (int j = 0; j < SashGroupList.Count; j++)
|
|
{
|
|
if (SashGroupList[j].Equals(CurrSplit.ParentArea))
|
|
{
|
|
return "Sash " + (j + 1);
|
|
}
|
|
else if (SashGroupList[j].Equals(CurrSplit.ParentArea.ParentArea))
|
|
{
|
|
for (int k = 0; k < SashGroupList[j].AreaList.Count; k++)
|
|
{
|
|
if (SashGroupList[j].AreaList[k].AreaList[0].Equals(CurrSplit))
|
|
{
|
|
return "Sash group " + (j + 1) + " - sash " + (k + 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return "Frame";
|
|
}
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sollevo evento per tornare alla pagina Tree
|
|
/// </summary>
|
|
private void ReqClose()
|
|
{
|
|
_ = EC_ReqClose.InvokeAsync(true);
|
|
}
|
|
|
|
private bool isOpen = false;
|
|
private void ToggleDropdown()
|
|
{
|
|
isOpen = !isOpen;
|
|
}
|
|
|
|
protected MeasureTypes MeasureType
|
|
{
|
|
get
|
|
{
|
|
MeasureTypes type = MeasureTypes.NULL;
|
|
if (CurrSplit.SplitVertList.Count > 0)
|
|
type = CurrSplit.SplitVertList.First().SelMeasureType;
|
|
else
|
|
type = CurrSplit.SplitHorizList.First().SelMeasureType;
|
|
for (int i = 1; i < CurrSplit.SplitVertList.Count; i++)
|
|
{
|
|
if (CurrSplit.SplitVertList.ElementAt(i).SelMeasureType != type)
|
|
return MeasureTypes.NULL;
|
|
}
|
|
for (int i = 1; i < CurrSplit.SplitHorizList.Count; i++)
|
|
{
|
|
if (CurrSplit.SplitHorizList.ElementAt(i).SelMeasureType != type)
|
|
return MeasureTypes.NULL;
|
|
}
|
|
return type;
|
|
}
|
|
set
|
|
{
|
|
foreach (var item in CurrSplit.SplitVertList)
|
|
{
|
|
item.SelMeasureTypeIndex = (int)value;
|
|
//item.SetSelMeasureType(value);
|
|
}
|
|
foreach (var item in CurrSplit.SplitHorizList)
|
|
{
|
|
item.SelMeasureTypeIndex = (int)value;
|
|
//item.SetSelMeasureType(value);
|
|
}
|
|
var args = new DataUpdateSplit()
|
|
{
|
|
currSplit = CurrSplit,
|
|
noSvg = true
|
|
};
|
|
_ = EC_UpdateSplit.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per cambiare il tipo di misura di tutti gli SplitDimension
|
|
/// </summary>
|
|
/// <param name="type"> nuovo tipo </param>
|
|
/// <returns></returns>
|
|
protected Task SetMeasureType(MeasureTypes type)
|
|
{
|
|
isOpen = !isOpen;
|
|
foreach (var item in CurrSplit.SplitVertList)
|
|
{
|
|
item.SelMeasureTypeIndex = (int)type;
|
|
//item.SetSelMeasureType(type);
|
|
}
|
|
foreach (var item in CurrSplit.SplitHorizList)
|
|
{
|
|
item.SelMeasureTypeIndex = (int)type;
|
|
//item.SetSelMeasureType(type);
|
|
}
|
|
var args = new DataUpdateSplit()
|
|
{
|
|
currSplit = CurrSplit,
|
|
noSvg = true
|
|
};
|
|
return EC_UpdateSplit.InvokeAsync(args);
|
|
}
|
|
|
|
private List<SplitElementDimension> horizList()
|
|
{
|
|
int subAreaMin = CurrSplit.ElemDimHorizList.Min(x => x.nSubArea);
|
|
return CurrSplit.ElemDimHorizList.Where(x => x.nSubArea == subAreaMin).ToList();
|
|
}
|
|
|
|
private List<SplitElementDimension> vertList()
|
|
{
|
|
int subAreaMin = CurrSplit.ElemDimVertList.Min(x => x.nSubArea);
|
|
return CurrSplit.ElemDimVertList.Where(x => x.nSubArea == subAreaMin).ToList();
|
|
}
|
|
|
|
private string MeasureTypeCss(MeasureTypes type)
|
|
{
|
|
for (int i = 0; i < CurrSplit.SplitVertList.Count; i++)
|
|
{
|
|
if (!CurrSplit.SplitVertList.ElementAt(i).MeasureType.Equals(type))
|
|
return "btn btn-outline-secondary";
|
|
}
|
|
for (int i = 0; i < CurrSplit.SplitHorizList.Count; i++)
|
|
{
|
|
if (!CurrSplit.SplitHorizList.ElementAt(i).MeasureType.Equals(type))
|
|
return "btn btn-outline-secondary";
|
|
}
|
|
return "btn btn-secondary";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe per raggruppare oggetti che servono per aggiornare split
|
|
/// </summary>
|
|
public class DataUpdateSplit
|
|
{
|
|
public Split currSplit { get; set; } = null!;
|
|
public bool svgNoHw { get; set; } = false;
|
|
public bool noSvg { get; set; } = false;
|
|
}
|
|
} |