8289e8caba
- aggiunta lista di template
136 lines
8.5 KiB
C#
136 lines
8.5 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.Json;
|
|
using static WebWindowConfigurator.Json.WindowConst;
|
|
|
|
namespace WebWindowConfigurator
|
|
{
|
|
public partial class WebWindowMaker
|
|
{
|
|
#region Public Properties
|
|
protected enum CompileStep
|
|
{
|
|
Draft = 0,
|
|
General = 1,
|
|
Sash,
|
|
Split,
|
|
Fill
|
|
}
|
|
|
|
private CompileStep currStep = CompileStep.Draft;
|
|
|
|
[Parameter]
|
|
public string CurrJwd { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_Close { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<string> EC_Update { get; set; }
|
|
|
|
#endregion Public 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);
|
|
}
|
|
|
|
private void AdvStep(CompileStep newStep)
|
|
{
|
|
currStep = newStep;
|
|
//switch(newStep)
|
|
//{
|
|
// case CompileStep.General:
|
|
// {
|
|
|
|
// break;
|
|
// }
|
|
//}
|
|
}
|
|
private Window m_CurrWindow { get; set; } = new Window();
|
|
|
|
public Area m_SelArea { get; set; } = null!;
|
|
|
|
protected Frame m_frame
|
|
{
|
|
get => (Frame)m_CurrWindow.AreaList[0];
|
|
}
|
|
|
|
[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}")
|
|
};
|
|
public Template? SelTemplate { get; set; } = null;
|
|
public Template? InsideTemplate { get; set; } = null;
|
|
|
|
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);
|
|
}
|
|
|
|
public void ReadJwd()
|
|
{
|
|
if (SelTemplate == null || SelTemplate.JWDTemplate == null) { return; }
|
|
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(SelTemplate.JWDTemplate, new PolymorphicJsonConverter());
|
|
m_CurrWindow = WindowFromJson.Deserialize();
|
|
}
|
|
#endregion Protected Methods
|
|
}
|
|
|
|
public class Template
|
|
{
|
|
private int m_nIndex;
|
|
public int nIndex
|
|
{
|
|
get
|
|
{
|
|
return m_nIndex;
|
|
}
|
|
}
|
|
|
|
public string sDescription { get; set; } = "";
|
|
|
|
private string m_JWDTemplate;
|
|
public string JWDTemplate
|
|
{
|
|
get
|
|
{
|
|
return m_JWDTemplate;
|
|
}
|
|
}
|
|
|
|
public Template(int nIndex, string sDescription, string JWDTemplate)
|
|
{
|
|
m_nIndex = nIndex;
|
|
this.sDescription = sDescription;
|
|
m_JWDTemplate = JWDTemplate;
|
|
}
|
|
}
|
|
} |