357b694581
- gestione oggetti sottostanti il template selezionato per interfaccia
178 lines
5.0 KiB
C#
178 lines
5.0 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Newtonsoft.Json;
|
|
using System.Collections.ObjectModel;
|
|
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 EventCallback<bool> EC_OnClose { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<string> EC_OnUpdate { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<TemplateSelectDTO> EC_OnSelectedTemplate { get; set; }
|
|
|
|
[Parameter]
|
|
public List<TemplateSelectDTO> IN_TemplateDTOList { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public Template IN_SelTemplate
|
|
{
|
|
get => m_SelTemplate;
|
|
set {
|
|
if (value != null && (m_SelTemplate == null || (m_SelTemplate != null && value.nIndex != m_SelTemplate.nIndex)) && !string.IsNullOrEmpty(value.JWD))
|
|
{
|
|
m_SelTemplate = value;
|
|
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(m_SelTemplate.JWD, new PolymorphicJsonConverter());
|
|
m_CurrWindow = WindowFromJson.Deserialize();
|
|
SearchInAreaList(m_CurrWindow.AreaList[0]);
|
|
m_SelSVG = m_SelTemplate.SVG;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private Template m_SelTemplate { get; set; } = null!;
|
|
|
|
public TemplateSelectDTO? SelTemplateDTO { get; set; } = null;
|
|
|
|
public string m_SelSVG { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Enums
|
|
|
|
protected enum CompileStep
|
|
{
|
|
Template = 0,
|
|
Frame = 1,
|
|
Split,
|
|
Sash,
|
|
Fill
|
|
}
|
|
|
|
#endregion Protected Enums
|
|
|
|
#region Protected Properties
|
|
|
|
private Frame m_Frame;
|
|
protected Frame Frame
|
|
{
|
|
get => m_Frame;
|
|
set => m_Frame = value;
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
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);
|
|
}
|
|
|
|
protected async void DoSelect(TemplateSelectDTO newSel)
|
|
{
|
|
SelTemplateDTO = newSel;
|
|
await EC_OnSelectedTemplate.InvokeAsync(newSel);
|
|
}
|
|
protected async Task DoSave()
|
|
{
|
|
var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented);
|
|
await EC_OnUpdate.InvokeAsync(CurrJwd);
|
|
}
|
|
protected async Task DoClose()
|
|
{
|
|
await EC_OnClose.InvokeAsync(true);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private CompileStep currStep = CompileStep.Template;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private Window m_CurrWindow { get; set; } = new Window();
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private List<Sash> m_SashList = new List<Sash>();
|
|
public List<Sash> SashList
|
|
{
|
|
get => m_SashList;
|
|
}
|
|
private List<Fill> m_FillList = new List<Fill>();
|
|
public List<Fill> FillList
|
|
{
|
|
get => m_FillList;
|
|
}
|
|
private List<Split> m_SplitList = new List<Split>();
|
|
public List<Split> SplitList
|
|
{
|
|
get => m_SplitList;
|
|
}
|
|
|
|
public void SearchInAreaList(Area node)
|
|
{
|
|
if (node != null)
|
|
{
|
|
switch (node.AreaType)
|
|
{
|
|
case AreaTypes.FRAME:
|
|
{
|
|
m_Frame = (Frame)node;
|
|
break;
|
|
}
|
|
case AreaTypes.SASH:
|
|
{
|
|
m_SashList.Add((Sash)node);
|
|
break;
|
|
}
|
|
case AreaTypes.FILL:
|
|
{
|
|
m_FillList.Add((Fill)node);
|
|
break;
|
|
}
|
|
case AreaTypes.SPLIT:
|
|
{
|
|
m_SplitList.Add((Split)node);
|
|
break;
|
|
}
|
|
}
|
|
foreach (var item in node.AreaList)
|
|
{
|
|
SearchInAreaList(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void AdvStep(CompileStep newStep)
|
|
{
|
|
currStep = newStep;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |