7eaeca2bce
- aggiunti nuovi esempi JWD - aggiunto SVG - modificati titoli tabs - modificata tabs Frame - aggiunti metodi deserialize
126 lines
3.5 KiB
C#
126 lines
3.5 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();
|
|
m_SelSVG = m_SelTemplate.SVG;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private Template m_SelTemplate { get; set; } = null!;
|
|
|
|
public TemplateSelectDTO? SelTemplateDTO { get; set; } = null;
|
|
|
|
public Area m_SelArea { 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
|
|
|
|
protected Frame m_frame
|
|
{
|
|
get => (Frame)m_CurrWindow.AreaList[0];
|
|
}
|
|
|
|
#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 void AdvStep(CompileStep newStep)
|
|
{
|
|
currStep = newStep;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |