Files
webwindowconfigurator/WebWindowConfigurator/WebWindowMaker.razor.cs
T

159 lines
9.0 KiB
C#

using Microsoft.AspNetCore.Components;
using Newtonsoft.Json;
using System.Reflection.Metadata;
using System.Runtime.Intrinsics.X86;
using System.Text.Json.Serialization;
using WebWindowConfigurator.DTO;
using WebWindowConfigurator.Json;
using static WebWindowConfigurator.Json.WindowConst;
namespace WebWindowConfigurator
{
public partial class WebWindowMaker
{
#region Public Properties
[Parameter]
public string CurrJwd { get; set; } = null!;
[Parameter]
public EventCallback<bool> EC_Close { get; set; }
[Parameter]
public EventCallback<TemplateSelectDTO> EC_TemplSelected { get; set; }
[Parameter]
public EventCallback<string> EC_Update { get; set; }
public Template? InsideTemplate { get; set; } = null;
[Parameter]
public List<TemplateSelectDTO> ListTemplates { get; set; } = null!;
[Parameter]
public Template m_CurrTemplate { get; set; } = null!;
public Area m_SelArea { get; set; } = null!;
#if false
[Parameter]
public List<Template> m_TemplateList { get; set; } = new List<Template>
{
new Template(1, "Anta singola","{\r\n \"ProfilePath\": \"Profilo78\",\r\n \"AreaList\": [\r\n {\r\n \"Shape\": \"RECTANGLE\",\r\n \"DimensionList\": [\r\n {\r\n \"nIndex\": 1,\r\n \"sName\": \"Width\",\r\n \"dValue\": 800.0\r\n },\r\n {\r\n \"nIndex\": 2,\r\n \"sName\": \"Height\",\r\n \"dValue\": 1200.0\r\n }\r\n ],\r\n \"JointList\": [\r\n {\r\n \"nIndex\": 1,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"nIndex\": 2,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"nIndex\": 3,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"nIndex\": 4,\r\n \"JointType\": \"FULL_H\"\r\n }\r\n ],\r\n \"BottomRail\": false,\r\n \"BottomRailQty\": 0,\r\n \"AreaList\": [\r\n {\r\n \"bIsSashVertical\": true,\r\n \"SashList\": [\r\n {\r\n \"OpeningType\": \"TILTTURN_LEFT\",\r\n \"bHasHandle\": true,\r\n \"dDimension\": 100.0\r\n }\r\n ],\r\n \"SashType\": \"NULL\",\r\n \"JointList\": [\r\n {\r\n \"nIndex\": 1,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"nIndex\": 2,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"nIndex\": 3,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"nIndex\": 4,\r\n \"JointType\": \"FULL_H\"\r\n }\r\n ],\r\n \"Hardware\": \"000000\",\r\n \"AreaList\": [\r\n {\r\n \"FillType\": \"GLASS\",\r\n \"AreaList\": [],\r\n \"AreaType\": \"FILL\"\r\n }\r\n ],\r\n \"AreaType\": \"SASH\"\r\n }\r\n ],\r\n \"AreaType\": \"FRAME\"\r\n }\r\n ]\r\n}"),
new Template(2, "Anta doppia", "{\r\n \"ProfilePath\": \"Profilo78\",\r\n \"AreaList\": [\r\n {\r\n \"Shape\": \"RECTANGLE\",\r\n \"DimensionList\": [\r\n {\r\n \"nIndex\": 1,\r\n \"sName\": \"Width\",\r\n \"dValue\": 1200.0\r\n },\r\n {\r\n \"nIndex\": 2,\r\n \"sName\": \"Height\",\r\n \"dValue\": 1400.0\r\n }\r\n ],\r\n \"JointList\": [\r\n {\r\n \"nIndex\": 1,\r\n \"JointType\": \"FULL_V\"\r\n },\r\n {\r\n \"nIndex\": 2,\r\n \"JointType\": \"FULL_V\"\r\n },\r\n {\r\n \"nIndex\": 3,\r\n \"JointType\": \"FULL_V\"\r\n },\r\n {\r\n \"nIndex\": 4,\r\n \"JointType\": \"FULL_V\"\r\n }\r\n ],\r\n \"BottomRail\": false,\r\n \"BottomRailQty\": 0,\r\n \"AreaList\": [\r\n {\r\n \"bIsSashVertical\": true,\r\n \"SashList\": [\r\n {\r\n \"OpeningType\": \"TURNONLY_LEFT\",\r\n \"bHasHandle\": false,\r\n \"dDimension\": 50.0\r\n },\r\n {\r\n \"OpeningType\": \"TILTTURN_RIGHT\",\r\n \"bHasHandle\": true,\r\n \"dDimension\": 50.0\r\n }\r\n ],\r\n \"SashType\": \"NULL\",\r\n \"JointList\": [\r\n {\r\n \"nIndex\": 1,\r\n \"JointType\": \"FULL_V\"\r\n },\r\n {\r\n \"nIndex\": 2,\r\n \"JointType\": \"FULL_V\"\r\n },\r\n {\r\n \"nIndex\": 3,\r\n \"JointType\": \"FULL_V\"\r\n },\r\n {\r\n \"nIndex\": 4,\r\n \"JointType\": \"FULL_V\"\r\n }\r\n ],\r\n \"Hardware\": \"000000\",\r\n \"AreaList\": [\r\n {\r\n \"AreaList\": [\r\n {\r\n \"FillType\": \"GLASS\",\r\n \"AreaList\": [],\r\n \"AreaType\": \"FILL\"\r\n }\r\n ],\r\n \"AreaType\": \"SPLITTED\"\r\n },\r\n {\r\n \"AreaList\": [\r\n {\r\n \"FillType\": \"GLASS\",\r\n \"AreaList\": [],\r\n \"AreaType\": \"FILL\"\r\n }\r\n ],\r\n \"AreaType\": \"SPLITTED\"\r\n }\r\n ],\r\n \"AreaType\": \"SASH\"\r\n }\r\n ],\r\n \"AreaType\": \"FRAME\"\r\n }\r\n ]\r\n}")
};
#endif
public TemplateSelectDTO? SelItem { get; set; } = null;
public Template? SelTemplate { get; set; } = null;
#endregion Public Properties
#region Public Methods
public void ReadJwd()
{
if (SelTemplate == null || string.IsNullOrEmpty(SelTemplate.JWDTemplate)) { return; }
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(SelTemplate.JWDTemplate, new PolymorphicJsonConverter());
m_CurrWindow = WindowFromJson.Deserialize();
}
#endregion Public Methods
#region Protected Enums
protected enum CompileStep
{
Draft = 0,
General = 1,
Sash,
Split,
Fill
}
#endregion Protected Enums
#region Protected Properties
protected Frame m_frame
{
get => (Frame)m_CurrWindow.AreaList[0];
}
#endregion Protected Properties
#region Protected Methods
protected async Task DoClose()
{
await EC_Close.InvokeAsync(true);
}
protected async Task DoSave()
{
//var CurrentWindow = new JsonWindow("Profilo68");
//var Frame = new JsonFrame(CurrWindow., false, 0);
//Frame.DimensionList.Add(new JsonFrameDimension(1, "Larghezza", CurrWindow.Height));
//Frame.DimensionList.Add(new JsonFrameDimension(1, "Altezza", CurrWindow.Width));
//Frame.AreaList.Add(new JsonSash(true, WindowConst.SashTypes.ACTIVE, ""));
//CurrentWindow.AreaList.Add(Frame);
//CurrJwd = @"prova";
//CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented);
await EC_Update.InvokeAsync(CurrJwd);
}
protected async void DoSelect(TemplateSelectDTO newSel)
{
SelItem = newSel;
//SelTemplate = item;
//ReadJwd();
await EC_TemplSelected.InvokeAsync(newSel);
// assegno template
SelTemplate = m_CurrTemplate;
ReadJwd();
}
protected override void OnInitialized()
{
//base.OnInitialized();
m_CurrWindow = new Window();
Frame NewFrame = (Frame)Frame.CreateFrame(m_CurrWindow);
m_CurrWindow.AreaList.Add(NewFrame);
m_SelArea = NewFrame;
Sash NewSash = Sash.CreateSash(NewFrame);
NewFrame.AreaList.Add(NewSash);
}
#endregion Protected Methods
#region Private Fields
private CompileStep currStep = CompileStep.Draft;
#endregion Private Fields
#region Private Properties
private Window m_CurrWindow { get; set; } = new Window();
#endregion Private Properties
#region Private Methods
private void AdvStep(CompileStep newStep)
{
currStep = newStep;
//switch(newStep)
//{
// case CompileStep.General:
// {
// break;
// }
//}
}
#endregion Private Methods
}
}