482 lines
16 KiB
C#
482 lines
16 KiB
C#
using EgwCoreLib.Razor;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using WebWindowComplex.Models;
|
|
using static WebWindowComplex.Json.WindowConst;
|
|
|
|
namespace WebWindowComplex.Compo
|
|
{
|
|
public partial class AreaSash
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Sash group corrente
|
|
/// </summary>
|
|
[CascadingParameter(Name = "CurrSashGroup")]
|
|
public Sash CurrSashGroup { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Sash dimension corrente
|
|
/// </summary>
|
|
[Parameter]
|
|
public SashDimension CurrSashDim { get; set; } = null!;
|
|
|
|
///// <summary>
|
|
///// Lista di ante che si stanno editando
|
|
///// </summary>
|
|
//[Parameter]
|
|
//public List<int> SashDimEditList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Lista delle sash
|
|
/// </summary>
|
|
[CascadingParameter(Name = "SashGroupList")]
|
|
public List<Sash> SashGroupList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Livello di accesso (utente base)
|
|
/// </summary>
|
|
[CascadingParameter(Name = "User")]
|
|
public bool User { get; set; } = false!;
|
|
|
|
/// <summary>
|
|
/// Lista di sash dimension in stato edit
|
|
/// </summary>
|
|
[CascadingParameter(Name = "SashDimEditList")]
|
|
public List<int> SashDimEditList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Indice della sash corrente
|
|
/// </summary>
|
|
[Parameter]
|
|
public int IndexSash { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Evento per aggiornare sash dimension
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<SashDimension> EC_UpdateSashDim { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// Evento per aggiornare sash
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateProfile> EC_UpdateSash { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per cambiare modalità di visualizzazione
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataChangeMode> EC_EditView { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per richiedere reset dizionari
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateRes> EC_ReqResetDict { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
//protected override void OnParametersSet()
|
|
//{
|
|
// base.OnParametersSet();
|
|
//}
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private enum ModeView
|
|
{
|
|
NULL = 0,
|
|
View = 1,
|
|
Edit = 2
|
|
}
|
|
|
|
private bool ForceChangeAll = false;
|
|
|
|
private bool isOpen = false;
|
|
|
|
private ModeView mode { get; set; } = ModeView.View;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
/// <summary>
|
|
/// Anta corrente
|
|
/// </summary>
|
|
private Area CurrAnta
|
|
{
|
|
get
|
|
{
|
|
if (CurrSashGroup.AreaList[IndexSash] is Splitted)
|
|
{
|
|
return CurrSashGroup.AreaList[IndexSash];
|
|
}
|
|
else
|
|
{
|
|
return CurrSashGroup;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
CurrAnta = value;
|
|
}
|
|
}
|
|
|
|
///// <summary>
|
|
///// Metodo per avere lo step da usare nella form-input
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public double CssStepNumber()
|
|
//{
|
|
// switch (CurrSashDim.MeasureType)
|
|
// {
|
|
// case Json.WindowConst.MeasureTypes.ABSOLUTE:
|
|
// {
|
|
// return 0.5;
|
|
// }
|
|
// case Json.WindowConst.MeasureTypes.PROPORTIONAL:
|
|
// {
|
|
// return 1;
|
|
// }
|
|
// case Json.WindowConst.MeasureTypes.PERCENTAGE:
|
|
// {
|
|
// return 0.5;
|
|
// }
|
|
// }
|
|
// return 0;
|
|
//}
|
|
|
|
/// <summary>
|
|
/// Selezione tipo di apertura anta
|
|
/// </summary>
|
|
private int OpeningTypeIndex
|
|
{
|
|
get => CurrSashDim.SelOpeningTypeIndex;
|
|
set
|
|
{
|
|
if (CurrSashDim.SelOpeningTypeIndex != value)
|
|
{
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetHwOpt });
|
|
CurrSashDim.SelOpeningTypeIndex = value;
|
|
_ = EC_UpdateSashDim.InvokeAsync(CurrSashDim);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezione tipo di misura della dimensione dell'anta
|
|
/// </summary>
|
|
private int MeasureTypeIndex
|
|
{
|
|
get => CurrSashDim.SelMeasureTypeIndex;
|
|
set
|
|
{
|
|
if (CurrSashDim.SelMeasureTypeIndex != value)
|
|
{
|
|
CurrSashDim.SelMeasureTypeIndex = value;
|
|
_ = EC_UpdateSashDim.InvokeAsync(CurrSashDim);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Inserimento dimensione anta
|
|
/// </summary>
|
|
private double Dimension
|
|
{
|
|
get => CurrSashDim.dDimension;
|
|
set
|
|
{
|
|
if (CurrSashDim.dDimension != value)
|
|
{
|
|
CurrSashDim.dDimension = (double)Math.Round((decimal)value, CssDecimals());
|
|
_ = EC_UpdateSashDim.InvokeAsync(CurrSashDim);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Metodo per avere il numero di decimali da usare nella form-input
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private int CssDecimals()
|
|
{
|
|
switch (CurrSashDim.MeasureType)
|
|
{
|
|
case MeasureTypes.ABSOLUTE:
|
|
{
|
|
return 2;
|
|
}
|
|
case MeasureTypes.PROPORTIONAL:
|
|
{
|
|
return 0;
|
|
}
|
|
case MeasureTypes.PERCENTAGE:
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sollevo evento richiesta per cambiare tutti i Joint
|
|
/// </summary>
|
|
/// <param name="JointType"> Tipo di giunto che si vuole </param>
|
|
/// <returns></returns>
|
|
private Task ChangeAllJoints(Json.WindowConst.Joints JointType)
|
|
{
|
|
for (int i = 0; i < CurrSashDim.JointList.Count; i++)
|
|
{
|
|
Frame? frame = CurrSashGroup.ParentWindow.AreaList.FirstOrDefault();
|
|
if (frame != null && (frame.Shape is Json.WindowConst.Shapes.ARC ||
|
|
frame.Shape is Json.WindowConst.Shapes.ARC_FULL ||
|
|
frame.Shape is Json.WindowConst.Shapes.DOUBLEARC ||
|
|
frame.Shape is Json.WindowConst.Shapes.THREECENTERARC) &&
|
|
(CurrSashGroup.ParentArea.ParentArea is Split split &&
|
|
split != null &&
|
|
split.AreaList.LastOrDefault() != null &&
|
|
split.AreaList.LastOrDefault()!.AreaList.FirstOrDefault() != null &&
|
|
split.AreaList.LastOrDefault()!.AreaList.FirstOrDefault()!.Equals(CurrSashGroup)))
|
|
{
|
|
if(CurrSashGroup.SashList.Count == 1)
|
|
{
|
|
if(i == 2 || i == CurrSashDim.JointList.Count - 1)
|
|
CurrSashDim.JointList.ElementAt(i).SelJointType = Joints.ANGLED;
|
|
else
|
|
CurrSashDim.JointList.ElementAt(i).SelJointType = JointType;
|
|
}
|
|
else
|
|
{
|
|
if (IndexSash == 0 && i == CurrSashDim.JointList.Count - 1)
|
|
CurrSashDim.JointList.ElementAt(i).SelJointType = Joints.ANGLED;
|
|
else if(IndexSash == CurrSashGroup.SashList.Count - 1 && i == 2)
|
|
CurrSashDim.JointList.ElementAt(i).SelJointType = Joints.ANGLED;
|
|
else
|
|
CurrSashDim.JointList.ElementAt(i).SelJointType = JointType;
|
|
}
|
|
}
|
|
else
|
|
CurrSashDim.JointList.ElementAt(i).SelJointType = JointType;
|
|
}
|
|
return EC_UpdateSashDim.InvokeAsync(CurrSashDim);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento joint
|
|
/// </summary>
|
|
/// <param name="updRec"> Tipo di giunto che si vuole </param>
|
|
/// <returns></returns>
|
|
private async Task UpdateJoint(Joint updRec)
|
|
{
|
|
// cerco il record
|
|
var currRec = CurrSashDim.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
|
|
// lo aggiorno
|
|
if (updRec != null)
|
|
{
|
|
currRec = updRec;
|
|
await EC_UpdateSashDim.InvokeAsync(CurrSashDim);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento element
|
|
/// </summary>
|
|
/// <param name="updRec"> Tipo di giunto che si vuole </param>
|
|
/// <returns></returns>
|
|
private async Task UpdateElement(ElementDimension updRec)
|
|
{
|
|
// cerco il record
|
|
var currRec = CurrSashDim.ElementDimensionList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
|
|
// lo aggiorno
|
|
if (updRec != null)
|
|
{
|
|
currRec = updRec;
|
|
await EC_UpdateSashDim.InvokeAsync(CurrSashDim);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per cambiare l'anta su cui è presente la maniglia
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private Task ChangeHandle()
|
|
{
|
|
// Cerco la Sash che si sta considerando nella lista Sash
|
|
var s = SashGroupList.Where(x => x.GroupId == CurrSashGroup.GroupId).FirstOrDefault();
|
|
if (s != null)
|
|
{
|
|
// Setto la presenza o meno della maniglia per ogni anta
|
|
foreach (SashDimension item in s.SashList)
|
|
{
|
|
if (item.Equals(CurrSashDim))
|
|
{
|
|
item.bHasHandle = true;
|
|
}
|
|
else
|
|
{
|
|
if (item.bHasHandle)
|
|
{
|
|
switch (item.SelOpeningType)
|
|
{
|
|
case Openings.TILTTURN_LEFT:
|
|
{
|
|
item.SelOpeningType = Openings.TURNONLY_LEFT;
|
|
break;
|
|
}
|
|
case Openings.TILTTURN_RIGHT:
|
|
{
|
|
item.SelOpeningType = Openings.TURNONLY_RIGHT;
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
item.bHasHandle = false;
|
|
}
|
|
}
|
|
}
|
|
CurrSashGroup.RefreshHardwareList();
|
|
CurrSashGroup.SetFirstHardware();
|
|
DataUpdateProfile args = new DataUpdateProfile()
|
|
{
|
|
sash = CurrSashGroup,
|
|
reqProfile = true
|
|
};
|
|
return EC_UpdateSash.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copio contenuto anta da indexCopy a IndexModify
|
|
/// </summary>
|
|
/// <param name="IndexCopy"> Indice dell'anta di cui voglio copiare contenuto </param>
|
|
/// <param name="IndexModify"> Indice dell'anta di cui voglio modificare contenuto </param>
|
|
/// <returns></returns>
|
|
private Task CopyContentSash(int IndexCopy, int IndexModify)
|
|
{
|
|
isOpen = !isOpen;
|
|
// Anta selezionata
|
|
Area sashSplitted = CurrSashGroup.AreaList[IndexModify];
|
|
// Rimuovo riempimento da anta selezionata
|
|
sashSplitted.AreaList.RemoveAt(0);
|
|
// Creo la copia dell'anta scelta
|
|
Area a;
|
|
if (CurrSashGroup.AreaList[IndexCopy].AreaList.FirstOrDefault() != null)
|
|
{
|
|
a = CurrSashGroup.AreaList[IndexCopy].AreaList.FirstOrDefault()!.Copy(sashSplitted);
|
|
// Aggiungo copia all'anta selezionata
|
|
CurrSashGroup.AreaList[IndexModify].AreaList.Add(a);
|
|
}
|
|
DataUpdateProfile args = new DataUpdateProfile()
|
|
{
|
|
sash = CurrSashGroup,
|
|
reqProfile = true
|
|
};
|
|
return EC_UpdateSash.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiungere lo split nella singola anta
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private Task AddSplitToSash()
|
|
{
|
|
CurrAnta.AddSplit();
|
|
DataUpdateProfile args = new DataUpdateProfile()
|
|
{
|
|
sash = CurrSashGroup,
|
|
reqProfile = true
|
|
};
|
|
return EC_UpdateSash.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiungere l'inglesina nella singola anta
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private Task AddInglesinaToSash()
|
|
{
|
|
CurrAnta.AddInglesina();
|
|
DataUpdateProfile args = new DataUpdateProfile()
|
|
{
|
|
sash = CurrSashGroup,
|
|
reqProfile = true
|
|
};
|
|
return EC_UpdateSash.InvokeAsync(args);
|
|
}
|
|
|
|
private void ToggleDropdown()
|
|
{
|
|
isOpen = !isOpen;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per determinare la visualizzazione dei pulsanti dei joint
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
private string ButtonJointCss(Json.WindowConst.Joints type)
|
|
{
|
|
foreach (var item in CurrSashDim.JointList)
|
|
{
|
|
if (!item.SelJointType.Equals(type))
|
|
return "btn btn-outline-secondary btn-sm";
|
|
}
|
|
return "btn btn-secondary btn-sm";
|
|
}
|
|
|
|
private void doEdit(int index)
|
|
{
|
|
var args = new DataChangeMode
|
|
{
|
|
IndexSashEdit = index,
|
|
IndexSashClose = -1
|
|
};
|
|
_ = EC_EditView.InvokeAsync(args);
|
|
}
|
|
protected void ClosePopup(int index)
|
|
{
|
|
var args = new DataChangeMode
|
|
{
|
|
//Edit = false,
|
|
IndexSashEdit = -1,
|
|
IndexSashClose = index
|
|
};
|
|
_ = EC_EditView.InvokeAsync(args);
|
|
}
|
|
|
|
private void ChangeAll()
|
|
{
|
|
ForceChangeAll = !ForceChangeAll;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
|
|
public class DataChangeMode {
|
|
public bool Edit { get; set; }
|
|
public int IndexSashEdit { get; set; }
|
|
public int IndexSashClose { get; set; }
|
|
}
|
|
|
|
public class DataUpdateProfile
|
|
{
|
|
public Sash sash { get; set; }
|
|
public bool reqProfile { get; set; } = false;
|
|
}
|
|
|
|
} |