From 8ef408c244f64e0b4d07d7708f3973671f9df2ac Mon Sep 17 00:00:00 2001 From: Annamaria Sassi Date: Fri, 16 Jan 2026 15:10:19 +0100 Subject: [PATCH] Aggiunto componente semplificato (per utente base) --- Test.UI/Components/Layout/NavMenu.razor | 38 +- Test.UI/Components/Pages/EditJWD.razor | 3 +- Test.UI/Components/Pages/Error.razor | 36 - Test.UI/Components/Pages/Gerarchia.razor | 22 - Test.UI/Components/Pages/Gerarchia.razor.cs | 182 ---- Test.UI/Components/Pages/Home.razor | 3 +- Test.UI/Components/Pages/SimpleEdit.razor | 31 + Test.UI/Components/Pages/SimpleEdit.razor.cs | 351 ++++++++ .../Components/Pages/TestComponentJWD.razor | 25 - .../Pages/TestComponentJWD.razor.cs | 217 ----- .../Pages/TestComponentTemplate.razor | 24 - .../Pages/TestComponentTemplate.razor.cs | 215 ----- WebWindowComplex/WebWindowComplex.csproj | 4 +- .../WebWindowConfigurator.csproj | 60 +- WebWindowTest/Compo/AreaFrame.razor | 26 - WebWindowTest/Compo/AreaFrame.razor.cs | 49 -- WebWindowTest/Compo/AreaFrameArcElem.razor | 66 ++ WebWindowTest/Compo/AreaFrameArcElem.razor.cs | 84 ++ WebWindowTest/Compo/AreaHwOption.razor | 60 +- WebWindowTest/Compo/AreaHwOption.razor.cs | 60 +- WebWindowTest/Compo/AreaSash.razor | 185 ++-- WebWindowTest/Compo/AreaSash.razor.cs | 315 ++++++- WebWindowTest/Compo/AreaSashArcElem.razor | 58 ++ WebWindowTest/Compo/AreaSashArcElem.razor.cs | 78 ++ WebWindowTest/Compo/AreaSplit.razor | 10 +- WebWindowTest/Compo/AreaSplit.razor.cs | 62 +- WebWindowTest/Compo/CardArcElement.razor | 27 + WebWindowTest/Compo/CardArcElement.razor.cs | 60 ++ WebWindowTest/Compo/CardFill.razor | 34 +- WebWindowTest/Compo/CardFill.razor.cs | 80 +- WebWindowTest/Compo/CardFrame.razor | 65 +- WebWindowTest/Compo/CardFrame.razor.cs | 185 ++-- WebWindowTest/Compo/CardSashGroup.razor | 179 ++-- WebWindowTest/Compo/CardSashGroup.razor.cs | 359 +++++--- WebWindowTest/Compo/CardSplit.razor | 237 +++-- WebWindowTest/Compo/CardSplit.razor.cs | 264 ++++-- WebWindowTest/Compo/CardTree.razor | 5 + WebWindowTest/Compo/CardTree.razor.cs | 12 +- ...nsions.razor => EditFrameDimensions.razor} | 0 ....razor.cs => EditFrameDimensions.razor.cs} | 15 +- WebWindowTest/Compo/EditJoint.razor | 12 +- WebWindowTest/Compo/EditJoint.razor.cs | 9 +- WebWindowTest/Compo/EditOptionCombo.razor | 16 +- WebWindowTest/Compo/EditOptionCombo.razor.cs | 17 +- WebWindowTest/Compo/EditOptionText.razor | 30 +- WebWindowTest/Compo/EditOptionText.razor.cs | 17 +- WebWindowTest/Compo/EditSplitDimensions.razor | 34 + .../Compo/EditSplitDimensions.razor.cs | 151 ++++ WebWindowTest/Compo/General.razor | 8 +- WebWindowTest/Compo/General.razor.cs | 59 +- WebWindowTest/DTO/BaseListPayload.cs | 25 +- WebWindowTest/DTO/SelectPayload.cs | 8 +- WebWindowTest/DTO/TemplateSelectorDTO.cs | 17 - WebWindowTest/ItemTable.cs | 12 + WebWindowTest/Json/JsonUtility.cs | 240 ++++- WebWindowTest/Json/WindowConst.cs | 8 + WebWindowTest/LayoutConst.cs | 25 +- WebWindowTest/Models/AGBOptionText.cs | 15 +- WebWindowTest/Models/Area.cs | 452 +++++++++- WebWindowTest/Models/AreaDimension.cs | 350 ++++++++ WebWindowTest/Models/Fill.cs | 2 - WebWindowTest/Models/Frame.cs | 238 ++++- WebWindowTest/Models/FrameArcElement.cs | 121 +++ WebWindowTest/Models/FrameDimension.cs | 116 ++- WebWindowTest/Models/Joint.cs | 3 - WebWindowTest/Models/ParametriOpzioni.cs | 196 +++++ WebWindowTest/Models/Sash.cs | 259 +++--- WebWindowTest/Models/SashArcElement.cs | 96 ++ WebWindowTest/Models/SashDimension.cs | 695 +++++++++++++-- WebWindowTest/Models/Split.cs | 373 ++++---- WebWindowTest/Models/SplitDimension.cs | 777 ++++++++++++++-- WebWindowTest/Models/Window.cs | 66 +- WebWindowTest/SerialMan.cs | 81 -- WebWindowTest/Template.cs | 48 - WebWindowTest/Test.razor | 224 ++--- WebWindowTest/Test.razor.cs | 832 ++++++++---------- 76 files changed, 6405 insertions(+), 3013 deletions(-) delete mode 100644 Test.UI/Components/Pages/Error.razor delete mode 100644 Test.UI/Components/Pages/Gerarchia.razor delete mode 100644 Test.UI/Components/Pages/Gerarchia.razor.cs create mode 100644 Test.UI/Components/Pages/SimpleEdit.razor create mode 100644 Test.UI/Components/Pages/SimpleEdit.razor.cs delete mode 100644 Test.UI/Components/Pages/TestComponentJWD.razor delete mode 100644 Test.UI/Components/Pages/TestComponentJWD.razor.cs delete mode 100644 Test.UI/Components/Pages/TestComponentTemplate.razor delete mode 100644 Test.UI/Components/Pages/TestComponentTemplate.razor.cs delete mode 100644 WebWindowTest/Compo/AreaFrame.razor delete mode 100644 WebWindowTest/Compo/AreaFrame.razor.cs create mode 100644 WebWindowTest/Compo/AreaFrameArcElem.razor create mode 100644 WebWindowTest/Compo/AreaFrameArcElem.razor.cs create mode 100644 WebWindowTest/Compo/AreaSashArcElem.razor create mode 100644 WebWindowTest/Compo/AreaSashArcElem.razor.cs create mode 100644 WebWindowTest/Compo/CardArcElement.razor create mode 100644 WebWindowTest/Compo/CardArcElement.razor.cs rename WebWindowTest/Compo/{EditDimensions.razor => EditFrameDimensions.razor} (100%) rename WebWindowTest/Compo/{EditDimensions.razor.cs => EditFrameDimensions.razor.cs} (60%) create mode 100644 WebWindowTest/Compo/EditSplitDimensions.razor create mode 100644 WebWindowTest/Compo/EditSplitDimensions.razor.cs delete mode 100644 WebWindowTest/DTO/TemplateSelectorDTO.cs create mode 100644 WebWindowTest/Models/AreaDimension.cs create mode 100644 WebWindowTest/Models/FrameArcElement.cs create mode 100644 WebWindowTest/Models/ParametriOpzioni.cs create mode 100644 WebWindowTest/Models/SashArcElement.cs delete mode 100644 WebWindowTest/SerialMan.cs delete mode 100644 WebWindowTest/Template.cs diff --git a/Test.UI/Components/Layout/NavMenu.razor b/Test.UI/Components/Layout/NavMenu.razor index 046de1f..fbd3f65 100644 --- a/Test.UI/Components/Layout/NavMenu.razor +++ b/Test.UI/Components/Layout/NavMenu.razor @@ -21,44 +21,24 @@
diff --git a/Test.UI/Components/Pages/EditJWD.razor b/Test.UI/Components/Pages/EditJWD.razor index 4323a12..86eadf7 100644 --- a/Test.UI/Components/Pages/EditJWD.razor +++ b/Test.UI/Components/Pages/EditJWD.razor @@ -1,4 +1,5 @@ -@page "/EditJWD" +@page "/" +@page "/EditJWD" @rendermode InteractiveServer EditJWD diff --git a/Test.UI/Components/Pages/Error.razor b/Test.UI/Components/Pages/Error.razor deleted file mode 100644 index 576cc2d..0000000 --- a/Test.UI/Components/Pages/Error.razor +++ /dev/null @@ -1,36 +0,0 @@ -@page "/Error" -@using System.Diagnostics - -Error - -

Error.

-

An error occurred while processing your request.

- -@if (ShowRequestId) -{ -

- Request ID: @RequestId -

-} - -

Development Mode

-

- Swapping to Development environment will display more detailed information about the error that occurred. -

-

- The Development environment shouldn't be enabled for deployed applications. - It can result in displaying sensitive information from exceptions to end users. - For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development - and restarting the app. -

- -@code{ - [CascadingParameter] - private HttpContext? HttpContext { get; set; } - - private string? RequestId { get; set; } - private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - - protected override void OnInitialized() => - RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; -} diff --git a/Test.UI/Components/Pages/Gerarchia.razor b/Test.UI/Components/Pages/Gerarchia.razor deleted file mode 100644 index 4ff140c..0000000 --- a/Test.UI/Components/Pages/Gerarchia.razor +++ /dev/null @@ -1,22 +0,0 @@ -@page "/Gerarchia" -@rendermode InteractiveServer - -Gerarchia - - - -@* -

- @m_CurrArgs.GetValueOrDefault("Jwd") -

*@ diff --git a/Test.UI/Components/Pages/Gerarchia.razor.cs b/Test.UI/Components/Pages/Gerarchia.razor.cs deleted file mode 100644 index af57175..0000000 --- a/Test.UI/Components/Pages/Gerarchia.razor.cs +++ /dev/null @@ -1,182 +0,0 @@ -using EgwCoreLib.Lux.Core; -using EgwCoreLib.Lux.Core.RestPayload; -using EgwCoreLib.Lux.Data.Services; -using Microsoft.AspNetCore.Components; -using Newtonsoft.Json; -using NLog; -using System.Diagnostics; -using System.Security.AccessControl; -using Egw.Window.Data; -using WebWindowComplex; -using WebWindowComplex.DTO; - -namespace Test.UI.Components.Pages -{ - public partial class Gerarchia : IDisposable - { - #region Public Properties - - public string InitialJwd = ""; - - #endregion Public Properties - - #region Public Methods - - public void Dispose() - { - DLService.PipeSvg.EA_NewMessage -= PipeSvg_EA_NewMessage; - } - - #endregion Public Methods - - #region Protected Fields - - protected string currJwd = "..."; - protected Dictionary m_CurrArgs = new Dictionary(); - - #endregion Protected Fields - - #region Protected Properties - protected List AvailHardwareList { get; set; } = new List(); - protected List AvailFamilyHardwareList { get; set; } = new List() - { - new string("Natura"), - new string("Optima") - }; - protected List AvailColorMaterialList { get; set; } = new List() - { - new string("White"), - new string("Black"), - new string("Blu") - }; - protected List AvailMaterialList { get; set; } = new List() - { - new string("Pine"), - new string("Fir") - }; - protected List AvailGlassList { get; set; } = new List() - { - new string("4/12/4"), - new string("4/16/4"), - new string("4/12/4/12/4"), - new string("4/16/4/16/4"), - new string("4T/12/4T"), - new string("4T/16/4T") - }; - protected string SelFamilyHardware { get; set; } = ""; - protected string SelColorMaterial { get; set; } = ""; - protected string SelMaterial { get; set; } = ""; - protected string SelGlass { get; set; } = ""; - - [Inject] - protected IConfiguration Config { get; set; } = null!; - - [Inject] - protected DataLayerServices DLService { get; set; } = null!; - - [Inject] - protected ImageCacheService ICService { get; set; } = null!; - - protected MarkupString JsonSer - { - get => (MarkupString)currJwd.Replace(Environment.NewLine, "
").Replace(" ", " "); - } - - #endregion Protected Properties - - #region Protected Methods - - protected override async Task OnInitializedAsync() - { - ConfInit(); - SelFamilyHardware = "Natura"; - SelColorMaterial = "Black"; - SelMaterial = "Pine"; - SelGlass = "4T/16/4T"; - DLService.PipeSvg.EA_NewMessage += PipeSvg_EA_NewMessage; - await ReloadData(); - } - - #endregion Protected Methods - - #region Private Fields - - private string apiUrl = ""; - private string calcTag = ""; - private string CalcUid = "CurrWindow"; - private string cFileTemplate = "Data/Setup.json"; - private string cFileHardware = "Hardware/Setup.json"; - private string currSvg = ""; - - private string imgBasePath = ""; - private string GenericBasePath = ""; - - private string subChannel = ""; - - private string windowUid = "CurrWindow"; - - #endregion Private Fields - - #region Private Methods - - private async void PipeSvg_EA_NewMessage(object? sender, EventArgs e) - { - // aggiorno visualizzazione - PubSubEventArgs currArgs = (PubSubEventArgs)e; - // conversione on-the-fly SVG da mostrare - if (!string.IsNullOrEmpty(currArgs.newMessage)) - { - if (currArgs.msgUid.Equals($"{subChannel}:{windowUid}")) - { - currSvg = currArgs.newMessage; - } - await InvokeAsync(StateHasChanged); - } - await Task.Delay(1); - } - - private void ConfInit() - { - apiUrl = Config.GetValue("ServerConf:Prog.ApiUrl") ?? ""; - imgBasePath = Config.GetValue("ServerConf:ImageBaseUrl") ?? ""; - GenericBasePath = Config.GetValue("ServerConf:GenericBaseUrl") ?? ""; - calcTag = Config.GetValue("ServerConf:CalcTag") ?? ""; - subChannel = Config.GetValue("ServerConf:SvgChannel") ?? ""; - } - - /// - /// Rilettura dati - /// - /// - private async Task ReloadData() - { - //return base.OnInitializedAsync(); - AvailHardwareList = new List(); - if (File.Exists(cFileHardware)) - { - string rawValHW = File.ReadAllText(cFileHardware); - var rawListHW = JsonConvert.DeserializeObject>(rawValHW) ?? new List(); - foreach (var item in rawListHW) - { - AvailHardwareList.Add(item); - } - } - await Task.Delay(100); - } - - private async Task SaveJWD(Dictionary CurrArgs) - { - m_CurrArgs = CurrArgs; - // chiamo la chiamata POST alla API, che manda la richiesta via REDIS - if (currJwd != null) - { - CalcRequestDTO calcRequestDTO = new CalcRequestDTO(); - calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; - calcRequestDTO.DictExec = m_CurrArgs; - await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{CalcUid}", calcRequestDTO); - } - } - - #endregion Private Methods - } -} \ No newline at end of file diff --git a/Test.UI/Components/Pages/Home.razor b/Test.UI/Components/Pages/Home.razor index 937c361..e2be797 100644 --- a/Test.UI/Components/Pages/Home.razor +++ b/Test.UI/Components/Pages/Home.razor @@ -1,5 +1,4 @@ -@page "/" -@page "/Home" +@page "/Home" @rendermode InteractiveServer Select template diff --git a/Test.UI/Components/Pages/SimpleEdit.razor b/Test.UI/Components/Pages/SimpleEdit.razor new file mode 100644 index 0000000..e13eb56 --- /dev/null +++ b/Test.UI/Components/Pages/SimpleEdit.razor @@ -0,0 +1,31 @@ +@page "/SimpleEdit" +@rendermode InteractiveServer + +SimpleEdit + + + + + +@if (!string.IsNullOrEmpty(outClose)) +{ +
+ @outClose +
+} +else if (!string.IsNullOrEmpty(outSave)) +{ +
+ @outSave +
+} + +
+
+ @JsonSer +
+
diff --git a/Test.UI/Components/Pages/SimpleEdit.razor.cs b/Test.UI/Components/Pages/SimpleEdit.razor.cs new file mode 100644 index 0000000..efae394 --- /dev/null +++ b/Test.UI/Components/Pages/SimpleEdit.razor.cs @@ -0,0 +1,351 @@ +using Egw.Window.Data; +using EgwCoreLib.Lux.Core; +using EgwCoreLib.Lux.Core.RestPayload; +using EgwCoreLib.Lux.Data.Services; +using Microsoft.AspNetCore.Components; +using Newtonsoft.Json; +using WebWindowTest.DTO; +using static WebWindowTest.LayoutConst; + +namespace Test.UI.Components.Pages +{ + public partial class SimpleEdit : IDisposable + { + #region Public Fields + + public string InitialJwd = ""; + + #endregion Public Fields + + #region Public Methods + + public void Dispose() + { + DLService.PipeSvg.EA_NewMessage -= PipeSvg_EA_NewMessage; + DLService.PipeShape.EA_NewMessage -= PipeShape_EA_NewMessage; + DLService.PipeHwOpt.EA_NewMessage -= PipeHwOption_EA_NewMessage; + } + + #endregion Public Methods + + #region Protected Fields + + /// + /// Predisposizione valori live SVG/JWD + /// + protected LivePayload CurrData = new LivePayload(); + + protected Dictionary currGroupShape = new Dictionary(); + protected Dictionary currHwOption = new Dictionary(); + protected string currJwd = "..."; + protected Dictionary m_CurrArgs = new Dictionary(); + protected string prevJwd = ""; + + /// + /// Configurazione elenchi anagrafiche + /// + protected BaseListPayload SetupList = new BaseListPayload(); + + #endregion Protected Fields + + #region Protected Properties + + protected List AvailColorMaterialList { get; set; } = new List() + { + new string("White"), + new string("Wood"), + new string("Black"), + new string("Blu") + }; + + protected List AvailFamilyHardwareList { get; set; } = new List() + { + new string("ArTech"), + new string("ArTechPlana") + }; + + protected List AvailGlassList { get; set; } = new List() + { + new string("Vetro BE 2S 4/12/4"), + new string("Vetro BE 2S 4/16/4"), + new string("Vetro BE 3S 4/12/4/12/4"), + new string("Vetro BE 3S 4/16/4/16/4"), + new string("Vetro BE 2S 4T/12/4T"), + new string("Vetro BE 2S 4T/16/4T") + }; + + protected List AvailHardwareList { get; set; } = new List(); + + protected List AvailMaterialList { get; set; } = new List() + { + new string("Pino"), + new string("Abete") + }; + + protected List AvailProfileList { get; set; } = new List() + { + new string("Profilo78"), + new string("ProfiloSaomad") + }; + + protected Dictionary> AvailThreshold { get; set; } = new Dictionary>() + { + {"Profilo78", new List() { new Threshold(3, "Bottom"), new Threshold(1, "Threshold")}}, + {"ProfiloSaomad", new List(){ new Threshold(3, "Bottom"), new Threshold(2, "BottomWaterdrip"), new Threshold(1, "Threshold")}} + }; + + [Inject] + protected IConfiguration Config { get; set; } = null!; + + [Inject] + protected DataLayerServices DLService { get; set; } = null!; + + [Inject] + protected ImageCacheService ICService { get; set; } = null!; + + protected MarkupString JsonSer + { + get => (MarkupString)currJwd.Replace(Environment.NewLine, "
").Replace(" ", " "); + } + + protected string SelColorMaterial { get; set; } = ""; + protected string SelFamilyHardware { get; set; } = ""; + protected string SelGlass { get; set; } = ""; + protected string SelMaterial { get; set; } = ""; + + #endregion Protected Properties + + #region Protected Methods + + protected override void OnAfterRender(bool firstRender) + { + if (firstRender) + { + // JS interop or data fetches go here + isInteractive = true; + } + } + + protected override async Task OnInitializedAsync() + { + ConfInit(); + Random random = new Random(); + CalcUid = Convert.ToString(random.Next(1000, 10000)); + windowUid = CalcUid; + //InitialJwd = File.ReadAllText("Data\\FinestraSplitGrid.jwd"); + InitialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); + //InitialJwd = File.ReadAllText("Data\\ArcoAntaDoppia.jwd"); + currJwd = InitialJwd; + // rileggo altri dati + await ReloadData(); + // preparo conf oggetti x controllo + SetupList = new BaseListPayload() + { + ColorMaterial = AvailColorMaterialList, + FamilyHardware = AvailFamilyHardwareList, + Glass = AvailGlassList, + Hardware = AvailHardwareList, + Material = AvailMaterialList, + Profile = AvailProfileList, + Threshold = AvailThreshold + }; + CurrData = new LivePayload() + { + CurrJwd = InitialJwd, + SvgPreview = currSvg, + DictShape = currGroupShape, + DictOptionsXml = currHwOption + }; + DLService.PipeSvg.EA_NewMessage += PipeSvg_EA_NewMessage; + DLService.PipeShape.EA_NewMessage += PipeShape_EA_NewMessage; + DLService.PipeHwOpt.EA_NewMessage += PipeHwOption_EA_NewMessage; + } + + #endregion Protected Methods + + #region Private Fields + + private string apiUrl = ""; + private string calcTag = ""; + private string CalcUid = "CurrWindow"; + private string windowUid = "CurrWindow"; + private string cFileHardware = "Hardware/Setup.json"; + private string currSvg = ""; + private string GenericBasePath = ""; + + /// + /// Semaforo x definire se sia gi in modalit ionterattiva o di prerendering + /// + private bool isInteractive = false; + + private string outClose = ""; + private string outSave = ""; + + private string imgBasePath = ""; + + private string channelHwOpt = ""; + private string channelShape = ""; + private string channelSvg = ""; + + #endregion Private Fields + + #region Private Methods + + /// + /// Effettua chiusura oggetto con eventuale save + /// + /// + private void CloseObj(bool reqSave) + { + outClose = !reqSave ? "Richiesto chiusura!" : ""; + outSave = reqSave ? "Richiesto salvataggio!" : ""; + } + + private void ConfInit() + { + apiUrl = Config.GetValue("ServerConf:Prog.ApiUrl") ?? ""; + imgBasePath = Config.GetValue("ServerConf:ImageBaseUrl") ?? ""; + GenericBasePath = Config.GetValue("ServerConf:GenericBaseUrl") ?? ""; + calcTag = Config.GetValue("ServerConf:CalcTag") ?? ""; + channelSvg = Config.GetValue("ServerConf:ChannelSvg") ?? ""; + channelShape = Config.GetValue("ServerConf:ChannelShape") ?? ""; + channelHwOpt = Config.GetValue("ServerConf:ChannelHwOpt") ?? ""; + } + + /// + /// Esecuzione azione richiesta + /// + /// Azione richiesta + private void DoAction(DataAction actReq) + { + switch (actReq) + { + case DataAction.None: + break; + + case DataAction.ResetDictShape: + CurrData.DictShape = new Dictionary(); + break; + + case DataAction.ResetHwOpt: + CurrData.DictOptionsXml = new Dictionary(); + break; + + default: + break; + } + } + + /// + /// Esecuzione richiesta + /// + /// + /// + private async Task ExecRequest(Dictionary CurrArgs) + { + // Proseguo solo se sono in interattivo (NO prerender pagina) + if (isInteractive) + { + outClose = ""; + outSave = ""; + // verifico se contiene JWD, lo aggiorno + if (CurrArgs.ContainsKey("SerializedData")) + { + currJwd = CurrArgs["SerializedData"]; + CurrData.CurrJwd = currJwd; + } + // se il SSE variato --> invio + if (!currJwd.Equals(prevJwd) || !EgwCoreLib.Utils.DictUtils.DictAreEqual(m_CurrArgs, CurrArgs)) + { + m_CurrArgs = CurrArgs; + prevJwd = currJwd; + CalcRequestDTO calcRequestDTO = new CalcRequestDTO(); + calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + calcRequestDTO.DictExec = m_CurrArgs; + // chiamo la chiamata POST alla API, che manda la richiesta via REDIS + await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{CalcUid}", calcRequestDTO); + } + } + } + + private async void PipeHwOption_EA_NewMessage(object? sender, EventArgs e) + { + // aggiorno visualizzazione + PubSubEventArgs currArgs = (PubSubEventArgs)e; + // conversione on-the-fly SVG da mostrare + if (!string.IsNullOrEmpty(currArgs.newMessage)) + { + if (currArgs.msgUid.StartsWith($"{channelHwOpt}:{windowUid}") && currArgs.newMessage.Length > 2) + { + // deserializzo il dizionario delle risposte... + Dictionary rawDict = JsonConvert.DeserializeObject>(currArgs.newMessage) ?? new Dictionary(); + if (rawDict.Count > 0) + { + currHwOption = rawDict; + CurrData.DictOptionsXml = currHwOption; + } + } + await InvokeAsync(StateHasChanged); + } + await Task.Delay(1); + } + + private async void PipeShape_EA_NewMessage(object? sender, EventArgs e) + { + // aggiorno visualizzazione + PubSubEventArgs currArgs = (PubSubEventArgs)e; + // conversione on-the-fly SVG da mostrare + if (!string.IsNullOrEmpty(currArgs.newMessage) && currArgs.newMessage.Length > 2) + { + if (currArgs.msgUid.StartsWith($"{channelShape}:{windowUid}")) + { + // deserializzo il dizionario delle risposte... + var rawDict = JsonConvert.DeserializeObject>(currArgs.newMessage); + currGroupShape = rawDict ?? new Dictionary(); + CurrData.DictShape = currGroupShape; + } + await InvokeAsync(StateHasChanged); + } + await Task.Delay(1); + } + + private async void PipeSvg_EA_NewMessage(object? sender, EventArgs e) + { + // aggiorno visualizzazione + PubSubEventArgs currArgs = (PubSubEventArgs)e; + // conversione on-the-fly SVG da mostrare + if (!string.IsNullOrEmpty(currArgs.newMessage)) + { + if (currArgs.msgUid.Equals($"{channelSvg}:{windowUid}")) + { + currSvg = currArgs.newMessage; + CurrData.SvgPreview = currArgs.newMessage; + } + await InvokeAsync(StateHasChanged); + } + await Task.Delay(1); + } + + /// + /// Rilettura dati + /// + /// + private async Task ReloadData() + { + //return base.OnInitializedAsync(); + AvailHardwareList = new List(); + if (File.Exists(cFileHardware)) + { + string rawValHW = File.ReadAllText(cFileHardware); + var rawListHW = JsonConvert.DeserializeObject>(rawValHW) ?? new List(); + foreach (var item in rawListHW) + { + AvailHardwareList.Add(item); + } + } + await Task.Delay(100); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/Test.UI/Components/Pages/TestComponentJWD.razor b/Test.UI/Components/Pages/TestComponentJWD.razor deleted file mode 100644 index 880d345..0000000 --- a/Test.UI/Components/Pages/TestComponentJWD.razor +++ /dev/null @@ -1,25 +0,0 @@ -@page "/TestComponentJWD" -@rendermode InteractiveServer - -TestComponent - - - - - @* - IN_SelGlass="@SelGlass" - IN_SelFamilyHardware="@SelFamilyHardware" - IN_SelColorMaterial="@SelColorMaterial" - IN_SelMaterial="@SelMaterial" - *@ - -

- @m_CurrArgs.GetValueOrDefault("Jwd") -

\ No newline at end of file diff --git a/Test.UI/Components/Pages/TestComponentJWD.razor.cs b/Test.UI/Components/Pages/TestComponentJWD.razor.cs deleted file mode 100644 index 38f9c50..0000000 --- a/Test.UI/Components/Pages/TestComponentJWD.razor.cs +++ /dev/null @@ -1,217 +0,0 @@ -using EgwCoreLib.Lux.Core; -using EgwCoreLib.Lux.Core.RestPayload; -using EgwCoreLib.Lux.Data.Services; -using Microsoft.AspNetCore.Components; -using Newtonsoft.Json; -using NLog; -using System.Diagnostics; -using System.Security.AccessControl; -using Egw.Window.Data; -using WebWindowTest; -using WebWindowTest.DTO; - -namespace Test.UI.Components.Pages -{ - public partial class TestComponentJWD : IDisposable - { - #region Public Properties - - public string InitialJwd = ""; - public Template SelTemplate { get; set; } = new Template(0, "---SELECT---", "", ""); - - #endregion Public Properties - - #region Public Methods - - public void Dispose() - { - DLService.PipeSvg.EA_NewMessage -= PipeSvg_EA_NewMessage; - } - - #endregion Public Methods - - #region Protected Fields - - protected string currJwd = "..."; - protected Dictionary m_CurrArgs = new Dictionary(); - - #endregion Protected Fields - - #region Protected Properties - - protected List AvailTemplateList { get; set; } = new List(); - protected List AvailHardwareList { get; set; } = new List(); - protected List AvailFamilyHardwareList { get; set; } = new List() - { - new string("Natura"), - new string("Optima") - }; - protected List AvailColorMaterialList { get; set; } = new List() - { - new string("White"), - new string("Black"), - new string("Blu") - }; - protected List AvailMaterialList { get; set; } = new List() - { - new string("Pine"), - new string("Fir") - }; - protected List AvailGlassList { get; set; } = new List() - { - new string("4/12/4"), - new string("4/16/4"), - new string("4/12/4/12/4"), - new string("4/16/4/16/4"), - new string("4T/12/4T"), - new string("4T/16/4T") - }; - protected string SelFamilyHardware { get; set; } = ""; - protected string SelColorMaterial { get; set; } = ""; - protected string SelMaterial { get; set; } = ""; - protected string SelGlass { get; set; } = ""; - - [Inject] - protected IConfiguration Config { get; set; } = null!; - - [Inject] - protected DataLayerServices DLService { get; set; } = null!; - - [Inject] - protected ImageCacheService ICService { get; set; } = null!; - - protected MarkupString JsonSer - { - get => (MarkupString)currJwd.Replace(Environment.NewLine, "
").Replace(" ", " "); - } - - #endregion Protected Properties - - #region Protected Methods - - protected override async Task OnInitializedAsync() - { - ConfInit(); - SelFamilyHardware = "Natura"; - //SelColorMaterial = "Black"; - //SelColorMaterial = "Pine"; - //SelGlass = "4T/16/4T"; - InitialJwd = File.ReadAllText("Data\\FinDueAnteBottomFisso.jwd"); - currJwd = InitialJwd; - DLService.PipeSvg.EA_NewMessage += PipeSvg_EA_NewMessage; - await ReloadData(); - } - - #endregion Protected Methods - - #region Private Fields - - private string apiUrl = ""; - private string calcTag = ""; - private string CalcUid = "CurrWindow"; - private string cFileTemplate = "Data/Setup.json"; - private string cFileHardware = "Hardware/Setup.json"; - private TemplateSelectDTO? currSel = null; - private string currSvg = ""; - - private string imgBasePath = ""; - private string GenericBasePath = ""; - - private string subChannel = ""; - - private string windowUid = "CurrWindow"; - - #endregion Private Fields - - #region Private Methods - - private async void PipeSvg_EA_NewMessage(object? sender, EventArgs e) - { - // aggiorno visualizzazione - PubSubEventArgs currArgs = (PubSubEventArgs)e; - // conversione on-the-fly SVG da mostrare - if (!string.IsNullOrEmpty(currArgs.newMessage)) - { - if (currArgs.msgUid.Equals($"{subChannel}:{windowUid}")) - { - currSvg = currArgs.newMessage; - } - await InvokeAsync(StateHasChanged); - } - await Task.Delay(1); - } - - private void ConfInit() - { - apiUrl = Config.GetValue("ServerConf:Prog.ApiUrl") ?? ""; - imgBasePath = Config.GetValue("ServerConf:ImageBaseUrl") ?? ""; - GenericBasePath = Config.GetValue("ServerConf:GenericBaseUrl") ?? ""; - calcTag = Config.GetValue("ServerConf:CalcTag") ?? ""; - subChannel = Config.GetValue("ServerConf:SvgChannel") ?? ""; - } - - /// - /// Rilettura dati - /// - /// - private async Task ReloadData() - { - //return base.OnInitializedAsync(); - AvailTemplateList = new List(); - AvailHardwareList = new List(); - // brutale, da rivedere... - if (string.IsNullOrEmpty(InitialJwd)) - { - if (File.Exists(cFileTemplate)) - { - string rawVal = File.ReadAllText(cFileTemplate); - var rawList = JsonConvert.DeserializeObject>(rawVal) ?? new List(); - - // calcolo URL immagini... DTO interno da rivedere? - foreach (var item in rawList) - { - item.ImageUrl = ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, item.SVGFileName); - AvailTemplateList.Add(item); - } - } - } - if (File.Exists(cFileHardware)) - { - string rawValHW = File.ReadAllText(cFileHardware); - var rawListHW = JsonConvert.DeserializeObject>(rawValHW) ?? new List(); - foreach (var item in rawListHW) - { - AvailHardwareList.Add(item); - } - } - await Task.Delay(100); - } - - private async Task SaveJWD(Dictionary CurrArgs) - { - m_CurrArgs = CurrArgs; - // chiamo la chiamata POST alla API, che manda la richiesta via REDIS - if (currJwd != null) - { - CalcRequestDTO calcRequestDTO = new CalcRequestDTO(); - calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; - calcRequestDTO.DictExec = m_CurrArgs; - await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{CalcUid}", calcRequestDTO); - } - } - - private void SetTemplate(TemplateSelectDTO selTemp) - { - string rawVal = ""; - currSel = selTemp; - // brutale,d a rivedere... - if (File.Exists(selTemp.JwdFileName)) - { - rawVal = File.ReadAllText(selTemp.JwdFileName); - } - SelTemplate = new Template(selTemp.Index, selTemp.Description, selTemp.SVGFileName, rawVal); - } - - #endregion Private Methods - } -} \ No newline at end of file diff --git a/Test.UI/Components/Pages/TestComponentTemplate.razor b/Test.UI/Components/Pages/TestComponentTemplate.razor deleted file mode 100644 index 1af5145..0000000 --- a/Test.UI/Components/Pages/TestComponentTemplate.razor +++ /dev/null @@ -1,24 +0,0 @@ -@page "/TestComponentTemplate" -@rendermode InteractiveServer - -TestComponent - - - - -

- @m_CurrArgs.GetValueOrDefault("Jwd") -

diff --git a/Test.UI/Components/Pages/TestComponentTemplate.razor.cs b/Test.UI/Components/Pages/TestComponentTemplate.razor.cs deleted file mode 100644 index efb1b5d..0000000 --- a/Test.UI/Components/Pages/TestComponentTemplate.razor.cs +++ /dev/null @@ -1,215 +0,0 @@ -using EgwCoreLib.Lux.Core; -using EgwCoreLib.Lux.Core.RestPayload; -using EgwCoreLib.Lux.Data.Services; -using Microsoft.AspNetCore.Components; -using Newtonsoft.Json; -using NLog; -using System.Diagnostics; -using System.Security.AccessControl; -using Egw.Window.Data; -using WebWindowTest; -using WebWindowTest.DTO; - -namespace Test.UI.Components.Pages -{ - public partial class TestComponentTemplate : IDisposable - { - #region Public Properties - - public string InitialJwd = ""; - public Template SelTemplate { get; set; } = new Template(0, "---SELECT---", "", ""); - - #endregion Public Properties - - #region Public Methods - - public void Dispose() - { - DLService.PipeSvg.EA_NewMessage -= PipeSvg_EA_NewMessage; - } - - #endregion Public Methods - - #region Protected Fields - - protected string currJwd = "..."; - protected Dictionary m_CurrArgs = new Dictionary(); - - #endregion Protected Fields - - #region Protected Properties - - protected List AvailTemplateList { get; set; } = new List(); - protected List AvailHardwareList { get; set; } = new List(); - protected List AvailFamilyHardwareList { get; set; } = new List() - { - new string("Natura"), - new string("Optima") - }; - protected List AvailColorMaterialList { get; set; } = new List() - { - new string("White"), - new string("Black"), - new string("Blu") - }; - protected List AvailMaterialList { get; set; } = new List() - { - new string("Pine"), - new string("Fir") - }; - protected List AvailGlassList { get; set; } = new List() - { - new string("4/12/4"), - new string("4/16/4"), - new string("4/12/4/12/4"), - new string("4/16/4/16/4"), - new string("4T/12/4T"), - new string("4T/16/4T") - }; - protected string SelFamilyHardware { get; set; } = ""; - protected string SelColorMaterial { get; set; } = ""; - protected string SelMaterial { get; set; } = ""; - protected string SelGlass { get; set; } = ""; - - [Inject] - protected IConfiguration Config { get; set; } = null!; - - [Inject] - protected DataLayerServices DLService { get; set; } = null!; - - [Inject] - protected ImageCacheService ICService { get; set; } = null!; - - protected MarkupString JsonSer - { - get => (MarkupString)currJwd.Replace(Environment.NewLine, "
").Replace(" ", " "); - } - - #endregion Protected Properties - - #region Protected Methods - - protected override async Task OnInitializedAsync() - { - ConfInit(); - SelFamilyHardware = "Natura"; - SelColorMaterial = "Black"; - SelMaterial = "Pine"; - SelGlass = "4T/16/4T"; - DLService.PipeSvg.EA_NewMessage += PipeSvg_EA_NewMessage; - await ReloadData(); - } - - #endregion Protected Methods - - #region Private Fields - - private string apiUrl = ""; - private string calcTag = ""; - private string CalcUid = "CurrWindow"; - private string cFileTemplate = "Data/Setup.json"; - private string cFileHardware = "Hardware/Setup.json"; - private TemplateSelectDTO? currSel = null; - private string currSvg = ""; - - private string imgBasePath = ""; - private string GenericBasePath = ""; - - private string subChannel = ""; - - private string windowUid = "CurrWindow"; - - #endregion Private Fields - - #region Private Methods - - private async void PipeSvg_EA_NewMessage(object? sender, EventArgs e) - { - // aggiorno visualizzazione - PubSubEventArgs currArgs = (PubSubEventArgs)e; - // conversione on-the-fly SVG da mostrare - if (!string.IsNullOrEmpty(currArgs.newMessage)) - { - if (currArgs.msgUid.Equals($"{subChannel}:{windowUid}")) - { - currSvg = currArgs.newMessage; - } - await InvokeAsync(StateHasChanged); - } - await Task.Delay(1); - } - - private void ConfInit() - { - apiUrl = Config.GetValue("ServerConf:Prog.ApiUrl") ?? ""; - imgBasePath = Config.GetValue("ServerConf:ImageBaseUrl") ?? ""; - GenericBasePath = Config.GetValue("ServerConf:GenericBaseUrl") ?? ""; - calcTag = Config.GetValue("ServerConf:CalcTag") ?? ""; - subChannel = Config.GetValue("ServerConf:SvgChannel") ?? ""; - } - - /// - /// Rilettura dati - /// - /// - private async Task ReloadData() - { - //return base.OnInitializedAsync(); - AvailTemplateList = new List(); - AvailHardwareList = new List(); - // brutale, da rivedere... - if(string.IsNullOrEmpty(InitialJwd)) - { - if (File.Exists(cFileTemplate)) - { - string rawVal = File.ReadAllText(cFileTemplate); - var rawList = JsonConvert.DeserializeObject>(rawVal) ?? new List(); - - // calcolo URL immagini... DTO interno da rivedere? - foreach (var item in rawList) - { - item.ImageUrl = ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, item.SVGFileName); - AvailTemplateList.Add(item); - } - } - } - if (File.Exists(cFileHardware)) - { - string rawValHW = File.ReadAllText(cFileHardware); - var rawListHW = JsonConvert.DeserializeObject>(rawValHW) ?? new List(); - foreach (var item in rawListHW) - { - AvailHardwareList.Add(item); - } - } - await Task.Delay(100); - } - - private async Task SaveJWD(Dictionary CurrArgs) - { - m_CurrArgs = CurrArgs; - // chiamo la chiamata POST alla API, che manda la richiesta via REDIS - if (currJwd != null) - { - CalcRequestDTO calcRequestDTO = new CalcRequestDTO(); - calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; - calcRequestDTO.DictExec = m_CurrArgs; - await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{CalcUid}", calcRequestDTO); - } - } - - private void SetTemplate(TemplateSelectDTO selTemp) - { - string rawVal = ""; - currSel = selTemp; - // brutale,d a rivedere... - if (File.Exists(selTemp.JwdFileName)) - { - rawVal = File.ReadAllText(selTemp.JwdFileName); - } - SelTemplate = new Template(selTemp.Index, selTemp.Description, selTemp.SVGFileName, rawVal); - } - - #endregion Private Methods - } -} \ No newline at end of file diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index 812f6e0..e20b419 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.1.1316 + 2.7.1.1615 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -463,6 +463,8 @@ + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index cb5d0b8..3666e7e 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.1.1316 + 2.7.1.1615 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -586,6 +586,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebWindowTest/Compo/AreaFrame.razor b/WebWindowTest/Compo/AreaFrame.razor deleted file mode 100644 index f7330d5..0000000 --- a/WebWindowTest/Compo/AreaFrame.razor +++ /dev/null @@ -1,26 +0,0 @@ -@using WebWindowTest.Models -
-
-
-
-
Area frame
-
-
- @if (CurrSashList.Count == 0 && CurrSplitList.Count == 0) - { -
- -
- } -
-
- @if (!(CurrFrameWindow.AreaList[0] is Split)) - { -
- -
- } -
-
-
-
\ No newline at end of file diff --git a/WebWindowTest/Compo/AreaFrame.razor.cs b/WebWindowTest/Compo/AreaFrame.razor.cs deleted file mode 100644 index adb7428..0000000 --- a/WebWindowTest/Compo/AreaFrame.razor.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Microsoft.AspNetCore.Components; -using WebWindowTest.Models; - -namespace WebWindowTest.Compo -{ - public partial class AreaFrame - { - #region Public Properties - - [Parameter] - public Frame CurrFrameWindow { get; set; } = null!; - - [Parameter] - public List CurrSashList { get; set; } = null!; - - [Parameter] - public List CurrSplitList { get; set; } = null!; - - [Parameter] - public EventCallback EC_AddSash { get; set; } - - [Parameter] - public EventCallback EC_AddSplit { get; set; } - - #endregion Public Properties - - #region Private Methods - - /// - /// Sollevo evento richiesta aggiunta sash - /// - /// - private async Task RaiseAddSash() - { - await EC_AddSash.InvokeAsync(true); - } - - /// - /// Sollevo evento richiesta aggiunta window - /// - /// - private async Task RaiseAddSplit() - { - await EC_AddSplit.InvokeAsync(true); - } - - #endregion Private Methods - } -} \ No newline at end of file diff --git a/WebWindowTest/Compo/AreaFrameArcElem.razor b/WebWindowTest/Compo/AreaFrameArcElem.razor new file mode 100644 index 0000000..c167194 --- /dev/null +++ b/WebWindowTest/Compo/AreaFrameArcElem.razor @@ -0,0 +1,66 @@ + +
+
+
Frame
+
+
+
+
+
+
+
+ +
+
+
+ Qty element + @if (insertQty) + { + @* *@ + } + else + { + + } +
+
+
+
+
+ @* *@ +
+
+ +
+
+
+
+
+
+ +
+
+
+ Section + @if (!insertQty) + { + @* *@ + } + else + { + + } +
+
+
+
+
+ @* *@ +
+
+ +
+
+
+
+
diff --git a/WebWindowTest/Compo/AreaFrameArcElem.razor.cs b/WebWindowTest/Compo/AreaFrameArcElem.razor.cs new file mode 100644 index 0000000..22b6c28 --- /dev/null +++ b/WebWindowTest/Compo/AreaFrameArcElem.razor.cs @@ -0,0 +1,84 @@ +using Microsoft.AspNetCore.Components; +using System.Runtime.CompilerServices; +using WebWindowTest.DTO; +using WebWindowTest.Models; + +namespace WebWindowTest.Compo +{ + public partial class AreaFrameArcElem + { + #region Public Properties + + /// + /// Frame corrente + /// + [Parameter] + public Frame CurrFrame { get; set; } = null!; + + [Parameter] + public EventCallback EC_UpdatePreview { get; set; } + + #endregion Public Properties + + #region Protected Properties + + //protected int ArcElementQty + //{ + // get => CurrFrame.FrameArcElem.nQty; + // set + // { + // CurrFrame.FrameArcElem.nQty = value; + // _ = EC_UpdatePreview.InvokeAsync(CurrFrame); + // } + //} + + //protected double ArcSection + //{ + // get => CurrFrame.FrameArcElem.nSection; + // set + // { + // CurrFrame.FrameArcElem.nSection = value; + // _ = EC_UpdatePreview.InvokeAsync(CurrFrame); + // } + //} + + #endregion Protected Properties + + #region Protected Methods + + protected void IsCheckedQty() + { + insertQty = !insertQty; + } + + //protected void IsCheckCutEdge() + //{ + // CurrFrame.FrameArcElem.bCutEdge = !CurrFrame.FrameArcElem.bCutEdge; + // _ = EC_UpdatePreview.InvokeAsync(CurrFrame); + //} + + //protected void IsCheckAlign() + //{ + // CurrFrame.FrameArcElem.bIsAlign = !CurrFrame.FrameArcElem.bIsAlign; + // _ = EC_UpdatePreview.InvokeAsync(CurrFrame); + //} + + protected string IsUsedQty() + { + if (insertQty) + return "form-control"; + else + return "form-control disabled"; + } + + + #endregion Protected Methods + + #region Private Fields + + private bool insertQty = false; + + #endregion Private Fields + } + +} \ No newline at end of file diff --git a/WebWindowTest/Compo/AreaHwOption.razor b/WebWindowTest/Compo/AreaHwOption.razor index cd5f478..11255c5 100644 --- a/WebWindowTest/Compo/AreaHwOption.razor +++ b/WebWindowTest/Compo/AreaHwOption.razor @@ -1,38 +1,54 @@ @using static WebWindowTest.Json.WindowConst -
+
Hardware option
- +
- @if (isLoadingHwOpt && CurrSash.HwOptionList.Count == 0) + @if (!hwOptCollapsed) { - - } - @if (!hwOptCollapsed || !isLoadingHwOpt) - { - @foreach (var currOpt in CurrSash.HwOptionList) + @if (IsLoadingHwOpt) { - switch (currOpt.Type) - { - case HwOptionTypes.COMBO: +
+

+ + + + + + + + +

+
+ } + else + { +
+ @foreach (var currOpt in CurrSashGroup.HwOptionList) + { + switch (currOpt.Type) { - AGBOptionCombo currOptCombo = (AGBOptionCombo)currOpt; - - break; + case HwOptionTypes.COMBO: + { + AGBOptionCombo currOptCombo = (AGBOptionCombo)currOpt; + + break; + } + case HwOptionTypes.TEXT: + { + AGBOptionText currOptText = (AGBOptionText)currOpt; + + break; + } } - case HwOptionTypes.TEXT: - { - AGBOptionText currOptText = (AGBOptionText)currOpt; - - break; - } - } + } +
} } -
\ No newline at end of file diff --git a/WebWindowTest/Compo/AreaHwOption.razor.cs b/WebWindowTest/Compo/AreaHwOption.razor.cs index d4db986..2d719ad 100644 --- a/WebWindowTest/Compo/AreaHwOption.razor.cs +++ b/WebWindowTest/Compo/AreaHwOption.razor.cs @@ -11,60 +11,60 @@ namespace WebWindowTest.Compo /// /// Sash corrente rispetto alla lista Sash /// - [Parameter] - public Sash CurrSash { get; set; } = null!; + [CascadingParameter(Name = "CurrSashGroup")] + public Sash CurrSashGroup { get; set; } = null!; /// - /// Evento per aggiornare gli hardware option di tipo combo + /// Evento per aggiornare gli hardware option /// [Parameter] - public EventCallback EC_UpdateHwOptCombo { get; set; } - - /// - /// Evento per aggiornare gli hardware option di tipo text - /// - [Parameter] - public EventCallback EC_UpdateHwOptText { get; set; } + public EventCallback EC_UpdateHwOpt { get; set; } /// /// Evento per chiamare la prima volta la lista delle opzioni /// [Parameter] public EventCallback EC_FirstHwOptionList { get; set; } - - private bool isLoadingHwOpt { get; set; } - private bool hwOptCollapsed { get; set; } + [CascadingParameter(Name = "IsLoading")] + public List IsLoading { get; set; } = new List(); + + private bool hwOptCollapsed { get; set; } = true; + + protected override void OnAfterRender(bool firstRender) + { + if (firstRender) + { + hwOptCollapsed = true; + } + } private async Task changeCollapsed() { hwOptCollapsed = !hwOptCollapsed; - if(CurrSash.HwOptionList.Count == 0) + if (CurrSashGroup.HwOptionList.Count == 0) { - isLoadingHwOpt = true; - await EC_FirstHwOptionList.InvokeAsync(CurrSash.GroupId); + await EC_FirstHwOptionList.InvokeAsync(); } } - /// - /// Report aggiornamento Option Combo - /// - /// - /// - private async Task RaiseOptCombo(AGBOptionCombo updRec) + private string hwIcon { - await EC_UpdateHwOptCombo.InvokeAsync(updRec); + get => hwOptCollapsed ? "fa-solid fa-chevron-down" : "fa-solid fa-chevron-up"; } - /// - /// Report aggiornamento Option Text - /// - /// - /// - private async Task RaiseOptText(AGBOptionText updRec) + private bool IsLoadingHwOpt { - await EC_UpdateHwOptText.InvokeAsync(updRec); + get => IsLoading != null && IsLoading.Count > 0 && IsLoading.Contains("LoadHwOpt"); } + } + /// + /// Classe per oggetto di aggiornamento delle opzioni + /// + public class DataUpdateHwOption + { + public AGBOptionText AGBOptText { get; set; } = null!; + public AGBOptionCombo AGBOptCombo { get; set; } = null!; } } \ No newline at end of file diff --git a/WebWindowTest/Compo/AreaSash.razor b/WebWindowTest/Compo/AreaSash.razor index e394f42..63d894b 100644 --- a/WebWindowTest/Compo/AreaSash.razor +++ b/WebWindowTest/Compo/AreaSash.razor @@ -1,70 +1,129 @@ -@using WebWindowTest.Models -
-
-
Sash @(CurrSashGroup.SashList.Count == 1 ? "" : (IndexSash + 1))
-
-
- - -
-
- Dimension - - % -
-
-
- +@using EgwCoreLib.Razor +@if(mode == ModeView.View) +{ +
+
+
Sash @(CurrSashGroup.SashList.Count == 1 ? "" : (IndexSash + 1))
+
-
- +
+ Tipology +
-
- @if (!(CurrAnta.AreaList[0] is Split)) - { -
-
-
- -
+
+ Dimension + + +
+
+
+
-
-
- -
+
+
- } -
- @for (int k = 0; k <= CurrSashGroup.SashList.Count - 1; k++) - { - @if (k != IndexSash) - { - int IndexCopy = k; - int IndexModify = IndexSash; -
-
- +
+} +else +{ +
+
Sash @(CurrSashGroup.SashList.Count == 1 ? "" : (IndexSash + 1))
+ +
+
+
+
+ Tipology + +
+
+ Dimension + + +
+
+
+ +
+
+
- } - } -
-
+
+
+
+
+
Joints
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ @foreach (Joint joint in CurrSashDim.JointList) + { + + } +
+
+} diff --git a/WebWindowTest/Compo/AreaSash.razor.cs b/WebWindowTest/Compo/AreaSash.razor.cs index 09c7e32..7f17139 100644 --- a/WebWindowTest/Compo/AreaSash.razor.cs +++ b/WebWindowTest/Compo/AreaSash.razor.cs @@ -1,5 +1,9 @@ +using EgwCoreLib.Razor; using Microsoft.AspNetCore.Components; +using Newtonsoft.Json.Linq; +using System; using WebWindowTest.Models; +using static WebWindowTest.Json.WindowConst; namespace WebWindowTest.Compo { @@ -8,7 +12,7 @@ namespace WebWindowTest.Compo /// /// Sash group corrente /// - [Parameter] + [CascadingParameter(Name = "CurrSashGroup")] public Sash CurrSashGroup { get; set; } = null!; /// @@ -17,6 +21,18 @@ namespace WebWindowTest.Compo [Parameter] public SashDimension CurrSashDim { get; set; } = null!; + /// + /// Lista delle sash + /// + [CascadingParameter(Name = "SashList")] + public List SashList { get; set; } = null!; + + /// + /// Modalità di visualizzazione (view /edit) + /// + [Parameter] + public bool EditMode { get; set; } = false; + /// /// Indice della sash corrente /// @@ -24,26 +40,33 @@ namespace WebWindowTest.Compo public int IndexSash { get; set; } = 0; /// - /// Evento per cambiare l'anta su cui presente la maniglia + /// Evento per aggiornare sash dimension /// [Parameter] - public EventCallback EC_ChangeHandle { get; set; } + public EventCallback EC_UpdateSashDim { get; set; } + /// - /// Evento per cambiare l'anta su cui presente la maniglia + /// Evento per aggiornare sash /// [Parameter] - public EventCallback EC_CopyContentSash { get; set; } + public EventCallback EC_UpdateSash { get; set; } + + /// + /// Evento per cambiare modalità di visualizzazione + /// + [Parameter] + public EventCallback EC_EditView { get; set; } /// /// Anta corrente /// - public Area CurrAnta - { + public Area CurrAnta + { get { - if(CurrSashGroup.AreaList[IndexSash] is Splitted) -{ + if (CurrSashGroup.AreaList[IndexSash] is Splitted) + { return CurrSashGroup.AreaList[IndexSash]; } else @@ -58,49 +81,267 @@ namespace WebWindowTest.Compo } /// - /// Sollevo evento per cambiare l'anta su cui presente la maniglia + /// Metodo per avere il numero di decimali da usare nella form-input /// /// - private async Task RaiseChangeHandle(SashDimension sashDim, Sash currSash) + public int CssDecimals() { - var Args = new DataChangeHandle + switch (CurrSashDim.MeasureType) { - currSashDimension = sashDim, - currItem = currSash, - }; - await EC_ChangeHandle.InvokeAsync(Args); + case Json.WindowConst.MeasureTypes.ABSOLUTE: + { + return 2; + } + case Json.WindowConst.MeasureTypes.PROPORTIONAL: + { + return 0; + } + case Json.WindowConst.MeasureTypes.PERCENTAGE: + { + return 1; + } + } + return 0; } /// - /// Sollevo evento per cambiare l'anta su cui presente la maniglia + /// Metodo per avere il lo step da usare nella form-input /// /// - private async Task RaiseCopyContentSash(Sash currSash, int indexC, int indexM) + public double CssStepNumber() { - var Args = new DataCopyContentSash + switch (CurrSashDim.MeasureType) { - currItem = currSash, - indexCopy = indexC, - indexModify = indexM, + case Json.WindowConst.MeasureTypes.ABSOLUTE: + { + return 0.5; + } + case Json.WindowConst.MeasureTypes.PROPORTIONAL: + { + return 1; + } + case Json.WindowConst.MeasureTypes.PERCENTAGE: + { + return 0.5; + } + } + return 0; + } + + /// + /// Selezione tipo di apertura anta + /// + protected int OpeningTypeIndex + { + get => CurrSashDim.SelOpeningTypeIndex; + set + { + if (CurrSashDim.SelOpeningTypeIndex != value) + { + CurrSashDim.SelOpeningTypeIndex = value; + _ = EC_UpdateSashDim.InvokeAsync(CurrSashDim); + } + } + } + + /// + /// Selezione tipo di misura della dimensione dell'anta + /// + protected int MeasureTypeIndex + { + get => CurrSashDim.SelMeasureTypeIndex; + set + { + if (CurrSashDim.SelMeasureTypeIndex != value) + { + CurrSashDim.SelMeasureTypeIndex = value; + _ = EC_UpdateSashDim.InvokeAsync(CurrSashDim); + } + } + } + + /// + /// Inserimento dimensione anta + /// + protected double Dimension + { + get => CurrSashDim.dDimension; + set + { + if (CurrSashDim.dDimension != value) + { + CurrSashDim.dDimension = (double)Math.Round((decimal)value, CssDecimals()); + _ = EC_UpdateSashDim.InvokeAsync(CurrSashDim); + } + } + } + + /// + /// Sollevo evento richiesta per cambiare tutti i Joint + /// + /// + private async Task ChangeAllJoints(Json.WindowConst.Joints JointType) + { + foreach (var item in CurrSashDim.JointList) + item.SetSelJointType(JointType); + await EC_UpdateSashDim.InvokeAsync(CurrSashDim); + } + + /// + /// Aggiornamento joint + /// + /// + /// + private async Task UpdateJoint(Joint updRec) + { + // cerco il record + var currRec = CurrSashDim.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); + // lo aggiorno + if (updRec != null) + { + currRec = updRec; + await EC_UpdateSashDim.InvokeAsync(CurrSashDim); + } + } + + /// + /// Metodo per cambiare l'anta su cui è presente la maniglia + /// + /// + private async Task ChangeHandle() + { + // Cerco la Sash che si sta considerando nella lista Sash + var s = SashList.Where(x => x.GroupId == CurrSashGroup.GroupId).FirstOrDefault(); + if (s != null) + { + // Setto la presenza o meno della maniglia per ogni anta + foreach (SashDimension item in s.SashList) + { + if (item.Equals(CurrSashDim)) + { + item.bHasHandle = true; + } + else + { + if (item.bHasHandle) + { + switch (item.SelOpeningType) + { + case Openings.TILTTURN_LEFT: + { + item.SetOpeningType(Openings.TURNONLY_LEFT); + break; + } + case Openings.TILTTURN_RIGHT: + { + item.SetOpeningType(Openings.TURNONLY_RIGHT); + break; + } + default: + { + break; + } + } + } + item.bHasHandle = false; + } + } + } + CurrSashGroup.RefreshHardwareList(); + CurrSashGroup.SetFirstHardware(); + await EC_UpdateSash.InvokeAsync(CurrSashGroup); + } + + /// + /// Copio contenuto anta da indexCopy a IndexModify + /// + /// + private async Task CopyContentSash(int IndexCopy, int IndexModify) + { + isOpen = !isOpen; + // Anta selezionata + Area sashSplitted = CurrSashGroup.AreaList[IndexModify]; + // Rimuovo riempimento da anta selezionata + sashSplitted.AreaList.RemoveAt(0); + // Creo la copia dell'anta scelta + Area a = CurrSashGroup.AreaList[IndexCopy].AreaList.First().Copy(sashSplitted); + // Aggiungo copia all'anta selezionata + CurrSashGroup.AreaList[IndexModify].AreaList.Add(a); + await EC_UpdateSash.InvokeAsync(CurrSashGroup); + } + + /// + /// Metodo per aggiungere lo split nella singola anta + /// + /// + private async Task AddSplitToSash() + { + CurrAnta.AddSplit(); + await EC_UpdateSash.InvokeAsync(CurrSashGroup); + } + + private bool isOpen = false; + + private void ToggleDropdown() + { + isOpen = !isOpen; + } + + /// + /// Metodo per determinare la visualizzazione dei pulsanti dei joint + /// + /// + /// + private string ButtonJointCss(WebWindowTest.Json.WindowConst.Joints type) + { + foreach (var item in CurrSashDim.JointList) + { + if (!item.SelJointType.Equals(type)) + return "btn btn-outline-secondary btn-sm"; + } + return "btn btn-secondary btn-sm"; + } + + private enum ModeView + { + NULL = 0, + View = 1, + Edit = 2 + } + protected override void OnParametersSet() + { + if (EditMode) + mode = ModeView.Edit; + else + mode = ModeView.View; + } + private ModeView mode { get; set; } = ModeView.View; + private void doEdit(int index) + { + var args = new DataChangeMode + { + Edit = true, + IndexSashEdit = index, + IndexSashClose = -1 }; - await EC_CopyContentSash.InvokeAsync(Args); + _ = EC_EditView.InvokeAsync(args); + } + protected void ClosePopup(int index) + { + var args = new DataChangeMode + { + Edit = false, + IndexSashEdit = -1, + IndexSashClose = index + }; + _ = EC_EditView.InvokeAsync(args); } } - public class DataChangeHandle - { - public SashDimension currSashDimension { get; set; } = null!; - public Sash currItem { get; set; } = null!; - + public class DataChangeMode { + public bool Edit { get; set; } + public int IndexSashEdit { get; set; } + public int IndexSashClose { get; set; } } - public class DataCopyContentSash - { - public Sash currItem { get; set; } = null!; - - public int indexCopy { get; set; } = 0; - - public int indexModify { get; set; } = 0; - - } } \ No newline at end of file diff --git a/WebWindowTest/Compo/AreaSashArcElem.razor b/WebWindowTest/Compo/AreaSashArcElem.razor new file mode 100644 index 0000000..4c0f3ae --- /dev/null +++ b/WebWindowTest/Compo/AreaSashArcElem.razor @@ -0,0 +1,58 @@ + +
+
+
Sash
+
+
+
+
+
+
+
+ +
+
+
+ Qty element + @if (insertQty) + { + @* *@ + } + else + { + + } +
+
+
+
+
+ @* *@ +
+
+ +
+
+
+
+
+
+ +
+
+
+ Section + @if (!insertQty) + { + @* *@ + } + else + { + + } +
+
+
+
+
+
diff --git a/WebWindowTest/Compo/AreaSashArcElem.razor.cs b/WebWindowTest/Compo/AreaSashArcElem.razor.cs new file mode 100644 index 0000000..9999b2b --- /dev/null +++ b/WebWindowTest/Compo/AreaSashArcElem.razor.cs @@ -0,0 +1,78 @@ +using Microsoft.AspNetCore.Components; +using System.Runtime.CompilerServices; +using WebWindowTest.DTO; +using WebWindowTest.Models; + +namespace WebWindowTest.Compo +{ + public partial class AreaSashArcElem + { + #region Public Properties + + /// + /// Sash corrente + /// + [Parameter] + public Sash CurrSashGroup { get; set; } = null!; + + [Parameter] + public EventCallback EC_UpdatePreview { get; set; } + + #endregion Public Properties + + #region Protected Properties + + //protected int ArcElementQty + //{ + // get => CurrSashGroup.SashArcElem.nQty; + // set + // { + // CurrSashGroup.SashArcElem.nQty = value; + // _ = EC_UpdatePreview.InvokeAsync(CurrSashGroup); + // } + //} + + //protected double ArcSection + //{ + // get => CurrSashGroup.SashArcElem.nSection; + // set + // { + // CurrSashGroup.SashArcElem.nSection = value; + // _ = EC_UpdatePreview.InvokeAsync(CurrSashGroup); + // } + //} + + #endregion Protected Properties + + #region Protected Methods + + protected void IsCheckedQty() + { + insertQty = !insertQty; + } + + //protected void IsCheckCutEdge() + //{ + // CurrSashGroup.SashArcElem.bCutEdge = !CurrSashGroup.SashArcElem.bCutEdge; + // _ = EC_UpdatePreview.InvokeAsync(CurrSashGroup); + //} + + protected string IsUsedQty() + { + if (insertQty) + return "form-control"; + else + return "form-control disabled"; + } + + + #endregion Protected Methods + + #region Private Fields + + private bool insertQty = false; + + #endregion Private Fields + } + +} \ No newline at end of file diff --git a/WebWindowTest/Compo/AreaSplit.razor b/WebWindowTest/Compo/AreaSplit.razor index 4b2664d..96087ee 100644 --- a/WebWindowTest/Compo/AreaSplit.razor +++ b/WebWindowTest/Compo/AreaSplit.razor @@ -1,20 +1,20 @@ 
-
-
Area split @(CurrSplittedList.Count > 1 ? (CurrSplittedList.IndexOf(CurrSplitted) + 1) : "")
+
+
Area split @(SplittedList.Count > 1 ? (SplittedList.IndexOf(CurrSplitted) + 1) : "")
- +
- @for (int j = 0; j < CurrSashList.Count; j++) + @for (int j = 0; j < SashList.Count; j++) { int Index = j;
- +
}
diff --git a/WebWindowTest/Compo/AreaSplit.razor.cs b/WebWindowTest/Compo/AreaSplit.razor.cs index 3e1fa53..66d3d28 100644 --- a/WebWindowTest/Compo/AreaSplit.razor.cs +++ b/WebWindowTest/Compo/AreaSplit.razor.cs @@ -12,80 +12,56 @@ namespace WebWindowTest.Compo /// Lista delle sash ///
[Parameter] - public List CurrSashList { get; set; } = null; + public List SashList { get; set; } = null!; /// /// Oggetto splitted corrente /// [Parameter] - public Splitted CurrSplitted { get; set; } = null; + public Splitted CurrSplitted { get; set; } = null!; /// /// Lista degli Splitted /// [Parameter] - public List CurrSplittedList { get; set; } = null; - - /// - /// Evento per copiare Sash - /// - [Parameter] - public EventCallback EC_CopySash { get; set; } + public List SplittedList { get; set; } = null!; /// /// Evento per aggiungere Sash /// [Parameter] - public EventCallback EC_AddSash { get; set; } + public EventCallback EC_UpdateSplitted { get; set; } #endregion Public Properties #region Private Methods /// - /// Sollevo evento richiesta copia sash + /// Metodo per copiare sash /// /// - private async Task RaiseCopySash(Splitted item, int indexCurrSash) + private async Task RaiseCopySash(int indexCurrSash) { - var Args = new DataAreaSplit - { - splitted = item, - index = indexCurrSash, - }; - await EC_CopySash.InvokeAsync(Args); + //Rimuovo contenuto di Splitted e rimuovo area da conteggio gruppi + CurrSplitted.AreaList.RemoveAll(i => i != null); + // Copio sash + Area a = SashList[indexCurrSash].Copy(CurrSplitted); + a.SetParentArea(CurrSplitted); + // Aggiungo copia a Splitted + CurrSplitted.AreaList.Add(a); + await EC_UpdateSplitted.InvokeAsync(CurrSplitted); } /// - /// Sollevo evento richiesta copia sash + /// Metodo per aggiungere prima sash /// /// - private async Task RaiseAddSash(Splitted item) + private async Task RaiseAddSash() { - var Args = new DataAreaSplitted - { - splitted = item - }; - await EC_AddSash.InvokeAsync(Args); + CurrSplitted.AddFirstSash(); + await EC_UpdateSplitted.InvokeAsync(CurrSplitted); } + #endregion Private Methods - - } - - /// - /// Classe per raggruppare oggetti che servono per copiare Sash - /// - public class DataAreaSplit - { - public Splitted splitted { get; set; } - public int index { get; set; } - } - - /// - /// Classe per raggruppare oggetti che servono per aggiungere Sash - /// - public class DataAreaSplitted - { - public Splitted splitted { get; set; } } } \ No newline at end of file diff --git a/WebWindowTest/Compo/CardArcElement.razor b/WebWindowTest/Compo/CardArcElement.razor new file mode 100644 index 0000000..e29174e --- /dev/null +++ b/WebWindowTest/Compo/CardArcElement.razor @@ -0,0 +1,27 @@ +
+
+
+
+
Arc Element
+
+
+ +
+
+
+
+
+ + + + @foreach (var sashGroup in SashList) + { +
+ + + } +
+
+
\ No newline at end of file diff --git a/WebWindowTest/Compo/CardArcElement.razor.cs b/WebWindowTest/Compo/CardArcElement.razor.cs new file mode 100644 index 0000000..0e7210c --- /dev/null +++ b/WebWindowTest/Compo/CardArcElement.razor.cs @@ -0,0 +1,60 @@ +using Microsoft.AspNetCore.Components; +using WebWindowTest.DTO; +using WebWindowTest.Models; + +namespace WebWindowTest.Compo +{ + public partial class CardArcElement + { + #region Public Properties + + /// + /// Frame corrente + /// + [Parameter] + public Frame CurrFrame { get; set; } = null!; + + /// + /// Lista sash group + /// + [Parameter] + public List SashList { get; set; } = null!; + + [Parameter] + public EventCallback EC_UpdatePreview { get; set; } + + [Parameter] + public EventCallback EC_ReqClose { get; set; } + + #endregion Public Properties + + private async Task UpdatePreview() + { + var args = new DataUpdateFrame + { + currFrame = CurrFrame + }; + await EC_UpdatePreview.InvokeAsync(args); + } + + private async Task UpdatePreviewSash(Sash CurrSashGRoup) + { + var currRec = SashList.First(x => x.GroupId == CurrSashGRoup.GroupId); + if (currRec != null) + { + currRec = CurrSashGRoup; + var args = new DataUpdateFrame + { + currFrame = CurrFrame + }; + await EC_UpdatePreview.InvokeAsync(args); + } + } + + private void ReqClose() + { + _ = EC_ReqClose.InvokeAsync(true); + } + } + +} \ No newline at end of file diff --git a/WebWindowTest/Compo/CardFill.razor b/WebWindowTest/Compo/CardFill.razor index 55c5fd6..aa3c88b 100644 --- a/WebWindowTest/Compo/CardFill.razor +++ b/WebWindowTest/Compo/CardFill.razor @@ -1,7 +1,7 @@ 
-
+
Fill @(CurrIndex + 1)
@@ -11,8 +11,8 @@
-
-
+
+
Select only current fill
@@ -26,33 +26,5 @@
-
-
-
Selected all fill
-
-
-
- -
-
-
-
- -
-
-
-@foreach (var currSplitted in SplittedList) -{ - @if (currSplitted.AreaList.First().Equals(CurrItem)) - { - - - } -} - diff --git a/WebWindowTest/Compo/CardFill.razor.cs b/WebWindowTest/Compo/CardFill.razor.cs index 1bec7eb..5fd7c53 100644 --- a/WebWindowTest/Compo/CardFill.razor.cs +++ b/WebWindowTest/Compo/CardFill.razor.cs @@ -18,31 +18,13 @@ namespace WebWindowTest.Compo /// Fill corrente rispetto alla lista fill /// [Parameter] - public Fill CurrItem { get; set; } = null!; + public Fill CurrFill { get; set; } = null!; /// /// Evento per cambiare tutti i fill /// [Parameter] - public EventCallback EC_ChangeAllType { get; set; } - - /// - /// Evento per cambiare solo il fill corrente - /// - [Parameter] - public EventCallback EC_ChangeType { get; set; } - - /// - /// Evento per copiare sash - /// - [Parameter] - public EventCallback EC_CopySash { get; set; } - - /// - /// Evento per aggiungere sash - /// - [Parameter] - public EventCallback EC_AddSash { get; set; } + public EventCallback EC_UpdateFill { get; set; } /// /// Evento per tornare nella pagine Tree @@ -50,67 +32,19 @@ namespace WebWindowTest.Compo [Parameter] public EventCallback EC_ReqClose { get; set; } - /// - /// Lista dei Fill - /// - [Parameter] - public List FillList { get; set; } = null!; - - /// - /// Lista delle sash - /// - [Parameter] - public List SashList { get; set; } = null!; - - /// - /// Lista degli Splitted - /// - [Parameter] - public List SplittedList { get; set; } = null!; - - #endregion Public Properties #region Protected Methods /// - /// Sollevo evento per cambiare tutti i Fill - /// - /// tipo di fill richiesto - /// - protected async Task ChangeAllFill(FillTypes reqFillType) - { - await EC_ChangeAllType.InvokeAsync(reqFillType); - } - - /// - /// Sollevo evento per cambiare solo il Fill corrente + /// Metodo per cambiare solo il Fill corrente /// /// tipo di fill richiesto /// protected async Task ChangeOneFill(FillTypes reqFillType) { - await EC_ChangeType.InvokeAsync(reqFillType); - } - - /// - /// Sollevo evento per copiare sash - /// - /// - /// - protected async Task CopySash(DataAreaSplit Args) - { - await EC_CopySash.InvokeAsync(Args); - } - - /// - /// Sollevo evento per aggiungere sash - /// - /// - /// - protected async Task AddSash(DataAreaSplitted Args) - { - await EC_AddSash.InvokeAsync(Args); + CurrFill.SetFillType(reqFillType); + await EC_UpdateFill.InvokeAsync(CurrFill); } #endregion Protected Methods @@ -118,7 +52,7 @@ namespace WebWindowTest.Compo #region Private Methods /// - /// Sollevo evento per tornare alla pagina Tree + /// Metodo per tornare alla pagina Tree /// private void ReqClose() { @@ -131,7 +65,7 @@ namespace WebWindowTest.Compo /// private string buttonFillCss(FillTypes reqFillTypes) { - return (FillList.ElementAt(CurrIndex).SelFillType == reqFillTypes) ? "btn btn-secondary btn-sm" : "btn btn-outline-secondary btn-sm"; + return (CurrFill.SelFillType == reqFillTypes) ? "btn btn-secondary btn-sm" : "btn btn-outline-secondary btn-sm"; } #endregion Private Methods diff --git a/WebWindowTest/Compo/CardFrame.razor b/WebWindowTest/Compo/CardFrame.razor index f1cb2e9..8db4f5d 100644 --- a/WebWindowTest/Compo/CardFrame.razor +++ b/WebWindowTest/Compo/CardFrame.razor @@ -1,5 +1,4 @@ -@using WebWindowTest.Models -@using static WebWindowTest.LayoutConst +@using static WebWindowTest.LayoutConst
@@ -14,81 +13,69 @@
-
+
- - + Tipology +

-
+
Dimension
- @foreach (FrameDimension dimension in FrameWindow.DimensionList) + @foreach (FrameDimension dimension in CurrFrameWindow.DimensionList) { - + }
-
+
Threshold
- - + Tipology +

-
+
Joints
- +
- +
- +
- @foreach (Joint joint in FrameWindow.JointList) + @foreach (Joint joint in CurrFrameWindow.JointList) { + @*
+ @((PositionJoints)(joint.nIndex - 1)) + +
*@ }
-
+
@if (SashList.Count == 0) {
@@ -97,7 +84,7 @@
Quantity - +
} @@ -105,13 +92,3 @@
- -@if (!(FrameWindow.AreaList[0] is Split) || (SashList.Count == 0 && SplitList.Count == 0)) -{ - - -} diff --git a/WebWindowTest/Compo/CardFrame.razor.cs b/WebWindowTest/Compo/CardFrame.razor.cs index 5cd3b74..d14f19c 100644 --- a/WebWindowTest/Compo/CardFrame.razor.cs +++ b/WebWindowTest/Compo/CardFrame.razor.cs @@ -1,3 +1,4 @@ +using Egw.Window.Data; using Microsoft.AspNetCore.Components; using WebWindowTest.Models; @@ -7,24 +8,6 @@ namespace WebWindowTest.Compo { #region Public Properties - /// - /// Evento per aggiungere sash - /// - [Parameter] - public EventCallback EC_AddSash { get; set; } - - /// - /// Evento per aggiungere split - /// - [Parameter] - public EventCallback EC_AddSplit { get; set; } - - /// - /// Evento per cambiare tutti i Joints - /// - [Parameter] - public EventCallback EC_ChangeAllJoints { get; set; } - /// /// Evento per tornare nella pagine Tree /// @@ -35,58 +18,111 @@ namespace WebWindowTest.Compo /// Evento per richiedere reset dizionario Shape ///
[Parameter] - public EventCallback EC_ReqResetDictShape { get; set; } + public EventCallback EC_ReqResetDict { get; set; } /// - /// Evento per aggiornare info frame (es cambaire tutti i Joints) + /// Evento per richiedere opzioni hardware /// [Parameter] - public EventCallback EC_UpdateFrame { get; set; } - + public EventCallback EC_ReqOptionHw { get; set; } + /// - /// Evento per richiesta calcolo Shape + /// Evento per richiesta calcolo preview /// [Parameter] - public EventCallback EC_UpdateShape { get; set; } + public EventCallback EC_UpdateFrame { get; set; } /// /// Frame corrente /// - [Parameter] - public Frame FrameWindow { get; set; } = null!; + [CascadingParameter(Name = "CurrFrameWindow")] + public Frame CurrFrameWindow { get; set; } = null!; /// /// Lista di sash /// - [Parameter] + [CascadingParameter(Name = "SashList")] public List SashList { get; set; } = null!; /// /// Lista di split /// - [Parameter] + [CascadingParameter(Name = "SplitList")] public List SplitList { get; set; } = null!; #endregion Public Properties #region Protected Properties + /// + /// Metodo per selezionare shape + /// protected int SelShapeIndex { - get => FrameWindow.SelShapeIndex; + get => CurrFrameWindow.SelShapeIndex; set { - if (FrameWindow.SelShapeIndex != value) + if (CurrFrameWindow.SelShapeIndex != value) { + CurrFrameWindow.SelShapeIndex = value; // richiesta reset dict shape - _ = EC_ReqResetDictShape.InvokeAsync(true); - FrameWindow.SelShapeIndex = value; + _ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDictShape}); foreach(var s in SashList) { s.SelHardwareFromId = "000000"; } - _ = EC_UpdateFrame.InvokeAsync(FrameWindow); - _ = EC_UpdateShape.InvokeAsync(FrameWindow); + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = true + }; + _ = EC_UpdateFrame.InvokeAsync(args); + } + } + } + + /// + /// Metodo per selezionare threshold + /// + protected int SelThreshold + { + get => CurrFrameWindow.SelThresholdFromType; + set + { + if (CurrFrameWindow.SelThresholdFromType != value) + { + CurrFrameWindow.SelThresholdFromType = value; + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = false + }; + _ = EC_UpdateFrame.InvokeAsync(args); + } + } + } + + /// + /// Selezione quantit bottom rail + /// + 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); } } } @@ -96,36 +132,24 @@ namespace WebWindowTest.Compo #region Private Methods /// - /// Sollevo evento richiesta aggiunta sash - /// - /// - private async Task AddSash() - { - //await EC_UpdateShape.InvokeAsync(FrameWindow); - await EC_AddSash.InvokeAsync(true); - } - - /// - /// Sollevo evento richiesta aggiunta window - /// - /// - private async Task AddSplit() - { - await EC_AddSplit.InvokeAsync(true); - } - - /// - /// Sollevo evento richiesta copia sash + /// Metodo per cambiare tutti i joint /// /// private async Task ChangeAllJoints(Json.WindowConst.Joints JointType, Area a) { - var Args = new DataChangeJoints + if (a is Frame) { - currJointType = JointType, - currArea = a, + foreach (Joint joint in CurrFrameWindow.JointList) + { + joint.SetSelJointType(JointType); + } + } + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = false }; - await EC_ChangeAllJoints.InvokeAsync(Args); + await EC_UpdateFrame.InvokeAsync(args); } /// @@ -143,45 +167,70 @@ namespace WebWindowTest.Compo private async Task UpdateDim(FrameDimension updRec) { // cerco il record - var currRec = FrameWindow.DimensionList.FirstOrDefault(x => x.ParentFrame == updRec.ParentFrame && x.nIndex == updRec.nIndex); + var currRec = CurrFrameWindow.DimensionList.FirstOrDefault(x => x.ParentFrame == updRec.ParentFrame && x.nIndex == updRec.nIndex); // lo aggiorno if (updRec != null) { currRec = updRec; - await EC_UpdateShape.InvokeAsync(FrameWindow); - await EC_UpdateFrame.InvokeAsync(FrameWindow); + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = true + }; + await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDictShape }); + await EC_UpdateFrame.InvokeAsync(args); } } /// - /// Report aggiornamento joint + /// Aggiornamento joint /// /// /// private async Task UpdateJoint(Joint updRec) { // cerco il record - var currRec = FrameWindow.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); + var currRec = CurrFrameWindow.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); // lo aggiorno if (updRec != null) { currRec = updRec; - await EC_UpdateFrame.InvokeAsync(FrameWindow); + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = false + }; + await EC_UpdateFrame.InvokeAsync(args); } } + /// + /// Metodo per la visualizzazione dei pulsanti joint + /// + /// + /// + private string ButtonJointCss(WebWindowTest.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"; + } + #endregion Private Methods } /// - /// Classe per raggruppare oggetti che servono per copiare Sash + /// Classe per raggruppare oggetti che servono per aggiornare frame /// - public class DataChangeJoints + public class DataUpdateFrame { #region Public Properties - public Area currArea { get; set; } = null!; - public Json.WindowConst.Joints currJointType { get; set; } + public Frame currFrame { get; set; } = null!; + public bool svgNoHw { get; set; } = false; #endregion Public Properties } diff --git a/WebWindowTest/Compo/CardSashGroup.razor b/WebWindowTest/Compo/CardSashGroup.razor index 96e9c51..85bf1f6 100644 --- a/WebWindowTest/Compo/CardSashGroup.razor +++ b/WebWindowTest/Compo/CardSashGroup.razor @@ -5,12 +5,7 @@
-
Sash group @(SashList.Count > 1 ? (CurrIndex + 1) : "")
-
-
-
- -
+
Sash group @(SashList.Count > 1 ? (SashList.IndexOf(CurrSashGroup) + 1) : "")
@@ -19,131 +14,105 @@
-
+
Qty sash - +
-
+
- - + Tipology +
-
+
Qty bottom rail - +

-
+
Hardware
- - + Family +
- @if (string.IsNullOrEmpty(CurrItem.SashShape)) - { -
- - -
- } - else - { -
- - -
- - - } -
-
-
-
-
Joints
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
+
+ Type +
- @foreach (Joint joint in CurrItem.JointList) - { - - }
-
-
-
- -
-
-
- @for (int i = 0; i < CurrItem.SashList.Count; i++) - { - - - } +
+ + +
- - \ No newline at end of file +
+
+
+ +
+
+ @for (int i = 0; i < CurrSashGroup.SashList.Count; i++) + { + @if (editMode && currSashDimEdit.Contains(i)) + { +
+ + +
+ } + else if(currSashDimEdit.Count == 0) + { + + + } + } +
+
+
\ No newline at end of file diff --git a/WebWindowTest/Compo/CardSashGroup.razor.cs b/WebWindowTest/Compo/CardSashGroup.razor.cs index d7fd76e..72ed248 100644 --- a/WebWindowTest/Compo/CardSashGroup.razor.cs +++ b/WebWindowTest/Compo/CardSashGroup.razor.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Components; using WebWindowTest.Models; using static WebWindowTest.Json.WindowConst; +using static WebWindowTest.LayoutConst; namespace WebWindowTest.Compo { @@ -8,41 +9,17 @@ namespace WebWindowTest.Compo { #region Public Properties - /// - /// Indice della sash corrente rispetto alla lista sash - /// - [Parameter] - public int CurrIndex { get; set; } = 0; - /// /// Sash corrente rispetto alla lista Sash /// - [Parameter] - public Sash CurrItem { get; set; } = null!; - - /// - /// Evento per cambiare tutti i Joints - /// - [Parameter] - public EventCallback EC_ChangeAllJoints { get; set; } - - /// - /// Evento per cambiare l'anta su cui presente la maniglia - /// - [Parameter] - public EventCallback EC_ChangeHandle { get; set; } - - /// - /// Evento per cambiare l'anta su cui presente la maniglia - /// - [Parameter] - public EventCallback EC_CopyContentSash { get; set; } + [CascadingParameter(Name = "CurrSashGroup")] + public Sash CurrSashGroup { get; set; } = null!; /// /// Evento per cambiare tutti i fill /// [Parameter] - public EventCallback EC_RemoveArea { get; set; } + public EventCallback EC_UpdateFrame { get; set; } /// /// Evento per tornare nella pagine Tree @@ -54,102 +31,228 @@ namespace WebWindowTest.Compo /// Evento per richiedere reset dizionario Shape /// [Parameter] - public EventCallback EC_ReqResetDictShape { get; set; } + public EventCallback EC_ReqResetDict { get; set; } /// - /// Evento per cambiare tutti i Joints + /// Evento per richiedere opzioni hardware /// [Parameter] - public EventCallback EC_UpdateSash { get; set; } + public EventCallback EC_ReqOptionHw { get; set; } /// - /// Evento per segnalare cambio hw e richiesta calcolo + /// Evento per richiedere per la prima volta opzioni hardware /// [Parameter] - public EventCallback EC_UpdateSashHardware { get; set; } + public EventCallback EC_ReqFirstOptionHw { get; set; } /// - /// Evento per richiedere la prima volta le opzioni hardware + /// Evento per segnalare aggiornamento /// [Parameter] - public EventCallback EC_CallFirstHwOpt { get; set; } + public EventCallback EC_UpdateSashGroup { get; set; } /// /// Lista di sash /// - [Parameter] + [CascadingParameter(Name = "SashList")] public List SashList { get; set; } = null!; + /// + /// Frame corrente + /// + [Parameter] + public Frame FrameWindow { get; set; } = null!; + #endregion Public Properties #region Protected Properties /// - /// Selezione hardware + /// Selezione quantit di ante /// - protected string SelHwType + protected int SashQty { - get => CurrItem.SelHardwareFromId; + get => CurrSashGroup.nSashQty; set { - if (CurrItem.SelHardwareFromId != value) + if (CurrSashGroup.nSashQty != value) { - CurrItem.SelHardwareFromId = value; - _ = EC_UpdateSashHardware.InvokeAsync(CurrItem); + CurrSashGroup.nSashQty = value; + var args = new DataUpdateSash() + { + currSash = CurrSashGroup, + svgNoHw = true + }; + _ = EC_UpdateSashGroup.InvokeAsync(args); + _ = EC_ReqOptionHw.InvokeAsync(CurrSashGroup); } } } + /// + /// Selezione quantit bottom rail + /// + protected int SashBottomRailQty + { + get => CurrSashGroup.SashBottomRailQty; + set + { + if (CurrSashGroup.SashBottomRailQty != value) + { + CurrSashGroup.SashBottomRailQty = value; + if (CurrSashGroup.SashBottomRailQty > 0) + CurrSashGroup.SetSashBottomRail(true); + else + CurrSashGroup.SetSashBottomRail(false); + var args = new DataUpdateSash() + { + currSash = CurrSashGroup + }; + _ = EC_UpdateSashGroup.InvokeAsync(args); + } + } + } + + /// + /// Selezione tipo di orientamento della sash + /// + protected int OrientationSashTypeIndex + { + get => CurrSashGroup.SelOrientationSashTypeIndex; + set + { + if (CurrSashGroup.SelOrientationSashTypeIndex != value) + { + CurrSashGroup.SelOrientationSashTypeIndex = value; + var args = new DataUpdateSash() + { + currSash = CurrSashGroup + }; + _ = EC_UpdateSashGroup.InvokeAsync(args); + } + } + } + + /// + /// Selezione famiglia hardware + /// + protected string FamilyHardware + { + get => CurrSashGroup.SelFamilyHardware; + set + { + if (CurrSashGroup.SelFamilyHardware != value) + { + CurrSashGroup.SelFamilyHardware = value; + var args = new DataUpdateSash() + { + currSash = CurrSashGroup, + svgNoHw = true + }; + _ = EC_UpdateSashGroup.InvokeAsync(args); + _ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetHwOpt}); + _ = EC_ReqOptionHw.InvokeAsync(CurrSashGroup); + } + } + } + + protected string SelHwType + { + get => CurrSashGroup.GetHardwareDescription; + } + #endregion Protected Properties #region Protected Methods /// - /// Sollevo evento per rimuovere area + /// Metodo per rimuovere area /// /// area da rimuovere /// - protected async Task RemoveArea(Area currArea) + protected async Task RemoveArea() { + CurrSashGroup.Remove(); + var args = new DataUpdateFrame() + { + currFrame = FrameWindow + }; // richiesta reset dict shape - await EC_ReqResetDictShape.InvokeAsync(true); - await EC_RemoveArea.InvokeAsync(currArea); + await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req=DataAction.ResetDictShape}); + await EC_UpdateFrame.InvokeAsync(args); + await EC_ReqClose.InvokeAsync(true); + } + + /// + /// Metodo per scegliere tipo di misura + /// + /// + /// + protected async Task SetMeasureType(MeasureTypes type) + { + isOpen = !isOpen; + for(int i = 0; i < CurrSashGroup.SashList.Count; i++) + { + CurrSashGroup.SashList.ElementAt(i).SetSelMeasureType(type, i); + } + var args = new DataUpdateSash + { + currSash = CurrSashGroup, + noSvg = true + }; + await EC_UpdateSashGroup.InvokeAsync(args); + } + + /// + /// Metodo per aggiornare la sash dimension + /// + /// + /// + protected async Task UpdateSashDimension(SashDimension updateSD) + { + var currRec = CurrSashGroup.SashList.First(x => x.nSashId == updateSD.nSashId); + if(currRec != null) + { + currRec = updateSD; + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + await EC_UpdateSashGroup.InvokeAsync(args); + } + } + + /// + /// Metodo per aggiornare sash + /// + /// + /// + protected async Task UpdateSash(Sash updateS) + { + if (updateS != null) + { + CurrSashGroup = updateS; + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + await EC_UpdateSashGroup.InvokeAsync(args); + } } #endregion Protected Methods #region Private Methods - /// - /// Sollevo evento richiesta per cambiare tutti i Joint - /// - /// - private async Task ChangeAllJoints(Json.WindowConst.Joints JointType, Area a) + private bool editMode = false; + private List currSashDimEdit = new List(); + private void EditView(DataChangeMode args) { - var Args = new DataChangeJoints - { - currJointType = JointType, - currArea = a, - }; - await EC_ChangeAllJoints.InvokeAsync(Args); - } - - /// - /// Sollevo evento per cambiare l'anta su cui presente la maniglia - /// - /// - private async Task ChangeHandle(DataChangeHandle Args) - { - await EC_ChangeHandle.InvokeAsync(Args); - } - - /// - /// Sollevo evento per cambiare l'anta su cui presente la maniglia - /// - /// - private async Task CopyContentSash(DataCopyContentSash Args) - { - await EC_CopyContentSash.InvokeAsync(Args); + editMode = args.Edit; + if(args.IndexSashEdit != -1) + currSashDimEdit.Add(args.IndexSashEdit); + if (args.IndexSashClose != -1) + currSashDimEdit.Remove(args.IndexSashClose); } /// @@ -161,53 +264,45 @@ namespace WebWindowTest.Compo } /// - /// Report aggiornamento joint + /// Aggiornamento opzioni hardware /// /// /// - private async Task UpdateJoint(Joint updRec) + private async Task UpdateOpt(DataUpdateHwOption argsHw) { - // cerco il record - var currRec = CurrItem.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); - // lo aggiorno - if (updRec != null) + AGBOptionCombo AGBOptCombo = argsHw.AGBOptCombo; + AGBOptionText AGBOptText = argsHw.AGBOptText; + if (AGBOptCombo != null) { - currRec = updRec; - await EC_UpdateSash.InvokeAsync(CurrItem); + // cerco il record + var currRec = CurrSashGroup.HwOptionList.FirstOrDefault(x => x.sName == AGBOptCombo.sName && x.sDescription == AGBOptCombo.sDescription); + // lo aggiorno + if (AGBOptCombo != null) + { + currRec = AGBOptCombo; + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + await EC_UpdateSashGroup.InvokeAsync(args); + await EC_ReqOptionHw.InvokeAsync(CurrSashGroup); + } } - } - - /// - /// Report aggiornamento Option Combo - /// - /// - /// - private async Task UpdateOptCombo(AGBOptionCombo updRec) - { - // cerco il record - var currRec = CurrItem.HwOptionList.FirstOrDefault(x => x.sName == updRec.sName && x.sDescription == updRec.sDescription); - // lo aggiorno - if (updRec != null) + else { - currRec = updRec; - await EC_UpdateSashHardware.InvokeAsync(CurrItem); - } - } - - /// - /// Report aggiornamento Option Text - /// - /// - /// - private async Task UpdateOptText(AGBOptionText updRec) - { - // cerco il record - var currRec = CurrItem.HwOptionList.FirstOrDefault(x => x.sName == updRec.sName && x.sDescription == updRec.sDescription); - // lo aggiorno - if (updRec != null) - { - currRec = updRec; - await EC_UpdateSashHardware.InvokeAsync(CurrItem); + // cerco il record + var currRec = CurrSashGroup.HwOptionList.FirstOrDefault(x => x.sName == AGBOptText.sName && x.sDescription == AGBOptText.sDescription); + // lo aggiorno + if (AGBOptText != null) + { + currRec = AGBOptText; + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + await EC_UpdateSashGroup.InvokeAsync(args); + await EC_ReqOptionHw.InvokeAsync(CurrSashGroup); + } } } @@ -216,11 +311,43 @@ namespace WebWindowTest.Compo /// /// /// - private async Task FirstHwOptionList(int groupId) + private async Task FirstHwOptionList() { - await EC_CallFirstHwOpt.InvokeAsync(groupId); + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + //await EC_UpdatePreview.InvokeAsync(args); + await EC_ReqFirstOptionHw.InvokeAsync(CurrSashGroup); } + private string ButtonMeasureCss(MeasureTypes type) + { + foreach(var item in CurrSashGroup.SashList) + { + if (!item.SelMeasureType.Equals(type)) + return "btn btn-outline-secondary btn-sm"; + } + return "btn btn-secondary btn-sm"; + } + + private bool isOpen = false; + private void ToggleDropdown() + { + isOpen = !isOpen; + } #endregion Private Methods } + + public class DataUpdateSash + { + public Sash currSash { get; set; } = null!; + public bool svgNoHw { get; set; } = false; + public bool noSvg { get; set; } = false; + } + + public class DataUpdateRes + { + public DataAction req { get; set; } = DataAction.None; + } } \ No newline at end of file diff --git a/WebWindowTest/Compo/CardSplit.razor b/WebWindowTest/Compo/CardSplit.razor index bead55d..4ac1a47 100644 --- a/WebWindowTest/Compo/CardSplit.razor +++ b/WebWindowTest/Compo/CardSplit.razor @@ -1,9 +1,10 @@ - +@using static WebWindowTest.Json.WindowConst +
-
@(descParentSplit(CurrItem))
+
@(descParentSplit())
@@ -11,119 +12,247 @@
-
-
-
Split
-
-
- @if ((CurrItem.nSplitQtyVert == 1 && CurrItem.nSplitQtyHoriz == 0) || (CurrItem.nSplitQtyVert == 0 && CurrItem.nSplitQtyHoriz == 1)) - { -
- -
- } -
-
+
+
Split
+ @if ((CurrSplit.nSplitQtyVert == 1 && CurrSplit.nSplitQtyHoriz == 0) || (CurrSplit.nSplitQtyVert == 0 && CurrSplit.nSplitQtyHoriz == 1)) + {
- +
+ } +
+ +
+
-
+
- + @foreach (var shapeType in CurrSplit.SplitShapeList) { } - @* - - - *@
- @if (CurrItem.nSplitQtyVert > 0) + @if (CurrSplit.nSplitQtyVert > 0) { -
+
QtyVert - +
} - @if (CurrItem.nSplitQtyHoriz > 0) + @if (CurrSplit.nSplitQtyHoriz > 0) { -
+
QtyHoriz - +
}
- @if (CurrItem.SplitVertList.Count > 0 && CurrItem.SplitHorizList.Count > 0) + @if (CurrSplit.SplitVertList.Count > 0 && CurrSplit.SplitHorizList.Count > 0) { -
- @foreach (var dim in CurrItem.SplitVertList) +
+ @for (int i = 0; i < CurrSplit.SplitVertList.Count; i++) { -
+ + + @*
Width - % -
+ +
*@ }
-
- @foreach (var dim in CurrItem.SplitHorizList) +
+ @for (int i = 0; i < CurrSplit.SplitHorizList.Count; i++) { -
+ + + @*
Height - % -
+ +
*@ } -
+
} - else if (CurrItem.SplitHorizList.Count > 0) + else if (CurrSplit.SplitHorizList.Count > 0) { - @foreach (var dim in CurrItem.SplitHorizList) + @for (int i = 0; i < CurrSplit.SplitHorizList.Count; i++) { -
+ + + @*
Height - % +
-
+
*@ } } - else if (CurrItem.SplitVertList.Count > 0) + else if (CurrSplit.SplitVertList.Count > 0) { - @foreach (var dim in CurrItem.SplitVertList) + @for (int i = 0; i < CurrSplit.SplitVertList.Count; i++) { -
+ + + @*
Width - % +
-
+
*@ } }
- @if (CurrItem.SelSplitShape == Json.WindowConst.SplitShapes.GRID) + @if (CurrSplit.SelSplitShape == Json.WindowConst.SplitShapes.GRID) {
-
+
- +
diff --git a/WebWindowTest/Compo/CardSplit.razor.cs b/WebWindowTest/Compo/CardSplit.razor.cs index 5eb59be..b6f9b37 100644 --- a/WebWindowTest/Compo/CardSplit.razor.cs +++ b/WebWindowTest/Compo/CardSplit.razor.cs @@ -1,21 +1,19 @@ using Microsoft.AspNetCore.Components; +using Newtonsoft.Json.Linq; using WebWindowTest.Models; +using static WebWindowTest.Json.WindowConst; +using static WebWindowTest.LayoutConst; namespace WebWindowTest.Compo { public partial class CardSplit { + /// - /// Indice del fill corrente rispetto alla lista fill + /// Split corrente rispetto alla lista split /// [Parameter] - public int CurrIndex { get; set; } = 0; - - /// - /// Fill corrente rispetto alla lista fill - /// - [Parameter] - public Split CurrItem { get; set; } = null!; + public Split CurrSplit { get; set; } = null!; /// /// Lista di sash @@ -30,28 +28,28 @@ namespace WebWindowTest.Compo public List SplitList { get; set; } = null!; /// - /// Evento per scambiare le aree di uno split + /// Frame /// [Parameter] - public EventCallback EC_SwapTwoAree { get; set; } + public Frame FrameWindow { get; set; } = null!; /// - /// Evento per rimuovere split + /// Evento per richiedere reset dizionario /// [Parameter] - public EventCallback EC_RemoveArea { get; set; } + public EventCallback EC_ReqResetDict { get; set; } /// - /// Evento per cambiare nel caso di split a griglia se inizia con lo split verticale + /// Evento per aggiornare Split /// [Parameter] - public EventCallback EC_ChangeStartVert { get; set; } + public EventCallback EC_UpdateSplit { get; set; } /// - /// Evento per richiedere reset dizionario Shape + /// Evento per aggiornare Frame /// [Parameter] - public EventCallback EC_ReqResetDictShape { get; set; } + public EventCallback EC_UpdateFrame { get; set; } /// /// Evento per tornare nella pagine Tree @@ -60,64 +58,184 @@ namespace WebWindowTest.Compo public EventCallback EC_ReqClose { get; set; } /// - /// Sollevo evento per scambiare le aree di uno split + /// Metodo per scambiare le aree di uno split (solo se si hanno due aree) /// /// split corrente /// - protected async Task SwapTwoAree(Split item) + protected async Task SwapTwoAree() { - // richiesta reset dict shape - _ = EC_ReqResetDictShape.InvokeAsync(true); - await EC_SwapTwoAree.InvokeAsync(item); - } - - /// - /// Sollevo evento per rimuovere split - /// - /// split corrente - /// - protected async Task RemoveArea(Split item) - { - // richiesta reset dict shape - await EC_ReqResetDictShape.InvokeAsync(true); - await EC_RemoveArea.InvokeAsync(item); - } - - /// - /// Sollevo evento per rimuovere split - /// - /// split corrente - /// - protected async Task ChangeStartVert(ChangeEventArgs e, Split item) - { - var Args = new DataChangeStartVert - { - eventArg = e, - currItem = item, + CurrSplit.SwapAree(); + var args = new DataUpdateSplit(){ + currSplit = CurrSplit, + svgNoHw = true }; - await EC_ChangeStartVert.InvokeAsync(Args); + await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape }); + await EC_UpdateSplit.InvokeAsync(args); + } + + /// + /// Metodo per rimuovere split + /// + /// split corrente + /// + protected async Task RemoveArea() + { + CurrSplit.Remove(); + var args = new DataUpdateFrame() + { + currFrame = FrameWindow + }; + // richiesta reset dict shape + await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape }); + await EC_UpdateFrame.InvokeAsync(args); + await EC_ReqClose.InvokeAsync(true); + } + + /// + /// Propriet per selezionare shape split + /// + /// + protected int SplitShapeIndex + { + get => CurrSplit.SelSplitShapeIndex; + set + { + if (CurrSplit.SelSplitShapeIndex != value) + { + CurrSplit.SelSplitShapeIndex = value; + var args = new DataUpdateSplit() + { + currSplit = CurrSplit + }; + // Se la shape selezionata grid o custom, richiede reset shape + if(value > 2) + _ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape }); + if (SearchSash(CurrSplit)) + _ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetHwOpt }); + _ = EC_UpdateSplit.InvokeAsync(args); + } + } + } + + private bool SearchSash(Area area) + { + if (area is Sash) + return true; + foreach (var item in area.AreaList) + return SearchSash(item); + return false; + } + + /// + /// Propriet per selezionare numero di split verticali + /// + /// + protected int SplitQtyVert + { + get => CurrSplit.nSplitQtyVert; + set + { + if (CurrSplit.nSplitQtyVert != value) + { + CurrSplit.nSplitQtyVert = value; + var args = new DataUpdateSplit() + { + currSplit = CurrSplit + }; + _ = EC_UpdateSplit.InvokeAsync(args); + } + } + } + + /// + /// Propriet per selezionare numero di split verticali + /// + /// + protected int SplitQtyHoriz + { + get => CurrSplit.nSplitQtyHoriz; + set + { + if (CurrSplit.nSplitQtyHoriz != value) + { + CurrSplit.nSplitQtyHoriz = value; + var args = new DataUpdateSplit() + { + currSplit = CurrSplit + }; + _ = EC_UpdateSplit.InvokeAsync(args); + } + } + } + + /// + /// Metodo per aggiornare la dimensione dello split + /// + /// + /// + protected async Task UpdateDimension(DataUpdateSplitDimension updRec) + { + SplitDimension currSplitDim = updRec.currSplit; + SplitDimension currRec = null; + // cerco il record + if (currSplitDim.bIsVertListDim) + currRec = CurrSplit.SplitVertList.ElementAt(updRec.index); + else + currRec = CurrSplit.SplitHorizList.ElementAt(updRec.index); + // lo aggiorno + if (currSplitDim != null) + { + currRec = currSplitDim; + var args = new DataUpdateSplit() + { + currSplit = CurrSplit, + noSvg = updRec.noSvg + }; + //await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape }); + await EC_UpdateSplit.InvokeAsync(args); + } + } + + /// + /// Metodo per rimuovere split + /// + /// + /// + protected async Task ChangeStartVert(ChangeEventArgs e) + { + foreach (Split s in SplitList) + { + if (s.Equals(CurrSplit)) + { + s.SetSplitStartVert((bool)e.Value); + } + } + var args = new DataUpdateSplit() + { + currSplit = CurrSplit + }; + await EC_UpdateSplit.InvokeAsync(args); } /// /// Metodo per determinare la descrizione del parent dello split corrente /// - /// split corrente /// - protected string descParentSplit(Split currSplit) + protected string descParentSplit() { - if ((currSplit.ParentArea is Splitted || currSplit.ParentArea is Sash) && SashList.Count > 0) + if ((CurrSplit.ParentArea is Splitted || CurrSplit.ParentArea is Sash) && SashList.Count > 0) { for (int j = 0; j < SashList.Count; j++) { - if (SashList[j].Equals(currSplit.ParentArea)) + if (SashList[j].Equals(CurrSplit.ParentArea)) { return "Sash " + (j + 1); } - else if (SashList[j].Equals(currSplit.ParentArea.ParentArea)) + else if (SashList[j].Equals(CurrSplit.ParentArea.ParentArea)) { for (int k = 0; k < SashList[j].AreaList.Count; k++) { - if (SashList[j].AreaList[k].AreaList[0].Equals(currSplit)) + if (SashList[j].AreaList[k].AreaList[0].Equals(CurrSplit)) { return "Sash group " + (j + 1) + " - sash " + (k + 1); } @@ -139,11 +257,45 @@ namespace WebWindowTest.Compo { _ = EC_ReqClose.InvokeAsync(true); } + + private bool isOpen = false; + private void ToggleDropdown() + { + isOpen = !isOpen; + } + + /// + /// Metodo per cambiare il tipo di misura di tutti gli SplitDimension + /// + /// nuovo tipo + /// + protected async Task SetMeasureType(MeasureTypes type) + { + isOpen = !isOpen; + foreach (var item in CurrSplit.SplitVertList) + { + item.SetSelMeasureType(type); + } + foreach (var item in CurrSplit.SplitHorizList) + { + item.SetSelMeasureType(type); + } + var args = new DataUpdateSplit() + { + currSplit = CurrSplit, + noSvg = true + }; + await EC_UpdateSplit.InvokeAsync(args); + } } - public class DataChangeStartVert + /// + /// Classe per raggruppare oggetti che servono per aggiornare split + /// + public class DataUpdateSplit { - public ChangeEventArgs eventArg { get; set; } = null!; - public Split currItem { get; set; } + public Split currSplit { get; set; } = null!; + public bool svgNoHw { get; set; } = false; + public bool noSvg { get; set; } = false; } } \ No newline at end of file diff --git a/WebWindowTest/Compo/CardTree.razor b/WebWindowTest/Compo/CardTree.razor index 40d2549..6d38bd5 100644 --- a/WebWindowTest/Compo/CardTree.razor +++ b/WebWindowTest/Compo/CardTree.razor @@ -37,6 +37,11 @@ } + @* @if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.SASH || + ItemTableList[i].Type is Json.WindowConst.AreaTypes.SPLIT) + { + + } *@ } else diff --git a/WebWindowTest/Compo/CardTree.razor.cs b/WebWindowTest/Compo/CardTree.razor.cs index d9a1fac..d9b131c 100644 --- a/WebWindowTest/Compo/CardTree.razor.cs +++ b/WebWindowTest/Compo/CardTree.razor.cs @@ -29,7 +29,7 @@ namespace WebWindowTest.Compo public EventCallback EC_NextStep { get; set; } /// - /// Sollevo evento richiesta prossimo step + /// Metodo per richiesta prossimo step /// /// private async Task RaiseNextStep(CompileStep cs, int indexStep) @@ -42,6 +42,16 @@ namespace WebWindowTest.Compo await EC_NextStep.InvokeAsync(Args); } + //private async Task Remove(CompileStep cs, int indexStep) + //{ + // var Args = new DataNextStep + // { + // currCompileStep = cs, + // index = indexStep, + // }; + // await EC_NextStep.InvokeAsync(Args); + //} + /// /// Metodo per riempire tabella con contenuto vuoto o con i simboli per rappresentare la struttura /// diff --git a/WebWindowTest/Compo/EditDimensions.razor b/WebWindowTest/Compo/EditFrameDimensions.razor similarity index 100% rename from WebWindowTest/Compo/EditDimensions.razor rename to WebWindowTest/Compo/EditFrameDimensions.razor diff --git a/WebWindowTest/Compo/EditDimensions.razor.cs b/WebWindowTest/Compo/EditFrameDimensions.razor.cs similarity index 60% rename from WebWindowTest/Compo/EditDimensions.razor.cs rename to WebWindowTest/Compo/EditFrameDimensions.razor.cs index a70fc99..243c295 100644 --- a/WebWindowTest/Compo/EditDimensions.razor.cs +++ b/WebWindowTest/Compo/EditFrameDimensions.razor.cs @@ -3,10 +3,13 @@ using WebWindowTest.Models; namespace WebWindowTest.Compo { - public partial class EditDimensions + public partial class EditFrameDimensions { #region Public Properties + /// + /// Frame dimension corrente + /// [Parameter] public FrameDimension CurrRec { get; set; } = null!; @@ -17,14 +20,18 @@ namespace WebWindowTest.Compo #region Private Properties + /// + /// Metodo per aggiornare valore dimension + /// private double CurrVal { - get => CurrRec.dValue; + get => CurrRec.dDimension; set { - if (CurrRec.dValue != value) + if (CurrRec.dDimension != value) { - CurrRec.dValue = value; + CurrRec.dDimension = value; + CurrRec.dDimension = value; _ = EC_Update.InvokeAsync(CurrRec); } } diff --git a/WebWindowTest/Compo/EditJoint.razor b/WebWindowTest/Compo/EditJoint.razor index 8577d08..84e0182 100644 --- a/WebWindowTest/Compo/EditJoint.razor +++ b/WebWindowTest/Compo/EditJoint.razor @@ -1,13 +1,5 @@ @using static WebWindowTest.LayoutConst
- - + @((PositionJoints)(CurrRec.nIndex - 1)) +
\ No newline at end of file diff --git a/WebWindowTest/Compo/EditJoint.razor.cs b/WebWindowTest/Compo/EditJoint.razor.cs index 6591eb7..7c563df 100644 --- a/WebWindowTest/Compo/EditJoint.razor.cs +++ b/WebWindowTest/Compo/EditJoint.razor.cs @@ -7,9 +7,13 @@ namespace WebWindowTest.Compo { #region Public Properties + /// + /// Joint corrente + /// [Parameter] public Joint CurrRec { get; set; } = null!; + [Parameter] public EventCallback EC_Update { get; set; } @@ -17,7 +21,10 @@ namespace WebWindowTest.Compo #region Private Properties - private int CurrVal + /// + /// Metodo per aggiornare joint corrente + /// + private int CurrJoint { get => CurrRec.SelJointTypeIndex; set diff --git a/WebWindowTest/Compo/EditOptionCombo.razor b/WebWindowTest/Compo/EditOptionCombo.razor index e02c3a3..7c3ed23 100644 --- a/WebWindowTest/Compo/EditOptionCombo.razor +++ b/WebWindowTest/Compo/EditOptionCombo.razor @@ -1,9 +1,11 @@ 
- - + @(CurrOpt.sName) + @if(CurrValue is String) + { + + } + else + { + + }
\ No newline at end of file diff --git a/WebWindowTest/Compo/EditOptionCombo.razor.cs b/WebWindowTest/Compo/EditOptionCombo.razor.cs index 31054d8..23f3041 100644 --- a/WebWindowTest/Compo/EditOptionCombo.razor.cs +++ b/WebWindowTest/Compo/EditOptionCombo.razor.cs @@ -7,27 +7,22 @@ namespace WebWindowTest.Compo { #region Public Properties + /// + /// Opzione hardware combo corrente + /// [Parameter] public AGBOptionCombo CurrOpt { get; set; } = null!; - [Parameter] - public EventCallback EC_Update { get; set; } - #endregion Public Properties #region Private Properties + /// + /// Metodo per aggiornare opzione hardware corrente + /// private string CurrValue { get => CurrOpt.sValue.sValue; - set - { - if (CurrOpt.sValue.sValue != value) - { - CurrOpt.sValue = CurrOpt.ValueList.FirstOrDefault(x => x.sValue == value); - _ = EC_Update.InvokeAsync(CurrOpt); - } - } } #endregion Private Properties diff --git a/WebWindowTest/Compo/EditOptionText.razor b/WebWindowTest/Compo/EditOptionText.razor index a26b8f6..3f80dd4 100644 --- a/WebWindowTest/Compo/EditOptionText.razor +++ b/WebWindowTest/Compo/EditOptionText.razor @@ -1,9 +1,29 @@ 
- - + } + else if (CurrOpt.ValueList.Count > 0) + { + if(CurrValue is String) { - + } - + else + { + + } + } + else + { + if (CurrValue is String) + { + + } + else + { + + } + }
\ No newline at end of file diff --git a/WebWindowTest/Compo/EditOptionText.razor.cs b/WebWindowTest/Compo/EditOptionText.razor.cs index 24d09cf..4548171 100644 --- a/WebWindowTest/Compo/EditOptionText.razor.cs +++ b/WebWindowTest/Compo/EditOptionText.razor.cs @@ -7,27 +7,22 @@ namespace WebWindowTest.Compo { #region Public Properties + /// + /// Opzione hardware text corrente + /// [Parameter] public AGBOptionText CurrOpt { get; set; } = null!; - [Parameter] - public EventCallback EC_Update { get; set; } - #endregion Public Properties #region Private Properties + /// + /// Metodo per aggiornare opzione hardware text corrente + /// private string CurrValue { get => CurrOpt.sValue; - set - { - if (CurrOpt.sValue != value) - { - CurrOpt.sValue = CurrOpt.ValueList.FirstOrDefault(x => x == value); - _ = EC_Update.InvokeAsync(CurrOpt); - } - } } #endregion Private Properties diff --git a/WebWindowTest/Compo/EditSplitDimensions.razor b/WebWindowTest/Compo/EditSplitDimensions.razor new file mode 100644 index 0000000..620dfe3 --- /dev/null +++ b/WebWindowTest/Compo/EditSplitDimensions.razor @@ -0,0 +1,34 @@ +@using EgwCoreLib.Razor + +
+
+ @Name + + @* *@ + +
+
diff --git a/WebWindowTest/Compo/EditSplitDimensions.razor.cs b/WebWindowTest/Compo/EditSplitDimensions.razor.cs new file mode 100644 index 0000000..0b0f091 --- /dev/null +++ b/WebWindowTest/Compo/EditSplitDimensions.razor.cs @@ -0,0 +1,151 @@ +using Microsoft.AspNetCore.Components; +using WebWindowTest.Models; + +namespace WebWindowTest.Compo +{ + public partial class EditSplitDimensions + { + #region Public Properties + + /// + /// Split dimension corrente + /// + [Parameter] + public SplitDimension CurrRec { get; set; } = null!; + + /// + /// Nome dello split dimension corrente + /// + [Parameter] + public string Name { get; set; } = null!; + + /// + /// Indice dello split dimension + /// + [Parameter] + public int Index { get; set; } = -1; + + [Parameter] + public EventCallback EC_Update { get; set; } + + #endregion Public Properties + + #region Private Properties + + /// + /// Metodo per aggiornare la dimensione + /// + private double CurrVal + { + get => CurrRec.dDimension; + set + { + if (CurrRec.dDimension != value) + { + CurrRec.dDimension = (double)Math.Round((decimal)value, CssDecimals()); + var args = new DataUpdateSplitDimension() + { + currSplit = CurrRec, + index = Index + }; + _ = EC_Update.InvokeAsync(args); + } + } + } + + /// + /// Metodo per aggiornare il tipo della dimensione + /// + private int CurrType + { + get => CurrRec.SelMeasureTypeIndex; + set + { + if (CurrRec.SelMeasureTypeIndex != value) + { + CurrRec.SelMeasureTypeIndex = value; + var args = new DataUpdateSplitDimension() + { + currSplit = CurrRec, + index=Index, + noSvg = true + }; + _ = EC_Update.InvokeAsync(args); + } + } + } + + private string SplitDimCss() + { + if(CurrRec.Parent is Split) + { + Split s = (Split)CurrRec.Parent; + if (s.SelSplitShape.Equals(Json.WindowConst.SplitShapes.GRID)) + return ""; + else + return "col-md-12 col-lg-6"; + } + return ""; + } + + /// + /// Metodo per avere il numero di decimali da usare nella form-input + /// + /// + public int CssDecimals() + { + switch (CurrRec.MeasureType) + { + case Json.WindowConst.MeasureTypes.ABSOLUTE: + { + return 2; + } + case Json.WindowConst.MeasureTypes.PROPORTIONAL: + { + return 0; + } + case Json.WindowConst.MeasureTypes.PERCENTAGE: + { + return 1; + } + } + return 0; + } + + /// + /// Metodo per avere il lo step da usare nella form-input + /// + /// + public double CssStepNumber() + { + switch (CurrRec.MeasureType) + { + case Json.WindowConst.MeasureTypes.ABSOLUTE: + { + return 0.5; + } + case Json.WindowConst.MeasureTypes.PROPORTIONAL: + { + return 1; + } + case Json.WindowConst.MeasureTypes.PERCENTAGE: + { + return 0.5; + } + } + return 0; + } + + #endregion Private Properties + } + + /// + /// Classe per aggiornare split dimension + /// + public class DataUpdateSplitDimension + { + public SplitDimension currSplit { get; set; } = null!; + public int index { get; set; } = -1; + public bool noSvg { get; set; } = false; + } +} \ No newline at end of file diff --git a/WebWindowTest/Compo/General.razor b/WebWindowTest/Compo/General.razor index fb2306d..77bcf26 100644 --- a/WebWindowTest/Compo/General.razor +++ b/WebWindowTest/Compo/General.razor @@ -12,7 +12,7 @@
-
+
diff --git a/WebWindowTest/Compo/General.razor.cs b/WebWindowTest/Compo/General.razor.cs index 508010e..5508fe0 100644 --- a/WebWindowTest/Compo/General.razor.cs +++ b/WebWindowTest/Compo/General.razor.cs @@ -15,16 +15,7 @@ namespace WebWindowTest.Compo public Window CurrWindow { get; set; } = null!; [Parameter] - public EventCallback EC_SelColor { get; set; } - - [Parameter] - public EventCallback EC_SelGlass { get; set; } - - [Parameter] - public EventCallback EC_SelWindMat { get; set; } - - [Parameter] - public EventCallback EC_SelProfile { get; set; } + public EventCallback EC_UpdateGeneral { get; set; } [Parameter] public EventCallback EC_ReqClose { get; set; } @@ -45,43 +36,71 @@ namespace WebWindowTest.Compo #region Protected Properties + /// + /// Colore corrente + /// protected string CurrColor { get => currColor; set { currColor = value; - _ = EC_SelColor.InvokeAsync(value); + var args = new DataUpdateGeneral + { + Color = value, + }; + _ = EC_UpdateGeneral.InvokeAsync(args); } } + /// + /// Vetro corrente + /// protected string CurrGlass { get => currGlass; set { currGlass = value; - _ = EC_SelGlass.InvokeAsync(value); + var args = new DataUpdateGeneral + { + Glass = value, + }; + _ = EC_UpdateGeneral.InvokeAsync(args); } } + /// + /// Materiale corrente + /// protected string CurrMaterial { get => currMaterial; set { currMaterial = value; - _ = EC_SelWindMat.InvokeAsync(value); + var args = new DataUpdateGeneral + { + Material = value, + }; + _ = EC_UpdateGeneral.InvokeAsync(args); } } + /// + /// Profilo corrente + /// protected string CurrProfile { get => currProfile; set { currProfile = value; - _ = EC_SelProfile.InvokeAsync(value); + var args = new DataUpdateGeneral + { + Profile = value, + }; + _ = EC_UpdateGeneral.InvokeAsync(args); } } @@ -123,4 +142,16 @@ namespace WebWindowTest.Compo _ = EC_ReqClose.InvokeAsync(true); } } + + + /// + /// Classe per aggiornamento dati general + /// + public class DataUpdateGeneral + { + public string Color { get; set; } = ""; + public string Glass { get; set; } = ""; + public string Material { get; set; } = ""; + public string Profile { get; set; } = ""; + } } \ No newline at end of file diff --git a/WebWindowTest/DTO/BaseListPayload.cs b/WebWindowTest/DTO/BaseListPayload.cs index 4085fe6..06d1dee 100644 --- a/WebWindowTest/DTO/BaseListPayload.cs +++ b/WebWindowTest/DTO/BaseListPayload.cs @@ -1,11 +1,4 @@ using Egw.Window.Data; -using Microsoft.AspNetCore.Components; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http.Headers; -using System.Text; -using System.Threading.Tasks; namespace WebWindowTest.DTO { @@ -13,12 +6,7 @@ namespace WebWindowTest.DTO /// Payload complessivo delle anagrafiche necessarie x Window ///
public class BaseListPayload - { - /// - /// Elenco template in formato DTO - /// - public List? TemplateDTO { get; set; } = null; - + { /// /// Elenco Famiglie HW in formato DTO /// @@ -49,6 +37,11 @@ namespace WebWindowTest.DTO /// public List Profile { get; set; } = null!; + /// + /// Elenco profili ammessi + /// + public Dictionary> Threshold { get; set; } = null!; + /// /// Verifica di validità dell'intero Payload /// @@ -61,7 +54,8 @@ namespace WebWindowTest.DTO bool matOK = Material != null && Material.Count > 0; bool colorOK = ColorMaterial != null && ColorMaterial.Count > 0; bool profileOK = Profile != null && Profile.Count > 0; - return famHwOK && glassOK && hwOK && colorOK && matOK && profileOK; + bool thresholdOK = Threshold != null && Threshold.Count > 0; + return famHwOK && glassOK && hwOK && colorOK && matOK && profileOK && thresholdOK; } /// /// Verifica che Payload sia almeno parzialmente popolato @@ -75,7 +69,8 @@ namespace WebWindowTest.DTO bool matOK = Material != null && Material.Count > 0; bool colorOK = ColorMaterial != null && ColorMaterial.Count > 0; bool profileOK = Profile != null && Profile.Count > 0; - return famHwOK || glassOK || hwOK || colorOK || matOK || profileOK; + bool thresholdOK = Threshold != null && Threshold.Count > 0; + return famHwOK || glassOK || hwOK || colorOK || matOK || profileOK || thresholdOK; } } } diff --git a/WebWindowTest/DTO/SelectPayload.cs b/WebWindowTest/DTO/SelectPayload.cs index b13603b..2879370 100644 --- a/WebWindowTest/DTO/SelectPayload.cs +++ b/WebWindowTest/DTO/SelectPayload.cs @@ -39,11 +39,6 @@ namespace WebWindowTest.DTO /// public string Profile { get; set; } = string.Empty; - /// - /// Template selezionato - /// - public Template Template { get; set; } = null!; - /// /// Verifica di validità dell'intero Payload /// @@ -55,8 +50,7 @@ namespace WebWindowTest.DTO bool glassOk = !string.IsNullOrEmpty(Glass); bool matOK = !string.IsNullOrEmpty(Material); bool profileOK = !string.IsNullOrEmpty(Profile); - bool templateOK = Template != null; - return famHwOK && colorOK && matOK && glassOk && templateOK && profileOK; + return famHwOK && colorOK && matOK && glassOk && profileOK; } } } diff --git a/WebWindowTest/DTO/TemplateSelectorDTO.cs b/WebWindowTest/DTO/TemplateSelectorDTO.cs deleted file mode 100644 index 8e832de..0000000 --- a/WebWindowTest/DTO/TemplateSelectorDTO.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace WebWindowTest.DTO -{ - public class TemplateSelectDTO - { - public int Index { get; set; } = 0; - public string Description { get; set; } = ""; - public string JwdFileName { get; set; } = ""; - public string SVGFileName { get; set; } = ""; - public string ImageUrl { get; set; } = ""; - } -} diff --git a/WebWindowTest/ItemTable.cs b/WebWindowTest/ItemTable.cs index 5acfe5f..174abaf 100644 --- a/WebWindowTest/ItemTable.cs +++ b/WebWindowTest/ItemTable.cs @@ -9,6 +9,9 @@ namespace WebWindowTest { public class ItemTable { + /// + /// Tipo di area + /// private AreaTypes m_type; public AreaTypes Type { @@ -22,6 +25,9 @@ namespace WebWindowTest } } + /// + /// Descrizione + /// private string m_desc; public string Desc { @@ -35,6 +41,9 @@ namespace WebWindowTest } } + /// + /// Numero di riga nell'albero gerarchico + /// private int m_row; public int Row { @@ -48,6 +57,9 @@ namespace WebWindowTest } } + /// + /// Numero di colonna nell'albero gerarchico + /// private int m_col; public int Col { diff --git a/WebWindowTest/Json/JsonUtility.cs b/WebWindowTest/Json/JsonUtility.cs index 05ad490..f52a07e 100644 --- a/WebWindowTest/Json/JsonUtility.cs +++ b/WebWindowTest/Json/JsonUtility.cs @@ -1,4 +1,5 @@ -using Microsoft.VisualBasic; +using Egw.Window.Data; +using Microsoft.VisualBasic; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; @@ -201,6 +202,20 @@ namespace WebWindowTest.Json } } + private string m_Threshold; + [JsonProperty] + public string Threshold + { + get + { + return m_Threshold; + } + set + { + m_Threshold = value; + } + } + private bool m_bBottomRail; [JsonProperty] public bool BottomRail @@ -229,13 +244,28 @@ namespace WebWindowTest.Json } } + //private JsonFrameArcElement m_FrameArcElem; + //[JsonProperty] + //public JsonFrameArcElement ArcElement + //{ + // get + // { + // return m_FrameArcElem; + // } + // set + // { + // m_FrameArcElem = value; + // } + //} + public JsonFrame() : base(AreaTypes.FRAME) { } - public JsonFrame(Shapes Shape, bool BottomRail, int BottomRailQty, int GroupId) : base(AreaTypes.FRAME) + public JsonFrame(Shapes Shape, string sThreshold, bool BottomRail, int BottomRailQty, int GroupId) : base(AreaTypes.FRAME) { m_Shape = Shape; + m_Threshold= sThreshold; m_bBottomRail = BottomRail; m_nBottomRailQty = BottomRailQty; base.GroupId = GroupId; @@ -247,11 +277,15 @@ namespace WebWindowTest.Json newFrame.SetGroupId(GroupId); newFrame.SetAreaType(AreaTypes.FRAME); newFrame.SetSelShape(m_Shape); + newFrame.RefreshThresholdList(); + newFrame.SetSelThresholdFromName(m_Threshold); newFrame.SetBottomRail(m_bBottomRail); newFrame.SetBottomRailQty(m_nBottomRailQty); + //if(ArcElement != null) + // newFrame.SetFrameArcElem(ArcElement.Deserialize(newFrame, ParentWindow)); //Frame.AppliedDone(); for (var DimensionIndex = 0; DimensionIndex <= m_DimensionList.Count - 1; DimensionIndex++) - newFrame.DimensionList[DimensionIndex].dValue = m_DimensionList[DimensionIndex].Value; + newFrame.DimensionList[DimensionIndex].SetDimension(m_DimensionList[DimensionIndex].Value); for (var JointIndex = 0; JointIndex <= m_JointList.Count - 1; JointIndex++) newFrame.JointList[JointIndex].SetSelJointType(m_JointList[JointIndex].JointType); foreach (var Area in AreaList) @@ -311,20 +345,6 @@ namespace WebWindowTest.Json } } - private List m_JointList = new List(); - [JsonProperty] - public List JointList - { - get - { - return m_JointList; - } - set - { - m_JointList = value; - } - } - private bool m_bBottomRail; [JsonProperty] public bool BottomRail @@ -353,6 +373,20 @@ namespace WebWindowTest.Json } } + //private JsonSashArcElement m_SashArcElem; + //[JsonProperty] + //public JsonSashArcElement ArcElement + //{ + // get + // { + // return m_SashArcElem; + // } + // set + // { + // m_SashArcElem = value; + // } + //} + private string m_Hardware; [JsonProperty] public string Hardware @@ -409,16 +443,17 @@ namespace WebWindowTest.Json newSash.SashList[SashIndex].SetOpeningType(m_SashList[SashIndex].OpeningType); newSash.SashList[SashIndex].SetHasHandle(m_SashList[SashIndex].HasHandle); newSash.SashList[SashIndex].SetDimension(m_SashList[SashIndex].Dimension); + newSash.SashList[SashIndex].SetMeasureType(m_SashList[SashIndex].MeasureType); + foreach (var Joint in m_SashList[SashIndex].JointList) + newSash.SashList[SashIndex].JointList.Add(Joint.Deserialize((Area)ParentArea)); } - foreach (var Joint in m_JointList) - newSash.JointList.Add(Joint.Deserialize((Area)ParentArea)); newSash.SetSelFamilyHardwareFromIndex(Hardware); - newSash.ReqRefreshShape(); + //newSash.ReqRefreshShape(); newSash.SetSelHardwareFromId(Hardware); foreach (var HwOption in m_HwOptionList) newSash.SelHwOptionList.Add(HwOption.Name, HwOption.Value); - //foreach (var HwOption in m_HwOptionList) - // newSash.HwOptionList.Add(HwOption.Deserialize()); + //if (ArcElement != null) + // newSash.SetSashArcElem(ArcElement.Deserialize(newSash, ParentWindow)); foreach (var Area in AreaList) { var AreaDeserealized = Area.Deserialize(newSash, ParentWindow); @@ -511,24 +546,24 @@ namespace WebWindowTest.Json Split.SetSplitQtyVert(0); else { - //Split.SplitVertList.Clear(); Split.SetSplitQtyVert(m_SplitVertList.Count - 1); for (var SplitIndex = 0; SplitIndex <= m_SplitVertList.Count - 1; SplitIndex++) { Split.SplitVertList[SplitIndex].SetIsRelative(m_SplitVertList[SplitIndex].IsRelative); Split.SplitVertList[SplitIndex].SetDimension(m_SplitVertList[SplitIndex].Dimension); + Split.SplitVertList[SplitIndex].SetMeasureType(m_SplitVertList[SplitIndex].MeasureType); } } if (m_SplitHorizList.Count == 0) Split.SetSplitQtyHoriz(0); else { - //Split.SplitHorizList.Clear(); Split.SetSplitQtyHoriz(m_SplitHorizList.Count - 1); for (var SplitIndex = 0; SplitIndex <= m_SplitHorizList.Count - 1; SplitIndex++) { Split.SplitHorizList[SplitIndex].SetIsRelative(m_SplitHorizList[SplitIndex].IsRelative); Split.SplitHorizList[SplitIndex].SetDimension(m_SplitHorizList[SplitIndex].Dimension); + Split.SplitHorizList[SplitIndex].SetMeasureType(m_SplitHorizList[SplitIndex].MeasureType); } } foreach (var Area in AreaList) @@ -618,6 +653,107 @@ namespace WebWindowTest.Json } } + //public class JsonFrameArcElement + //{ + // private double m_Section; + // [JsonProperty] + // public double Section + // { + // get + // { + // return m_Section; + // } + // set + // { + // m_Section = value; + // } + // } + + // private bool m_bCutEdge; + // [JsonProperty] + // public bool CutEdge + // { + // get + // { + // return m_bCutEdge; + // } + // set + // { + // m_bCutEdge = value; + // } + // } + + // private bool m_bIsAlign; + // [JsonProperty] + // public bool IsAlign + // { + // get + // { + // return m_bIsAlign; + // } + // set + // { + // m_bIsAlign = value; + // } + // } + + // public JsonFrameArcElement(double Section, bool CutEdge, bool IsAlign) + // { + // m_Section = Section; + // m_bCutEdge = CutEdge; + // m_bIsAlign = IsAlign; + // } + + // internal FrameArcElement Deserialize(Area ParentArea, Window ParentWindow) + // { + // FrameArcElement arcElement = new FrameArcElement(ParentArea, ParentWindow, m_Section, m_bCutEdge, m_bIsAlign); + // return arcElement; + // } + //} + + //public class JsonSashArcElement + //{ + // private double m_Section; + // [JsonProperty] + // public double Section + // { + // get + // { + // return m_Section; + // } + // set + // { + // m_Section = value; + // } + // } + + // private bool m_bCutEdge; + // [JsonProperty] + // public bool CutEdge + // { + // get + // { + // return m_bCutEdge; + // } + // set + // { + // m_bCutEdge = value; + // } + // } + + // public JsonSashArcElement(double Section, bool CutEdge) + // { + // m_Section = Section; + // m_bCutEdge = CutEdge; + // } + + // internal SashArcElement Deserialize(Area ParentArea, Window ParentWindow) + // { + // SashArcElement arcElement = new SashArcElement(ParentArea, ParentWindow, m_Section, m_bCutEdge); + // return arcElement; + // } + //} + public class JsonJoint { private int m_nIndex; @@ -769,17 +905,14 @@ namespace WebWindowTest.Json } } - private bool m_bHasHandle; + private MeasureTypes m_MeasureType; [JsonProperty] - public bool HasHandle + [JsonConverter(typeof(StringEnumConverter))] + public MeasureTypes MeasureType { get { - return m_bHasHandle; - } - set - { - m_bHasHandle = value; + return m_MeasureType; } } @@ -797,9 +930,38 @@ namespace WebWindowTest.Json } } - public JsonSashDimension(Openings OpeningType, bool HasHandle, double Dimension, int SashId) + private bool m_bHasHandle; + [JsonProperty] + public bool HasHandle + { + get + { + return m_bHasHandle; + } + set + { + m_bHasHandle = value; + } + } + + private List m_JointList = new List(); + [JsonProperty] + public List JointList + { + get + { + return m_JointList; + } + set + { + m_JointList = value; + } + } + + public JsonSashDimension(Openings OpeningType, MeasureTypes MeasureType, bool HasHandle, double Dimension, int SashId) { m_OpeningType = OpeningType; + m_MeasureType = MeasureType; m_bHasHandle = HasHandle; m_dDimension = Dimension; m_nSashId = SashId; @@ -832,10 +994,22 @@ namespace WebWindowTest.Json } } - public JsonSplitDimension(bool IsRelative, double Dimension) + private MeasureTypes m_MeasureType; + [JsonProperty] + [JsonConverter(typeof(StringEnumConverter))] + public MeasureTypes MeasureType + { + get + { + return m_MeasureType; + } + } + + public JsonSplitDimension(bool IsRelative, double Dimension, MeasureTypes MeasureType) { m_bIsRelative = IsRelative; m_dDimension = Dimension; + m_MeasureType = MeasureType; } } diff --git a/WebWindowTest/Json/WindowConst.cs b/WebWindowTest/Json/WindowConst.cs index 73e5cbd..17f27f9 100644 --- a/WebWindowTest/Json/WindowConst.cs +++ b/WebWindowTest/Json/WindowConst.cs @@ -118,6 +118,14 @@ namespace WebWindowTest.Json COMBO = 3 } + public enum MeasureTypes: int + { + NULL = 0, + ABSOLUTE = 1, + PROPORTIONAL = 2, + PERCENTAGE = 3 + } + // Specifies the display state of an element. public enum Visibility { diff --git a/WebWindowTest/LayoutConst.cs b/WebWindowTest/LayoutConst.cs index e7207d2..327ae77 100644 --- a/WebWindowTest/LayoutConst.cs +++ b/WebWindowTest/LayoutConst.cs @@ -10,13 +10,13 @@ namespace WebWindowTest { public enum CompileStep { - Template = 0, - Tree = 1, - Frame, + Tree = 0, + Frame = 1, Split, Sash, Fill, - General + General, + ArcElement } public enum PositionJoints @@ -26,5 +26,22 @@ namespace WebWindowTest TR, // Top Right TL // Top Left } + + public enum DataAction + { + /// + /// Nessuna richiesta + /// + None = 0, + + /// + /// Reset dizionario shape + /// + ResetDictShape, + /// + /// Reset dizionario HwOptions + /// + ResetHwOpt + } } } diff --git a/WebWindowTest/Models/AGBOptionText.cs b/WebWindowTest/Models/AGBOptionText.cs index 619400b..258d75d 100644 --- a/WebWindowTest/Models/AGBOptionText.cs +++ b/WebWindowTest/Models/AGBOptionText.cs @@ -50,9 +50,18 @@ namespace WebWindowTest.Models public AGBOptionText(ParametriOpzioniParametri HdwOptionParam) : base(HdwOptionParam) { m_Type = HwOptionTypes.TEXT; - foreach (var Value in HdwOptionParam.Opzioni) - m_ValueList.Add(Value.Valore); - m_sValue = m_ValueList.FirstOrDefault(x => x == HdwOptionParam.ValoreCorrente) ?? ""; + if(HdwOptionParam.Opzioni != null) + { + foreach (var Value in HdwOptionParam.Opzioni) + m_ValueList.Add(Value.Valore); + m_sValue = m_ValueList.FirstOrDefault(x => x == HdwOptionParam.ValoreCorrente); + if (string.IsNullOrEmpty(m_sValue)) + m_sValue = m_ValueList.FirstOrDefault(); + } + else + { + m_sValue = HdwOptionParam.ValoreCorrente; + } } #endregion Public Constructors diff --git a/WebWindowTest/Models/Area.cs b/WebWindowTest/Models/Area.cs index aed0b6c..26c5960 100644 --- a/WebWindowTest/Models/Area.cs +++ b/WebWindowTest/Models/Area.cs @@ -1,4 +1,5 @@ -using WebWindowTest.Json; +using System.ComponentModel.Design; +using WebWindowTest.Json; using static WebWindowTest.Json.WindowConst; namespace WebWindowTest.Models @@ -69,7 +70,6 @@ namespace WebWindowTest.Models set { m_nAreaId = value; - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -108,8 +108,15 @@ namespace WebWindowTest.Models SashArea.SetSelFamilyHardware(""); // Inserisco hardware di default SashArea.SetSelHardwareFromId("000000"); + //if (ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.ARC || + // ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.DOUBLEARC || + // ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.ARC_FULL || + // ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.THREECENTERARC) + // SashArea.SashArcElem = new SashArcElement(SashArea, ParentWindow, 10, true); + //else + // SashArea.SashArcElem = null; // Salvo gli oggetti già presenti e li cancello da AreaList - List ContentArea = new List(); + List ContentArea = new List(); ContentArea.Add(AreaList[0]); AreaList.Remove(AreaList[0]); // Aggiungo area @@ -117,8 +124,6 @@ namespace WebWindowTest.Models // Inserisco il riempimento precedente AreaList[0].AreaList.Add(ContentArea[0]); AreaList[0].AreaList[0].SetParentArea(AreaList[0]); - // Richiesta SVG con hardware di default - ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); } public void AddSplit() @@ -140,24 +145,23 @@ namespace WebWindowTest.Models List newSplittedList = new List(); for (int i = 0; i < 2; i++) newSplittedList.Add(Splitted.CreateSplitted(SplitArea)); - // Inserisco nelle aree Splitted il Fill salvato e un Fill uguale (e setto ParentArea del fill) - ContentArea[0].SetParentArea(newSplittedList[0]); - newSplittedList[0].AreaList.Add(ContentArea[0]); + // Inserisco nelle aree Splitted Fill e la struttura precedente (e setto ParentArea del fill) + ContentArea[0].SetParentArea(newSplittedList[1]); + newSplittedList[1].AreaList.Add(ContentArea[0]); if (ContentArea[0] is Fill) { Fill fill1 = (Fill)ContentArea[0]; - Fill fill2 = Fill.CreateFill(newSplittedList[1], fill1.FillType); - newSplittedList[1].AreaList.Add(fill2); + Fill fill2 = Fill.CreateFill(newSplittedList[0], fill1.FillType); + newSplittedList[0].AreaList.Add(fill2); } else { - Fill fill2 = Fill.CreateFill(newSplittedList[1], FillTypes.GLASS); - newSplittedList[1].AreaList.Add(fill2); + Fill fill2 = Fill.CreateFill(newSplittedList[0], FillTypes.GLASS); + newSplittedList[0].AreaList.Add(fill2); } // All'area Split aggiunto le due aree Splitted for (int i = 0; i < 2; i++) AreaList[0].AreaList.Add(newSplittedList[i]); - ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); } public abstract Area Copy(Area ParentArea); @@ -176,6 +180,202 @@ namespace WebWindowTest.Models AreaList[0] = AreaList[1]; AreaList[1] = tempArea; } + Frame frame = ParentWindow.AreaList.First(); + switch (frame.Shape) + { + case Shapes.RECTANGLE: + case Shapes.ARC_FULL: + case Shapes.TRIANGLE: + { + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Height")).First().dDimension, "Height"); + break; + } + + case Shapes.RIGHTCHAMFER: + { + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Left Height")).First().dDimension, "Left Height"); + break; + } + + case Shapes.LEFTCHAMFER: + { + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Right Height")).First().dDimension, "Right Height"); + break; + } + + case Shapes.DOUBLECHAMFER: + case Shapes.ARC: + { + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Full Height")).First().dDimension, "Full Height"); + break; + } + + case Shapes.DOUBLEARC: + { + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Full Height")).First().dDimension, "Full Height"); + break; + } + + case Shapes.THREECENTERARC: + { + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Full Height")).First().dDimension, "Full Height"); + break; + } + } + } + + /// + /// Cerca nell'albero gli oggetti Sash e Split per associare la larghezza + /// + /// + public void SearchAreaList(Area node, double dim, string nameDim) + { + if (node != null) + { + if (node.AreaType.Equals(AreaTypes.SASH)) + UpdateDimSubArea((Sash)node, dim, nameDim); + else if (node.AreaType.Equals(AreaTypes.SPLIT)) + UpdateDimSubArea((Split)node, dim, nameDim); + for (int i = 0; i < node.AreaList.Count; i++) + { + if (node.AreaType.Equals(AreaTypes.SASH)) + { + Sash s = (Sash)node; + List dimList = new List(); + foreach (var item in s.SashList) + dimList.Add(new AreaDimension(item.dDimension, item.MeasureType)); + if(nameDim.Equals("Width")) + SearchAreaList(node.AreaList.ElementAt(i), s.SashList.ElementAt(i).CalculateAbsoluteValue(dimList, dim), nameDim); + else + SearchAreaList(node.AreaList.ElementAt(i), dim, nameDim); + } + else if (node.AreaType.Equals(AreaTypes.SPLIT)) + { + Split s = (Split)node; + List dimList = new List(); + if (s.SplitHorizList.Count > 0 && i < s.SplitHorizList.Count) + { + foreach (var item in s.SplitHorizList) + dimList.Add(new AreaDimension(item.dDimension, item.MeasureType)); + if(nameDim.Equals("Width")) + SearchAreaList(node.AreaList.ElementAt(i), dim, nameDim); + else + SearchAreaList(node.AreaList.ElementAt(i), s.SplitHorizList.ElementAt(i).CalculateAbsoluteValue(dimList, dim), nameDim); + } + if (s.SplitVertList.Count > 0 && i < s.SplitVertList.Count) + { + foreach (var item in s.SplitVertList) + dimList.Add(new AreaDimension(item.dDimension, item.MeasureType)); + if(nameDim.Equals("Width")) + SearchAreaList(node.AreaList.ElementAt(i), s.SplitVertList.ElementAt(i).CalculateAbsoluteValue(dimList, dim), nameDim); + else + SearchAreaList(node.AreaList.ElementAt(i), dim, nameDim); + } + } + else + SearchAreaList(node.AreaList.ElementAt(i), dim, nameDim); + } + } + } + + public void UpdateDimSubArea(Area area, double dim, string nameDim) + { + if (area is Sash && nameDim.Equals("Width")) + { + Sash sash = (Sash)area; + int countAbsolute = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUTE)).Count(); + int countProportional = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).Count(); + int countPercentage = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).Count(); + List dimList = new List(); + Split split = new Split(null, null); + if (sash.ParentArea.ParentArea is Split) + split = (Split)sash.ParentArea.ParentArea; + if (sash.ParentArea is Frame || (sash.ParentArea.ParentArea is Split && split.SplitHorizList.Count > 0)) + { + Frame frame = new Frame(null, null); + if(split.SplitHorizList.Count > 0) + frame = (Frame)sash.ParentArea.ParentArea.ParentArea; + else + frame = (Frame)sash.ParentArea; + foreach (var i in frame.DimensionList) + dimList.Add(new AreaDimension(i.dDimension, i.SelMeasureType)); + } + else + { + //Split s = (Split)sash.ParentArea.ParentArea; + foreach (var i in split.SplitVertList) + dimList.Add(new AreaDimension(i.dDimension, i.SelMeasureType)); + } + if (countAbsolute == sash.SashList.Count) + { + double sum = sash.SashList.Sum(x => x.dDimension); + double res = dim - sum; + if (res > 0) + { + foreach (var sashDim in sash.SashList) + { + sashDim.SetDimension(sashDim.dDimension + res / countAbsolute); + } + } + else + { + foreach (var sashDim in sash.SashList) + { + // Sommo perchè res è negativo + sashDim.SetDimension(sashDim.dDimension + res / countAbsolute); + } + } + } + else if (countAbsolute < sash.SashList.Count && countPercentage != sash.SashList.Count && countProportional != sash.SashList.Count) + { + if (countPercentage > 0 && countPercentage <= sash.SashList.Count && countProportional == 0) + { + double sumAbsolute = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUTE)).Sum(x => x.dDimension); + var percentageList = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList(); + foreach (var i in percentageList) + { + i.SetDimension(i.ConvertIn(dimList, (dim - sumAbsolute) / countPercentage, i.MeasureType, dim)); + } + } + } + } + else if (area is Split) + { + Split split = (Split)area; + List splitList = new List(); + if (nameDim.Equals("Width")) + splitList = split.SplitVertList; + else + splitList = split.SplitHorizList; + int countAbsolute = splitList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUTE)).Count(); + if (countAbsolute != 0 && countAbsolute == splitList.Count) + { + double sum = splitList.Sum(x => x.dDimension); + double res = 0; + res = dim - sum; + if (res > 0) + { + foreach (var item in splitList) + { + item.SetDimension(item.dDimension + res / countAbsolute); + } + } + else + { + foreach (var item in splitList) + { + // Sommo perchè res è negativo + item.SetDimension(item.dDimension + res / countAbsolute); + } + } + } + } } #endregion Public Methods @@ -194,6 +394,232 @@ namespace WebWindowTest.Models m_ParentArea = ParentArea; } + /// + /// Metodo per convertire da misura proporzionale a misura assoluta o percentuale + /// + /// + /// + internal double ConvertFromPropVal(Sash sashGroup, double sashDim, MeasureTypes newType, double widthTot) + { + double tot = widthTot; + List adList = new List(); + foreach (var it in sashGroup.SashList) + { + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType)); + } + //Somma misura non proporzionali + double sumNotProp = sashGroup.SashList + .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL && !m.Equals(this)) + .Sum(m => m.CalculateAbsoluteValue(adList, tot)); + //Calcolo residuo + double res = tot - sumNotProp; + if (res < 0) res = 0; + //Misure proporzionali + var proportionalList = sashGroup.SashList + .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + .ToList(); + + double sumPesi = proportionalList.Sum(p => p.dDimension); + if (sumPesi == 0) sumPesi = 1; + if (newType.Equals(MeasureTypes.ABSOLUTE)) + { + return res / sumPesi * sashDim; + } + else + { + return (res / sumPesi * sashDim) / tot * 100; + } + } + + /// + /// Metodo per convertire da misura proporzionale a misura assoluta o percentuale + /// + /// + /// + internal double ConvertFromPropVal(List splitList, double splitDim, MeasureTypes newType, double widthTot) + { + double tot = widthTot; + List adList = new List(); + foreach (var it in splitList) + { + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType)); + } + //Somma misura non proporzionali + double sumNotProp = splitList + .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL && !m.Equals(this)) + .Sum(m => m.CalculateAbsoluteValue(adList, tot)); + //Calcolo residuo + double res = tot - sumNotProp; + if (res < 0) res = 0; + //Misure proporzionali + var proportionalList = splitList + .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + .ToList(); + + double sumPesi = proportionalList.Sum(p => p.dDimension); + if (sumPesi == 0) + sumPesi = 1; + return res / sumPesi * splitDim; + } + + /// + /// Metodo per calcolare larghezza area + /// + /// area di partenza + /// larghezza di partenza + /// + public double CalculateWidthArea(Area area, double width) + { + for (int i = 0; i < area.AreaList.Count; i++) + { + double risultato = -1; + if (area.Equals(this)) + return width; + Area item = area.AreaList[i]; + if (area is Split) + { + Split split = (Split)area; + if (split.SplitVertList.Count > 0) + { + switch (split.SplitVertList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateWidthArea(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + risultato = CalculateWidthArea(item, ConvertFromPropVal(split.SplitVertList, split.SplitVertList.ElementAt(i).dDimension, MeasureTypes.ABSOLUTE, width)); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthArea(item, split.SplitVertList.ElementAt(i).dDimension * width / 100); + break; + } + } + } + else + { + risultato = CalculateWidthArea(item, width); + } + if (risultato != -1) + return risultato; + } + else if (area is Sash) + { + Sash sash = (Sash)area; + switch (sash.SashList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateWidthArea(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + risultato = CalculateWidthArea(item, ConvertFromPropVal(sash, sash.SashList.ElementAt(i).dDimension, MeasureTypes.ABSOLUTE, width)); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthArea(item, sash.SashList.ElementAt(i).dDimension * width / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateWidthArea(item, width); + if (risultato != -1) + return risultato; + } + } + return width; + } + + /// + /// Metodo per calcolare larghezza area + /// + /// area di partenza + /// altezza di partenza + /// + public double CalculateHeightArea(Area area, double height) + { + for (int i = 0; i < area.AreaList.Count; i++) + { + double risultato = -1; + if (area.Equals(this)) + return height; + Area item = area.AreaList[i]; + if (area is Split) + { + Split split = (Split)area; + if (split.SplitHorizList.Count > 0) + { + switch (split.SplitHorizList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateHeightArea(item, split.SplitHorizList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + risultato = CalculateHeightArea(item, ConvertFromPropVal(split.SplitHorizList, split.SplitHorizList.ElementAt(i).dDimension, MeasureTypes.ABSOLUTE, height) ); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateHeightArea(item, split.SplitHorizList.ElementAt(i).dDimension * height / 100); + break; + } + } + } + else + { + risultato = CalculateHeightArea(item, height); + } + if (risultato != -1) + return risultato; + } + else if (area is Sash) + { + Sash sash = (Sash)area; + switch (sash.SashList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateHeightArea(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + risultato = CalculateHeightArea(item, ConvertFromPropVal(sash, sash.SashList.ElementAt(i).dDimension, MeasureTypes.ABSOLUTE, height)); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateHeightArea(item, sash.SashList.ElementAt(i).dDimension * height / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateHeightArea(item, height); + if (risultato != -1) + return risultato; + } + } + return height; + } + #endregion Internal Methods #region Protected Fields diff --git a/WebWindowTest/Models/AreaDimension.cs b/WebWindowTest/Models/AreaDimension.cs new file mode 100644 index 0000000..4e0d242 --- /dev/null +++ b/WebWindowTest/Models/AreaDimension.cs @@ -0,0 +1,350 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static WebWindowTest.Json.WindowConst; + +namespace WebWindowTest.Models +{ + public class AreaDimension + { + #region Public Constructors + + public AreaDimension(double dDimension, MeasureTypes MeasureType) + { + m_dDimension = dDimension; + m_SelMeasureType = MeasureType; + //m_Parent = Parent; + } + + #endregion Public Constructors + + #region Public Properties + + public virtual double dDimension + { + get + { + return m_dDimension; + } + set + { + m_dDimension = value; + } + } + + //public Area Parent + //{ + // get + // { + // return m_Parent; + // } + // set + // { + // m_Parent = value; + // } + //} + + public MeasureTypes MeasureType + { + get + { + return m_SelMeasureType; + } + } + + public List MeasureTypeList + { + get + { + return m_MeasureTypeList; + } + } + + public MeasureTypes SelMeasureType + { + get + { + return m_SelMeasureType; + } + set + { + m_SelMeasureType = value; + } + } + + public virtual int SelMeasureTypeIndex + { + get + { + return (int)m_SelMeasureType; + } + set + { + if (m_SelMeasureType != (MeasureTypes)value) + { + MeasureTypes newType = (MeasureTypes)value; + } + } + } + + #endregion Public Properties + + #region Private Fields + + protected double m_dDimension; + + protected List m_MeasureTypeList = new List + { + new IdNameStruct((int)MeasureTypes.ABSOLUTE, "Absolute"), + new IdNameStruct((int)MeasureTypes.PROPORTIONAL, "Proportional"), + new IdNameStruct((int)MeasureTypes.PERCENTAGE, "Percentage"), + }; + + protected MeasureTypes m_SelMeasureType; + + // reference + // protected Area m_Parent; + + #endregion Private Fields + + #region Public Methods + + public void SetDimension(double dValue) + { + m_dDimension = dValue; + } + + /// + /// Metodo per convertire la dimensione dal vecchio tipo al nuovo tipo + /// + /// Vecchio tipo + /// Nuovo tipo + /// + public double ConvertDimension(List itemList, MeasureTypes oldType, MeasureTypes newType, double widthTot, int indexSash) + { + switch (oldType) + { + case MeasureTypes.ABSOLUTE: + { + if (newType.Equals(MeasureTypes.PERCENTAGE)) + { + //return Double.Round((m_dDimension / m_Parent.Width) * 100, 1); + return (dDimension / widthTot) * 100; + } + else + { + return Double.Round(CalculatePropVal(itemList, indexSash, widthTot)); + } + } + case MeasureTypes.PROPORTIONAL: + { + if (newType.Equals(MeasureTypes.ABSOLUTE)) + { + //return Double.Round(ConvertFromPropVal(newType), 2); + return ConvertFromPropVal(itemList, newType, widthTot); + } + else + { + //return Double.Round(ConvertFromPropVal(newType), 1); + return ConvertFromPropVal(itemList, newType, widthTot); + } + } + case MeasureTypes.PERCENTAGE: + { + if (newType.Equals(MeasureTypes.ABSOLUTE)) + { + //return Double.Round((m_dDimension * m_Parent.Width) / 100, 2); + return (dDimension * widthTot) / 100; + } + else + { + return Double.Round(CalculatePropVal(itemList, indexSash, widthTot)); + } + } + } + return -1; + } + + #endregion Public Methods + + #region Internal Methods + + /// + /// Calcolo MCD + /// + /// + /// + /// + internal double CalculateMCD(double a, double b) + { + while (b >= 0.01) + { + double temp = b; + b = a % b; + a = temp; + } + //return Double.Round(a,2); + return a; + } + + /// + /// Metodo per ricalcolare i valori proporzionali a causa della modifica di uno + /// + /// + internal double CalculatePropVal(List itemList, int indexArea, double widthTot) + { + if (itemList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0) + { + return 1; + } + List absoluteValue = new List(); + foreach (var item in itemList) + { + absoluteValue.Add(item.CalculateAbsoluteValue(itemList, widthTot)); + } + int numProportional = itemList.Where(x => x.SelMeasureType == MeasureTypes.PROPORTIONAL).Count(); + if(itemList.Count > 2 && numProportional == itemList.Count - 1) + { + int inedMin = absoluteValue.IndexOf(absoluteValue.Min()); + var mcd = CalculateMCD(absoluteValue.ElementAt(indexArea), absoluteValue.ElementAt(inedMin)); + itemList.ElementAt(inedMin).SetDimension(absoluteValue.ElementAt(inedMin) / mcd); + itemList.ElementAt(indexArea).SetDimension(absoluteValue.ElementAt(indexArea) / mcd); + } + else + { + for (int i = 0; i < itemList.Count; i++) + { + if (!itemList.ElementAt(i).Equals(this) && + itemList.ElementAt(i).MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + { + if (absoluteValue.ElementAt(indexArea) <= absoluteValue.ElementAt(i)) + { + var mcd = CalculateMCD(absoluteValue.ElementAt(indexArea), absoluteValue.ElementAt(i)); + itemList.ElementAt(i).SetDimension(absoluteValue.ElementAt(i) / mcd); + itemList.ElementAt(indexArea).SetDimension(absoluteValue.ElementAt(indexArea) / mcd); + } + else + { + var mcd = CalculateMCD(absoluteValue.ElementAt(indexArea), absoluteValue.ElementAt(i)); + itemList.ElementAt(i).SetDimension(absoluteValue.ElementAt(i) / mcd); + itemList.ElementAt(indexArea).SetDimension(absoluteValue.ElementAt(indexArea) / mcd); + } + break; + } + } + } + return itemList.ElementAt(indexArea).dDimension; + } + + /// + /// Metodo per trasformare una dimensione in valore assoluto rispetto alla larghezza totale + /// + /// Larghezza totale + /// + internal double CalculateAbsoluteValue(List itemList, double widthTot) + { + switch (SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + //return Double.Round(dDimension, 2); + return dDimension; + } + case MeasureTypes.PROPORTIONAL: + { + //return Double.Round(Proportional2AbsolutVal(), 2); + return ProportionalToAbsoluteVal(itemList, dDimension, widthTot); + } + case MeasureTypes.PERCENTAGE: + { + //return Double.Round((dDimension / 100) * widthTot, 1); + return (dDimension / 100) * widthTot; + } + } + return 0; + } + + /// + /// Metodo per convertire una dimensione da un valore assoluto al suo rispettivo tipo + /// + /// Valore assoluto + /// Tipo di misura della dimensione + /// Larghezza totale + /// + internal double ConvertIn(List itemList, double absoluteVal, MeasureTypes type, double widthTot) + { + switch (type) + { + case MeasureTypes.ABSOLUTE: + { + return absoluteVal; + } + case MeasureTypes.PROPORTIONAL: + { + return ProportionalToAbsoluteVal(itemList, absoluteVal, widthTot); + } + case MeasureTypes.PERCENTAGE: + { + return (absoluteVal / widthTot) * 100; + } + } + return -1; + } + + /// + /// Metodo per convertire da misura proporzionale a misura assoluta o percentuale + /// + /// + /// + internal double ConvertFromPropVal(List itemList, MeasureTypes newType, double widthTot) + { + double tot = widthTot; + //Somma misura non proporzionali + double sumNotProp = itemList.Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL && !m.Equals(this)) + .Sum(m => m.CalculateAbsoluteValue(itemList, tot)); + //Calcolo residuo + double res = tot - sumNotProp; + if (res < 0) res = 0; + //Misure proporzionali + var proportionalList = itemList.Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + .ToList(); + + double sumPesi = proportionalList.Sum(p => p.dDimension); + if (sumPesi == 0) sumPesi = 1; + if (newType.Equals(MeasureTypes.ABSOLUTE)) + { + return res / sumPesi * dDimension; + } + else + { + return (res / sumPesi * dDimension) / tot * 100; + } + } + + /// + /// Metodo per trasformare il valore proporzionale in assoluto + /// + /// + internal double ProportionalToAbsoluteVal(List itemList, double dimensionProp, double widthTot) + { + double tot = widthTot; + //Somma misura non proporzionali + double sumNotProp = itemList.Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL) + .Sum(m => m.CalculateAbsoluteValue(itemList, tot)); + //Calcolo residuo + double res = tot - sumNotProp; + if (res < 0) res = 0; + //Misure proporzionali + var proportionalList = itemList.Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + .ToList(); + double sumPesi = proportionalList.Sum(p => p.dDimension); + if (sumPesi == 0) sumPesi = 1; + return res / sumPesi * dimensionProp; + } + + + #endregion Public Method + } +} diff --git a/WebWindowTest/Models/Fill.cs b/WebWindowTest/Models/Fill.cs index fe068da..af9390e 100644 --- a/WebWindowTest/Models/Fill.cs +++ b/WebWindowTest/Models/Fill.cs @@ -52,7 +52,6 @@ namespace WebWindowTest.Models set { m_SelFillType = (FillTypes)IdNameStruct.IdFromInd(value, m_FillTypeList); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -97,7 +96,6 @@ namespace WebWindowTest.Models internal void SetSelFillType(FillTypes value) { m_SelFillType = value; - //m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } internal void SetFillType(FillTypes value) { diff --git a/WebWindowTest/Models/Frame.cs b/WebWindowTest/Models/Frame.cs index 8fc00d6..9f0fc05 100644 --- a/WebWindowTest/Models/Frame.cs +++ b/WebWindowTest/Models/Frame.cs @@ -1,4 +1,5 @@ -using System; +using Egw.Window.Data; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -10,6 +11,13 @@ namespace WebWindowTest.Models { public class Frame : Area { + #region Public Fields + + // Lista hardware completa passata dal chiamante del componente + public static Dictionary> m_AllThresholdList = new Dictionary>(); + + #endregion Public Fields + #region Public Constructors public Frame(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) @@ -20,6 +28,18 @@ namespace WebWindowTest.Models #region Public Properties + //public FrameArcElement? FrameArcElem + //{ + // get + // { + // return m_FrameArcElem; + // } + // set + // { + // m_FrameArcElem = value!; + // } + //} + public bool BottomRail { get @@ -29,7 +49,42 @@ namespace WebWindowTest.Models set { m_bBottomRail = value; - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + } + } + + public List ThresholdList + { + get + { + return m_ThresholdList; + } + set + { + m_ThresholdList = value; + } + } + + public Threshold SelThreshold + { + get + { + return m_SelThreshold; + } + set + { + m_SelThreshold = value; + } + } + + public int SelThresholdFromType + { + get + { + return m_SelThreshold.Type; + } + set + { + m_SelThreshold = m_ThresholdList.Where(x => x.Type.Equals(value)).First(); } } @@ -53,7 +108,6 @@ namespace WebWindowTest.Models m_bBottomRail = false; } } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -79,12 +133,10 @@ namespace WebWindowTest.Models { get { - //return IdNameStruct.IndFromId((int)m_Shape, m_ShapeList); return (int)m_Shape; } set { - //Shapes SelShape = (Shapes)IdNameStruct.IdFromInd(value, m_ShapeList); Shapes SelShape = (Shapes)value; if (m_Shape != SelShape) { @@ -92,7 +144,8 @@ namespace WebWindowTest.Models List oldDimensionList = new List(DimensionList); // verifico parametri Dimension DimensionList.Clear(); - double widthVal = oldDimensionList.Where(x => x.sName.Equals("Width")).Select(x => x.dValue).First(); + //double widthVal = oldDimensionList.Where(x => x.sName.Equals("Width")).Select(x => x.dValue).First(); + double widthVal = oldDimensionList.Where(x => x.sName.Equals("Width")).Select(x => x.dDimension).First(); // aggiungo Dimensioni switch (SelShape) { @@ -100,7 +153,9 @@ namespace WebWindowTest.Models case Shapes.ARC_FULL: { DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1800, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1400, true)); + foreach (var dim in DimensionList) + SearchAreaList(this, dim.dDimension, dim.sName); break; } @@ -109,6 +164,8 @@ namespace WebWindowTest.Models DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1800, true)); DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1500, true)); + SearchAreaList(this, widthVal, "Width"); + SearchAreaList(this, 1800, "Left Height"); break; } @@ -117,6 +174,8 @@ namespace WebWindowTest.Models DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1500, true)); DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1800, true)); + SearchAreaList(this, widthVal, "Width"); + SearchAreaList(this, 1800, "Right Height"); break; } @@ -124,16 +183,20 @@ namespace WebWindowTest.Models case Shapes.ARC: { DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1800 - (0.4 * widthVal), true)); DimensionList.Add(new FrameDimension(this, 3, "Full Height", 1800, true)); + SearchAreaList(this, widthVal, "Width"); + SearchAreaList(this, 1800, "Full Height"); break; } case Shapes.DOUBLEARC: { DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 2400 - (0.6 * widthVal), true)); DimensionList.Add(new FrameDimension(this, 3, "Full Height", 2400, true)); + SearchAreaList(this, widthVal, "Width"); + SearchAreaList(this, 2400, "Full Height"); break; } @@ -143,6 +206,8 @@ namespace WebWindowTest.Models DimensionList.Add(new FrameDimension(this, 2, "Height", 2400 - (0.4 * widthVal), true)); DimensionList.Add(new FrameDimension(this, 3, "Full Height", 2400, true)); DimensionList.Add(new FrameDimension(this, 4, "Radius", 200, true)); + SearchAreaList(this, 2000, "Width"); + SearchAreaList(this, 2400, "Full Height"); break; } @@ -151,6 +216,8 @@ namespace WebWindowTest.Models DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); DimensionList.Add(new FrameDimension(this, 3, "Height projection", 0, true)); + SearchAreaList(this, widthVal, "Width"); + SearchAreaList(this, 1500, "Height"); break; } @@ -162,6 +229,9 @@ namespace WebWindowTest.Models } // salvo tipo Joint List oldJointType = new List(JointList); + // salvo la lista di sash + List sashList = new List(); + SearchSash(sashList, this); // aggiungo Joint m_JointList.Clear(); switch (SelShape) @@ -170,25 +240,20 @@ namespace WebWindowTest.Models case Shapes.RIGHTCHAMFER: case Shapes.LEFTCHAMFER: case Shapes.DOUBLECHAMFER: - case Shapes.ARC: - case Shapes.DOUBLEARC: { JointList.Add(new Joint(this, 1, oldJointType[0].SelJointType)); JointList.Add(new Joint(this, 2, oldJointType[1].SelJointType)); JointList.Add(new Joint(this, 3, oldJointType[2].SelJointType)); - JointList.Add(new Joint(this, 4, oldJointType[3].SelJointType)); + if (oldJointType.Count > 3) + JointList.Add(new Joint(this, 4, oldJointType[3].SelJointType)); + else + JointList.Add(new Joint(this, 4, Joints.FULL_V)); break; } + case Shapes.ARC: case Shapes.ARC_FULL: - { - JointList.Add(new Joint(this, 1, oldJointType[0].SelJointType)); - JointList.Add(new Joint(this, 2, oldJointType[1].SelJointType)); - JointList.Add(new Joint(this, 3, Joints.ANGLED)); - JointList.Add(new Joint(this, 4, Joints.ANGLED)); - break; - } - + case Shapes.DOUBLEARC: case Shapes.THREECENTERARC: { JointList.Add(new Joint(this, 1, oldJointType[0].SelJointType)); @@ -197,26 +262,76 @@ namespace WebWindowTest.Models JointList.Add(new Joint(this, 4, Joints.ANGLED)); break; } + case Shapes.TRIANGLE: { JointList.Add(new Joint(this, 1, oldJointType[0].SelJointType)); JointList.Add(new Joint(this, 2, oldJointType[1].SelJointType)); JointList.Add(new Joint(this, 3, Joints.ANGLED)); + foreach (var s in sashList) + { + foreach (var sashDim in s.SashList) + { + sashDim.JointList.RemoveAt(sashDim.JointList.Count - 1); + sashDim.JointList.Last().SelJointType = Joints.ANGLED; + } + } break; } - case Shapes.CUSTOM: { JointList.Clear(); break; } } + if (JointList.Count > 3) + { + foreach (var s in sashList) + { + foreach (var sashDim in s.SashList) + { + if (sashDim.JointList.Count == 3) + sashDim.JointList.Add(new Joint(s, 4, Joints.FULL_V)); + } + } + } + //switch (SelShape) + //{ + // case Shapes.RECTANGLE: + // case Shapes.RIGHTCHAMFER: + // case Shapes.LEFTCHAMFER: + // case Shapes.DOUBLECHAMFER: + // case Shapes.TRIANGLE: + // { + // FrameArcElem = null; + // foreach (var s in sashList) + // s.SashArcElem = null; + // break; + // } + //} m_Shape = SelShape; } - //m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } + protected List SearchSash(List sashList, Area node) + { + if (node != null) + { + if (node.AreaType.Equals(AreaTypes.SASH)) + { + sashList.Add((Sash)node); + //Sash s = (Sash)node; + //s.SashArcElem = null; + } + foreach (var item in node.AreaList) + { + SearchSash(sashList, item); + } + } + return sashList; + } + public Shapes Shape { get @@ -237,6 +352,37 @@ namespace WebWindowTest.Models #region Public Methods + public void RefreshThresholdList() + { + m_ThresholdList.Clear(); + m_ThresholdList = m_AllThresholdList.GetValueOrDefault(ParentWindow.sProfilePath); + } + + public double HeightFrame() + { + switch (SelShapeIndex) + { + case (int)Shapes.RECTANGLE: + case (int)Shapes.TRIANGLE: + case (int)Shapes.ARC_FULL: + { + return DimensionList.Where(x => x.sName == "Height").First().dDimension; + } + case (int)Shapes.RIGHTCHAMFER: + { + return DimensionList.Where(x => x.sName == "Left Height").First().dDimension; + } + case (int)Shapes.LEFTCHAMFER: + { + return DimensionList.Where(x => x.sName == "Right Height").First().dDimension; + } + default: + { + return DimensionList.Where(x => x.sName == "Full Height").First().dDimension; + } + } + } + public override Frame Copy(Area ParentArea) { return null; @@ -246,14 +392,25 @@ namespace WebWindowTest.Models #region Internal Methods + //internal void SetFrameArcElem(FrameArcElement arcElement) + //{ + // m_FrameArcElem = arcElement; + //} + internal static Area CreateFrame(Window Window) { - Frame NewFrame = new Frame(null, Window); - NewFrame.SetAreaType(AreaTypes.FRAME); - NewFrame.SetSelShape(Shapes.RECTANGLE); - NewFrame.SetBottomRail(false); - NewFrame.SetBottomRailQty(0); - return NewFrame; + Frame newFrame = new Frame(null, Window); + newFrame.SetAreaType(AreaTypes.FRAME); + newFrame.SetSelShape(Shapes.RECTANGLE); + newFrame.SetBottomRail(false); + newFrame.SetBottomRailQty(0); + newFrame.RefreshThresholdList(); + if (m_AllThresholdList != null && m_AllThresholdList.Any()) + { + newFrame.SetSelThresholdFromName(m_AllThresholdList.GetValueOrDefault(Window.sProfilePath)?.FirstOrDefault()?.Name ?? ""); + } + //newFrame.FrameArcElem = null; + return newFrame; } internal override JsonArea Serialize(bool hideHw) @@ -261,7 +418,11 @@ namespace WebWindowTest.Models Area.nCounterGroup = 0; if (nCounterGroup < GroupId) Area.nCounterGroup = GroupId; - JsonFrame JsonFrame = new JsonFrame(m_Shape, m_bBottomRail, m_nBottomRailQty, GroupId); + JsonFrame JsonFrame = new JsonFrame(m_Shape, m_SelThreshold.Name, m_bBottomRail, m_nBottomRailQty, GroupId); + //if (FrameArcElem != null) + // JsonFrame.ArcElement = FrameArcElem.Serialize(); + //else + // JsonFrame.ArcElement = null; foreach (var Dimension in DimensionList) JsonFrame.DimensionList.Add(Dimension.Serialize()); foreach (var Joint in JointList) @@ -396,12 +557,31 @@ namespace WebWindowTest.Models m_Shape = Value; } + internal void SetSelThresholdFromName(string? value) + { + // verifica ci sia un valore... + if (!string.IsNullOrEmpty(value)) + { + m_SelThreshold = m_ThresholdList.Where(x => x.Name.Equals(value)).First(); + } + else + { + m_SelThreshold = m_ThresholdList.FirstOrDefault() ?? new Threshold(1, "Bottom"); + } + } + #endregion Internal Methods #region Private Fields + //private FrameArcElement m_FrameArcElem = new FrameArcElement(); + private bool m_bBottomRail; + private Threshold m_SelThreshold; + + private List m_ThresholdList = new List(); + private List m_DimensionList = new List(); private List m_JointList = new List(); diff --git a/WebWindowTest/Models/FrameArcElement.cs b/WebWindowTest/Models/FrameArcElement.cs new file mode 100644 index 0000000..f9fdf9d --- /dev/null +++ b/WebWindowTest/Models/FrameArcElement.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using WebWindowTest.Json; +using static WebWindowTest.Json.WindowConst; + +namespace WebWindowTest.Models +{ + public class FrameArcElement + { + #region Public Constructors + + public FrameArcElement() { } + + public FrameArcElement(Area ParentArea, Window ParentWindow, double nSection, bool bCutEdge, bool bIsAlign) + { + m_ParentArea = ParentArea; + m_ParentWindow = ParentWindow; + m_nSection = nSection; + m_bCutEdge = bCutEdge; + m_bIsAlign = bIsAlign; + } + + #endregion Public Constructors + + #region Public Properties + + public int nQty + { + get + { + return m_nQty; + } + set + { + m_nQty = value; + } + } + + public double nSection + { + get + { + return m_nSection; + } + set + { + m_nSection = value; + } + } + + public bool bCutEdge + { + get + { + return m_bCutEdge; + } + set + { + m_bCutEdge = value; + } + } + + public bool bIsAlign + { + get + { + return m_bIsAlign; + } + set + { + m_bIsAlign = value; + } + } + + #endregion Public Properties + + #region Internal Methods + + internal void SetQty(int Qty) + { + m_nQty = Qty; + } + + internal void SetSection(double Section) + { + m_nSection = Section; + } + + //internal JsonFrameArcElement Serialize() + //{ + // JsonFrameArcElement jArcElement = new JsonFrameArcElement(nSection, bCutEdge, bIsAlign); + // return jArcElement; + //} + + #endregion Internal Methods + + #region Protected Fields + + protected Area m_ParentArea; + protected Window m_ParentWindow; + + #endregion Protected Fields + + #region Private Fields + + private double m_nSection; + + private int m_nQty; + + private bool m_bCutEdge = false; + + private bool m_bIsAlign = false; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowTest/Models/FrameDimension.cs b/WebWindowTest/Models/FrameDimension.cs index 306a8b9..3becfc6 100644 --- a/WebWindowTest/Models/FrameDimension.cs +++ b/WebWindowTest/Models/FrameDimension.cs @@ -1,22 +1,23 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using WebWindowTest.Json; +using static WebWindowTest.Json.WindowConst; namespace WebWindowTest.Models { - public class FrameDimension + public class FrameDimension:AreaDimension { #region Public Constructors - public FrameDimension(Frame ParentFrame, int nIndex, string sName, double dValue, bool bIsLen) + public FrameDimension(Frame ParentFrame, int nIndex, string sName, double dDimension, bool bIsLen) : base(dDimension, MeasureTypes.ABSOLUTE) { m_ParentFrame = ParentFrame; m_nIndex = nIndex; m_sName = sName; - m_dValue = dValue; m_bIsLen = bIsLen; } @@ -24,24 +25,109 @@ namespace WebWindowTest.Models #region Public Properties - public double dValue + public override double dDimension { get { - return m_dValue; + return m_dDimension; } set { - m_dValue = value; - if (value > MaxDim) + if(dDimension != value) { - m_dValue = MaxDim; + if (ParentFrame.SelShapeIndex == (int)Shapes.RECTANGLE || + ParentFrame.SelShapeIndex == (int)Shapes.RIGHTCHAMFER || + ParentFrame.SelShapeIndex == (int)Shapes.LEFTCHAMFER || + ParentFrame.SelShapeIndex == (int)Shapes.DOUBLECHAMFER || + ParentFrame.SelShapeIndex == (int)Shapes.TRIANGLE) + { + if (value > MaxDim) + { + m_dDimension = MaxDim; + } + else if (value < MinDim && !m_sName.Equals("Radius") && !m_sName.Equals("Height projection")) + { + m_dDimension = MinDim; + } + else + m_dDimension = value; + } + else + { + var widthArea = (ParentFrame.DimensionList.First(x => x.sName.Equals("Width"))).m_dDimension; + if (ParentFrame.SelShapeIndex == (int)Shapes.ARC_FULL) + { + var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).m_dDimension; + if (sName.Equals("Height") && value > 0.5 * widthArea && value < MaxDim) + { + m_dDimension = value; + } + else if (sName.Equals("Width") && height > 0.5 * value && value > MinDim) + { + m_dDimension = value; + } + } + else if (ParentFrame.SelShapeIndex == (int)Shapes.ARC) + { + var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).m_dDimension; + var fullHeight = ParentFrame.DimensionList.First(x => x.sName.Equals("Full Height")).m_dDimension; + if (sName.Equals("Full Height") && (value - height) < 0.5 * widthArea && value < MaxDim) + { + m_dDimension = value; + } + else if (sName.Equals("Height") && (fullHeight - value) < 0.5 * widthArea && value < MaxDim) + { + m_dDimension = value; + } + else if (sName.Equals("Width") && (fullHeight - height) < 0.5 * value && value < MaxDim) + { + m_dDimension = value; + } + } + else if (ParentFrame.SelShapeIndex == (int)Shapes.THREECENTERARC) + { + var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).m_dDimension; + var fullHeight = ParentFrame.DimensionList.First(x => x.sName.Equals("Full Height")).m_dDimension; + if (sName.Equals("Full Height") && (value - height) < 0.5 * widthArea && value < MaxDim) + { + m_dDimension = value; + } + else if (sName.Equals("Height") && (fullHeight - value) < 0.5 * widthArea && value < MaxDim) + { + m_dDimension = value; + } + else if (sName.Equals("Width") && (fullHeight - height) < 0.5 * value) + { + m_dDimension = value; + } + else if (sName.Equals("Radius") && value < 0.5 * widthArea) + { + m_dDimension = value; + } + } + else if (ParentFrame.SelShapeIndex == (int)Shapes.DOUBLEARC) + { + var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).m_dDimension; + var fullHeight = ParentFrame.DimensionList.First(x => x.sName.Equals("Full Height")).m_dDimension; + if (sName.Equals("Full Height") && (value - height) > 0.5 * widthArea && value < MaxDim) + { + m_dDimension = value; + } + else if (sName.Equals("Height") && (fullHeight - value) > 0.5 * widthArea && value < MaxDim) + { + m_dDimension = value; + } + else if (sName.Equals("Width") && (fullHeight - height) > 0.5 * value && value > MinDim) + { + m_dDimension = value; + } + } + } + if (ParentFrame.AreaList.Count > 0 && sName.Equals("Width")) + ParentFrame.SearchAreaList(ParentFrame, dDimension, "Width"); + else + ParentFrame.SearchAreaList(ParentFrame, dDimension, "Height"); } - else if (value < MinDim && !m_sName.Equals("Radius")) - { - m_dValue = MinDim; - } - m_ParentFrame.ParentWindow.OnUpdatePreview(m_ParentFrame.ParentWindow.sSerialized()); } } @@ -75,7 +161,7 @@ namespace WebWindowTest.Models internal JsonFrameDimension Serialize() { - JsonFrameDimension JsonFrameDimension = new JsonFrameDimension(m_nIndex, m_sName, m_dValue); + JsonFrameDimension JsonFrameDimension = new JsonFrameDimension(m_nIndex, m_sName, m_dDimension); return JsonFrameDimension; } @@ -91,7 +177,7 @@ namespace WebWindowTest.Models private bool m_bIsLen = false; - private double m_dValue; + //private double m_dDimension; private int m_nIndex; diff --git a/WebWindowTest/Models/Joint.cs b/WebWindowTest/Models/Joint.cs index 4ef40e9..ad3f85b 100644 --- a/WebWindowTest/Models/Joint.cs +++ b/WebWindowTest/Models/Joint.cs @@ -63,14 +63,11 @@ namespace WebWindowTest.Models { get { - //return IdNameStruct.IndFromId((int)m_SelJointType, m_JointTypeList); return (int)m_SelJointType; } set { - //m_SelJointType = (Joints)IdNameStruct.IdFromInd(value, m_JointTypeList); m_SelJointType = (Joints)value; - m_ParentArea.ParentWindow.OnUpdatePreview(m_ParentArea.ParentWindow.sSerialized()); } } diff --git a/WebWindowTest/Models/ParametriOpzioni.cs b/WebWindowTest/Models/ParametriOpzioni.cs new file mode 100644 index 0000000..8448c0f --- /dev/null +++ b/WebWindowTest/Models/ParametriOpzioni.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebWindowTest.Models +{ + public partial class ParametriOpzioni + { + private ParametriOpzioniParametri[] itemsField; + + /// + [System.Xml.Serialization.XmlElement("Parametri", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ParametriOpzioniParametri[] Items + { + get + { + return itemsField; + } + set + { + itemsField = value; + } + } + } + + public partial class ParametriOpzioniParametri + { + private string nomeParametroField; + + private string descrizioneParametroField; + + private string valoreCorrenteField; + + private string tipoField; + + private string visibleField; + + private string ricalcolaSeModificatoField; + + private ParametriOpzioniParametriOpzioni[] opzioniField; + + /// + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string NomeParametro + { + get + { + return nomeParametroField; + } + set + { + nomeParametroField = value; + } + } + + /// + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string DescrizioneParametro + { + get + { + return descrizioneParametroField; + } + set + { + descrizioneParametroField = value; + } + } + + /// + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string ValoreCorrente + { + get + { + return valoreCorrenteField; + } + set + { + valoreCorrenteField = value; + } + } + + /// + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string Tipo + { + get + { + return tipoField; + } + set + { + tipoField = value; + } + } + + /// + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string Visible + { + get + { + return visibleField; + } + set + { + visibleField = value; + } + } + + /// + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string RicalcolaSeModificato + { + get + { + return ricalcolaSeModificatoField; + } + set + { + ricalcolaSeModificatoField = value; + } + } + + /// + [System.Xml.Serialization.XmlElement("Opzioni", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + public ParametriOpzioniParametriOpzioni[] Opzioni + { + get + { + return opzioniField; + } + set + { + opzioniField = value; + } + } + } + + public partial class ParametriOpzioniParametriOpzioni + { + private string nomeParametroField; + + private string descrizioneOpzioneField; + + private string valoreField; + + /// + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string NomeParametro + { + get + { + return nomeParametroField; + } + set + { + nomeParametroField = value; + } + } + + /// + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string DescrizioneOpzione + { + get + { + return descrizioneOpzioneField; + } + set + { + descrizioneOpzioneField = value; + } + } + + /// + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string Valore + { + get + { + return valoreField; + } + set + { + valoreField = value; + } + } + } + +} + + diff --git a/WebWindowTest/Models/Sash.cs b/WebWindowTest/Models/Sash.cs index 2ecb53d..8d94ee7 100644 --- a/WebWindowTest/Models/Sash.cs +++ b/WebWindowTest/Models/Sash.cs @@ -19,7 +19,7 @@ namespace WebWindowTest.Models // Lista hardware completa passata dal chiamante del componente public static List m_HardwareCompleteList = new List(); - // Lista hardware completa passata dal chiamante del componente + // Lista famiglia hardware completa passata dal chiamante del componente public static List s_FamilyHardwareList = new List(); #endregion Public Fields @@ -34,26 +34,6 @@ namespace WebWindowTest.Models #region Public Properties - public bool bIsMeasureGlass - { - get - { - return m_bIsMeasureGlass; - } - set - { - m_bIsMeasureGlass = value; - } - } - - public bool bIsPercentage - { - get - { - return m_bIsPercentage; - } - } - public bool bIsSashVertical { get @@ -66,6 +46,18 @@ namespace WebWindowTest.Models } } + //public SashArcElement? SashArcElem + //{ + // get + // { + // return m_SashArcElement; + // } + // set + // { + // m_SashArcElement = value!; + // } + //} + public List HardwareList { get @@ -90,18 +82,6 @@ namespace WebWindowTest.Models } } - public List JointList - { - get - { - return m_JointList; - } - set - { - m_JointList = value; - } - } - public int nSashQty { get @@ -110,17 +90,20 @@ namespace WebWindowTest.Models } set { - if (value >= 0 && value <= 3) + if (value > 0 && value <= 3) { + double widthTot = CalculateWidthArea(ParentWindow.AreaList.First(), ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dDimension); if (value > m_SashList.Count) { // recupero larghezza ultimo - double dLastDimension = 100; - double dNewDimension = 100; + double dLastDimension = widthTot; + double dNewDimension = widthTot; if (m_SashList.Count > 0) { dLastDimension = m_SashList[m_SashList.Count - 1].dDimension; dNewDimension = dLastDimension / (value + 1 - nSashQty); + if (m_SashList[m_SashList.Count - 1].MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + dNewDimension = 1; m_SashList[m_SashList.Count - 1].SetDimension(dNewDimension); } else @@ -128,7 +111,12 @@ namespace WebWindowTest.Models // aggiungo area Sash di default for (var SplitIndex = m_SashList.Count; SplitIndex <= value - 1; SplitIndex++) { - SashList.Add(new SashDimension(dNewDimension, true, this, SplitIndex + 1)); + var addSashDim = new SashDimension(dNewDimension, m_SashList[m_SashList.Count - 1].MeasureType, this, SplitIndex + 1); + for(int i = 1; i <= 4; i++) + { + addSashDim.JointList.Add(new Joint(this, i, Joints.FULL_V)); + } + SashList.Add(addSashDim); } } else if (value < m_SashList.Count) @@ -136,12 +124,29 @@ namespace WebWindowTest.Models if (value > 0) { double dLastDimension = 0; + SashDimension itemDelete = null; + double deleteDim; for (var SplitIndex = m_SashList.Count - 1; SplitIndex >= value; SplitIndex += -1) { - dLastDimension += m_SashList[SplitIndex].dDimension; + //dLastDimension += m_SashList[SplitIndex].dDimension; + itemDelete = m_SashList[SplitIndex]; SashList.RemoveAt(SplitIndex); } - dLastDimension += m_SashList[SashList.Count - 1].dDimension; + if (!itemDelete.SelMeasureType.Equals(m_SashList[SashList.Count - 1].SelMeasureType)) + { + AreaDimension ad = new AreaDimension(itemDelete.dDimension, itemDelete.SelMeasureType); + List adList = new List(); + foreach (var it in SashList) + { + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType)); + } + deleteDim = ad.ConvertDimension(adList, itemDelete.SelMeasureType, m_SashList[SashList.Count - 1].SelMeasureType, widthTot, m_SashList.IndexOf(itemDelete)); + } + //deleteDim = Convert.ConvertDimension(itemDelete, itemDelete.SelMeasureType, m_SashList[SashList.Count - 1].SelMeasureType, itemDelete.dDimension, widthTot); + else + deleteDim = itemDelete.dDimension; + //dLastDimension += m_SashList[SashList.Count - 1].dDimension; + dLastDimension = deleteDim + m_SashList[SashList.Count - 1].dDimension; SashList[SashList.Count - 1].SetDimension(dLastDimension); if (value == 1) SashList.First().SetHasHandle(true); @@ -219,13 +224,12 @@ namespace WebWindowTest.Models } } } + for (int i = 0; i < AreaList.Count; i++) + AreaList.ElementAt(i).SearchAreaList(AreaList.ElementAt(i), SashList.ElementAt(i).dDimension, "Width"); } RefreshHardwareList(); - RefreshHardwareOptionList(); + ClearHardwareOptionList(); SetFirstHardware(); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - ReqRefreshHwOption(); - //m_ParentWindow.OnReqHwOptionPreview(m_ParentWindow.sSerialized(), GroupId); } } @@ -265,7 +269,6 @@ namespace WebWindowTest.Models } set { - // Controllo che il valore inserito sia positivo if (value >= 0) { m_nSashBottomRailQty = value; @@ -277,7 +280,6 @@ namespace WebWindowTest.Models { m_bSashBottomRail = false; } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } } @@ -315,7 +317,6 @@ namespace WebWindowTest.Models set { SetSelFamilyHardware(value); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -328,7 +329,10 @@ namespace WebWindowTest.Models set { m_SelHardware = value; - ReqRefreshHwOption(); + if (HwOptionList.Count != 0) + { + ClearHardwareOptionList(); + } } } @@ -341,13 +345,19 @@ namespace WebWindowTest.Models set { m_SelHardware = m_HardwareList.FirstOrDefault(x => !string.IsNullOrEmpty(value) && x.Id.Equals(value)) ?? new Hardware(CustomHwId, "", "", Enums.OpeningTypes.Null, "", 0, 0); + HwOptionList.Clear(); if (SelHardware.Id == CustomHwId) { - HwOptionList.Clear(); SelHwOptionList.Clear(); } - //ReqRefreshHwOption(); - //ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); + } + } + + public string GetHardwareDescription + { + get + { + return m_SelHardware.Description; } } @@ -367,12 +377,10 @@ namespace WebWindowTest.Models { get { - //return IdNameStruct.IndFromId((int)m_SelOrientationSashType, m_OrientationSashTypeList); return (int)m_SelOrientationSashType; } set { - //m_SelOrientationSashType = (OrientationSash)IdNameStruct.IdFromInd(value, m_OrientationSashTypeList); m_SelOrientationSashType = (OrientationSash)value; if (value == 0) { @@ -382,7 +390,6 @@ namespace WebWindowTest.Models { m_bIsSashVertical = false; } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -407,10 +414,6 @@ namespace WebWindowTest.Models newSash.SetIsSashVertical(bIsSashVertical); newSash.SetOrientationSashType(OrientationSashType); newSash.SetSashBottomRailQty(SashBottomRailQty); - newSash.SetSelFamilyHardwareFromIndex(m_SelHardware.Id); - newSash.ReqRefreshShape(); - newSash.RefreshHardwareOptionList(); - newSash.SetSelHardware(m_SelHardware); for (int i = 0; i < SashList.Count; i++) { //Cancello SashDimension di default e aggiungo la copia @@ -418,16 +421,20 @@ namespace WebWindowTest.Models SashDimension newSashDim = SashList[i].Copy(); newSash.SashList.Insert(i, newSashDim); } - foreach (var item in JointList) - { - Joint newJoint = item.Copy(); - newSash.JointList.Add(newJoint); - } foreach (var item in AreaList) { Area newArea = item.Copy(newSash); newSash.AreaList.Add(newArea); } + newSash.SetSelFamilyHardwareFromIndex(m_SelHardware.Id); + newSash.SetSelHardwareFromId(CustomHwId); + //if (ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.ARC || + // ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.DOUBLEARC || + // ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.ARC_FULL || + // ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.THREECENTERARC) + // newSash.SashArcElem = new SashArcElement(newSash, ParentWindow, 10, true); + //else + // newSash.SashArcElem = null; return newSash; } @@ -440,6 +447,11 @@ namespace WebWindowTest.Models { m_HardwareList.Clear(); Enums.OpeningTypes sOpeningType = ConvertOpeningType(); + if (string.IsNullOrEmpty(m_SelFamilyHardware)) + m_SelFamilyHardware = s_FamilyHardwareList.FirstOrDefault(); + int sashPosition = 1; + if (nSashQty > 2 && !(SashList.First().bHasHandle || SashList.Last().bHasHandle)) + sashPosition = 2; var iComp = StringComparison.InvariantCultureIgnoreCase; var rawList = m_HardwareCompleteList .Where(x => x.Id == "000000" || @@ -447,53 +459,28 @@ namespace WebWindowTest.Models x.FamilyName.Equals(m_SelFamilyHardware, iComp) && x.SashQty == nSashQty && x.Shape.Equals(m_CurrShape, iComp) && - x.OpeningType == sOpeningType) + x.OpeningType == sOpeningType && + x.SashPosition == sashPosition) ) .ToList() ?? new List(); + if(rawList.Count == 0 || rawList == null) + { + Hardware hw = new Hardware(CustomHwId, m_SelFamilyHardware, "Custom", sOpeningType, m_CurrShape, nSashQty, 1); + rawList.Add(hw); + } m_HardwareList = new List(rawList); - //if (rawList != null && rawList.Count > 0) - //{ - // m_HardwareList = new List(rawList); - //} - //else - //{ - // m_HardwareList = new List(); - //} } } + /// + /// Metodo per rimuovere l'intero sash group + /// public void Remove() { ParentArea.AreaList.Remove(this); Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); newFill.SetAreaType(AreaTypes.FILL); ParentArea.AreaList.Add(newFill); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - } - - /// - /// Richiesta calcolo shape corrente - /// - public void ReqRefreshShape() - { - if (m_HardwareCompleteList != null && m_HardwareCompleteList.Count > 0) - { - m_HardwareList.Clear(); - // reset shape corrente - m_CurrShape = ""; - // chiamata evento calcolo shape: gruppo da calcolare - m_ParentWindow.OnReqShapePreview(m_ParentWindow.sSerialized(), GroupId); - } - } - - /// - /// Richiesta calcolo hardware option list - /// - public void ReqRefreshHwOption() - { - HwOptionList.Clear(); - // chiamata evento calcolo opzioni hardware - m_ParentWindow.OnReqHwOptionPreview(m_ParentWindow.sSerialized(), GroupId); } public void SetSelFamilyHardware(string sFamilyHw) @@ -505,6 +492,8 @@ namespace WebWindowTest.Models RefreshHardwareList(); } SetFirstHardware(); + if (HwOptionList.Count != 0) + ClearHardwareOptionList(); } /// @@ -514,43 +503,43 @@ namespace WebWindowTest.Models public void UpdateShape(string newShape) { m_CurrShape = newShape; - bool noHwValid = false; // la famiglia hw è vuota seleziono il primo hardware valido e utilizzo la sua famiglia if(string.IsNullOrEmpty(m_SelFamilyHardware) || m_SelFamilyHardware == "") { var listHwValid = Sash.m_HardwareCompleteList - .Where(x => x.Shape == m_CurrShape && - x.SashQty == nSashQty && - x.OpeningType == ConvertOpeningType() - ) - .FirstOrDefault(); + .FirstOrDefault(x => x.Shape == m_CurrShape && + x.SashQty == nSashQty && + x.OpeningType == ConvertOpeningType() + ); if(listHwValid == null) { - noHwValid = true; var familyHwValid = Sash.m_HardwareCompleteList .Select(x => x.FamilyName) .First(); + SelHardwareFromId = "000000"; + ClearHardwareOptionList(); } else + { SetSelFamilyHardware(listHwValid.FamilyName); - } - if (noHwValid) - { - SelHardwareFromId = "000000"; + } } else { RefreshHardwareList(); // se il vecchio hw selezionato non va più bene viene selezionato il primo della lista if (!HardwareList.Contains(m_SelHardware) || m_SelHardware.Shape != m_CurrShape) + { SetFirstHardware(); + ClearHardwareOptionList(); + } } } #endregion Public Methods #region Internal Methods - + internal static Sash CreateSash(Area Area) { Sash newSash = new Sash(Area, Area.ParentWindow); @@ -560,13 +549,17 @@ namespace WebWindowTest.Models newSash.SetSashQty(1); newSash.SetOrientationSashType(OrientationSash.VERTICAL); newSash.SetIsSashVertical(true); - for (var JointIndex = 0; JointIndex <= 3; JointIndex++) - newSash.JointList.Add(new Joint(newSash, JointIndex + 1, Joints.FULL_H)); + foreach(var sashDim in newSash.SashList) + { + for (var JointIndex = 0; JointIndex <= 3; JointIndex++) + sashDim.JointList.Add(new Joint(newSash, JointIndex + 1, Joints.FULL_V)); + } newSash.SetSashBottomRail(false); newSash.SetSashBottomRailQty(0); newSash.SetSelFamilyHardware(Sash.s_FamilyHardwareList.First()); - newSash.RefreshHardwareOptionList(); + newSash.ClearHardwareOptionList(); newSash.SetFirstHardware(); + //newSash.SashArcElem = null; return newSash; } @@ -650,10 +643,9 @@ namespace WebWindowTest.Models } } - internal void RefreshHardwareOptionList() + internal void ClearHardwareOptionList() { m_HwOptionList.Clear(); - //ReqRefreshHwOption(); } internal override JsonArea Serialize(bool hideHw) @@ -664,8 +656,6 @@ namespace WebWindowTest.Models JsonSash JsonSash = new JsonSash(m_bIsSashVertical, m_SashType, m_bSashBottomRail, m_nSashBottomRailQty, currHwId, GroupId); foreach (var SashDimension in SashList) JsonSash.SashList.Add(SashDimension.Serialize()); - foreach (var Joint in JointList) - JsonSash.JointList.Add(Joint.Serialize()); if(HwOptionList.Count > 0) { foreach (var HwOption in HwOptionList) @@ -676,17 +666,25 @@ namespace WebWindowTest.Models foreach (var HwOption in SelHwOptionList) JsonSash.HwOptionList.Add(new JsonHwOption(HwOption.Key, HwOption.Value)); } + //if (SashArcElem != null) + // JsonSash.ArcElement = SashArcElem.Serialize(); + //else + // JsonSash.ArcElement = null; foreach (var Area in AreaList) JsonSash.AreaList.Add(Area.Serialize(hideHw)); return JsonSash; } + //internal void SetSashArcElem(SashArcElement arcElement) + //{ + // m_SashArcElement = arcElement; + //} + internal void SetFirstHardware() { if (m_HardwareList.Count > 0) { m_SelHardware = m_HardwareList.First(); - //ReqRefreshHwOption(); } } @@ -750,14 +748,18 @@ namespace WebWindowTest.Models case HwOptionTypes.COMBO: { AGBOptionCombo OptCombo = (AGBOptionCombo)HwOption; - var selValue = OptCombo.ValueList.Where(x => x.sValue == selHwOption).First(); - OptCombo.sValue = selValue; + var selValue = OptCombo.ValueList.Where(x => x.sValue == selHwOption).FirstOrDefault(); + if (selValue != null) + OptCombo.sValue = selValue; + else + OptCombo.sValue = OptCombo.ValueList.First(); break; } case HwOptionTypes.TEXT: { AGBOptionText OptText = (AGBOptionText)HwOption; - OptText.sValue = selHwOption; + if(OptText.ValueList.FirstOrDefault(x => x.Equals(selHwOption)) != null || OptText.sName.Equals("HMan")) + OptText.sValue = selHwOption; break; } } @@ -804,7 +806,10 @@ namespace WebWindowTest.Models dNewDimension = dLastDimension / (Qty + 1 - nSashQty); // aggiungo area Sash di default for (var SplitIndex = m_SashList.Count; SplitIndex <= Qty - 1; SplitIndex++) - SashList.Add(new SashDimension(dNewDimension, true, this, SplitIndex + 1)); + { + SashDimension newSashDim = new SashDimension(dNewDimension, MeasureTypes.PERCENTAGE, this, SplitIndex + 1); + SashList.Add(newSashDim); + } } else if (Qty < m_SashList.Count) { @@ -833,11 +838,6 @@ namespace WebWindowTest.Models return SelFamilyHardware; } - internal void SetSelHardware(Hardware value) - { - SelHardware = value; - } - internal void SetSelHardwareFromId(string sId) { if (m_HardwareList.Count == 0) @@ -864,8 +864,6 @@ namespace WebWindowTest.Models private bool m_bIsMeasureGlass; - private bool m_bIsPercentage = true; - private bool m_bIsSashVertical; private bool m_bSashBottomRail; @@ -876,8 +874,6 @@ namespace WebWindowTest.Models private List m_HwOptionList = new List(); private Dictionary m_SelHwOptionList = new Dictionary(); - private List m_JointList = new List(); - private int m_nSashBottomRailQty; private List m_OrientationSashTypeList = new List @@ -888,9 +884,10 @@ namespace WebWindowTest.Models private List m_SashList = new List(); private SashTypes m_SashType; - private string m_SelFamilyHardware; + private string m_SelFamilyHardware = ""; private Hardware m_SelHardware; private OrientationSash m_SelOrientationSashType; + //private SashArcElement m_SashArcElement; #endregion Private Fields diff --git a/WebWindowTest/Models/SashArcElement.cs b/WebWindowTest/Models/SashArcElement.cs new file mode 100644 index 0000000..c3a1b5b --- /dev/null +++ b/WebWindowTest/Models/SashArcElement.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using WebWindowTest.Json; +using static WebWindowTest.Json.WindowConst; + +namespace WebWindowTest.Models +{ + public class SashArcElement + { + #region Public Constructors + + public SashArcElement() { } + + public SashArcElement(Area ParentArea, Window ParentWindow, double nSection, bool bCutEdge) + { + m_ParentArea = ParentArea; + m_ParentWindow = ParentWindow; + m_nSection = nSection; + m_bCutEdge = bCutEdge; + } + + #endregion Public Constructors + + #region Public Properties + + public int nQty + { + get + { + return m_nQty; + } + set + { + m_nQty = value; + } + } + + public double nSection + { + get + { + return m_nSection; + } + set + { + m_nSection = value; + } + } + + public bool bCutEdge + { + get + { + return m_bCutEdge; + } + set + { + m_bCutEdge = value; + } + } + + #endregion Public Properties + + #region Internal Methods + + //internal JsonSashArcElement Serialize() + //{ + // JsonSashArcElement jArcElement = new JsonSashArcElement(nSection, bCutEdge); + // return jArcElement; + //} + + #endregion Internal Methods + + #region Protected Fields + + protected Area m_ParentArea; + protected Window m_ParentWindow; + + #endregion Protected Fields + + #region Private Fields + + private double m_nSection; + + private int m_nQty; + + private bool m_bCutEdge = false; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowTest/Models/SashDimension.cs b/WebWindowTest/Models/SashDimension.cs index c37c068..07ceca9 100644 --- a/WebWindowTest/Models/SashDimension.cs +++ b/WebWindowTest/Models/SashDimension.cs @@ -1,23 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Runtime.InteropServices; +using System.Security.Principal; using WebWindowTest.Json; using static WebWindowTest.Json.WindowConst; namespace WebWindowTest.Models { - public class SashDimension + public class SashDimension : AreaDimension { #region Public Constructors - public SashDimension(double dDimension, bool bIsRelative, Sash Parent, int nSashId) + public SashDimension(double dDimension, MeasureTypes MeasureType, Sash Parent, int nSashId):base(dDimension, MeasureType) { m_dDimension = dDimension; - m_bIsRelative = bIsRelative; - m_Parent = Parent; m_nSashId = nSashId; + m_Parent = Parent; + SetMeasureType(MeasureType); // assengno maniglia if (Parent.SashList.Count == 0 || !Parent.SashList.Any(x => x.bHasHandle)) m_bHasHandle = true; @@ -106,19 +103,34 @@ namespace WebWindowTest.Models set { m_bHasHandle = value; - //m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); } } - public bool bIsRelative + public Sash Parent { get { - return m_bIsRelative; + return m_Parent; + } + set + { + m_Parent = value; } } - public double dDimension + public List JointList + { + get + { + return m_JointList; + } + set + { + m_JointList = value; + } + } + + public override double dDimension { get { @@ -126,72 +138,167 @@ namespace WebWindowTest.Models } set { - // Controllo che il valore inserito sia compreso tra 0 e 100 - if (value > 0 && value < 100) + double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dDimension); + double valMinAbsolute = 200; + double valMaxAbsolute = widthTot - valMinAbsolute * (m_Parent.SashList.Count - 1); + bool valueAccept = false; + switch (MeasureType) { - // se sono in percentuale - if (m_bIsRelative) - { - // verifico se ci sono assoluti - List RelativeDimList = m_Parent.SashList.Where(x => x.bIsRelative).ToList(); - if (RelativeDimList.Count > 0) + case MeasureTypes.ABSOLUTE: { - if (m_Parent.bIsPercentage) + valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false; + break; + } + case MeasureTypes.PROPORTIONAL: + { + valMaxAbsolute = 20; + valueAccept = (value >= 1) ? true : false; + break; + } + case MeasureTypes.PERCENTAGE: + { + valMaxAbsolute = valMaxAbsolute / widthTot * 100; + valMinAbsolute = valMinAbsolute / widthTot * 100; + valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false; + break; + } + } + if (valueAccept) + { + List dimensions = m_Parent.SashList; + List absoluteValList = new List(); + AreaDimension ad = new AreaDimension(m_dDimension, SelMeasureType); + List adList = new List(); + foreach (var it in m_Parent.SashList) + { + adList.Add(new AreaDimension(it.m_dDimension, it.SelMeasureType)); + } + int index = 0; + foreach (var item in m_Parent.SashList) + { + absoluteValList.Add(adList.ElementAt(index).CalculateAbsoluteValue(adList, widthTot)); + index++; + } + int nIndex = dimensions.IndexOf(this); + int proportionalCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count; + int percentageCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList().Count; + // Le dimensioni sono solo in proporzionale + if (proportionalCount == absoluteValList.Count || SelMeasureType.Equals(MeasureTypes.PROPORTIONAL) || + (SelMeasureType.Equals(MeasureTypes.ABSOLUTE) && proportionalCount == absoluteValList.Count -1)) + { + m_dDimension = value; + } + // Le dimensioni sono solo in percentuale + else if (percentageCount == dimensions.Count) + { + if (value < m_dDimension) + { + // L'anta modificata non è l'ultima + if (nIndex < dimensions.Count - 1) + dimensions[nIndex + 1].SetDimension(dimensions[nIndex + 1].m_dDimension + (m_dDimension - value)); + else if (dimensions.Count > 1) + dimensions[nIndex - 1].SetDimension(dimensions[nIndex - 1].m_dDimension + (m_dDimension - value)); + else { - int nIndex = RelativeDimList.IndexOf(this); - // se diminuisce dimensione - if (value < m_dDimension) - { - if (nIndex < RelativeDimList.Count - 1) - RelativeDimList[nIndex + 1].SetDimension(RelativeDimList[nIndex + 1].dDimension + (m_dDimension - value)); - else if (RelativeDimList.Count > 1) - RelativeDimList[nIndex - 1].SetDimension(RelativeDimList[nIndex - 1].dDimension + (m_dDimension - value)); - else - { - m_dDimension = 100; - return; - } - } - // se aumenta dimensione - else - { - double dRes = value; - // se non ultima anta - if (nIndex < RelativeDimList.Count - 1) - { - for (var nInd = 0; nInd <= nIndex - 1; nInd++) - dRes += RelativeDimList[nInd].dDimension; - dRes = (100 - dRes) / (RelativeDimList.Count - nIndex - 1); - for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) - RelativeDimList[Ind].SetDimension(dRes); - } - // se ultima anta - else if (RelativeDimList.Count > 1) - { - if (RelativeDimList.Count > 2) - { - for (var Ind = 0; Ind <= nIndex - 2; Ind++) - dRes += RelativeDimList[Ind].dDimension; - } - - //for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) - // dRes += RelativeDimList[Ind].dDimension; - dRes = (100 - dRes); - RelativeDimList[nIndex - 1].SetDimension(dRes); - //for (var nInd = 0; nInd <= nIndex - 1; nInd++) - // RelativeDimList[nInd].SetDimension(dRes); - } - else - { - m_dDimension = 100; - return; - } - } + m_dDimension = 100; + return; } } + else + { + double dRes = value; + // se non ultima anta + if (nIndex < dimensions.Count - 1) + { + for (var nInd = 0; nInd <= nIndex - 1; nInd++) + dRes += dimensions[nInd].m_dDimension; + dRes = (100 - dRes) / (dimensions.Count - nIndex - 1); + for (var Ind = nIndex + 1; Ind <= dimensions.Count - 1; Ind++) + dimensions[Ind].SetDimension(dRes); + } + // se ultima anta + else if (dimensions.Count > 1) + { + if (dimensions.Count > 2) + { + for (var Ind = 0; Ind <= nIndex - 2; Ind++) + dRes += dimensions[Ind].m_dDimension; + } + dRes = (100 - dRes); + dimensions[nIndex - 1].SetDimension(dRes); + } + else + { + m_dDimension = 100; + return; + } + } + m_dDimension = value; } - m_dDimension = value; - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + // Le dimensioni sono miste o solo in assoluto + else + { + double valueInAbsolute = 0; + switch (MeasureType) + { + case MeasureTypes.ABSOLUTE: + { + valueInAbsolute = value; + break; + } + case MeasureTypes.PROPORTIONAL: + { + var pesi = value + dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL) && !x.Equals(this)) + .Sum(x => x.m_dDimension); + valueInAbsolute = widthTot / pesi * value; + break; + } + case MeasureTypes.PERCENTAGE: + { + valueInAbsolute = (value / 100) * widthTot; + break; + } + } + if (value < m_dDimension) + { + // L'anta modificata non è l'ultima + if (nIndex < absoluteValList.Count - 1) + { + absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] + (absoluteValList[nIndex] - valueInAbsolute); + absoluteValList[nIndex] = valueInAbsolute; + } + // L'anta modificata è l'ultima + else if (dimensions.Count > 1) + { + absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] + (absoluteValList[nIndex] - valueInAbsolute); + absoluteValList[nIndex] = valueInAbsolute; + } + } + else + { + // L'anta modificata non è l'ultima + if (nIndex < absoluteValList.Count - 1) + { + absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] - (valueInAbsolute - absoluteValList[nIndex]); + absoluteValList[nIndex] = valueInAbsolute; + } + // L'anta modificata è l'ultima + else if (dimensions.Count > 1) + { + absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] - (valueInAbsolute - absoluteValList[nIndex]); + absoluteValList[nIndex] = valueInAbsolute; + } + } + if (MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + m_dDimension = value; + for (int i = 0; i < absoluteValList.Count; i++) + { + var item = m_Parent.SashList.ElementAt(i); + item.SetDimension(ad.ConvertIn(adList, absoluteValList[i], (MeasureTypes)item.SelMeasureTypeIndex, widthTot)); + } + } + foreach(var item in m_Parent.AreaList) + item.SearchAreaList(item, dDimension, "Width"); } } } @@ -208,7 +315,7 @@ namespace WebWindowTest.Models { get { - return (Openings)m_SelOpeningType; + return m_SelOpeningType; } } @@ -229,8 +336,7 @@ namespace WebWindowTest.Models set { m_SelOpeningType = value; - m_Parent.ReqRefreshShape(); - m_Parent.RefreshHardwareOptionList(); + m_Parent.ClearHardwareOptionList(); m_Parent.SetFirstHardware(); } } @@ -239,22 +345,72 @@ namespace WebWindowTest.Models { get { - //return IdNameStruct.IndFromId((int)m_SelOpeningType, m_OpeningTypeList); return (int)m_SelOpeningType; } set { - //Openings newOpening = (Openings)IdNameStruct.IdFromInd(value, m_OpeningTypeList); Openings newOpening = (Openings)value; if ((newOpening != Openings.TILTTURN_LEFT && newOpening != Openings.TILTTURN_RIGHT) || (newOpening == Openings.TILTTURN_LEFT && m_bHasHandle) || (newOpening == Openings.TILTTURN_RIGHT && m_bHasHandle)) { m_SelOpeningType = newOpening; - m_Parent.ReqRefreshShape(); - m_Parent.RefreshHardwareOptionList(); + m_Parent.ClearHardwareOptionList(); + m_Parent.RefreshHardwareList(); m_Parent.SetFirstHardware(); - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + } + } + } + + //public MeasureTypes MeasureType + //{ + // get + // { + // return m_SelMeasureType; + // } + //} + + //public List MeasureTypeList + //{ + // get + // { + // return m_MeasureTypeList; + // } + //} + + //public MeasureTypes SelMeasureType + //{ + // get + // { + // return m_SelMeasureType; + // } + // set + // { + // m_SelMeasureType = value; + // } + //} + + public override int SelMeasureTypeIndex + { + get + { + return (int)SelMeasureType; + } + set + { + if(SelMeasureType != (MeasureTypes)value) + { + MeasureTypes newType = (MeasureTypes)value; + double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dDimension); + AreaDimension ad = new AreaDimension(m_dDimension, SelMeasureType); + List adList = new List(); + foreach (var it in m_Parent.SashList) + { + adList.Add(new AreaDimension(it.m_dDimension, it.SelMeasureType)); + } + m_dDimension = ad.ConvertDimension(adList, SelMeasureType, newType, widthTot, nSashId-1); + //m_dDimension = Convert.ConvertDimension(this, m_SelMeasureType, newType, m_dDimension, widthTot); + SelMeasureType = (MeasureTypes)value; } } } @@ -263,11 +419,72 @@ namespace WebWindowTest.Models #region Public Methods + /// + /// Metodo per convertire la dimensione dal vecchio tipo al nuovo tipo + /// + /// Vecchio tipo + /// Nuovo tipo + /// + //public double ConvertDimension(MeasureTypes oldType, MeasureTypes newType, double widthTot) + //{ + // switch (oldType) + // { + // case MeasureTypes.ABSOLUTE: + // { + // if (newType.Equals(MeasureTypes.PERCENTAGE)) + // { + // //return Double.Round((m_dDimension / m_Parent.Width) * 100, 1); + // return (m_dDimension / widthTot) * 100; + // } + // else + // { + // return CalculatePropVal(widthTot); + // } + // } + // case MeasureTypes.PROPORTIONAL: + // { + // if (newType.Equals(MeasureTypes.ABSOLUTE)) + // { + // //return Double.Round(ConvertFromPropVal(newType), 2); + // return ConvertFromPropVal(newType, widthTot, dDimension); + // } + // else + // { + // //return Double.Round(ConvertFromPropVal(newType), 1); + // return ConvertFromPropVal(newType, widthTot, dDimension); + // } + // } + // case MeasureTypes.PERCENTAGE: + // { + // if (newType.Equals(MeasureTypes.ABSOLUTE)) + // { + // //return Double.Round((m_dDimension * m_Parent.Width) / 100, 2); + // return (m_dDimension * widthTot) / 100; + // } + // else + // { + // return CalculatePropVal(widthTot); + // } + // } + // } + // return -1; + //} + + /// + /// Metodo per copiare l'intero oggetto + /// + /// public SashDimension Copy() { - SashDimension newSashDim = new SashDimension(dDimension, bIsRelative, m_Parent, m_nSashId); + SashDimension newSashDim = new SashDimension(m_dDimension, MeasureType, m_Parent, m_nSashId); + newSashDim.SetMeasureType(MeasureType); newSashDim.SetOpeningType(SelOpeningType); newSashDim.SetHasHandle(bHasHandle); + foreach (var item in JointList) + { + Joint newJoint = item.Copy(); + newSashDim.JointList.Add(newJoint); + } return newSashDim; } @@ -275,16 +492,277 @@ namespace WebWindowTest.Models #region Internal Methods + /// + /// Metodo per calcolare larghezza intera sash group + /// + /// area di partenza + /// larghezza di partenza + /// + internal double CalculateWidthSashGroup(Area area, double width) + { + for(int i = 0; i < area.AreaList.Count; i++) + { + double risultato = -1; + if (area.Equals(m_Parent)) + return width; + Area item = area.AreaList[i]; + if (area is Split) + { + Split split = (Split)area; + if (split.SplitVertList.Count > 0) + { + switch (split.SplitVertList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + AreaDimension ad = new AreaDimension(split.SplitVertList.ElementAt(i).dDimension, split.SplitVertList.ElementAt(i).SelMeasureType); + List adList = new List(); + foreach(var it in split.SplitVertList) + { + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType)); + } + risultato = CalculateWidthSashGroup(item, ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, width)); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension * width / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateWidthSashGroup(item, width); + } + } + else if (area is Sash) + { + Sash sash = (Sash)area; + switch (sash.SashList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateWidthSashGroup(item, ConvertFromPropVal(MeasureTypes.ABSOLUTE, width, sash.SashList.ElementAt(i).dDimension)); + AreaDimension ad = new AreaDimension(sash.SashList.ElementAt(i).dDimension, sash.SashList.ElementAt(i).SelMeasureType); + List adList = new List(); + foreach (var it in sash.SashList) + { + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType)); + } + risultato = CalculateWidthSashGroup(item, ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, width)); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension * width / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateWidthSashGroup(item, width); + if (risultato != -1) + return risultato; + } + } + return width; + } + + ///// + ///// Calcolo MCD + ///// + ///// + ///// + ///// + //internal static double CalculateMCD(double a, double b) + //{ + // while (b >= 0.01) + // { + // double temp = b; + // b = a % b; + // a = temp; + // } + // //return Double.Round(a,2); + // return a; + //} + + ///// + ///// Metodo per ricalcolare i valori proporzionali a causa della modifica di uno + ///// + ///// + //internal double CalculatePropVal(double widthTot) + //{ + // if (m_Parent.SashList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0) + // { + // return 1; + // } + // List absoluteValue = new List(); + // foreach (var item in m_Parent.SashList) + // { + // absoluteValue.Add(item.CalculateAbsoluteValue(widthTot)); + // } + // for (int i = 0; i < m_Parent.SashList.Count; i++) + // { + // if (!m_Parent.SashList.ElementAt(i).Equals(this) && + // m_Parent.SashList.ElementAt(i).MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + // { + // int nIndex = m_Parent.SashList.IndexOf(this); + // if (absoluteValue.ElementAt(nIndex) <= absoluteValue.ElementAt(i)) + // { + // var mcd = CalculateMCD(absoluteValue.ElementAt(nIndex), absoluteValue.ElementAt(i)); + // m_Parent.SashList.ElementAt(i).m_dDimension = absoluteValue.ElementAt(i) / mcd; + // m_dDimension = absoluteValue.ElementAt(nIndex) / mcd; + // } + // else + // { + // var mcd = CalculateMCD(absoluteValue.ElementAt(nIndex), absoluteValue.ElementAt(i)); + // m_Parent.SashList.ElementAt(i).m_dDimension = absoluteValue.ElementAt(i) / mcd; + // m_dDimension = absoluteValue.ElementAt(nIndex) / mcd; + // } + // break; + // } + // } + // return m_dDimension; + //} + + ///// + ///// Metodo per trasformare una dimensione in valore assoluto rispetto alla larghezza totale + ///// + ///// Larghezza totale + ///// + //internal double CalculateAbsoluteValue(double widthTot) + //{ + // switch (MeasureType) + // { + // case MeasureTypes.ABSOLUTE: + // { + // //return Double.Round(dDimension, 2); + // return dDimension; + // } + // case MeasureTypes.PROPORTIONAL: + // { + // //return Double.Round(Proportional2AbsolutVal(), 2); + // return ProportionalFromAbsoluteVal(widthTot); + // } + // case MeasureTypes.PERCENTAGE: + // { + // //return Double.Round((dDimension / 100) * widthTot, 1); + // return (dDimension / 100) * widthTot; + // } + // } + // return 0; + //} + + ///// + ///// Metodo per convertire una dimensione da un valore assoluto al suo rispettivo tipo + ///// + ///// Valore assoluto + ///// Tipo di misura della dimensione + ///// Larghezza totale + ///// + //internal double ConvertIn(double absoluteVal, MeasureTypes type, double widthTot) + //{ + // switch (type) + // { + // case MeasureTypes.ABSOLUTE: + // { + // return absoluteVal; + // } + // case MeasureTypes.PROPORTIONAL: + // { + // return ProportionalFromAbsoluteVal(widthTot); + // } + // case MeasureTypes.PERCENTAGE: + // { + // return (absoluteVal / widthTot) * 100; + // } + // } + // return -1; + //} + + ///// + ///// Metodo per convertire da misura proporzionale a misura assoluta o percentuale + ///// + ///// + ///// + //internal double ConvertFromPropVal(MeasureTypes newType, double widthTot, double dim) + //{ + // double tot = widthTot; + // //Somma misura non proporzionali + // double sumNotProp = m_Parent.SashList + // .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL && !m.Equals(this)) + // .Sum(m => m.CalculateAbsoluteValue(tot)); + // //Calcolo residuo + // double res = tot - sumNotProp; + // if (res < 0) res = 0; + // //Misure proporzionali + // var proportionalList = m_Parent.SashList + // .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + // .ToList(); + + // double sumPesi = proportionalList.Sum(p => p.dDimension); + // if (sumPesi == 0) sumPesi = 1; + // if (newType.Equals(MeasureTypes.ABSOLUTE)) + // { + // return res / sumPesi * dim; + // } + // else + // { + // return (res / sumPesi * dim) / tot * 100; + // } + //} + + ///// + ///// Metodo per trasformare il valore proporzionale in assoluto + ///// + ///// + //internal double ProportionalFromAbsoluteVal(double widthTot) + //{ + // double tot = widthTot; + // //Somma misura non proporzionali + // double sumNotProp = m_Parent.SashList + // .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL) + // .Sum(m => m.CalculateAbsoluteValue(tot)); + // //Calcolo residuo + // double res = tot - sumNotProp; + // if (res < 0) res = 0; + // //Misure proporzionali + // var proportionalList = m_Parent.SashList + // .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + // .ToList(); + // double sumPesi = proportionalList.Sum(p => p.dDimension); + // if (sumPesi == 0) sumPesi = 1; + // return res / sumPesi * dDimension; + //} + internal JsonSashDimension Serialize() { - JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, m_bHasHandle, m_dDimension, m_nSashId); + JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, MeasureType, m_bHasHandle, dDimension, m_nSashId); + foreach (var Joint in JointList) + JsonSashDimension.JointList.Add(Joint.Serialize()); return JsonSashDimension; } - internal void SetDimension(double dValue) - { - m_dDimension = dValue; - } + //internal void SetDimension(double dValue) + //{ + // m_dDimension = dValue; + //} internal void SetHasHandle(bool value) { @@ -296,15 +774,40 @@ namespace WebWindowTest.Models m_SelOpeningType = value; } + internal void SetMeasureType(MeasureTypes value) + { + SelMeasureType = value; + } + + internal void SetSelMeasureType(MeasureTypes value, int indexSash) + { + if (SelMeasureType != (MeasureTypes)value) + { + MeasureTypes newType = (MeasureTypes)value; + double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dDimension); + AreaDimension ad = new AreaDimension(dDimension, SelMeasureType); + List newDimensions = new List(); + foreach(var item in m_Parent.SashList) + { + newDimensions.Add(new AreaDimension(item.dDimension, item.SelMeasureType)); + } + m_dDimension = ad.ConvertDimension(newDimensions, SelMeasureType, newType, widthTot, indexSash); + if(newType is MeasureTypes.PROPORTIONAL) + { + for (int i = 0; i < newDimensions.Count; i++) + m_Parent.SashList.ElementAt(i).SetDimension(newDimensions.ElementAt(i).dDimension); + } + SelMeasureType = (MeasureTypes)value; + } + } + #endregion Internal Methods #region Private Fields private bool m_bHasHandle; - private bool m_bIsRelative = false; - - private double m_dDimension; + //private double m_dDimension; private int m_nSashId; @@ -337,11 +840,23 @@ namespace WebWindowTest.Models //new IdNameStruct((int)Openings.LIFTSLIDE_RIGHT, "←┐") }; + //private List m_MeasureTypeList = new List + //{ + // new IdNameStruct((int)MeasureTypes.ABSOLUTE, "Absolute"), + // new IdNameStruct((int)MeasureTypes.PROPORTIONAL, "Proportional"), + // new IdNameStruct((int)MeasureTypes.PERCENTAGE, "Percentage"), + //}; + // reference private Sash m_Parent; + private List m_JointList = new List(); + private Openings m_SelOpeningType; + //private MeasureTypes m_SelMeasureType; + #endregion Private Fields + } } \ No newline at end of file diff --git a/WebWindowTest/Models/Split.cs b/WebWindowTest/Models/Split.cs index 6881b04..a415e6a 100644 --- a/WebWindowTest/Models/Split.cs +++ b/WebWindowTest/Models/Split.cs @@ -20,13 +20,13 @@ namespace WebWindowTest.Models #region Public Properties - public bool bIsPercentage - { - get - { - return m_bIsPercentage; - } - } + //public bool bIsPercentage + //{ + // get + // { + // return m_bIsPercentage; + // } + //} public bool bSplitStartVert { @@ -37,7 +37,6 @@ namespace WebWindowTest.Models set { m_bSplitStartVert = value; - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -49,81 +48,86 @@ namespace WebWindowTest.Models } set { - if (value == 0) + if(value >= 0 && value < 6) { - for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value; SplitIndex += -1) - m_SplitHorizList.RemoveAt(SplitIndex); - if (nSplitQtyVert == 0) + if (value == 0) { - ParentArea.AreaList.Remove(this); - Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); - newFill.SetAreaType(AreaTypes.FILL); - ParentArea.AreaList.Add(newFill); - } - else - SetSplitShape(SplitShapes.VERTICAL); - } - else - { - // Ricalcolo dimensioni aggiungendo split - if (value > m_SplitHorizList.Count - 1) - { - // recupero larghezza ultimo - double dLastDimension = 100; - double dNewDimension = 100; - if (m_SplitHorizList.Count > 0) + for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value; SplitIndex += -1) + m_SplitHorizList.RemoveAt(SplitIndex); + if (nSplitQtyVert == 0) { - dLastDimension = m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension; - dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz); - m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dNewDimension); + ParentArea.AreaList.Remove(this); + Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + ParentArea.AreaList.Add(newFill); } else - dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz); - // aggiungo area Split di default - for (var SplitIndex = m_SplitHorizList.Count; SplitIndex <= value; SplitIndex++) - m_SplitHorizList.Add(new SplitDimension(dNewDimension, true, this, false)); + SetSplitShape(SplitShapes.VERTICAL); } - // Ricalcolo dimensioni rimuovendo split else { - double dLastDimension = 0; - for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + double heightTot = CalculateHeightArea(ParentWindow.AreaList.First(), HeightFrame()); + // Ricalcolo dimensioni aggiungendo split + if (value > m_SplitHorizList.Count - 1) { - dLastDimension += m_SplitHorizList[SplitIndex].dDimension; - m_SplitHorizList.RemoveAt(SplitIndex); + // recupero larghezza ultimo + double dLastDimension = heightTot; + double dNewDimension = heightTot; + if (m_SplitHorizList.Count > 0) + { + dLastDimension = m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension; + dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz); + if (m_SplitHorizList[m_SplitHorizList.Count - 1].MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + dNewDimension = 1; + m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dNewDimension); + } + else + dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz); + // aggiungo area Split di default + for (var SplitIndex = m_SplitHorizList.Count; SplitIndex <= value; SplitIndex++) + m_SplitHorizList.Add(new SplitDimension(dNewDimension, m_SplitHorizList[m_SplitHorizList.Count - 1].MeasureType, true, this, false)); } - dLastDimension += m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension; - m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dLastDimension); - } - // Controllo quanti split verticali ci sono - int nVert = m_SplitVertList.Count > 0 ? m_SplitVertList.Count : 1; - // Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta - for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitHorizList.Count * nVert) - 1; SplitIndex++) - { - AreaList.Add(Splitted.CreateSplitted(this)); - Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); - newFill.SetAreaType(AreaTypes.FILL); - AreaList[AreaList.Count - 1].AreaList.Add(newFill); - } - // Se ho più di uno split, elimino l'ultimo - if (AreaList.Count > 2) - { - int nAreaList = AreaList.Count - 1; - for (var SplitIndex = (m_SplitHorizList.Count * nVert); SplitIndex <= nAreaList; SplitIndex++) + // Ricalcolo dimensioni rimuovendo split + else { - AreaList.Remove(AreaList[AreaList.Count - 1]); + double dLastDimension = 0; + for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + { + dLastDimension += m_SplitHorizList[SplitIndex].dDimension; + m_SplitHorizList.RemoveAt(SplitIndex); + } + dLastDimension += m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension; + m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dLastDimension); + } + // Controllo quanti split verticali ci sono + int nVert = m_SplitVertList.Count > 0 ? m_SplitVertList.Count : 1; + // Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta + for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitHorizList.Count * nVert) - 1; SplitIndex++) + { + AreaList.Add(Splitted.CreateSplitted(this)); + Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + AreaList[AreaList.Count - 1].AreaList.Add(newFill); + } + // Se ho più di uno split, elimino l'ultimo + if (AreaList.Count > 2) + { + int nAreaList = AreaList.Count - 1; + for (var SplitIndex = (m_SplitHorizList.Count * nVert); SplitIndex <= nAreaList; SplitIndex++) + { + AreaList.Remove(AreaList[AreaList.Count - 1]); + } + } + // Se elimino l'unico split presente + else + { + Splitted s = (Splitted)AreaList[0]; + s.SetParentArea(ParentArea); + ParentArea.AreaList.Add(s); + ParentArea.AreaList.Remove(this); } - } - // Se elimino l'unico split presente - else - { - Splitted s = (Splitted)AreaList[0]; - s.SetParentArea(ParentArea); - ParentArea.AreaList.Add(s); - ParentArea.AreaList.Remove(this); } } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -135,86 +139,116 @@ namespace WebWindowTest.Models } set { - if (value == 0) + if (value >= 0 && value < 6) { - for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value; SplitIndex += -1) - m_SplitVertList.RemoveAt(SplitIndex); - if (nSplitQtyHoriz == 0) + if (value == 0) { - ParentArea.AreaList.Remove(this); - Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); - newFill.SetAreaType(AreaTypes.FILL); - ParentArea.AreaList.Add(newFill); - } - else - SetSplitShape(SplitShapes.HORIZONTAL); - } - else - { - // Ricalcolo dimensioni aggiungendo split - if (value > m_SplitVertList.Count - 1) - { - // recupero larghezza ultimo - double dLastDimension = 100; - double dNewDimension = 100; - if (m_SplitVertList.Count > 0) + for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value; SplitIndex += -1) + m_SplitVertList.RemoveAt(SplitIndex); + if (nSplitQtyHoriz == 0) { - dLastDimension = m_SplitVertList[m_SplitVertList.Count - 1].dDimension; - dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert); - m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dNewDimension); + ParentArea.AreaList.Remove(this); + Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + ParentArea.AreaList.Add(newFill); } else - dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert); - // aggiungo area Split di default - for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= value; SplitIndex++) - m_SplitVertList.Add(new SplitDimension(dNewDimension, true, this, true)); + SetSplitShape(SplitShapes.HORIZONTAL); } - else if (value == 0) - { - m_SplitVertList.RemoveAt(1); - m_SplitVertList.RemoveAt(0); - } - // Ricalcolo dimensioni rimuovendo split else { - double dLastDimension = 0; - for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + double widthTot = CalculateWidthArea(ParentWindow.AreaList.First(), ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dDimension); + // Ricalcolo dimensioni aggiungendo split + if (value > m_SplitVertList.Count - 1) { - dLastDimension += m_SplitVertList[SplitIndex].dDimension; - m_SplitVertList.RemoveAt(SplitIndex); + // recupero larghezza ultimo + double dLastDimension = widthTot; + double dNewDimension = widthTot; + if (m_SplitVertList.Count > 0) + { + dLastDimension = m_SplitVertList[m_SplitVertList.Count - 1].dDimension; + dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert); + if (m_SplitVertList[m_SplitVertList.Count - 1].MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + dNewDimension = 1; + m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dNewDimension); + } + else + dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert); + // aggiungo area Split di default + for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= value; SplitIndex++) + m_SplitVertList.Add(new SplitDimension(dNewDimension, m_SplitVertList[m_SplitVertList.Count - 1].MeasureType, true, this, true)); } - dLastDimension += m_SplitVertList[m_SplitVertList.Count - 1].dDimension; - m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dLastDimension); - } - // Controllo quanti split orizzontali ci sono - int nHoriz = m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count : 1; - // Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta - for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitVertList.Count * nHoriz) - 1; SplitIndex++) - { - AreaList.Add(Splitted.CreateSplitted(this)); - Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); - newFill.SetAreaType(AreaTypes.FILL); - AreaList[AreaList.Count - 1].AreaList.Add(newFill); - } - // Se ho più di uno split, elimino l'ultimo - if (AreaList.Count > 2) - { - int nAreaList = AreaList.Count - 1; - for (var SplitIndex = (m_SplitVertList.Count * nHoriz); SplitIndex <= nAreaList; SplitIndex++) + else if (value == 0) { - AreaList.Remove(AreaList[AreaList.Count - 1]); + m_SplitVertList.RemoveAt(1); + m_SplitVertList.RemoveAt(0); + } + // Ricalcolo dimensioni rimuovendo split + else + { + int countProportional = m_SplitVertList.Count(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)); + if(m_SplitVertList.Last().MeasureType.Equals(MeasureTypes.PROPORTIONAL) && countProportional - 1 == 1) + { + m_SplitVertList.RemoveAt(m_SplitVertList.Count() - 1); + m_SplitVertList.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).FirstOrDefault().SetDimension(1); + } + else + { + double dLastDimension = 0; + for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + { + dLastDimension += m_SplitVertList[SplitIndex].dDimension; + m_SplitVertList.RemoveAt(SplitIndex); + } + dLastDimension += m_SplitVertList[m_SplitVertList.Count - 1].dDimension; + m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dLastDimension); + } + } + // Controllo quanti split orizzontali ci sono + int nHoriz = m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count : 1; + // Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta + for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitVertList.Count * nHoriz) - 1; SplitIndex++) + { + AreaList.Add(Splitted.CreateSplitted(this)); + Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + AreaList[AreaList.Count - 1].AreaList.Add(newFill); + } + // Se ho più di uno split, elimino l'ultimo + if (AreaList.Count > 2) + { + int nAreaList = AreaList.Count - 1; + for (var SplitIndex = (m_SplitVertList.Count * nHoriz); SplitIndex <= nAreaList; SplitIndex++) + { + AreaList.Remove(AreaList[AreaList.Count - 1]); + } + } + // Se elimino l'unico split presente + else + { + Splitted s = (Splitted)AreaList[0]; + s.SetParentArea(ParentArea); + ParentArea.AreaList.Add(s); + ParentArea.AreaList.Remove(this); } } - // Se elimino l'unico split presente - else + if(SplitHorizList.Count > 0) { - Splitted s = (Splitted)AreaList[0]; - s.SetParentArea(ParentArea); - ParentArea.AreaList.Add(s); - ParentArea.AreaList.Remove(this); + for (int i = 0; i < AreaList.Count; i++) + { + if(i < SplitHorizList.Count) + AreaList.ElementAt(i).SearchAreaList(AreaList.ElementAt(i), SplitHorizList.ElementAt(i).dDimension, "Width"); + } + } + if (SplitVertList.Count > 0) + { + for (int i = 0; i < AreaList.Count; i++) + { + if(i < SplitVertList.Count) + AreaList.ElementAt(i).SearchAreaList(AreaList.ElementAt(i), SplitVertList.ElementAt(i).dDimension, "Height"); + } } } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -222,15 +256,13 @@ namespace WebWindowTest.Models { get { - //return IdNameStruct.IndFromId((int)m_SelSplitShape, m_SplitShapeList); return (int)m_SelSplitShape; } set { - //m_SelSplitShape = (SplitShapes)IdNameStruct.IdFromInd(value, m_SplitShapeList); + SplitShapes OldSelShapeSplit = m_SelSplitShape; m_SelSplitShape = (SplitShapes)value; - // Cancello elementi nello split e azzero quantità orizzontale e verticale - AreaList.Clear(); + // Azzero quantità orizzontale e verticale SetSplitQtyVert(0); SetSplitQtyHoriz(0); if (m_SelSplitShape == SplitShapes.VERTICAL) @@ -252,17 +284,21 @@ namespace WebWindowTest.Models SetSplitQtyHoriz(1); SetSplitStartVert(true); } - // Aggiungo area Splitted e vetro - int nVert = m_SplitVertList.Count > 0 ? m_SplitVertList.Count : 1; - int nHoriz = m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count : 1; - for (var SplitIndex = 0; SplitIndex <= (nVert * nHoriz) - 1; SplitIndex++) + if(OldSelShapeSplit == SplitShapes.GRID || m_SelSplitShape == SplitShapes.GRID) { - AreaList.Add(Splitted.CreateSplitted(this)); - Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); - newFill.SetAreaType(AreaTypes.FILL); - AreaList[SplitIndex].AreaList.Add(newFill); + // Cancello vecchio contenuto dello split + AreaList.Clear(); + // Aggiungo area Splitted e vetro + int nVert = m_SplitVertList.Count > 0 ? m_SplitVertList.Count : 1; + int nHoriz = m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count : 1; + for (var SplitIndex = 0; SplitIndex <= (nVert * nHoriz) - 1; SplitIndex++) + { + AreaList.Add(Splitted.CreateSplitted(this)); + Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + AreaList[SplitIndex].AreaList.Add(newFill); + } } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -320,12 +356,16 @@ namespace WebWindowTest.Models AddCounterGroup(); newSplit.SetGroupId(nCounterGroup); newSplit.SetSplitStartVert(bSplitStartVert); - newSplit.SetSplitQtyVert(nSplitQtyVert); for (int i = 0; i < SplitVertList.Count; i++) - newSplit.SplitVertList.ElementAt(i).SetDimension(SplitVertList.ElementAt(i).dDimension); - newSplit.SetSplitQtyHoriz(nSplitQtyHoriz); + newSplit.SplitVertList.Add(SplitVertList[i].Copy()); for (int i = 0; i < SplitHorizList.Count; i++) - newSplit.SplitHorizList.ElementAt(i).SetDimension(SplitHorizList.ElementAt(i).dDimension); + newSplit.SplitHorizList.Add(SplitHorizList[i].Copy()); + //newSplit.SetSplitQtyVert(nSplitQtyVert); + //for (int i = 0; i < SplitVertList.Count; i++) + // newSplit.SplitVertList.ElementAt(i).SetDimension(SplitVertList.ElementAt(i).dDimension); + //newSplit.SetSplitQtyHoriz(nSplitQtyHoriz); + //for (int i = 0; i < SplitHorizList.Count; i++) + // newSplit.SplitHorizList.ElementAt(i).SetDimension(SplitHorizList.ElementAt(i).dDimension); newSplit.SetSplitShape(SelSplitShape); newSplit.SetAreaType(AreaType); foreach (var item in AreaList) @@ -342,7 +382,7 @@ namespace WebWindowTest.Models Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); newFill.SetAreaType(AreaTypes.FILL); ParentArea.AreaList.Add(newFill); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + //m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } #endregion Public Methods @@ -405,7 +445,7 @@ namespace WebWindowTest.Models dNewDimension = dLastDimension / (QtyHoriz + 1 - nSplitQtyHoriz); // aggiungo area Split di default for (var SplitIndex = m_SplitHorizList.Count; SplitIndex <= QtyHoriz; SplitIndex++) - m_SplitHorizList.Add(new SplitDimension(dNewDimension, true, this, false)); + m_SplitHorizList.Add(new SplitDimension(dNewDimension, MeasureTypes.PERCENTAGE, true, this, false)); } else if (QtyHoriz < m_SplitHorizList.Count) { @@ -431,7 +471,7 @@ namespace WebWindowTest.Models dNewDimension = dLastDimension / (QtyVert + 1 - nSplitQtyVert); // aggiungo area Split di default for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= QtyVert; SplitIndex++) - m_SplitVertList.Add(new SplitDimension(dNewDimension, true, this, true)); + m_SplitVertList.Add(new SplitDimension(dNewDimension, MeasureTypes.PERCENTAGE, true, this, true)); } else if (QtyVert < m_SplitVertList.Count) { @@ -450,6 +490,31 @@ namespace WebWindowTest.Models m_bSplitStartVert = SplitStartVert; } + internal double HeightFrame() + { + switch (ParentWindow.AreaList.First().SelShapeIndex) + { + case (int)Shapes.RECTANGLE: + case (int)Shapes.TRIANGLE: + case (int)Shapes.ARC_FULL: + { + return ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Height").First().dDimension; + } + case (int)Shapes.RIGHTCHAMFER: + { + return ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Left Height").First().dDimension; + } + case (int)Shapes.LEFTCHAMFER: + { + return ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Right Height").First().dDimension; + } + default: + { + return ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Full Height").First().dDimension; + } + } + } + #endregion Internal Methods #region Private Fields @@ -472,6 +537,8 @@ namespace WebWindowTest.Models private List m_SplitVertList = new List(); + //private double m_Width = 0; + #endregion Private Fields } } \ No newline at end of file diff --git a/WebWindowTest/Models/SplitDimension.cs b/WebWindowTest/Models/SplitDimension.cs index 7cb4408..a63b055 100644 --- a/WebWindowTest/Models/SplitDimension.cs +++ b/WebWindowTest/Models/SplitDimension.cs @@ -1,17 +1,19 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WebWindowTest.Json; +using static WebWindowTest.Json.WindowConst; namespace WebWindowTest.Models { - public class SplitDimension + public class SplitDimension:AreaDimension { #region Public Constructors - public SplitDimension(double dDimension, bool bIsRelative, Split Parent, bool IsVertList) + public SplitDimension(double dDimension, MeasureTypes MeasureType, bool bIsRelative, Split Parent, bool IsVertList):base(dDimension, MeasureType) { m_dDimension = dDimension; m_bIsRelative = bIsRelative; @@ -39,7 +41,7 @@ namespace WebWindowTest.Models } } - public double dDimension + public override double dDimension { get { @@ -47,79 +49,182 @@ namespace WebWindowTest.Models } set { - // Controllo che il valore inserito sia compreso tra 0 e 100 - if (value > 0 && value < 100) + double dimensionTot = 0; + List dimensions = null; + Frame frame = m_Parent.ParentWindow.AreaList.FirstOrDefault(); + if (bIsVertListDim) { - // se sono in percentuale - if (m_bIsRelative) - { - List RelativeDimList = new List(); - if (bIsVertListDim) - RelativeDimList = m_Parent.SplitVertList.Where(x => x.bIsRelative).ToList(); - else - RelativeDimList = m_Parent.SplitHorizList.Where(x => x.bIsRelative).ToList(); - // verifico se ci sono assoluti - //List RelativeDimList = m_Parent.SplitPositionList.Where(x => x.bIsRelative).ToList(); - if (RelativeDimList.Count > 0) + dimensions = m_Parent.SplitVertList; + dimensionTot = CalculateWidthSplitGroup(frame, frame.DimensionList.Where(x => x.sName == "Width").First().dDimension, new AreaFound(-1, false)).m_Dimension; + } + else + { + dimensions = m_Parent.SplitHorizList; + //dimensionTot = (CalculateHeightSplitGroup(m_Parent, HeightTot(), new AreaFound(-1, false))).m_Dimension; + dimensionTot = (CalculateHeightSplitGroup(frame, frame.HeightFrame(), new AreaFound(-1, false))).m_Dimension; + } + double valMinAbsolute = 100; + double valMaxAbsolute = dimensionTot - valMinAbsolute * (dimensions.Count - 1); + bool valueAccept = false; + switch (MeasureType) + { + case MeasureTypes.ABSOLUTE: { - if (m_Parent.bIsPercentage) + valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false; + break; + } + case MeasureTypes.PROPORTIONAL: + { + valMaxAbsolute = 20; + valueAccept = (value >= 1) ? true : false; + break; + } + case MeasureTypes.PERCENTAGE: + { + valMaxAbsolute = valMaxAbsolute / dimensionTot * 100; + valMinAbsolute = valMinAbsolute / dimensionTot * 100; + valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false; + break; + } + } + if (valueAccept) + { + List absoluteValList = new List(); + AreaDimension ad = new AreaDimension(dDimension, SelMeasureType); + List adList = new List(); + foreach (var it in dimensions) + { + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType)); + } + foreach (var item in dimensions) + { + absoluteValList.Add(item.CalculateAbsoluteValue(adList, dimensionTot)); + } + int nIndex = dimensions.IndexOf(this); + int proportionalCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count; + int percentageCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList().Count; + // Le dimensioni sono solo in proporzionale + if (proportionalCount == absoluteValList.Count) + { + m_dDimension = value; + } + // Le dimensioni sono solo in percentuale + else if (percentageCount == dimensions.Count) + { + if (value < dDimension) + { + // L'anta modificata non è l'ultima + if (nIndex < dimensions.Count - 1) + dimensions[nIndex + 1].SetDimension(dimensions[nIndex + 1].dDimension + (m_dDimension - value)); + else if (dimensions.Count > 1) + dimensions[nIndex - 1].SetDimension(dimensions[nIndex - 1].dDimension + (m_dDimension - value)); + else { - int nIndex = RelativeDimList.IndexOf(this); - if (value < m_dDimension) + m_dDimension = 100; + return; + } + } + else + { + double dRes = value; + // se non ultima anta + if (nIndex < dimensions.Count - 1) + { + for (var nInd = 0; nInd <= nIndex - 1; nInd++) + dRes += dimensions[nInd].dDimension; + dRes = (100 - dRes) / (dimensions.Count - nIndex - 1); + for (var Ind = nIndex + 1; Ind <= dimensions.Count - 1; Ind++) + dimensions[Ind].SetDimension(dRes); + } + // se ultima anta + else if (dimensions.Count > 1) + { + if (dimensions.Count > 2) { - if (nIndex < RelativeDimList.Count - 1) - RelativeDimList[nIndex + 1].SetDimension(RelativeDimList[nIndex + 1].dDimension + (m_dDimension - value)); - else if (RelativeDimList.Count > 1) - RelativeDimList[nIndex - 1].SetDimension(RelativeDimList[nIndex - 1].dDimension + (m_dDimension - value)); - else - { - m_dDimension = 100; - return; - } - } - else - { - double dRes = value; - if (nIndex < RelativeDimList.Count - 1) - { - for (var nInd = 0; nInd <= nIndex - 1; nInd++) - dRes += RelativeDimList[nInd].dDimension; - dRes = (100 - dRes) / (RelativeDimList.Count - nIndex - 1); - if (dRes != 0) - { - for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) - RelativeDimList[Ind].SetDimension(dRes); - } - else - return; - } - else if (RelativeDimList.Count > 1) - { - if (RelativeDimList.Count > 2) - { - for (var Ind = 0; Ind <= nIndex - 2; Ind++) - dRes += RelativeDimList[Ind].dDimension; - } - dRes = (100 - dRes); - if (dRes != 0) - RelativeDimList[nIndex - 1].SetDimension(dRes); - else - return; - } - else - { - m_dDimension = 100; - return; - } + for (var Ind = 0; Ind <= nIndex - 2; Ind++) + dRes += dimensions[Ind].dDimension; } + dRes = (100 - dRes); + dimensions[nIndex - 1].SetDimension(dRes); } else { + m_dDimension = 100; + return; } } + m_dDimension = value; + } + // Le dimensioni sono miste o solo in assoluto + else + { + double valueInAbsolute = 0; + switch (MeasureType) + { + case MeasureTypes.ABSOLUTE: + { + valueInAbsolute = value; + break; + } + case MeasureTypes.PROPORTIONAL: + { + var pesi = value + dimensions + .Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL) && !x.Equals(this)) + .Sum(x => x.m_dDimension); + valueInAbsolute = dimensionTot / pesi * value; + break; + } + case MeasureTypes.PERCENTAGE: + { + valueInAbsolute = (value / 100) * dimensionTot; + break; + } + } + if (value < dDimension) + { + // L'anta modificata non è l'ultima + if (nIndex < absoluteValList.Count - 1) + { + absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] + (absoluteValList[nIndex] - valueInAbsolute); + absoluteValList[nIndex] = valueInAbsolute; + } + // L'anta modificata è l'ultima + else if (dimensions.Count > 1) + { + absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] + (absoluteValList[nIndex] - valueInAbsolute); + absoluteValList[nIndex] = valueInAbsolute; + } + } + else + { + // L'anta modificata non è l'ultima + if (nIndex < absoluteValList.Count - 1) + { + absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] - (valueInAbsolute - absoluteValList[nIndex]); + absoluteValList[nIndex] = valueInAbsolute; + } + // L'anta modificata è l'ultima + else if (dimensions.Count > 1) + { + absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] - (valueInAbsolute - absoluteValList[nIndex]); + absoluteValList[nIndex] = valueInAbsolute; + } + } + if (MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + m_dDimension = value; + for (int i = 0; i < absoluteValList.Count; i++) + { + var item = dimensions.ElementAt(i); + item.SetDimension(ad.ConvertIn(adList, absoluteValList[i], (MeasureTypes)item.SelMeasureTypeIndex, dimensionTot)); + } + } + for (int i = 0; i < m_Parent.AreaList.Count; i++) + { + if (m_Parent.SplitHorizList.Count > 0 && i < m_Parent.SplitHorizList.Count) + m_Parent.AreaList.ElementAt(i).SearchAreaList(m_Parent.AreaList.ElementAt(i), m_Parent.SplitHorizList.ElementAt(i).dDimension, "Height"); + if (m_Parent.SplitVertList.Count > 0 && i < m_Parent.SplitVertList.Count) + m_Parent.AreaList.ElementAt(i).SearchAreaList(m_Parent.AreaList.ElementAt(i), m_Parent.SplitVertList.ElementAt(i).dDimension, "Width"); } - m_dDimension = value; - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); } } } @@ -136,13 +241,128 @@ namespace WebWindowTest.Models } } + //public MeasureTypes MeasureType + //{ + // get + // { + // return m_SelMeasureType; + // } + //} + + //public List MeasureTypeList + //{ + // get + // { + // return m_MeasureTypeList; + // } + //} + + //public MeasureTypes SelMeasureType + //{ + // get + // { + // return m_SelMeasureType; + // } + // set + // { + // m_SelMeasureType = value; + // } + //} + + public override int SelMeasureTypeIndex + { + get + { + return (int)m_SelMeasureType; + } + set + { + if (m_SelMeasureType != (MeasureTypes)value) + { + MeasureTypes newType = (MeasureTypes)value; + List splitList = null; + Frame frame = m_Parent.ParentWindow.AreaList.FirstOrDefault(); + double tot = 0; + if (bIsVertListDim) + { + splitList = m_Parent.SplitVertList; + tot = CalculateWidthSplitGroup(frame, frame.DimensionList.Where(x => x.sName == "Width").First().dDimension, new AreaFound(-1, false)).m_Dimension; + } + else + { + splitList = m_Parent.SplitHorizList; + tot = (CalculateHeightSplitGroup(frame, frame.HeightFrame(), new AreaFound(-1, false))).m_Dimension; + } + AreaDimension ad = new AreaDimension(dDimension, SelMeasureType); + List adList = new List(); + foreach (var it in splitList) + { + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType)); + } + m_dDimension = ad.ConvertDimension(adList, m_SelMeasureType, newType, tot, splitList.IndexOf(this)); + m_SelMeasureType = (MeasureTypes)value; + } + } + } + #endregion Public Properties #region Public Methods + ///// + ///// Metodo per convertire la dimensione dal vecchio tipo al nuovo tipo + ///// + ///// Vecchio tipo + ///// Nuovo tipo + ///// + //public double ConvertDimension(MeasureTypes oldType, MeasureTypes newType, double widthTot, List splitList) + //{ + // switch (oldType) + // { + // case MeasureTypes.ABSOLUTE: + // { + // if (newType.Equals(MeasureTypes.PERCENTAGE)) + // { + // //return Double.Round((m_dDimension / m_Parent.Width) * 100, 1); + // return (m_dDimension / widthTot) * 100; + // } + // else + // { + // return CalculatePropVal(widthTot, splitList); + // } + // } + // case MeasureTypes.PROPORTIONAL: + // { + // if (newType.Equals(MeasureTypes.ABSOLUTE)) + // { + // //return Double.Round(ConvertFromPropVal(newType), 2); + // return ConvertFromPropVal(newType, widthTot, splitList); + // } + // else + // { + // //return Double.Round(ConvertFromPropVal(newType), 1); + // return ConvertFromPropVal(newType, widthTot, splitList); + // } + // } + // case MeasureTypes.PERCENTAGE: + // { + // if (newType.Equals(MeasureTypes.ABSOLUTE)) + // { + // //return Double.Round((m_dDimension * m_Parent.Width) / 100, 2); + // return (m_dDimension * widthTot) / 100; + // } + // else + // { + // return CalculatePropVal(widthTot, splitList); + // } + // } + // } + // return -1; + //} + public SplitDimension Copy() { - SplitDimension newSplitDim = new SplitDimension(dDimension, bIsRelative, m_Parent, bIsVertListDim); + SplitDimension newSplitDim = new SplitDimension(dDimension, MeasureType, bIsRelative, m_Parent, bIsVertListDim); return newSplitDim; } @@ -150,16 +370,356 @@ namespace WebWindowTest.Models #region Internal Methods + /// + /// Metodo per calcolare larghezza intero split group + /// + /// area di partenza + /// larghezza di partenza + /// area di ritorno + /// + internal AreaFound CalculateWidthSplitGroup(Area area, double width, AreaFound res) + { + for (int i = 0; i < area.AreaList.Count; i++) + { + if (area.Equals(m_Parent)) + { + res.m_Dimension = width; + res.m_Found = true; + return res; + } + Area item = area.AreaList[i]; + if (area is Split) + { + Split split = (Split)area; + if(split.SplitVertList.Count > 0) + { + int index = i; + if (split.SelSplitShape is SplitShapes.GRID) + index = i % split.SplitHorizList.Count; + switch (split.SplitVertList.ElementAt(index).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + res = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(index).dDimension, res); + break; + } + case MeasureTypes.PROPORTIONAL: + { + AreaDimension ad = new AreaDimension(split.SplitVertList.ElementAt(index).dDimension, split.SplitVertList.ElementAt(index).SelMeasureType); + List adList = new List(); + foreach (var it in split.SplitVertList) + { + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType)); + } + res = CalculateWidthSplitGroup(item, ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, width), res); + break; + } + case MeasureTypes.PERCENTAGE: + { + res = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(index).dDimension * width / 100, res); + break; + } + } + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + else + { + res = CalculateWidthSplitGroup(item, width, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + } + else if (area is Sash) + { + Sash sash = (Sash)area; + switch (sash.SashList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + res = CalculateWidthSplitGroup(item, sash.SashList.ElementAt(i).dDimension, res); + break; + } + case MeasureTypes.PROPORTIONAL: + { + AreaDimension ad = new AreaDimension(sash.SashList.ElementAt(i).dDimension, sash.SashList.ElementAt(i).SelMeasureType); + List adList = new List(); + foreach (var it in sash.SashList) + { + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType)); + } + res = CalculateWidthSplitGroup(item, ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, width), res); + break; + } + case MeasureTypes.PERCENTAGE: + { + res = CalculateWidthSplitGroup(item, sash.SashList.ElementAt(i).dDimension * width / 100, res); + break; + } + } + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + else + { + res = CalculateWidthSplitGroup(item, width, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + } + return res; + } + + /// + /// Metodo per calcolare altezza intero split group + /// + /// area di partenza + /// altezza di partenza + /// area di ritorno + /// + internal AreaFound CalculateHeightSplitGroup(Area area, double height, AreaFound res) + { + for (int i = 0; i < area.AreaList.Count; i++) + { + if (area.Equals(m_Parent)) + { + res.m_Dimension = height; + res.m_Found = true; + return res; + } + Area item = area.AreaList[i]; + if (area is Split) + { + Split split = (Split)area; + if (split.SplitHorizList.Count > 0) + { + int index = i; + if (split.SelSplitShape is SplitShapes.GRID) + index = i % split.SplitHorizList.Count; + switch (split.SplitHorizList.ElementAt(index).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + double heightItemGroup = split.SplitHorizList.ElementAt(index).dDimension; + res = CalculateHeightSplitGroup(item, heightItemGroup, res); + break; + } + case MeasureTypes.PROPORTIONAL: + { + AreaDimension ad = new AreaDimension(split.SplitHorizList.ElementAt(index).dDimension, split.SplitHorizList.ElementAt(index).SelMeasureType); + List adList = new List(); + foreach (var it in split.SplitHorizList) + { + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType)); + } + double heightItemGroup = ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, height); + res = CalculateHeightSplitGroup(item, heightItemGroup, res); + break; + } + case MeasureTypes.PERCENTAGE: + { + double heightItemGroup = split.SplitHorizList.ElementAt(index).dDimension * height / 100; + res = CalculateHeightSplitGroup(item, heightItemGroup, res); + break; + } + } + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + else + { + res = CalculateHeightSplitGroup(item, height, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + } + else + { + res = CalculateHeightSplitGroup(item, height, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + } + return res; + } + + ///// + ///// Calcolo MCD + ///// + ///// + ///// + ///// + //internal static double CalculateMCD(double a, double b) + //{ + // while (b >= 0.01) + // { + // double temp = b; + // b = a % b; + // a = temp; + // } + // //return Double.Round(a,2); + // return a; + //} + + ///// + ///// Metodo per ricalcolare i valori proporzionali a causa della modifica di uno + ///// + ///// + //internal double CalculatePropVal(double widthTot, List splitList) + //{ + // if (splitList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0) + // { + // return 1; + // } + // List absoluteValue = new List(); + // foreach (var item in splitList) + // { + // absoluteValue.Add(item.CalculateAbsoluteValue(widthTot, splitList)); + // } + // for (int i = 0; i < splitList.Count; i++) + // { + // if (!splitList.ElementAt(i).Equals(this) && + // splitList.ElementAt(i).MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + // { + // int nIndex = splitList.IndexOf(this); + // if (absoluteValue.ElementAt(nIndex) <= absoluteValue.ElementAt(i)) + // { + // var mcd = CalculateMCD(absoluteValue.ElementAt(nIndex), absoluteValue.ElementAt(i)); + // splitList.ElementAt(i).m_dDimension = absoluteValue.ElementAt(i) / mcd; + // m_dDimension = absoluteValue.ElementAt(nIndex) / mcd; + // } + // else + // { + // var mcd = CalculateMCD(absoluteValue.ElementAt(nIndex), absoluteValue.ElementAt(i)); + // splitList.ElementAt(i).m_dDimension = absoluteValue.ElementAt(i) / mcd; + // m_dDimension = absoluteValue.ElementAt(nIndex) / mcd; + // } + // break; + // } + // } + // return m_dDimension; + //} + + ///// + ///// Metodo per trasformare una dimensione in valore assoluto rispetto alla larghezza totale + ///// + ///// Larghezza totale + ///// + //internal double CalculateAbsoluteValue(double widthTot, List splitList) + //{ + // switch (MeasureType) + // { + // case MeasureTypes.ABSOLUTE: + // { + // //return Double.Round(dDimension, 2); + // return dDimension; + // } + // case MeasureTypes.PROPORTIONAL: + // { + // //return Double.Round(Proportional2AbsolutVal(), 2); + // return Proportional2AbsoluteVal(widthTot, splitList); + // } + // case MeasureTypes.PERCENTAGE: + // { + // //return Double.Round((dDimension / 100) * widthTot, 1); + // return (dDimension / 100) * widthTot; + // } + // } + // return 0; + //} + + ///// + ///// Metodo per convertire una dimensione da un valore assoluto al suo rispettivo tipo + ///// + ///// Valore assoluto + ///// Tipo di misura della dimensione + ///// Larghezza totale + ///// + //internal double ConvertIn(double absoluteVal, MeasureTypes type, double widthTot, List splitList) + //{ + // switch (type) + // { + // case MeasureTypes.ABSOLUTE: + // { + // return absoluteVal; + // } + // case MeasureTypes.PROPORTIONAL: + // { + // return Proportional2AbsoluteVal(widthTot, splitList); + // } + // case MeasureTypes.PERCENTAGE: + // { + // return (absoluteVal / widthTot) * 100; + // } + // } + // return -1; + //} + + ///// + ///// Metodo per convertire da misura proporzionale a misura assoluta o percentuale + ///// + ///// + ///// + //internal double ConvertFromPropVal(MeasureTypes newType, double widthTot, List splitList) + //{ + // double tot = widthTot; + // //Somma misura non proporzionali + // double sumNotProp = splitList + // .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL && !m.Equals(this)) + // .Sum(m => m.CalculateAbsoluteValue(tot, splitList)); + // //Calcolo residuo + // double res = tot - sumNotProp; + // if (res < 0) res = 0; + // //Misure proporzionali + // var proportionalList = splitList + // .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + // .ToList(); + + // double sumPesi = proportionalList.Sum(p => p.dDimension); + // if (sumPesi == 0) sumPesi = 1; + // if (newType.Equals(MeasureTypes.ABSOLUTE)) + // { + // return res / sumPesi * dDimension; + // } + // else + // { + // return (res / sumPesi * dDimension) / tot * 100; + // } + //} + + ///// + ///// Metodo per trasformare il valore proporzionale in assoluto + ///// + ///// + //internal double Proportional2AbsoluteVal(double widthTot, List splitList) + //{ + // double tot = widthTot; + // //Somma misura non proporzionali + // double sumNotProp = splitList + // .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL) + // .Sum(m => m.CalculateAbsoluteValue(tot, splitList)); + // //Calcolo residuo + // double res = tot - sumNotProp; + // if (res < 0) res = 0; + // //Misure proporzionali + // var proportionalList = splitList + // .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + // .ToList(); + // double sumPesi = proportionalList.Sum(p => p.dDimension); + // if (sumPesi == 0) sumPesi = 1; + // return res / sumPesi * dDimension; + //} + internal JsonSplitDimension Serialize() { - JsonSplitDimension JsonSplitDimension = new JsonSplitDimension(m_bIsRelative, m_dDimension); + JsonSplitDimension JsonSplitDimension = new JsonSplitDimension(m_bIsRelative, m_dDimension, MeasureType); return JsonSplitDimension; } - internal void SetDimension(double dValue) - { - m_dDimension = dValue; - } + //internal void SetDimension(double dValue) + //{ + // m_dDimension = dValue; + //} internal void SetIsRelative(bool value) { @@ -171,6 +731,58 @@ namespace WebWindowTest.Models m_bIsVertListDim = value; } + internal void SetMeasureType(MeasureTypes value) + { + m_SelMeasureType = value; + } + + internal void SetSelMeasureType(MeasureTypes value) + { + if (m_SelMeasureType != (MeasureTypes)value) + { + MeasureTypes newType = (MeasureTypes)value; + Frame frame = m_Parent.ParentWindow.AreaList.FirstOrDefault(); + double dimSplitGroup = 0; + if (bIsVertListDim) + { + dimSplitGroup = (CalculateWidthSplitGroup(frame, frame.DimensionList.Where(x => x.sName == "Width").First().dDimension, new AreaFound(-1, false))).m_Dimension; + AreaDimension ad = new AreaDimension(dDimension, SelMeasureType); + List newDimensions = new List(); + foreach (var item in m_Parent.SplitVertList) + { + newDimensions.Add(new AreaDimension(item.dDimension, item.SelMeasureType)); + } + m_dDimension = ad.ConvertDimension(newDimensions, m_SelMeasureType, newType, dimSplitGroup, m_Parent.SplitVertList.IndexOf(this)); + if (newType is MeasureTypes.PROPORTIONAL) + { + for (int i = 0; i < m_Parent.SplitVertList.Count; i++) + { + m_Parent.SplitVertList.ElementAt(i).SetDimension(newDimensions.ElementAt(i).dDimension); + } + } } + else + { + //tot = (CalculateHeightSplitGroup(m_Parent, HeightTot(), new AreaFound(-1, false))).m_Dimension; + dimSplitGroup = (CalculateHeightSplitGroup(frame, frame.HeightFrame(), new AreaFound(-1, false))).m_Dimension; + AreaDimension ad = new AreaDimension(dDimension, SelMeasureType); + List newDimensions = new List(); + foreach (var item in m_Parent.SplitHorizList) + { + newDimensions.Add(new AreaDimension(item.dDimension, item.SelMeasureType)); + } + m_dDimension = ad.ConvertDimension(newDimensions, m_SelMeasureType, newType, dimSplitGroup, m_Parent.SplitHorizList.IndexOf(this)); + if(newType is MeasureTypes.PROPORTIONAL) + { + for(int i = 0; i < m_Parent.SplitHorizList.Count; i++) + { + m_Parent.SplitHorizList.ElementAt(i).SetDimension(newDimensions.ElementAt(i).dDimension); + } + } + } + m_SelMeasureType = (MeasureTypes)value; + } + } + #endregion Internal Methods #region Private Fields @@ -179,11 +791,32 @@ namespace WebWindowTest.Models private bool m_bIsVertListDim = false; - private double m_dDimension; + //private double m_dDimension; + + //private List m_MeasureTypeList = new List + //{ + // new IdNameStruct((int)MeasureTypes.ABSOLUTE, "Absolute"), + // new IdNameStruct((int)MeasureTypes.PROPORTIONAL, "Proportional"), + // new IdNameStruct((int)MeasureTypes.PERCENTAGE, "Percentage"), + //}; + + //private MeasureTypes m_SelMeasureType; // reference private Split m_Parent; #endregion Private Fields } + + public class AreaFound + { + public AreaFound(double dimension, bool found) + { + m_Dimension = dimension; + m_Found = found; + } + + public double m_Dimension { get; set; } = -1; + public bool m_Found { get; set; } = false; + } } \ No newline at end of file diff --git a/WebWindowTest/Models/Window.cs b/WebWindowTest/Models/Window.cs index 71d9f9f..900e3f3 100644 --- a/WebWindowTest/Models/Window.cs +++ b/WebWindowTest/Models/Window.cs @@ -11,7 +11,7 @@ using System.Xml.Linq; using System.Xml.Serialization; using WebWindowTest.Json; using static WebWindowTest.Json.WindowConst; -using static WebWindowTest.ParametriOpzioni; +using static WebWindowTest.Models.ParametriOpzioni; namespace WebWindowTest.Models { @@ -19,9 +19,9 @@ namespace WebWindowTest.Models { #region Public Events - public event EventHandler OnPreview = delegate { }; - public event EventHandler OnReqShape = delegate { }; - public event EventHandler OnReqHwOption = delegate { }; + //public event EventHandler OnPreview = delegate { }; + //public event EventHandler OnReqShape = delegate { }; + //public event EventHandler OnReqHwOption = delegate { }; #endregion Public Events @@ -48,7 +48,6 @@ namespace WebWindowTest.Models set { m_sColorMaterial = value; - OnUpdatePreview(sSerialized()); } } @@ -61,7 +60,6 @@ namespace WebWindowTest.Models set { m_sGlass = value; - OnUpdatePreview(sSerialized()); } } @@ -74,7 +72,6 @@ namespace WebWindowTest.Models set { m_sMaterial = value; - OnUpdatePreview(sSerialized()); } } @@ -87,7 +84,6 @@ namespace WebWindowTest.Models set { m_sProfilePath = value; - OnUpdatePreview(sSerialized()); } } @@ -95,35 +91,35 @@ namespace WebWindowTest.Models #region Internal Methods - internal void OnUpdatePreview(string sJwd) - { - OnPreviewEventArgs e = new OnPreviewEventArgs(sJwd); - EventHandler handler = OnPreview; - if (handler != null) - { - handler(this, e); - } - } + //internal void OnUpdatePreview(string sJwd) + //{ + // OnPreviewEventArgs e = new OnPreviewEventArgs(sJwd); + // EventHandler handler = OnPreview; + // if (handler != null) + // { + // handler(this, e); + // } + //} - internal void OnReqShapePreview(string sJwd, int groupId) - { - OnReqShapeEventArgs e = new OnReqShapeEventArgs(sJwd, groupId); - EventHandler handler = OnReqShape; - if (handler != null) - { - handler(this, e); - } - } + //internal void OnReqShapePreview(string sJwd, int groupId) + //{ + // OnReqShapeEventArgs e = new OnReqShapeEventArgs(sJwd, groupId); + // EventHandler handler = OnReqShape; + // if (handler != null) + // { + // handler(this, e); + // } + //} - internal void OnReqHwOptionPreview(string sJwd, int groupId) - { - OnReqHwOptEventArgs e = new OnReqHwOptEventArgs(sJwd, groupId); - EventHandler handler = OnReqHwOption; - if (handler != null) - { - handler(this, e); - } - } + //internal void OnReqHwOptionPreview(string sJwd, int groupId) + //{ + // OnReqHwOptEventArgs e = new OnReqHwOptEventArgs(sJwd, groupId); + // EventHandler handler = OnReqHwOption; + // if (handler != null) + // { + // handler(this, e); + // } + //} /// /// Serializzazione dell'oggetto windows diff --git a/WebWindowTest/SerialMan.cs b/WebWindowTest/SerialMan.cs deleted file mode 100644 index a3f01f7..0000000 --- a/WebWindowTest/SerialMan.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Egw.Window.Data; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using WebWindowTest.Json; -using WebWindowTest.Models; -using static WebWindowTest.Json.WindowConst; - -namespace WebWindowTest -{ - public class SerialMan - { - /// - /// Riceve un JWD in ingresso e effettua una sostituzione dei parametri rieschiesti (SE non nulli) - /// - /// - /// - /// - /// - /// Valore serializzato con le modifiche richieste - public static string MassUpdate(string currSer, string? newFamilyHardware, Hardware? newHardware, string? newColorMaterial, string? newMaterial, string? newGlass, string? newProfile) - { - string outVal = currSer; - // serializzazione JWD --> window - JsonWindow WindowFromJson = JsonConvert.DeserializeObject(currSer, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); - Window currWindow = WindowFromJson.Deserialize(); - // verifica 1:1 delle richieste - if (!string.IsNullOrEmpty(newFamilyHardware)) - { - SearchSash(currWindow.AreaList.First(), newFamilyHardware, null); - } - if (newHardware != null) - { - SearchSash(currWindow.AreaList.First(), null, newHardware); - } - if (!string.IsNullOrEmpty(newColorMaterial)) - { - currWindow.sColorMaterial = newColorMaterial; - } - if (!string.IsNullOrEmpty(newMaterial)) - { - currWindow.sMaterial = newMaterial; - } - if (!string.IsNullOrEmpty(newGlass)) - { - currWindow.sGlass = newGlass; - } - if (!string.IsNullOrEmpty(newProfile)) - { - currWindow.sProfilePath = newProfile; - } - var CurrJwd = JsonConvert.SerializeObject(currWindow.Serialize(), Formatting.Indented); - return CurrJwd; - - - } - - internal static void SearchSash(Area currentArea, string? newFamilyHw, Hardware? newHardware) - { - if (currentArea.AreaType.Equals(AreaTypes.SASH)) - { - Sash s = (Sash)currentArea; - if (!string.IsNullOrEmpty(newFamilyHw)) - { - s.SelFamilyHardware = newFamilyHw; - } - if (newHardware != null) - { - s.SelHardware = newHardware; - } - } - foreach (Area child in currentArea.AreaList) - { - SearchSash(child, newFamilyHw, newHardware); - } - } - } -} diff --git a/WebWindowTest/Template.cs b/WebWindowTest/Template.cs deleted file mode 100644 index 55b6472..0000000 --- a/WebWindowTest/Template.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace WebWindowTest -{ - public class Template - { - private int m_nIndex; - public int nIndex - { - get - { - return m_nIndex; - } - } - - public string sDescription { get; set; } = ""; - - private string m_JWD; - public string JWD - { - get - { - return m_JWD; - } - } - - private string m_SVG; - public string SVG - { - get - { - return m_SVG; - } - } - - public Template(int nIndex, string sDescription, string SVG, string JWD) - { - m_nIndex = nIndex; - this.sDescription = sDescription; - m_SVG = SVG; - m_JWD = JWD; - } - } -} diff --git a/WebWindowTest/Test.razor b/WebWindowTest/Test.razor index 4570016..6a1e6bc 100644 --- a/WebWindowTest/Test.razor +++ b/WebWindowTest/Test.razor @@ -21,103 +21,40 @@
} - else if (listErrLink != null && listErrLink.Count > 0) - { -
-
Errore configurazione:
-
-
    - @foreach (var item in listErrLink) - { -
  • @item.Value
  • - } -
-
-
- } else { -
+
-
-
+
+
-
-
- @if (currStep != CompileStep.Template) - { - - } +
+
+
-
+
-
+
- @if (string.IsNullOrEmpty(LiveData.CurrJwd)) - { - @if (currStep == CompileStep.Template && ListPayload.TemplateDTO != null) - { - - - - - - - - - - @foreach (var item in ListPayload.TemplateDTO) - { - string colorClass = ""; - @if (SelTemplateDTO != null && item.Index == SelTemplateDTO.Index) - colorClass = "table-success"; - else - colorClass = ""; - - - - - - } - -
#ImageDescription
@item.Index@item.Description
- } - } @if (currStep == CompileStep.Tree) { - } @@ -127,103 +64,118 @@ { m_PreviousWindow = m_CurrWindow; } - - + + + + + + + + } else if (currStep == CompileStep.Split) { - @if (currSplit >= SplitList.Count || currSplit == -1) + @if (currSplitIndex >= SplitList.Count || currSplitIndex == -1) { currStep = CompileStep.Tree; } else { - } } else if (currStep == CompileStep.Sash) { - @if (currSash >= SashList.Count || currSash == -1) + @if (currSashIndex >= SashList.Count || currSashIndex == -1) { currStep = CompileStep.Tree; } else { - - + + + + + + + + } } else if (currStep == CompileStep.Fill) { - @if (currFill >= FillList.Count || currFill == -1) + @if (currFillIndex >= FillList.Count || currFillIndex == -1) { currStep = CompileStep.Tree; } else { - +
+
+
+
+
All fill
+
+
+ +
+
+ +
+
+
+
+ @if (SplittedList != null && SplittedList.Count > 0) + { + Splitted currSplitted = SplittedList.Where(x => x.AreaList.First().Equals(FillList[currFillIndex])).FirstOrDefault() ?? new Splitted(null, null); + @if (currSplitted.ParentArea != null && currSplitted.ParentWindow != null) + { + + + } + } } } else if (currStep == CompileStep.General) { - }
- @if (currStep != CompileStep.Template) - { -
- @outSvg -
- } +
+ @outSvg +
if (listWarnings != null && listWarnings.Count > 0) {
diff --git a/WebWindowTest/Test.razor.cs b/WebWindowTest/Test.razor.cs index b200e64..39a7131 100644 --- a/WebWindowTest/Test.razor.cs +++ b/WebWindowTest/Test.razor.cs @@ -1,13 +1,14 @@ using Egw.Window.Data; using Microsoft.AspNetCore.Components; using Newtonsoft.Json; -using System.Reflection.Metadata; +using System.Threading.Tasks; using WebWindowTest.Compo; using WebWindowTest.DTO; using WebWindowTest.Json; using WebWindowTest.Models; -using static WebWindowTest.LayoutConst; +using WebWindowTest; using static WebWindowTest.Json.WindowConst; +using static WebWindowTest.LayoutConst; namespace WebWindowTest { @@ -15,33 +16,23 @@ namespace WebWindowTest { #region Public Enums - public enum DataAction - { - /// - /// Nessuna richiesta - /// - None = 0, - - /// - /// Reset dizionario shape - /// - ResetDictShape - } - public enum DataReq { /// /// Nessuna richiesta /// None = 0, + /// /// Richiesta hardware opzioni /// ReqHwOpt, + /// /// Richiesta svg /// ReqSvg, + /// /// Richiesta shape sash group /// @@ -84,12 +75,6 @@ namespace WebWindowTest [Parameter] public EventCallback EC_OnClose { get; set; } - /// - /// Evento selezione template - /// - [Parameter] - public EventCallback EC_OnSelectedTemplate { get; set; } - /// /// Sollevo evento errore validazione con una lista di errori rilevati /// @@ -116,9 +101,6 @@ namespace WebWindowTest { if (m_CurrWindow != null) { - m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; - m_CurrWindow.OnReqHwOption -= M_CurrWindow_OnHwOption; - m_CurrWindow.OnReqShape -= M_CurrWindow_OnShape; m_CurrWindow = null; } } @@ -127,6 +109,8 @@ namespace WebWindowTest #region Protected Fields + protected List currLoading = new List(); + /// /// Dati live precedenti x comparazione /// @@ -170,12 +154,16 @@ namespace WebWindowTest get => m_SashList; } + protected List SplittedList + { + get => m_SplittedList; + } + protected string SelColorMaterial { get; set; } = ""; protected string SelFamilyHardware { get; set; } = ""; protected string SelGlass { get; set; } = ""; protected string SelMaterial { get; set; } = ""!; protected string SelProfile { get; set; } = ""; - protected TemplateSelectDTO? SelTemplateDTO { get; set; } = null; protected List SplitList { @@ -186,78 +174,6 @@ namespace WebWindowTest #region Protected Methods - /// - /// Metodo per la scelta della maniglia univoca - /// - /// anta su cui si seleziona la maniglia - /// - protected void ChangeHandle(DataChangeHandle Args) - { - SashDimension sashDim = Args.currSashDimension; - Sash currSash = Args.currItem; - // Cerco la Sash che si sta considerando nella lista Sash - var s = SashList.Where(x => x.GroupId == currSash.GroupId).FirstOrDefault(); - if(s != null) - { - // Setto la presenza o meno della maniglia per ogni anta - foreach (SashDimension item in s.SashList) - { - if (item.Equals(sashDim)) - { - item.bHasHandle = true; - } - else - { - if (item.bHasHandle) - { - switch (item.SelOpeningType) - { - case Openings.TILTTURN_LEFT: - { - item.SetOpeningType(Openings.TURNONLY_LEFT); - break; - } - case Openings.TILTTURN_RIGHT: - { - item.SetOpeningType(Openings.TURNONLY_RIGHT); - break; - } - default: - { - break; - } - } - } - item.bHasHandle = false; - } - } - } - // Per ogni anta della Sash setto HasHandle - currSash.RefreshHardwareList(); - currSash.SetFirstHardware(); - _ = DoPreviewSvg(); - } - - /// - /// Metodo per la scelta dello split intero nella modalità griglia - /// - /// split su cui si sceglie - /// - protected async Task changeStartVert(DataChangeStartVert Args) - { - ChangeEventArgs e = Args.eventArg; - Split currSplit = Args.currItem; - // Cerco la Sash che si sta considerando nella lista Sash - foreach (Split s in SplitList) - { - if (s.Equals(currSplit)) - { - s.SetSplitStartVert((bool)e.Value); - } - } - await DoPreviewSvg(); - } - /// /// Metodo per riempire la lista ItemTable in modo da poter rappresentarla come tabella /// @@ -501,7 +417,7 @@ namespace WebWindowTest } /// - /// Richiesta calcolo Options HW da JWD + /// Richiesta calcolo Options HW /// /// Lista degli ID numerici dei gruppi da valutare /// @@ -509,6 +425,7 @@ namespace WebWindowTest { if (m_CurrWindow != null) { + loadListAdd("LoadHwOpt"); #if DEBUG var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented); #else @@ -549,7 +466,7 @@ namespace WebWindowTest //if (!prevLiveData.CurrJwd.Equals(CurrJwd)) { prevJwd = CurrJwd; - prevReq= (int)DataReq.ReqShape; + prevReq = (int)DataReq.ReqShape; Dictionary Args = new Dictionary(); Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}"); Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.SASHSHAPE}"); @@ -580,17 +497,6 @@ namespace WebWindowTest await EC_OnClose.InvokeAsync(true); } - /// - /// Selezione del template - /// - /// template selezionato - protected async void DoSelect(TemplateSelectDTO newSel) - { - editLock = false; - SelTemplateDTO = newSel; - await EC_OnSelectedTemplate.InvokeAsync(newSel); - } - protected override void OnAfterRender(bool firstRender) { isRendered = true; @@ -657,6 +563,39 @@ namespace WebWindowTest catch (Exception ex) { listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}"); + // uso un oggetto "basico" per non fermarmi + //string jwd = "{\r\n \"ProfilePath\": \"Profilo78\",\r\n \"Material\": \"Pino\",\r\n \"ColorMaterial\": \"Black\",\r\n \"Glass\": \"Vetro BE 2S 4T/16/4T\",\r\n \"AreaList\": [\r\n {\r\n \"Shape\": \"RECTANGLE\",\r\n \"DimensionList\": [\r\n {\r\n \"Index\": 1,\r\n \"Name\": \"Width\",\r\n \"Value\": 800.0\r\n },\r\n {\r\n \"Index\": 2,\r\n \"Name\": \"Height\",\r\n \"Value\": 1200.0\r\n }\r\n ],\r\n \"JointList\": [\r\n {\r\n \"Index\": 1,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"Index\": 2,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"Index\": 3,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"Index\": 4,\r\n \"JointType\": \"FULL_H\"\r\n }\r\n ],\r\n \"BottomRail\": false,\r\n \"BottomRailQty\": 0,\r\n \"GroupId\": 1,\r\n \"AreaList\": [\r\n {\r\n \"FillType\": \"GLASS\",\r\n \"GroupId\": 7,\r\n \"AreaList\": [],\r\n \"AreaType\": \"FILL\"\r\n }\r\n ],\r\n \"AreaType\": \"FRAME\"\r\n }\r\n ]\r\n}"; + //WindowFromJson = JsonConvert.DeserializeObject(jwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + //setCurrWindow(WindowFromJson); + //await DoPreviewSvg(true); + Window window = new Window(); + Frame frame = new Frame(null, window); + List DimensionList = new List + { + new FrameDimension(frame, 1, "Width", 800, false), + new FrameDimension(frame, 1, "Height", 1200, true) + }; + List JointList = new List + { + new Joint(frame, 1, Joints.FULL_H), + new Joint(frame, 2, Joints.FULL_H), + new Joint(frame, 3, Joints.FULL_H), + new Joint(frame, 4, Joints.FULL_H) + }; + //FrameArcElement ae = new FrameArcElement(frame, window, 10, true, true); + JsonWindow jsonWindow = new JsonWindow("Profilo78", "Pino", "Black", "Vetro BE 2S 4T/16/4T"); + JsonFrame jsonFrame = new JsonFrame(Shapes.RECTANGLE, null, false, 0, 1); + jsonWindow.AreaList.Add(jsonFrame); + //jsonFrame.ArcElement = ae.Serialize(); + foreach (var Dimension in DimensionList) + jsonFrame.DimensionList.Add(Dimension.Serialize()); + foreach (var Joint in JointList) + jsonFrame.JointList.Add(Joint.Serialize()); + jsonFrame.AreaList.Add(Fill.CreateFill(frame, FillTypes.GLASS).Serialize(true)); + string jwd = JsonConvert.SerializeObject(jsonWindow); + WindowFromJson = JsonConvert.DeserializeObject(jwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + setCurrWindow(WindowFromJson); + await DoPreviewSvg(true); } } else @@ -668,12 +607,12 @@ namespace WebWindowTest checkWarnings(); if (SashList.Count > 0) { - currAnta = 0; + currAntaIndex = 0; } if (updRequested) { // se mancasse dizionario forme chiamo quello - if (LiveData.DictShape.Count == 0) + if (LiveData.DictShape.Count == 0 && listErrLink.Count == 0) { if (firstDisplay && isRendered) { @@ -684,13 +623,21 @@ namespace WebWindowTest List reqList = SashList.Select(x => x.GroupId).ToList(); if (reqList.Count > 0) { + //prevReq = (int)DataReq.ReqShape; await DoReqShape(reqList); } } else { // chiedo SVG - await DoPreviewSvg(true); + //prevReq = (int)DataReq.ReqSvg; + if (prevReq != (int)DataReq.ReqSvg || !prevLiveData.JwdEqual(LiveData.CurrJwd)) + { + if (prevReq != (int)DataReq.ReqHwOpt) + await DoPreviewSvg(true); + else if (LiveData.DictOptionsXml.Count > 0) + await DoPreviewSvg(true); + } } } } @@ -710,22 +657,24 @@ namespace WebWindowTest { if (m_CurrWindow != null) { - m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; - m_CurrWindow.OnReqHwOption -= M_CurrWindow_OnHwOption; - m_CurrWindow.OnReqShape -= M_CurrWindow_OnShape; m_CurrWindow = null; } m_CurrWindow = WindowFromJson.Deserialize(); - m_CurrWindow.OnPreview += M_CurrWindow_OnPreview; - m_CurrWindow.OnReqHwOption += M_CurrWindow_OnHwOption; - m_CurrWindow.OnReqShape += M_CurrWindow_OnShape; - // Recupero dimensioni Frame e Joint del frame della finestra precedente + FrameWindow = m_CurrWindow.AreaList[0]; if (m_PreviousWindow != null) { for (int i = 0; i < 2; i++) - m_CurrWindow.AreaList.First().DimensionList[i] = m_PreviousWindow.AreaList.First().DimensionList[i]; - for (int i = 0; i < 4; i++) - m_CurrWindow.AreaList.First().JointList[i] = m_PreviousWindow.AreaList.First().JointList[i]; + m_CurrWindow.AreaList.First().DimensionList[i].dDimension = m_PreviousWindow.AreaList.First().DimensionList[i].dDimension; + if (m_CurrWindow.AreaList.First().Shape == Shapes.TRIANGLE) + { + for (int i = 0; i < 2; i++) + m_CurrWindow.AreaList.First().JointList[i].SetSelJointType(m_PreviousWindow.AreaList.First().JointList[i].SelJointType); + } + else + { + for (int i = 0; i < 4; i++) + m_CurrWindow.AreaList.First().JointList[i].SetSelJointType(m_PreviousWindow.AreaList.First().JointList[i].SelJointType); + } } if (m_CurrWindow != null) { @@ -733,11 +682,14 @@ namespace WebWindowTest UpdateLists(); } if (SashList.Count > 0) - currAnta = 0; + currAntaIndex = 0; // Aggiorno window con dati shape e hw option UpdateDict(); } + /// + /// Aggiornamento dei dati con informazioni ricevute dai dizionari + /// protected void UpdateDict() { // se ho i dizionari delle forme le aggiungo @@ -746,14 +698,23 @@ namespace WebWindowTest // Inserisco le forme ricevuto nei sash group foreach (var item in LiveData.DictShape) { - Sash sashFromGroupId = SashList.Where(x => x.GroupId == item.Key).First(); + Sash sashFromGroupId = SashList.First(x => x.GroupId == item.Key); sashFromGroupId.SashShape = item.Value; sashFromGroupId.UpdateShape(item.Value); } + if (prevReq == (int)DataReq.ReqShape) + { + if (reqHwOpt > 0) + { + List reqList = SashList.Select(x => x.GroupId).ToList(); + _ = DoReqOptHardware(reqList); + } + } } // se ho le opzioni hw le aggiungo if (LiveData.DictOptionsXml.Count > 0) { + loadListRem("LoadHwOpt"); foreach (var item in SashList) { if (LiveData.DictOptionsXml.ContainsKey(item.GroupId)) @@ -785,6 +746,7 @@ namespace WebWindowTest /// protected void UpdateSelParameter() { + Frame.m_AllThresholdList = ListPayload.Threshold; Sash.m_HardwareCompleteList = ListPayload.Hardware; Sash.s_FamilyHardwareList = ListPayload.FamilyHardware; if (CurrSelection != null && CurrSelection.IsValid()) @@ -801,12 +763,18 @@ namespace WebWindowTest #region Private Fields - private int currAnta = 0; - private int currFill = -1; - private int currSash = -1; - private int currSplit = -1; + private int currAntaIndex = 0; + + private int currFillIndex = -1; + + private int currSashIndex = -1; + + private int currSplitIndex = -1; + private CompileStep currStep; + private bool editLock = false; + private bool firstDisplay = true; /// @@ -855,10 +823,6 @@ namespace WebWindowTest private Window? m_PreviousWindow { get; set; } = null; - private string m_SelFamilyHardware { get; set; } = ""; - - private Template m_SelTemplate { get; set; } = null!; - /// /// Salvataggio JWD precedente x evitare loop su update (aggiornato dopo chiamate redis) /// @@ -868,51 +832,12 @@ namespace WebWindowTest /// Salvataggio tipo di domanda precedente /// private int prevReq { get; set; } = 0; + private int reqHwOpt { get; set; } = 0; #endregion Private Properties #region Private Methods - /// - /// Metodo per aggiungere una Sash - /// - /// - /// - private void AddSashIntoSplit(DataAreaSplitted Args) - { - Splitted currSplitted = Args.splitted; - currSplitted.AddFirstSash(); - // ricalcolo liste - UpdateLists(); - // richiedo update shape - List reqList = SashList.Select(x => x.GroupId).ToList(); - _ = DoReqShape(reqList); - //_ = DoReqOptHardware(reqList); - } - - /// - /// Metodo per aggiungere una sash di default al Frame - /// - /// - private void AddSashToFrame(Frame f) - { - f.AddFirstSash(); - // ricalcolo liste - UpdateLists(); - // richiedo update shape - List reqList = SashList.Select(x => x.GroupId).ToList(); - _ = DoReqShape(reqList); - } - - /// - /// Metodo per aggiungere uno split di default al Frame - /// - /// - private void AddSplitToFrame(Frame f) - { - f.AddSplit(); - } - /// /// Metodo per andare allo step successivo /// @@ -920,95 +845,9 @@ namespace WebWindowTest private void AdvStep(CompileStep newStep) { currStep = newStep; - currSash = -1; - currFill = -1; - currSplit = -1; - } - - /// - /// Calcola larghezza colonna button nav - /// - /// - private string buttonCss() - { - return (currStep == CompileStep.Template) ? "col-4 d-grid gap-1 d-md-flex justify-content-md-end align-items-center" : "col-4 d-grid gap-1 d-md-flex justify-content-md-end align-items-center"; - } - - /// - /// Calcola bottone selezionato per il Fill - /// - /// - private string buttonFillCss(FillTypes currFillTypes) - { - if (FillList.ElementAt(currFill).SelFillType == currFillTypes) - return "btn btn-secondary btn-sm"; - else - return "btn btn-outline-secondary btn-sm"; - } - - /// - /// Prima chiamata alle opzioni hardware - /// - /// Group Id del sash group di cui si vuole Hw option - /// - private async Task CallFirstHwOpt(int groupId) - { - bool isFirst = true; - List reqList = new List() { groupId }; - await DoReqOptHardware(reqList, isFirst); - } - - /// - /// Metodo per settare tutti i Fill in contemporanea - /// - /// tipo di riempimento (GLASS o WOOD) - /// - private async Task ChangeAllFill(FillTypes type) - { - foreach (Fill currFill in FillList) - { - currFill.SetSelFillType(type); - } - await DoPreviewSvg(); - } - - /// - /// Metodo per settare tutti i Joints di Frame o Sash come ANGLED o FULL_H o FULL_V - /// - /// - /// - private async Task ChangeAllJoints(DataChangeJoints Args) - { - WindowConst.Joints type = Args.currJointType; - Area area = Args.currArea; - if (area is Frame) - { - foreach (Joint joint in FrameWindow.JointList) - { - joint.SetSelJointType(type); - } - } - else - { - Sash a = (Sash)area; - foreach (Joint joint in a.JointList) - { - joint.SetSelJointType(type); - } - } - await DoPreviewSvg(); - } - - /// - /// Metodo per settare tutti i Fill in contemporanea - /// - /// tipo di riempimento (GLASS o WOOD) - /// - private async Task ChangeOneFill(FillTypes type) - { - Fill fillChange = FillList.ElementAt(currFill); - fillChange.SetSelFillType(type); - await DoPreviewSvg(); + currSashIndex = -1; + currFillIndex = -1; + currSplitIndex = -1; } /// @@ -1078,82 +917,27 @@ namespace WebWindowTest } /// - /// Metodo per copiare contenuto di un'anta in un'altra anta + /// Helper aggiunta elemento a lista caricamento /// - /// - private async Task CopyContentSash(DataCopyContentSash Args) + /// + private void loadListAdd(string loadCode) { - Sash sashItem = Args.currItem; - int IndexCopy = Args.indexCopy; - int IndexModify = Args.indexModify; - // Anta selezionata - Area sashSplitted = sashItem.AreaList[IndexModify]; - // Rimuovo riempimento da anta selezionata - sashSplitted.AreaList.RemoveAt(0); - // Creo la copia dell'anta scelta - Area a = sashItem.AreaList[IndexCopy].AreaList.First().Copy(sashSplitted); - // Aggiungo copia all'anta selezionata - sashItem.AreaList[IndexModify].AreaList.Add(a); - await DoPreviewSvg(); + if (!currLoading.Contains(loadCode)) + { + currLoading.Add(loadCode); + } } /// - /// Metodo per copiare una Sash intera + /// Helper rimozione elemento a lista caricamento /// - /// - /// - private async Task CopySash(DataAreaSplit Args) + /// + private void loadListRem(string loadCode) { - Splitted currSplitted = Args.splitted; - int numSash = Args.index; - //Rimuovo contenuto di Splitted e rimuovo area da conteggio gruppi - currSplitted.AreaList.RemoveAll(i => i != null); - //Area.DelCounterGroup(); - // Copio sash - Area a = SashList[numSash].Copy(currSplitted); - a.SetParentArea(currSplitted); - // Aggiungo copia a Splitted - currSplitted.AreaList.Add(a); - await DoPreviewSvg(); - } - - private void M_CurrWindow_OnHwOption(object? sender, OnReqHwOptEventArgs e) - { - Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}"); - Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.HARDWAREOPTIONS}"); - Args.Add("SerializedData", e.sJwd); - string listGroupId = JsonConvert.SerializeObject(new List { e.nGroupId }); - Args.Add("GroupId", listGroupId); - _ = EC_DoUpdate.InvokeAsync(Args); - } - - private void M_CurrWindow_OnPreview(object? sender, OnPreviewEventArgs e) - { - Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.QuestionModes.PREVIEW}"); - Args.Add("SerializedData", e.sJwd); - _ = EC_DoUpdate.InvokeAsync(Args); - } - - private void M_CurrWindow_OnShape(object? sender, OnReqShapeEventArgs e) - { - Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}"); - Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.SASHSHAPE}"); - Args.Add("SerializedData", e.sJwd); - string listGroupId = JsonConvert.SerializeObject(new List { e.groupId }); - Args.Add("GroupId", listGroupId); - _ = EC_DoUpdate.InvokeAsync(Args); - } - - /// - /// Calcola larghezza colonna contenente nav da mostrare - /// - /// - private string mainCss() - { - return (currStep == CompileStep.Template) ? "col-12 d-flex flex-column" : "col-6 d-flex flex-column"; + if (currLoading.Contains(loadCode)) + { + currLoading.Remove(loadCode); + } } /// @@ -1168,23 +952,23 @@ namespace WebWindowTest { case CompileStep.Sash: { - currSash = Index; - currFill = -1; - currSplit = -1; + currSashIndex = Index; + currFillIndex = -1; + currSplitIndex = -1; break; } case CompileStep.Fill: { - currFill = Index; - currSash = -1; - currSplit = -1; + currFillIndex = Index; + currSashIndex = -1; + currSplitIndex = -1; break; } case CompileStep.Split: { - currSplit = Index; - currSash = -1; - currFill = -1; + currSplitIndex = Index; + currSashIndex = -1; + currFillIndex = -1; break; } } @@ -1201,30 +985,13 @@ namespace WebWindowTest NextStep(newStep, Index); } - /// - /// Metodo per eliminare Split o Sash - /// - /// Area corrente - /// - private void RemoveArea(Area currArea) - { - if (currArea is Split) - ((Split)currArea).Remove(); - else if (currArea is Sash) - { - ((Sash)currArea).Remove(); - } - currStep = CompileStep.Tree; - } - /// /// Richiesta reset dizionario Shape con action /// /// - /// - private void ReqResetDict(bool args) + private async Task ReqResetDict(DataUpdateRes args) { - _ = EC_ActionReq.InvokeAsync(DataAction.ResetDictShape); + await EC_ActionReq.InvokeAsync(args.req); } /// @@ -1236,23 +1003,15 @@ namespace WebWindowTest AdvStep(CompileStep.Tree); } - /// - /// Cerca e aggiorna la sash - /// - /// area corrente che si sta valutando - /// id della sash che si sta cercando - /// nuova sash - /// - private Area SearchSash(Area currentArea, int idSearch, Sash newSash) + private Area SearchArea(Area currentArea, int idSearch, Area itemSearch) { - if (currentArea.GroupId == idSearch && currentArea.AreaType.Equals(AreaTypes.SASH)) + if (currentArea.GroupId == idSearch && currentArea.AreaType.Equals(itemSearch.AreaType)) { - currentArea = newSash; return currentArea; } foreach (Area child in currentArea.AreaList) { - Area found = SearchSash(child, idSearch, newSash); + Area found = SearchArea(child, idSearch, itemSearch); if (found != null) { return found; @@ -1262,70 +1021,26 @@ namespace WebWindowTest } /// - /// Selezione del colore + /// Metodo per aggiornare valori della sezione General /// /// - private void SelectColor(string newVal) + private void UpdatePreviewGeneral(DataUpdateGeneral args) { + string Color = args.Color; + string Glass = args.Glass; + string Material = args.Material; + string Profile = args.Profile; if (m_CurrWindow != null) { - m_CurrWindow.sColorMaterial = newVal; - } - } - - /// - /// Selezione del vetro - /// - /// - private void SelectGlass(string newVal) - { - if (m_CurrWindow != null) - { - m_CurrWindow.sGlass = newVal; - } - } - - /// - /// Selezione del materiale - /// - /// - private void SelectMat(string newVal) - { - if (m_CurrWindow != null) - { - m_CurrWindow.sMaterial = newVal; - } - } - - /// - /// Selezione del profilo - /// - /// - private void SelectProfile(string newVal) - { - if (m_CurrWindow != null) - { - m_CurrWindow.sProfilePath = newVal; - } - } - - /// - /// Metodo per scambiare due aree di uno split - /// - /// Area corrente - /// - private async Task SwapTwoAree(Area currArea) - { - currArea.SwapAree(); - await DoPreviewSvg(true, true); - if(currArea is Split) - { - List reqShape = new List(); - if(currArea.AreaList[0].AreaList.Where(x => x.AreaType == AreaTypes.SASH).ToList().Count() > 0) - reqShape.Add(currArea.AreaList[0].AreaList.Where(x => x.AreaType == AreaTypes.SASH).Select(x => x.GroupId).FirstOrDefault()); - if (currArea.AreaList[1].AreaList.Where(x => x.AreaType == AreaTypes.SASH).ToList().Count() > 0) - reqShape.Add(currArea.AreaList[1].AreaList.Where(x => x.AreaType == AreaTypes.SASH).Select(x => x.GroupId).FirstOrDefault()); - await DoReqShape(reqShape); + if (!string.IsNullOrEmpty(Color)) + m_CurrWindow.sColorMaterial = Color; + else if (!string.IsNullOrEmpty(Glass)) + m_CurrWindow.sGlass = Glass; + else if (!string.IsNullOrEmpty(Material)) + m_CurrWindow.sMaterial = Material; + else if (!string.IsNullOrEmpty(Profile)) + m_CurrWindow.sProfilePath = Profile; + _ = DoPreviewSvg(); } } @@ -1338,21 +1053,21 @@ namespace WebWindowTest { if (testStep == CompileStep.Sash) { - if ((currSash == 0 && Index == 0) || (currSash == 1 && Index == 1)) + if ((currSashIndex == 0 && Index == 0) || (currSashIndex == 1 && Index == 1)) return "nav-link active fw-bold"; else return "nav-link text-secondary"; } else if (testStep == CompileStep.Fill) { - if ((currFill == 0 && Index == 0) || (currFill == 1 && Index == 1)) + if ((currFillIndex == 0 && Index == 0) || (currFillIndex == 1 && Index == 1)) return "nav-link active fw-bold"; else return "nav-link text-secondary"; } else if (testStep == CompileStep.Split) { - if ((currSplit == 0 && Index == 0) || (currSplit == 1 && Index == 1)) + if ((currSplitIndex == 0 && Index == 0) || (currSplitIndex == 1 && Index == 1)) return "nav-link active fw-bold"; else return "nav-link text-secondary"; @@ -1360,15 +1075,194 @@ namespace WebWindowTest return (testStep == currStep) ? "nav-link active fw-bold" : "nav-link text-secondary"; } + /// + /// Metodo per cambiare tutti i Fill e richiedere aggiornamento SVG + /// + /// tipo di fill richiesto + /// + protected async Task ChangeAllFill(FillTypes reqFillType) + { + updateAllFill(FrameWindow, reqFillType); + await DoPreviewSvg(); + } + + /// + /// Metodo per aggiornare tutti i Fill al nuovo tipo + /// + /// area corrente + /// tipo a cui aggiornare + private void updateAllFill(Area area, FillTypes type) + { + if (area.AreaType.Equals(AreaTypes.FILL)) + { + Fill fill = (Fill)area; + fill.SetSelFillType(type); + return; + } + foreach (Area child in area.AreaList) + { + updateAllFill(child, type); + } + } + + /// + /// Aggiornamento Fill + /// + /// Fill da aggiornare + /// + private async Task UpdatePreviewFill(Fill newFill) + { + if (newFill != null) + { + // cerco il record + var currRec = (Fill)SearchArea(FrameWindow, newFill.GroupId, newFill); + // lo aggiorno + currRec = newFill; + await DoPreviewSvg(); + } + } + /// /// Aggiornamento Frame /// - /// + /// nuovo frame /// - private async Task UpdateFrame(Frame newFrame) + private async Task UpdatePreviewFrame(DataUpdateFrame args) { - FrameWindow = newFrame; - await DoPreviewSvg(); + Frame newFrame = args.currFrame; + bool forceSvgNoHw = args.svgNoHw; + if (newFrame != null) + { + // cerco il record + var currRec = m_CurrWindow.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId); + // lo aggiorno + currRec = newFrame; + if (forceSvgNoHw) + await DoPreviewSvg(true, true); + else + await DoPreviewSvg(); + } + } + + /// + /// Aggiornamento opzioni dato nuovo frame + /// + /// nuovo frame + /// + private async Task UpdateHwOptionsFrame(Frame newFrame) + { + if (newFrame != null) + { + // cerco il record + var currRec = m_CurrWindow.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId); + // lo aggiorno + currRec = newFrame; + // resetto hw lst + await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); + reqHwOpt++; + if (prevReq == (int)DataReq.ReqShape) + { + // richiesta calcolo opzioni hardware per la singola sash group + List reqList = SashList.Select(x => x.GroupId).ToList(); + // chiamo con gruppo della nuova sash + await DoReqOptHardware(reqList); + } + } + } + + /// + /// Aggiornamento opzioni data nuova sash group + /// + /// nuovo frame + /// + private async Task UpdateHwOptionsSash(Sash newSash) + { + if (newSash != null) + { + // cerco il record + var currRec = SearchArea(FrameWindow, newSash.GroupId, newSash); + // lo aggiorno + currRec = newSash; + // resetto hw lst + await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); + //reqHwOpt++; + //if(prevReq == (int)DataReq.ReqShape) + //{ + // richiesta calcolo opzioni hardware per la singola sash group + List reqList = SashList.Select(x => x.GroupId).ToList(); + // chiamo con gruppo della nuova sash + await DoReqOptHardware(reqList); + //} + } + } + + /// + /// Richiesta opzioni hardware per la prima volta + /// + /// nuovo frame + /// + private async Task ReqFirstOptionHw(Sash newSash) + { + if (newSash != null) + { + // cerco il record + var currRec = SearchArea(FrameWindow, newSash.GroupId, newSash); + // lo aggiorno + currRec = newSash; + // resetto hw lst + await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); + // richiesta calcolo opzioni hardware per la singola sash group + List reqList = SashList.Select(x => x.GroupId).ToList(); + // chiamo con gruppo della nuova sash + await DoReqOptHardware(reqList); + } + } + + /// + /// Aggiornamento Frame + /// + /// nuovo frame + /// + private async Task UpdatePreviewSplit(DataUpdateSplit args) + { + Split newSplit = args.currSplit; + bool forceSvgNoHw = args.svgNoHw; + bool noSvg = args.noSvg; + if (newSplit != null) + { + // cerco il record + var currRec = SearchArea(FrameWindow, newSplit.GroupId, newSplit); + // lo aggiorno + currRec = newSplit; + if (!noSvg) + { + if (forceSvgNoHw) + await DoPreviewSvg(true, true); + else + await DoPreviewSvg(); + } + } + } + + /// + /// Metodo per aggiornare Splitted + /// + /// Splitted da aggiornare + /// + private async Task UpdatePreviewSplitted(Splitted currSplitted) + { + if (currSplitted != null) + { + var item = SearchArea(FrameWindow, currSplitted.GroupId, currSplitted); + item = currSplitted; + // ricalcolo liste + UpdateLists(); + // richiedo update shape + List reqList = SashList.Select(x => x.GroupId).ToList(); + await DoPreviewSvg(); + await DoReqShape(reqList); + } + } /// @@ -1376,54 +1270,30 @@ namespace WebWindowTest /// /// nuova sash /// - private async Task UpdateHwOptions(Sash newSash) + private async Task UpdatePreviewSashGroup(DataUpdateSash args) { - // richiesta calcolo opzioni hardware per la singola sash group - //string req = newSash.SelHardware.Id; - List reqList = new List() { newSash.GroupId }; - // chiamo con gruppo della nuova sash - await DoReqOptHardware(reqList); - } - - /// - /// Aggiornamento Sash e Frame - /// - /// nuova sash - /// - private async Task UpdateSash(Sash newSash) - { - SearchSash(FrameWindow, newSash.GroupId, newSash); - await DoPreviewSvg(); - } - - /// - /// Aggiornamento Shape x ogni Group di Sash della finestra - /// - /// - /// - private async Task UpdateShape(Frame newFrame) - { - FrameWindow = newFrame; - if (SashList.Count > 0) + Sash newSash = args.currSash; + bool svgNoHw = args.svgNoHw; + bool noSvg = args.noSvg; + if (svgNoHw) { - // ciclo x ogni group della mia frame - List reqList = SashList.Select(x => x.GroupId).ToList(); - await DoReqShape(reqList); + Sash item = (Sash)SearchArea(FrameWindow, newSash.GroupId, newSash); + if (newSash != null && item != null) + { + item = newSash; + await DoPreviewSvg(true, true); + } + } + else + { + Sash item = (Sash)SearchArea(FrameWindow, newSash.GroupId, newSash); + if (newSash != null && item != null) + { + item = newSash; + if (!noSvg) + await DoPreviewSvg(); + } } - } - - /// - /// Aggiornamento shape dato GroupId - /// - /// nuova sash - /// - private async Task UpdateShape(int groupId) - { - List reqList = new List() { groupId }; - await DoReqShape(reqList); -#if false - await DoReqShape(groupId); -#endif } #endregion Private Methods