diff --git a/Test.UI/Data/AntaDoppia.jwd b/Test.UI/Data/AntaDoppia.jwd
index 486ff5f..ee77baa 100644
--- a/Test.UI/Data/AntaDoppia.jwd
+++ b/Test.UI/Data/AntaDoppia.jwd
@@ -47,6 +47,24 @@
"SashId": 1,
"OpeningType": "TILTTURN_LEFT",
"HasHandle": true,
+ "JointList": [
+ {
+ "Index": 1,
+ "JointType": "FULL_H"
+ },
+ {
+ "Index": 2,
+ "JointType": "FULL_H"
+ },
+ {
+ "Index": 3,
+ "JointType": "FULL_H"
+ },
+ {
+ "Index": 4,
+ "JointType": "FULL_H"
+ }
+ ],
"MeasureType": "PERCENTAGE",
"Dimension": 50.0
},
@@ -54,29 +72,29 @@
"SashId": 2,
"OpeningType": "TURNONLY_RIGHT",
"HasHandle": false,
+ "JointList": [
+ {
+ "Index": 1,
+ "JointType": "FULL_H"
+ },
+ {
+ "Index": 2,
+ "JointType": "FULL_H"
+ },
+ {
+ "Index": 3,
+ "JointType": "FULL_H"
+ },
+ {
+ "Index": 4,
+ "JointType": "FULL_H"
+ }
+ ],
"MeasureType": "PERCENTAGE",
"Dimension": 50.0
}
],
"SashType": "NULL",
- "JointList": [
- {
- "Index": 1,
- "JointType": "FULL_H"
- },
- {
- "Index": 2,
- "JointType": "FULL_H"
- },
- {
- "Index": 3,
- "JointType": "FULL_H"
- },
- {
- "Index": 4,
- "JointType": "FULL_H"
- }
- ],
"BottomRail": false,
"BottomRailQty": 0,
"Hardware": "000633",
diff --git a/WebWindowComplex/Compo/AreaHwOption.razor b/WebWindowComplex/Compo/AreaHwOption.razor
index f468647..a6a1b40 100644
--- a/WebWindowComplex/Compo/AreaHwOption.razor
+++ b/WebWindowComplex/Compo/AreaHwOption.razor
@@ -1,6 +1,6 @@
@using static WebWindowComplex.Json.WindowConst
-
+
Hardware option
diff --git a/WebWindowComplex/Compo/AreaSash.razor b/WebWindowComplex/Compo/AreaSash.razor
index 0d9473e..08ac786 100644
--- a/WebWindowComplex/Compo/AreaSash.razor
+++ b/WebWindowComplex/Compo/AreaSash.razor
@@ -1,92 +1,249 @@
@using EgwCoreLib.Razor
-
-
-
Sash @(CurrSashGroup.SashList.Count == 1 ? "" : (IndexSash + 1))
-
-
-
-
-
- @*
-
-
-
*@
-
- Dimension
-
- @* *@
-
-
-
-
-
RaiseChangeHandle(CurrSashDim, CurrSashGroup)">
+@if(mode == ModeView.View)
+{
+
+
+
Sash @(CurrSashGroup.SashList.Count == 1 ? "" : (IndexSash + 1))
+
-
-
+
+
+
-
- @if (!(CurrAnta.AreaList[0] is Split))
- {
-
-
-
-
+
+ Dimension
+
+ @* *@
+
+
+ @*
+
+
+
Joints
+
+
+
-
-
- }
-
- @for (int k = 0; k <= CurrSashGroup.SashList.Count - 1; k++)
- {
- @if (k != IndexSash)
+ @if (!JointCollapsed)
{
- int IndexCopy = k;
- int IndexModify = IndexSash;
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
}
+ @if (!JointCollapsed)
+ {
+ @foreach (Joint joint in CurrSashDim.JointList)
+ {
+
+ }
+ }
+
+
+
+ RaiseChangeHandle(CurrSashDim, CurrSashGroup)">
+
+
+
+
+
+ @if (!(CurrAnta.AreaList[0] is Split))
+ {
+
+
+
+
+
+
+
+
}
+
+ @for (int k = 0; k <= CurrSashGroup.SashList.Count - 1; k++)
+ {
+ @if (k != IndexSash)
+ {
+ int IndexCopy = k;
+ int IndexModify = IndexSash;
+
+
+
+
+
+ }
+ }
+
*@
-
+}
+else
+{
+
+
+
+
+
+
+
+
+
+
+
+
+ Dimension
+
+ @* *@
+
+
+
+
+ RaiseChangeHandle(CurrSashDim, CurrSashGroup)">
+
+
+
+
+
+
+ @for (int k = 0; k <= CurrSashGroup.SashList.Count - 1; k++)
+ {
+ @if (k != IndexSash)
+ {
+ int IndexCopy = k;
+ int IndexModify = IndexSash;
+
+
+
+
+
+ }
+ }
+
+
+
+
+
+
Joints
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @foreach (Joint joint in CurrSashDim.JointList)
+ {
+
+ }
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/WebWindowComplex/Compo/AreaSash.razor.cs b/WebWindowComplex/Compo/AreaSash.razor.cs
index f217e26..4b7ddda 100644
--- a/WebWindowComplex/Compo/AreaSash.razor.cs
+++ b/WebWindowComplex/Compo/AreaSash.razor.cs
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components;
using Newtonsoft.Json.Linq;
using System;
using WebWindowComplex.Models;
+using static WebWindowComplex.Json.WindowConst;
namespace WebWindowComplex.Compo
{
@@ -32,6 +33,12 @@ namespace WebWindowComplex.Compo
[Parameter]
public EventCallback
EC_ChangeHandle { get; set; }
+ ///
+ /// Evento per aggiornare sash dimension
+ ///
+ [Parameter]
+ public EventCallback EC_UpdateSashDim { get; set; }
+
///
/// Evento per cambiare l'anta su cui è presente la maniglia
///
@@ -80,6 +87,34 @@ namespace WebWindowComplex.Compo
return 0;
}
+ ///
+ /// 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);
+ }
+
+ ///
+ /// Report 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);
+ }
+ }
+
///
/// Sollevo evento per cambiare l'anta su cui è presente la maniglia
///
@@ -98,16 +133,56 @@ namespace WebWindowComplex.Compo
/// Sollevo evento per cambiare l'anta su cui è presente la maniglia
///
///
- private async Task RaiseCopyContentSash(Sash currSash, int indexC, int indexM)
+ private async Task RaiseCopyContentSash(int indexC, int indexM)
{
var Args = new DataCopyContentSash
{
- currItem = currSash,
+ currItem = CurrSashGroup,
indexCopy = indexC,
indexModify = indexM,
};
await EC_CopyContentSash.InvokeAsync(Args);
}
+
+ private bool JointCollapsed { get; set; } = true;
+
+ private async Task changeCollapsed()
+ {
+ JointCollapsed = !JointCollapsed;
+ }
+
+ private string jointCollapsedIcon
+ {
+ get => JointCollapsed ? "↓" : "↑";
+ }
+
+ private string ButtonJointCss(WebWindowComplex.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
+ }
+
+ private ModeView mode = ModeView.View;
+ private void doEdit()
+ {
+ mode = ModeView.Edit;
+ StateHasChanged();
+ }
+ protected void ClosePopup()
+ {
+ mode = ModeView.View;
+ }
}
public class DataChangeHandle
diff --git a/WebWindowComplex/Compo/CardFrame.razor b/WebWindowComplex/Compo/CardFrame.razor
index 15ac48b..ea02118 100644
--- a/WebWindowComplex/Compo/CardFrame.razor
+++ b/WebWindowComplex/Compo/CardFrame.razor
@@ -21,14 +21,6 @@
{
}
- @*
-
-
-
-
-
-
- *@
@@ -66,17 +58,17 @@
-
+
-
+
-
+
diff --git a/WebWindowComplex/Compo/CardFrame.razor.cs b/WebWindowComplex/Compo/CardFrame.razor.cs
index be02a74..162f3de 100644
--- a/WebWindowComplex/Compo/CardFrame.razor.cs
+++ b/WebWindowComplex/Compo/CardFrame.razor.cs
@@ -170,6 +170,16 @@ namespace WebWindowComplex.Compo
}
}
+ private string ButtonJointCss(WebWindowComplex.Json.WindowConst.Joints type)
+ {
+ foreach (var item in FrameWindow.JointList)
+ {
+ if (!item.SelJointType.Equals(type))
+ return "btn btn-outline-secondary btn-sm";
+ }
+ return "btn btn-secondary btn-sm";
+ }
+
#endregion Private Methods
}
diff --git a/WebWindowComplex/Compo/CardSashGroup.razor b/WebWindowComplex/Compo/CardSashGroup.razor
index 5077b35..53403ea 100644
--- a/WebWindowComplex/Compo/CardSashGroup.razor
+++ b/WebWindowComplex/Compo/CardSashGroup.razor
@@ -91,14 +91,16 @@
}
-
-
}
+ @*
Joints
@@ -123,13 +125,41 @@
{
}
-
+
*@
+
+
+
Measure type
+
+
+
+
+
+
+
+
+@*
+ *@
+
+
+
+
@for (int i = 0; i < CurrItem.SashList.Count; i++)
{
@@ -137,6 +167,7 @@
CurrSashGroup="CurrItem"
IndexSash="i"
EC_ChangeHandle="ChangeHandle"
+ EC_UpdateSashDim="UpdateSashDimension"
EC_CopyContentSash="CopyContentSash">
}
diff --git a/WebWindowComplex/Compo/CardSashGroup.razor.cs b/WebWindowComplex/Compo/CardSashGroup.razor.cs
index 534b447..cecba4b 100644
--- a/WebWindowComplex/Compo/CardSashGroup.razor.cs
+++ b/WebWindowComplex/Compo/CardSashGroup.razor.cs
@@ -20,11 +20,11 @@ namespace WebWindowComplex.Compo
[Parameter]
public Sash CurrItem { get; set; } = null!;
- ///
- /// Evento per cambiare tutti i Joints
- ///
- [Parameter]
- public EventCallback
EC_ChangeAllJoints { get; set; }
+ /////
+ ///// Evento per cambiare tutti i Joints
+ /////
+ //[Parameter]
+ //public EventCallback EC_ChangeAllJoints { get; set; }
///
/// Evento per cambiare l'anta su cui è presente la maniglia
@@ -116,24 +116,29 @@ namespace WebWindowComplex.Compo
await EC_RemoveArea.InvokeAsync(currArea);
}
+ protected async Task SetMeasureType(MeasureTypes type)
+ {
+ foreach(var item in CurrItem.SashList)
+ {
+ item.SetSelMeasureType(type);
+ }
+ await EC_UpdateSash.InvokeAsync(CurrItem);
+ }
+
+ protected async Task UpdateSashDimension(SashDimension updateSD)
+ {
+ var currRec = CurrItem.SashList.Where(x => x.nSashId == updateSD.nSashId).FirstOrDefault();
+ if(currRec != null)
+ {
+ currRec = updateSD;
+ await EC_UpdateSash.InvokeAsync(CurrItem);
+ }
+ }
+
#endregion Protected Methods
#region Private Methods
- ///
- /// Sollevo evento richiesta per cambiare tutti i Joint
- ///
- ///
- private async Task ChangeAllJoints(Json.WindowConst.Joints JointType, Area a)
- {
- var Args = new DataChangeJoints
- {
- currJointType = JointType,
- currArea = a,
- };
- await EC_ChangeAllJoints.InvokeAsync(Args);
- }
-
///
/// Sollevo evento per cambiare l'anta su cui è presente la maniglia
///
@@ -160,22 +165,22 @@ namespace WebWindowComplex.Compo
_ = EC_ReqClose.InvokeAsync(true);
}
- ///
- /// Report aggiornamento joint
- ///
- ///
- ///
- private async Task UpdateJoint(Joint updRec)
- {
- // cerco il record
- var currRec = CurrItem.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
- // lo aggiorno
- if (updRec != null)
- {
- currRec = updRec;
- await EC_UpdateSash.InvokeAsync(CurrItem);
- }
- }
+ /////
+ ///// Report aggiornamento joint
+ /////
+ /////
+ /////
+ //private async Task UpdateJoint(Joint updRec)
+ //{
+ // // cerco il record
+ // var currRec = CurrItem.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
+ // // lo aggiorno
+ // if (updRec != null)
+ // {
+ // currRec = updRec;
+ // await EC_UpdateSash.InvokeAsync(CurrItem);
+ // }
+ //}
///
/// Report aggiornamento Option Combo
@@ -221,6 +226,16 @@ namespace WebWindowComplex.Compo
await EC_CallFirstHwOpt.InvokeAsync(groupId);
}
+ private string ButtonMeasureCss(MeasureTypes type)
+ {
+ foreach(var item in CurrItem.SashList)
+ {
+ if (!item.SelMeasureType.Equals(type))
+ return "btn btn-outline-secondary btn-sm";
+ }
+ return "btn btn-secondary btn-sm";
+ }
+
#endregion Private Methods
}
}
\ No newline at end of file
diff --git a/WebWindowComplex/Json/JsonUtility.cs b/WebWindowComplex/Json/JsonUtility.cs
index fef03b9..44983d1 100644
--- a/WebWindowComplex/Json/JsonUtility.cs
+++ b/WebWindowComplex/Json/JsonUtility.cs
@@ -311,19 +311,19 @@ namespace WebWindowComplex.Json
}
}
- private List m_JointList = new List();
- [JsonProperty]
- public List JointList
- {
- get
- {
- return m_JointList;
- }
- set
- {
- m_JointList = value;
- }
- }
+ //private List m_JointList = new List();
+ //[JsonProperty]
+ //public List JointList
+ //{
+ // get
+ // {
+ // return m_JointList;
+ // }
+ // set
+ // {
+ // m_JointList = value;
+ // }
+ //}
private bool m_bBottomRail;
[JsonProperty]
@@ -410,9 +410,11 @@ namespace WebWindowComplex.Json
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));
+ //foreach (var Joint in m_JointList)
+ // newSash.JointList.Add(Joint.Deserialize((Area)ParentArea));
newSash.SetSelFamilyHardwareFromIndex(Hardware);
newSash.ReqRefreshShape();
newSash.SetSelHardwareFromId(Hardware);
@@ -780,6 +782,20 @@ namespace WebWindowComplex.Json
}
}
+ private double m_dDimension;
+ [JsonProperty]
+ public double Dimension
+ {
+ get
+ {
+ return m_dDimension;
+ }
+ set
+ {
+ m_dDimension = value;
+ }
+ }
+
private bool m_bHasHandle;
[JsonProperty]
public bool HasHandle
@@ -794,17 +810,17 @@ namespace WebWindowComplex.Json
}
}
- private double m_dDimension;
+ private List m_JointList = new List();
[JsonProperty]
- public double Dimension
+ public List JointList
{
get
{
- return m_dDimension;
+ return m_JointList;
}
set
{
- m_dDimension = value;
+ m_JointList = value;
}
}
diff --git a/WebWindowComplex/Models/FrameDimension.cs b/WebWindowComplex/Models/FrameDimension.cs
index 2a71c14..9636022 100644
--- a/WebWindowComplex/Models/FrameDimension.cs
+++ b/WebWindowComplex/Models/FrameDimension.cs
@@ -42,8 +42,8 @@ namespace WebWindowComplex.Models
{
m_dValue = MinDim;
}
- //if(ParentFrame.AreaList.Count > 0)
- // SearchAreaList(ParentFrame);
+ if (ParentFrame.AreaList.Count > 0)
+ SearchAreaList(ParentFrame);
m_ParentFrame.ParentWindow.OnUpdatePreview(m_ParentFrame.ParentWindow.sSerialized());
}
}
@@ -80,110 +80,79 @@ namespace WebWindowComplex.Models
/// Cerca nell'albero gli oggetti Sash e Split per associare la larghezza
///
///
- //protected void SearchAreaList(Area node)
- //{
- // if (node != null)
- // {
- // if(node.AreaType.Equals(AreaTypes.SASH))
- // calculateWidth((Sash)node);
- // else if(node.AreaType.Equals(AreaTypes.SPLIT))
- // calculateWidth((Split)node);
- // foreach (var item in node.AreaList)
- // {
- // SearchAreaList(item);
- // }
- // }
- //}
+ protected void SearchAreaList(Area node)
+ {
+ if (node != null)
+ {
+ if (node.AreaType.Equals(AreaTypes.SASH))
+ calculateWidth((Sash)node);
+ else if (node.AreaType.Equals(AreaTypes.SPLIT))
+ calculateWidth((Split)node);
+ foreach (var item in node.AreaList)
+ {
+ SearchAreaList(item);
+ }
+ }
+ }
- ///
- /// Ricalcolo larghezza Sash e SPlit
- ///
- ///
- //protected void calculateWidth(Area area)
- //{
- // if (area is Sash)
- // {
- // Sash sash = (Sash)area;
- // if (area.ParentArea is Frame)
- // {
- // Frame frame = (Frame)area.ParentArea;
- // sash.Width = (frame.DimensionList.Where(x => x.sName == "Width").FirstOrDefault())!.dValue;
- // }
- // else if (sash.ParentArea.ParentArea is Split)
- // {
- // Split split = (Split)sash.ParentArea.ParentArea;
- // if (split.SplitVertList.Count > 0)
- // {
- // int indexSplit = 0;
- // for (int i = 0; i < split.AreaList.Count; i++)
- // {
- // if (split.AreaList.ElementAt(i).AreaList.First().Equals(sash))
- // indexSplit = i;
- // }
- // switch (split.SplitVertList.ElementAt(indexSplit).MeasureType)
- // {
- // case MeasureTypes.ABSOLUT:
- // {
- // sash.Width = split.SplitVertList.ElementAt(indexSplit).dDimension;
- // break;
- // }
- // case MeasureTypes.PROPORTIONAL:
- // {
- // /// TO DO!!!!!
- // break;
- // }
- // case MeasureTypes.PERCENTAGE:
- // {
- // sash.Width = split.SplitVertList.ElementAt(indexSplit).dDimension / 100 * split.Width;
- // break;
- // }
- // }
- // }
- // else
- // {
- // Frame frame = (Frame)sash.ParentWindow.AreaList[0];
- // sash.Width = (frame.DimensionList.Where(x => x.sName == "Width").FirstOrDefault())!.dValue;
- // }
- // }
- // }
- // else if (area is Split)
- // {
- // Split split = (Split)area;
- // if (area.ParentArea is Frame)
- // {
- // Frame frame = (Frame)area.ParentArea;
- // split.Width = (frame.DimensionList.Where(x => x.sName == "Width").FirstOrDefault())!.dValue;
- // }
- // else if (split.ParentArea.ParentArea is Sash)
- // {
- // Sash sash = (Sash)split.ParentArea.ParentArea;
- // int indexSash = 0;
- // for (int i = 0; i < sash.AreaList.Count; i++)
- // {
- // if (sash.AreaList.ElementAt(i).AreaList.First().Equals(split))
- // indexSash = i;
- // }
- // switch (sash.SashList.ElementAt(indexSash).MeasureType)
- // {
- // case MeasureTypes.ABSOLUT:
- // {
- // split.Width = sash.SashList.ElementAt(indexSash).dDimension;
- // break;
- // }
- // case MeasureTypes.PROPORTIONAL:
- // {
- // /// TO DO!!!!!
- // break;
- // }
- // case MeasureTypes.PERCENTAGE:
- // {
- // split.Width = sash.SashList.ElementAt(indexSash).dDimension / 100 * sash.Width;
- // break;
- // }
- // }
- // }
- // }
- //}
+ protected void calculateWidth(Area area)
+ {
+ if(area is Sash && sName.Equals("Width"))
+ {
+ Sash sash = (Sash)area;
+ int countAbsolute = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUT)).Count();
+ if(countAbsolute == sash.SashList.Count)
+ {
+ double sum = sash.SashList.Sum(x => x.dDimension);
+ double res = dValue - 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(area is Split)
+ {
+ Split split = (Split)area;
+ List splitList = null;
+ if (sName.Equals("Width"))
+ splitList = split.SplitVertList;
+ else
+ splitList = split.SplitHorizList;
+ int countAbsolute = splitList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUT)).Count();
+ if (countAbsolute != 0 && countAbsolute == splitList.Count)
+ {
+ double sum = splitList.Sum(x => x.dDimension);
+ double res = dValue - sum;
+ if (res > 0)
+ {
+ foreach (var sashDim in splitList)
+ {
+ sashDim.SetDimension(sashDim.dDimension + res / countAbsolute);
+ }
+ }
+ else
+ {
+ foreach (var sashDim in splitList)
+ {
+ // Sommo perchè res è negativo
+ sashDim.SetDimension(sashDim.dDimension + res / countAbsolute);
+ }
+ }
+ }
+ }
+ }
internal JsonFrameDimension Serialize()
{
diff --git a/WebWindowComplex/Models/Sash.cs b/WebWindowComplex/Models/Sash.cs
index 0255e20..8fba15b 100644
--- a/WebWindowComplex/Models/Sash.cs
+++ b/WebWindowComplex/Models/Sash.cs
@@ -34,52 +34,6 @@ namespace WebWindowComplex.Models
#region Public Properties
- /////
- ///// Larghezza gruppo ante
- /////
- //public double Width
- //{
- // get
- // {
- // return m_Width;
- // }
- // set
- // {
- // if (m_Width != value && m_Width != 0)
- // {
- // // Se larghezza aumentata
- // if (SashList.Sum(x => x.CalculateAbsolutValue(m_Width)) < value)
- // {
- // if (SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0 &&
- // SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList().Count != SashList.Count)
- // {
- // double res = value - m_Width;
- // foreach (var item in SashList)
- // item.SetDimension(item.ConvertIn(item.CalculateAbsolutValue(m_Width) + res / SashList.Count, (MeasureTypes)item.SelMeasureTypeIndex, value));
- // }
- // }
- // // Larghezza diminuita
- // else if (SashList.Sum(x => x.CalculateAbsolutValue(m_Width)) > value)
- // {
- // if (SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0 &&
- // SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList().Count != SashList.Count)
- // {
- // double res = m_Width - value;
- // foreach (var item in SashList)
- // item.SetDimension(item.ConvertIn(item.CalculateAbsolutValue(m_Width) - res / SashList.Count, (MeasureTypes)item.SelMeasureTypeIndex, value));
- // }
- // }
- // m_Width = value;
- // m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
- // }
- // else
- // {
- // m_Width = value;
- // m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
- // }
- // }
- //}
-
public bool bIsMeasureGlass
{
get
@@ -92,14 +46,6 @@ namespace WebWindowComplex.Models
}
}
- //public bool bIsPercentage
- //{
- // get
- // {
- // return m_bIsPercentage;
- // }
- //}
-
public bool bIsSashVertical
{
get
@@ -136,17 +82,17 @@ namespace WebWindowComplex.Models
}
}
- public List JointList
- {
- get
- {
- return m_JointList;
- }
- set
- {
- m_JointList = value;
- }
- }
+ //public List JointList
+ //{
+ // get
+ // {
+ // return m_JointList;
+ // }
+ // set
+ // {
+ // m_JointList = value;
+ // }
+ //}
public int nSashQty
{
@@ -158,11 +104,12 @@ namespace WebWindowComplex.Models
{
if (value > 0 && value <= 3)
{
+ double widthTot = CalculateWidthSashGroup(ParentWindow.AreaList.First(), ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue);
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;
@@ -174,7 +121,12 @@ namespace WebWindowComplex.Models
// aggiungo area Sash di default
for (var SplitIndex = m_SashList.Count; SplitIndex <= value - 1; SplitIndex++)
{
- SashList.Add(new SashDimension(dNewDimension, m_SashList[m_SashList.Count - 1].MeasureType, 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_H));
+ }
+ SashList.Add(addSashDim);
}
}
else if (value < m_SashList.Count)
@@ -189,7 +141,6 @@ namespace WebWindowComplex.Models
itemDelete = m_SashList[SplitIndex];
SashList.RemoveAt(SplitIndex);
}
- double widthTot = CalculateWidthSashGroup(ParentWindow.AreaList.First(), ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue);
double deleteDim = itemDelete.ConvertDimension(itemDelete.SelMeasureType, m_SashList[SashList.Count - 1].SelMeasureType, widthTot);
//dLastDimension += m_SashList[SashList.Count - 1].dDimension;
dLastDimension = deleteDim + m_SashList[SashList.Count - 1].dDimension;
@@ -473,11 +424,11 @@ namespace WebWindowComplex.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 JointList)
+ //{
+ // Joint newJoint = item.Copy();
+ // newSash.JointList.Add(newJoint);
+ //}
foreach (var item in AreaList)
{
Area newArea = item.Copy(newSash);
@@ -602,12 +553,20 @@ namespace WebWindowComplex.Models
#endregion Public Methods
#region Internal Methods
+
+ ///
+ /// Metodo per calcolare larghezza intera sash group
+ ///
+ /// area di partenza
+ /// larghezza di partenza
+ ///
internal double CalculateWidthSashGroup(Area area, double width)
{
- if (area.Equals(this))
- return 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)
{
@@ -616,20 +575,22 @@ namespace WebWindowComplex.Models
{
case MeasureTypes.ABSOLUT:
{
- CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension);
+ risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension);
break;
}
case MeasureTypes.PROPORTIONAL:
{
- //CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension);
+ //risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension);
break;
}
case MeasureTypes.PERCENTAGE:
{
- CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension * width / 100);
+ risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension * width / 100);
break;
}
}
+ if (risultato != -1)
+ return risultato;
}
else if (area is Sash)
{
@@ -638,27 +599,31 @@ namespace WebWindowComplex.Models
{
case MeasureTypes.ABSOLUT:
{
- CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension);
+ risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension);
break;
}
case MeasureTypes.PROPORTIONAL:
{
- //CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension);
+ //risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension);
break;
}
case MeasureTypes.PERCENTAGE:
{
- CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension * width / 100);
+ risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension * width / 100);
break;
}
}
+ if (risultato != -1)
+ return risultato;
}
else
{
- CalculateWidthSashGroup(item, width);
+ risultato = CalculateWidthSashGroup(item, width);
+ if (risultato != -1)
+ return risultato;
}
}
- return -1;
+ return width;
}
internal static Sash CreateSash(Area Area)
{
@@ -669,8 +634,13 @@ namespace WebWindowComplex.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_H));
+ }
+ //for (var JointIndex = 0; JointIndex <= 3; JointIndex++)
+ // newSash.JointList.Add(new Joint(newSash, JointIndex + 1, Joints.FULL_H));
newSash.SetSashBottomRail(false);
newSash.SetSashBottomRailQty(0);
newSash.SetSelFamilyHardware(Sash.s_FamilyHardwareList.First());
@@ -773,8 +743,8 @@ namespace WebWindowComplex.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());
+ //foreach (var Joint in JointList)
+ // JsonSash.JointList.Add(Joint.Serialize());
if(HwOptionList.Count > 0)
{
foreach (var HwOption in HwOptionList)
@@ -912,7 +882,12 @@ namespace WebWindowComplex.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, MeasureTypes.PERCENTAGE, this, SplitIndex + 1));
+ {
+ SashDimension newSashDim = new SashDimension(dNewDimension, MeasureTypes.PERCENTAGE, this, SplitIndex + 1);
+ //for (var JointIndex = 0; JointIndex <= 3; JointIndex++)
+ // newSashDim.JointList.Add(new Joint(this, JointIndex + 1, Joints.FULL_H));
+ SashList.Add(newSashDim);
+ }
}
else if (Qty < m_SashList.Count)
{
@@ -982,7 +957,7 @@ namespace WebWindowComplex.Models
private List m_HwdOptionList = new List();
private Dictionary m_SelHwdOptionList = new Dictionary();
- private List m_JointList = new List();
+ //private List m_JointList = new List();
private int m_nSashBottomRailQty;
diff --git a/WebWindowComplex/Models/SashDimension.cs b/WebWindowComplex/Models/SashDimension.cs
index 16161f3..9058f22 100644
--- a/WebWindowComplex/Models/SashDimension.cs
+++ b/WebWindowComplex/Models/SashDimension.cs
@@ -1,4 +1,5 @@
-using System.Security.Principal;
+using System.Runtime.InteropServices;
+using System.Security.Principal;
using WebWindowComplex.Json;
using static WebWindowComplex.Json.WindowConst;
@@ -105,7 +106,19 @@ namespace WebWindowComplex.Models
//m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized());
}
}
-
+
+ public List JointList
+ {
+ get
+ {
+ return m_JointList;
+ }
+ set
+ {
+ m_JointList = value;
+ }
+ }
+
public double dDimension
{
get
@@ -115,7 +128,7 @@ namespace WebWindowComplex.Models
set
{
double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue);
- double valMinAbsolut = 100;
+ double valMinAbsolut = 200;
double valMaxAbsolut = widthTot - valMinAbsolut * (m_Parent.SashList.Count - 1);
bool valueAccept = false;
switch (MeasureType)
@@ -265,69 +278,8 @@ namespace WebWindowComplex.Models
item.SetDimension(ConvertIn(absolutValList[i], (MeasureTypes)item.SelMeasureTypeIndex, widthTot));
}
}
-
m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized());
}
-
- //// se sono in percentuale
- //if (m_MeasureType.Equals(MeasureTypes.PERCENTAGE))
- //{
- // // Controllo che il valore inserito sia compreso tra 0 e 100
- // if (value > 0 && value < 100)
- // {
- // // verifico se ci sono altri in percentuale
- // List RelativeDimList = m_Parent.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList();
- // if (RelativeDimList.Count > 0)
- // {
- // 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;
- // }
- // dRes = (100 - dRes);
- // RelativeDimList[nIndex - 1].SetDimension(dRes);
- // }
- // else
- // {
- // m_dDimension = 100;
- // return;
- // }
- // }
- // }
- // }
- // m_dDimension = value;
- // m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized());
- //}
}
}
@@ -379,7 +331,6 @@ namespace WebWindowComplex.Models
}
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) ||
@@ -506,6 +457,11 @@ namespace WebWindowComplex.Models
newSashDim.SetMeasureType(MeasureType);
newSashDim.SetOpeningType(SelOpeningType);
newSashDim.SetHasHandle(bHasHandle);
+ foreach (var item in JointList)
+ {
+ Joint newJoint = item.Copy();
+ newSashDim.JointList.Add(newJoint);
+ }
return newSashDim;
}
@@ -513,6 +469,12 @@ namespace WebWindowComplex.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++)
@@ -579,30 +541,65 @@ namespace WebWindowComplex.Models
return width;
}
- internal JsonSashDimension Serialize()
+ ///
+ /// Calcolo MCD
+ ///
+ ///
+ ///
+ ///
+ internal static double CalculateMCD(double a, double b)
{
- JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, MeasureType, m_bHasHandle, m_dDimension, m_nSashId);
- return JsonSashDimension;
+ while (b >= 0.01)
+ {
+ double temp = b;
+ b = a % b;
+ a = temp;
+ }
+ //return Double.Round(a,2);
+ return a;
}
- internal void SetDimension(double dValue)
+ ///
+ /// Metodo per ricalcolare i valori proporzionali a causa della modifica di uno
+ ///
+ ///
+ internal double CalculatePropVal(double widthTot)
{
- m_dDimension = dValue;
- }
-
- internal void SetHasHandle(bool value)
- {
- m_bHasHandle = value;
- }
-
- internal void SetOpeningType(Openings value)
- {
- m_SelOpeningType = value;
- }
-
- internal void SetMeasureType(MeasureTypes value)
- {
- m_SelMeasureType = value;
+ if (m_Parent.SashList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0)
+ {
+ return 1;
+ }
+ List absolutValue = new List();
+ foreach (var item in m_Parent.SashList)
+ {
+ absolutValue.Add(item.CalculateAbsolutValue(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 (absolutValue.ElementAt(nIndex) <= absolutValue.ElementAt(i))
+ {
+ var mcd = CalculateMCD(absolutValue.ElementAt(nIndex), absolutValue.ElementAt(i));
+ //m_Parent.SashList.ElementAt(i).m_dDimension = Double.Round(absolutValue.ElementAt(i) / mcd, 2);
+ //m_dDimension = Double.Round(absolutValue.ElementAt(nIndex) / mcd, 2);
+ m_Parent.SashList.ElementAt(i).m_dDimension = absolutValue.ElementAt(i) / mcd;
+ m_dDimension = absolutValue.ElementAt(nIndex) / mcd;
+ }
+ else
+ {
+ var mcd = CalculateMCD(absolutValue.ElementAt(nIndex), absolutValue.ElementAt(i));
+ //m_Parent.SashList.ElementAt(i).m_dDimension = Double.Round(absolutValue.ElementAt(i) / mcd, 2);
+ //m_dDimension = Double.Round(absolutValue.ElementAt(nIndex) / mcd, 2);
+ m_Parent.SashList.ElementAt(i).m_dDimension = absolutValue.ElementAt(i) / mcd;
+ m_dDimension = absolutValue.ElementAt(nIndex) / mcd;
+ }
+ break;
+ }
+ }
+ return m_dDimension;
}
///
@@ -610,7 +607,7 @@ namespace WebWindowComplex.Models
///
/// Larghezza totale
///
- public double CalculateAbsolutValue(double widthTot)
+ internal double CalculateAbsolutValue(double widthTot)
{
switch (MeasureType)
{
@@ -640,7 +637,7 @@ namespace WebWindowComplex.Models
/// Tipo di misura della dimensione
/// Larghezza totale
///
- public double ConvertIn(double absolutVal, MeasureTypes type, double widthTot)
+ internal double ConvertIn(double absolutVal, MeasureTypes type, double widthTot)
{
switch (type)
{
@@ -682,7 +679,7 @@ namespace WebWindowComplex.Models
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.ABSOLUT))
@@ -694,9 +691,9 @@ namespace WebWindowComplex.Models
return (res / sumPesi * dDimension) / tot * 100;
}
}
-
+
///
- /// Metodo per calcolare il valore proporzionale
+ /// Metodo per trasformare il valore proporzionale in assoluto
///
///
internal double Proportional2AbsolutVal(double widthTot)
@@ -715,68 +712,47 @@ namespace WebWindowComplex.Models
.ToList();
double sumPesi = proportionalList.Sum(p => p.dDimension);
if (sumPesi == 0) sumPesi = 1;
- return res / sumPesi*dDimension;
+ return res / sumPesi * dDimension;
}
- ///
- /// Calcolo MCD
- ///
- ///
- ///
- ///
- internal static double CalcolaMCD(double a, double b)
+ internal JsonSashDimension Serialize()
{
- while (b >= 0.01)
- {
- double temp = b;
- b = a % b;
- a = temp;
- }
- //return Double.Round(a,2);
- return a;
+ JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, MeasureType, m_bHasHandle, m_dDimension, m_nSashId);
+ foreach (var Joint in JointList)
+ JsonSashDimension.JointList.Add(Joint.Serialize());
+ return JsonSashDimension;
}
- ///
- /// Metodo per ricalcolare i valori proporzionali a causa della modifica di uno
- ///
- ///
- internal double CalculatePropVal(double widthTot)
+ internal void SetDimension(double dValue)
{
- if(m_Parent.SashList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0)
+ m_dDimension = dValue;
+ }
+
+ internal void SetHasHandle(bool value)
+ {
+ m_bHasHandle = value;
+ }
+
+ internal void SetOpeningType(Openings value)
+ {
+ m_SelOpeningType = value;
+ }
+
+ internal void SetMeasureType(MeasureTypes value)
+ {
+ m_SelMeasureType = value;
+ }
+
+ internal void SetSelMeasureType(MeasureTypes value)
+ {
+ if (m_SelMeasureType != (MeasureTypes)value)
{
- return 1;
+ MeasureTypes newType = (MeasureTypes)value;
+ double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue);
+ m_dDimension = ConvertDimension(m_SelMeasureType, newType, widthTot);
+ m_SelMeasureType = (MeasureTypes)value;
+ //m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized());
}
- List absolutValue = new List();
- foreach (var item in m_Parent.SashList)
- {
- absolutValue.Add(item.CalculateAbsolutValue(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 (absolutValue.ElementAt(nIndex) <= absolutValue.ElementAt(i))
- {
- var mcd = CalcolaMCD(absolutValue.ElementAt(nIndex), absolutValue.ElementAt(i));
- //m_Parent.SashList.ElementAt(i).m_dDimension = Double.Round(absolutValue.ElementAt(i) / mcd, 2);
- //m_dDimension = Double.Round(absolutValue.ElementAt(nIndex) / mcd, 2);
- m_Parent.SashList.ElementAt(i).m_dDimension = absolutValue.ElementAt(i) / mcd;
- m_dDimension = absolutValue.ElementAt(nIndex) / mcd;
- }
- else
- {
- var mcd = CalcolaMCD(absolutValue.ElementAt(nIndex), absolutValue.ElementAt(i));
- //m_Parent.SashList.ElementAt(i).m_dDimension = Double.Round(absolutValue.ElementAt(i) / mcd, 2);
- //m_dDimension = Double.Round(absolutValue.ElementAt(nIndex) / mcd, 2);
- m_Parent.SashList.ElementAt(i).m_dDimension = absolutValue.ElementAt(i) / mcd;
- m_dDimension = absolutValue.ElementAt(nIndex) / mcd;
- }
- break;
- }
- }
- return m_dDimension;
}
#endregion Internal Methods
@@ -828,6 +804,8 @@ namespace WebWindowComplex.Models
// reference
private Sash m_Parent;
+ private List m_JointList = new List();
+
private Openings m_SelOpeningType;
private MeasureTypes m_SelMeasureType;
diff --git a/WebWindowComplex/Models/SplitDimension.cs b/WebWindowComplex/Models/SplitDimension.cs
index d31d81c..fef0c3b 100644
--- a/WebWindowComplex/Models/SplitDimension.cs
+++ b/WebWindowComplex/Models/SplitDimension.cs
@@ -49,80 +49,237 @@ namespace WebWindowComplex.Models
}
set
{
- // Controllo che il valore inserito sia compreso tra 0 e 100
- if (value > 0 && value < 100)
+ double widthTot = CalculateWidthSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue);
+ List dimensions = null;
+ if (bIsVertListDim)
+ dimensions = m_Parent.SplitVertList;
+ else
+ dimensions = m_Parent.SplitHorizList;
+ double valMinAbsolut = 100;
+ double valMaxAbsolut = widthTot - valMinAbsolut * (dimensions.Count - 1);
+ bool valueAccept = false;
+ switch (MeasureType)
{
- // 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)
+ case MeasureTypes.ABSOLUT:
{
- if (m_Parent.bIsPercentage)
+ valueAccept = (value < valMaxAbsolut && value > valMinAbsolut) ? true : false;
+ break;
+ }
+ case MeasureTypes.PROPORTIONAL:
+ {
+ valMaxAbsolut = 20;
+ valueAccept = (value > 1) ? true : false;
+ break;
+ }
+ case MeasureTypes.PERCENTAGE:
+ {
+ valMaxAbsolut = valMaxAbsolut / widthTot * 100;
+ valMinAbsolut = valMinAbsolut / widthTot * 100;
+ valueAccept = (value < valMaxAbsolut && value > valMinAbsolut) ? true : false;
+ break;
+ }
+ }
+ if (valueAccept)
+ {
+ List absolutValList = new List();
+ foreach (var item in dimensions)
+ {
+ absolutValList.Add(item.CalculateAbsolutValue(widthTot, dimensions));
+ }
+ 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 == absolutValList.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.ABSOLUT:
+ {
+ 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 < dDimension)
+ {
+ // L'anta modificata non è l'ultima
+ if (nIndex < absolutValList.Count - 1)
+ {
+ absolutValList[nIndex + 1] = absolutValList[nIndex + 1] + (absolutValList[nIndex] - valueInAbsolute);
+ absolutValList[nIndex] = valueInAbsolute;
+ }
+ // L'anta modificata è l'ultima
+ else if (dimensions.Count > 1)
+ {
+ absolutValList[nIndex - 1] = absolutValList[nIndex - 1] + (absolutValList[nIndex] - valueInAbsolute);
+ absolutValList[nIndex] = valueInAbsolute;
+ }
+ }
+ else
+ {
+ // L'anta modificata non è l'ultima
+ if (nIndex < absolutValList.Count - 1)
+ {
+ absolutValList[nIndex + 1] = absolutValList[nIndex + 1] - (valueInAbsolute - absolutValList[nIndex]);
+ absolutValList[nIndex] = valueInAbsolute;
+ }
+ // L'anta modificata è l'ultima
+ else if (dimensions.Count > 1)
+ {
+ absolutValList[nIndex - 1] = absolutValList[nIndex - 1] - (valueInAbsolute - absolutValList[nIndex]);
+ absolutValList[nIndex] = valueInAbsolute;
+ }
+ }
+ if (MeasureType.Equals(MeasureTypes.PROPORTIONAL))
+ m_dDimension = value;
+ for (int i = 0; i < absolutValList.Count; i++)
+ {
+ var item = dimensions.ElementAt(i);
+ item.SetDimension(ConvertIn(absolutValList[i], (MeasureTypes)item.SelMeasureTypeIndex, widthTot, dimensions));
+ }
}
- m_dDimension = value;
m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized());
}
+ //// Controllo che il valore inserito sia compreso tra 0 e 100
+ //if (value > 0 && value < 100)
+ //{
+ // // 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)
+ // {
+ // if (m_Parent.bIsPercentage)
+ // {
+ // int nIndex = RelativeDimList.IndexOf(this);
+ // 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;
+ // }
+ // }
+ // 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;
+ // }
+ // }
+ // }
+ // else
+ // {
+ // }
+ // }
+ // }
+ // m_dDimension = value;
+ // m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized());
+ //}
}
}
@@ -176,11 +333,15 @@ namespace WebWindowComplex.Models
{
if (m_SelMeasureType != (MeasureTypes)value)
{
+ MeasureTypes newType = (MeasureTypes)value;
+ List splitList = null;
+ if (bIsVertListDim)
+ splitList = m_Parent.SplitVertList;
+ else
+ splitList = m_Parent.SplitHorizList;
+ double widthTot = CalculateWidthSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue);
+ m_dDimension = ConvertDimension(m_SelMeasureType, newType, widthTot, splitList);
m_SelMeasureType = (MeasureTypes)value;
- if (m_SelMeasureType.Equals(MeasureTypes.PROPORTIONAL))
- {
- dDimension = 1;
- }
m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized());
}
}
@@ -190,6 +351,57 @@ namespace WebWindowComplex.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, List splitList)
+ {
+ switch (oldType)
+ {
+ case MeasureTypes.ABSOLUT:
+ {
+ 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.ABSOLUT))
+ {
+ //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.ABSOLUT))
+ {
+ //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, MeasureTypes.PERCENTAGE, bIsRelative, m_Parent, bIsVertListDim);
@@ -200,6 +412,252 @@ namespace WebWindowComplex.Models
#region Internal Methods
+ ///
+ /// Metodo per calcolare larghezza intera split group
+ ///
+ /// area di partenza
+ /// larghezza di partenza
+ ///
+ internal double CalculateWidthSplitGroup(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;
+ switch (split.SplitVertList.ElementAt(i).SelMeasureType)
+ {
+ case MeasureTypes.ABSOLUT:
+ {
+ risultato = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(i).dDimension);
+ break;
+ }
+ case MeasureTypes.PROPORTIONAL:
+ {
+ //risultato = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(i).dDimension);
+ break;
+ }
+ case MeasureTypes.PERCENTAGE:
+ {
+ risultato = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(i).dDimension * width / 100);
+ break;
+ }
+ }
+ if (risultato != -1)
+ return risultato;
+ }
+ else if (area is Sash)
+ {
+ Sash sash = (Sash)area;
+ switch (sash.SashList.ElementAt(i).SelMeasureType)
+ {
+ case MeasureTypes.ABSOLUT:
+ {
+ risultato = CalculateWidthSplitGroup(item, sash.SashList.ElementAt(i).dDimension);
+ break;
+ }
+ case MeasureTypes.PROPORTIONAL:
+ {
+ //risultato = CalculateWidthSplitGroup(item, sash.SashList.ElementAt(i).dDimension);
+ break;
+ }
+ case MeasureTypes.PERCENTAGE:
+ {
+ risultato = CalculateWidthSplitGroup(item, sash.SashList.ElementAt(i).dDimension * width / 100);
+ break;
+ }
+ }
+ if (risultato != -1)
+ return risultato;
+ }
+ else
+ {
+ risultato = CalculateWidthSplitGroup(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, List splitList)
+ {
+ if (splitList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0)
+ {
+ return 1;
+ }
+ List absolutValue = new List();
+ foreach (var item in splitList)
+ {
+ absolutValue.Add(item.CalculateAbsolutValue(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 (absolutValue.ElementAt(nIndex) <= absolutValue.ElementAt(i))
+ {
+ var mcd = CalculateMCD(absolutValue.ElementAt(nIndex), absolutValue.ElementAt(i));
+ //m_Parent.SashList.ElementAt(i).m_dDimension = Double.Round(absolutValue.ElementAt(i) / mcd, 2);
+ //m_dDimension = Double.Round(absolutValue.ElementAt(nIndex) / mcd, 2);
+ splitList.ElementAt(i).m_dDimension = absolutValue.ElementAt(i) / mcd;
+ m_dDimension = absolutValue.ElementAt(nIndex) / mcd;
+ }
+ else
+ {
+ var mcd = CalculateMCD(absolutValue.ElementAt(nIndex), absolutValue.ElementAt(i));
+ //m_Parent.SashList.ElementAt(i).m_dDimension = Double.Round(absolutValue.ElementAt(i) / mcd, 2);
+ //m_dDimension = Double.Round(absolutValue.ElementAt(nIndex) / mcd, 2);
+ splitList.ElementAt(i).m_dDimension = absolutValue.ElementAt(i) / mcd;
+ m_dDimension = absolutValue.ElementAt(nIndex) / mcd;
+ }
+ break;
+ }
+ }
+ return m_dDimension;
+ }
+
+ ///
+ /// Metodo per trasformare una dimensione in valore assoluto rispetto alla larghezza totale
+ ///
+ /// Larghezza totale
+ ///
+ internal double CalculateAbsolutValue(double widthTot, List splitList)
+ {
+ switch (MeasureType)
+ {
+ case MeasureTypes.ABSOLUT:
+ {
+ //return Double.Round(dDimension, 2);
+ return dDimension;
+ }
+ case MeasureTypes.PROPORTIONAL:
+ {
+ //return Double.Round(Proportional2AbsolutVal(), 2);
+ return Proportional2AbsolutVal(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 absolutVal, MeasureTypes type, double widthTot, List splitList)
+ {
+ switch (type)
+ {
+ case MeasureTypes.ABSOLUT:
+ {
+ //return Double.Round(absolutVal, 2);
+ return absolutVal;
+ }
+ case MeasureTypes.PROPORTIONAL:
+ {
+ //return Proportional2AbsolutVal();
+ return Proportional2AbsolutVal(widthTot, splitList);
+ }
+ case MeasureTypes.PERCENTAGE:
+ {
+ //return Double.Round((absolutVal / widthTot) * 100, 1);
+ return (absolutVal / 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.CalculateAbsolutValue(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.ABSOLUT))
+ {
+ return res / sumPesi * dDimension;
+ }
+ else
+ {
+ return (res / sumPesi * dDimension) / tot * 100;
+ }
+ }
+
+ ///
+ /// Metodo per trasformare il valore proporzionale in assoluto
+ ///
+ ///
+ internal double Proportional2AbsolutVal(double widthTot, List splitList)
+ {
+ double tot = widthTot;
+ //Somma misura non proporzionali
+ double sumNotProp = splitList
+ .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL)
+ .Sum(m => m.CalculateAbsolutValue(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, MeasureType);
diff --git a/WebWindowComplex/TableComp.razor b/WebWindowComplex/TableComp.razor
index 6158c55..598c086 100644
--- a/WebWindowComplex/TableComp.razor
+++ b/WebWindowComplex/TableComp.razor
@@ -78,7 +78,7 @@
{
m_PreviousWindow = m_CurrWindow;
}
- net8.0
enable
enable
- 2.7.11.1815
+ 2.7.11.2017
Annamaria Sassi
Egalware
Componente gestione Configurazioni avanzate Window per LUX
@@ -140,6 +140,10 @@
+
+
+
+
diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj
index c797584..54e7a0d 100644
--- a/WebWindowConfigurator/WebWindowConfigurator.csproj
+++ b/WebWindowConfigurator/WebWindowConfigurator.csproj
@@ -6,7 +6,7 @@
net8.0
enable
enable
- 2.7.11.1815
+ 2.7.11.2017
Annamaria Sassi
Egalware
Componente gestione JWD per LUX
@@ -167,6 +167,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+