ada0fc2ce5
- Correzioni valori nulli - Aggiunta funzione per calcolare altezza sashGroup
345 lines
12 KiB
C#
345 lines
12 KiB
C#
using Egw.Window.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using WebWindowComplex.Models;
|
|
|
|
namespace WebWindowComplex.Compo
|
|
{
|
|
public partial class CardFrame
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Evento per tornare nella pagine Tree
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<bool> EC_ReqClose { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per richiedere reset dizionari
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateRes> EC_ReqResetDict { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per richiedere opzioni hardware
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<Frame> EC_ReqOptionHw { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per richiesta calcolo preview
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateFrame> EC_UpdateFrame { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per richiesta profili degli Element
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<Frame> EC_ReqElement { get; set; }
|
|
|
|
/// <summary>
|
|
/// Frame corrente
|
|
/// </summary>
|
|
[CascadingParameter(Name = "CurrFrameWindow")]
|
|
public Frame CurrFrameWindow { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Lista di sash
|
|
/// </summary>
|
|
[CascadingParameter(Name = "SashList")]
|
|
public List<Sash> SashList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Lista di split
|
|
/// </summary>
|
|
[CascadingParameter(Name = "SplitList")]
|
|
public List<Split> SplitList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Livello di accesso (utente base)
|
|
/// </summary>
|
|
[CascadingParameter(Name = "User")]
|
|
public bool User { get; set; } = false!;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Metodo per selezionare shape
|
|
/// </summary>
|
|
protected int SelShapeIndex
|
|
{
|
|
get => CurrFrameWindow.SelShapeIndex;
|
|
set
|
|
{
|
|
if (CurrFrameWindow.SelShapeIndex != value)
|
|
{
|
|
CurrFrameWindow.SelShapeIndex = value;
|
|
// richiesta reset dict shape, profili element e hw option
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDictShape});
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetHwOpt });
|
|
foreach (var s in SashList)
|
|
{
|
|
s.SelHardwareFromId = "000000";
|
|
}
|
|
var args = new DataUpdateFrame()
|
|
{
|
|
currFrame = CurrFrameWindow,
|
|
svgNoHw = true
|
|
};
|
|
_ = EC_ReqElement.InvokeAsync(CurrFrameWindow);
|
|
_ = EC_UpdateFrame.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per selezionare threshold
|
|
/// </summary>
|
|
protected int SelThreshold
|
|
{
|
|
get => CurrFrameWindow.SelThresholdFromType;
|
|
set
|
|
{
|
|
if (CurrFrameWindow.SelThresholdFromType != value)
|
|
{
|
|
Threshold? threshold = CurrFrameWindow.ThresholdList.Where(x => x.Type.Equals(value)).FirstOrDefault();
|
|
string valueName = "";
|
|
if (threshold != null)
|
|
valueName = threshold.Name;
|
|
if (SashList.Count > 0 || (SashList.Count == 0 && !valueName.Equals("Threshold")))
|
|
{
|
|
CurrFrameWindow.SelThresholdFromType = value;
|
|
var args = new DataUpdateFrame()
|
|
{
|
|
currFrame = CurrFrameWindow,
|
|
svgNoHw = false
|
|
};
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
_ = EC_ReqElement.InvokeAsync(CurrFrameWindow);
|
|
_ = EC_UpdateFrame.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezione quantità bottom rail
|
|
/// </summary>
|
|
protected int FrameBottomRailQty
|
|
{
|
|
get => CurrFrameWindow.BottomRailQty;
|
|
set
|
|
{
|
|
if (CurrFrameWindow.BottomRailQty != value)
|
|
{
|
|
CurrFrameWindow.BottomRailQty = value;
|
|
if (CurrFrameWindow.BottomRailQty > 0)
|
|
CurrFrameWindow.SetBottomRail(true);
|
|
else
|
|
CurrFrameWindow.SetBottomRail(false);
|
|
var args = new DataUpdateFrame()
|
|
{
|
|
currFrame = CurrFrameWindow,
|
|
svgNoHw = false
|
|
};
|
|
_ = EC_UpdateFrame.InvokeAsync(args);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiungere sash
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task AddSash()
|
|
{
|
|
CurrFrameWindow.AddFirstSash();
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
var args = new DataUpdateFrame()
|
|
{
|
|
currFrame = CurrFrameWindow,
|
|
svgNoHw = true
|
|
};
|
|
await EC_ReqElement.InvokeAsync(CurrFrameWindow);
|
|
await EC_UpdateFrame.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per aggiungere window
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task AddSplit()
|
|
{
|
|
CurrFrameWindow.AddSplit();
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
var args = new DataUpdateFrame()
|
|
{
|
|
currFrame = CurrFrameWindow,
|
|
svgNoHw = true
|
|
};
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req=LayoutConst.DataAction.ResetDictShape});
|
|
if(SashList.Count > 0)
|
|
await EC_ReqOptionHw.InvokeAsync(CurrFrameWindow);
|
|
await EC_ReqElement.InvokeAsync(CurrFrameWindow);
|
|
await EC_UpdateFrame.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per cambiare tutti i joint
|
|
/// </summary>
|
|
/// <param name="JointType"></param>
|
|
/// <returns></returns>
|
|
private Task ChangeAllJoints(Json.WindowConst.Joints JointType)
|
|
{
|
|
foreach (Joint joint in CurrFrameWindow.JointList)
|
|
{
|
|
joint.SetSelJointType(JointType);
|
|
}
|
|
var args = new DataUpdateFrame() { currFrame = CurrFrameWindow, svgNoHw = false };
|
|
return EC_UpdateFrame.InvokeAsync(args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sollevo evento per tornare alla pagina Tree
|
|
/// </summary>
|
|
private void ReqClose()
|
|
{
|
|
_ = EC_ReqClose.InvokeAsync(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento dimensione editata
|
|
/// </summary>
|
|
/// <param name="updRec"> Dimensione aggiornata </param>
|
|
/// <returns></returns>
|
|
private async Task UpdateDim(FrameDimension updRec)
|
|
{
|
|
// cerco il record
|
|
var currRec = CurrFrameWindow.DimensionList.FirstOrDefault(x => x.ParentFrame == updRec.ParentFrame && x.nIndex == updRec.nIndex);
|
|
// lo aggiorno
|
|
if (updRec != null)
|
|
{
|
|
currRec = updRec;
|
|
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDimElem });
|
|
var args = new DataUpdateFrame()
|
|
{
|
|
currFrame = CurrFrameWindow,
|
|
svgNoHw = true
|
|
};
|
|
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDictShape });
|
|
await EC_ReqElement.InvokeAsync(CurrFrameWindow);
|
|
await EC_UpdateFrame.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento joint
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdateJoint(Joint updRec)
|
|
{
|
|
// cerco il record
|
|
var currRec = CurrFrameWindow.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
|
|
// lo aggiorno
|
|
if (updRec != null)
|
|
{
|
|
currRec = updRec;
|
|
var args = new DataUpdateFrame()
|
|
{
|
|
currFrame = CurrFrameWindow,
|
|
svgNoHw = false
|
|
};
|
|
await EC_UpdateFrame.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento element
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
/// <returns></returns>
|
|
private async Task UpdateElement(ElementDimension updRec)
|
|
{
|
|
// cerco il record
|
|
var currRec = CurrFrameWindow.ElementDimensionList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
|
|
// lo aggiorno
|
|
if (updRec != null)
|
|
{
|
|
currRec = updRec;
|
|
var args = new DataUpdateFrame()
|
|
{
|
|
currFrame = CurrFrameWindow,
|
|
svgNoHw = true
|
|
};
|
|
await EC_UpdateFrame.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento Frame
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
private async Task UpdateFrame(DataBottomRail updRec)
|
|
{
|
|
// lo aggiorno
|
|
if (updRec.frame != null)
|
|
{
|
|
CurrFrameWindow = updRec.frame;
|
|
var args = new DataUpdateFrame()
|
|
{
|
|
currFrame = CurrFrameWindow,
|
|
svgNoHw = true
|
|
};
|
|
await EC_UpdateFrame.InvokeAsync(args);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per la visualizzazione dei pulsanti joint
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
private string ButtonJointCss(Json.WindowConst.Joints type)
|
|
{
|
|
foreach (var item in CurrFrameWindow.JointList)
|
|
{
|
|
if (!item.SelJointType.Equals(type))
|
|
return "btn btn-outline-secondary btn-sm";
|
|
}
|
|
return "btn btn-secondary btn-sm";
|
|
}
|
|
|
|
private string EditDimensionCss()
|
|
{
|
|
if(CurrFrameWindow.DimensionList.Count % 2 == 0)
|
|
return "col-md-12 col-lg-6";
|
|
else
|
|
return "col-md-12 col-lg-4";
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe per raggruppare oggetti che servono per aggiornare frame
|
|
/// </summary>
|
|
public class DataUpdateFrame
|
|
{
|
|
#region Public Properties
|
|
|
|
public Frame currFrame { get; set; } = null!;
|
|
public bool svgNoHw { get; set; } = false;
|
|
public int groupIdDelete { get; set; } = -1;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
} |