1395 lines
41 KiB
C#
1395 lines
41 KiB
C#
using Egw.Window.Data;
|
|
using Microsoft.VisualBasic;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json.Serialization;
|
|
using WebWindowComplex.Models;
|
|
using static WebWindowComplex.Json.WindowConst;
|
|
|
|
namespace WebWindowComplex.Json
|
|
{
|
|
[JsonObject(MemberSerialization.OptIn)]
|
|
public class JsonWindow
|
|
{
|
|
private string m_sProfilePath;
|
|
[JsonProperty]
|
|
public string ProfilePath
|
|
{
|
|
get
|
|
{
|
|
return m_sProfilePath;
|
|
}
|
|
set
|
|
{
|
|
m_sProfilePath = value;
|
|
}
|
|
}
|
|
|
|
private string m_sWood;
|
|
[JsonProperty]
|
|
public string Wood
|
|
{
|
|
get
|
|
{
|
|
return m_sWood;
|
|
}
|
|
set
|
|
{
|
|
m_sWood = value;
|
|
}
|
|
}
|
|
|
|
private string m_sColorMaterial;
|
|
[JsonProperty]
|
|
public string ColorMaterial
|
|
{
|
|
get
|
|
{
|
|
return m_sColorMaterial;
|
|
}
|
|
set
|
|
{
|
|
m_sColorMaterial = value;
|
|
}
|
|
}
|
|
|
|
private string m_sGlass;
|
|
[JsonProperty]
|
|
public string Glass
|
|
{
|
|
get
|
|
{
|
|
return m_sGlass;
|
|
}
|
|
set
|
|
{
|
|
m_sGlass = value;
|
|
}
|
|
}
|
|
|
|
private List<JsonArea> m_AreaList = new List<JsonArea>();
|
|
[JsonProperty]
|
|
public List<JsonArea> AreaList
|
|
{
|
|
get
|
|
{
|
|
return m_AreaList;
|
|
}
|
|
set
|
|
{
|
|
m_AreaList = value;
|
|
}
|
|
}
|
|
|
|
public JsonWindow(string ProfilePath, string Wood, string ColorMaterial, string Glass)
|
|
{
|
|
m_sProfilePath = ProfilePath;
|
|
m_sWood = Wood;
|
|
m_sColorMaterial = ColorMaterial;
|
|
m_sGlass = Glass;
|
|
}
|
|
|
|
internal Window Deserialize()
|
|
{
|
|
Window Window = new Window()
|
|
{
|
|
sProfilePath = m_sProfilePath,
|
|
sWood = m_sWood,
|
|
sColorMaterial = m_sColorMaterial,
|
|
sGlass = m_sGlass
|
|
};
|
|
foreach (var Area in AreaList)
|
|
{
|
|
JsonFrame jf = (JsonFrame)Area;
|
|
Frame frame = (Frame)jf.Deserialize(null, Window);
|
|
Window.AreaList.Add(frame ?? new(null, Window));
|
|
}
|
|
return Window;
|
|
}
|
|
}
|
|
|
|
public class JsonArea
|
|
{
|
|
private int m_nGroupId;
|
|
[JsonProperty]
|
|
public int GroupId
|
|
{
|
|
get
|
|
{
|
|
return m_nGroupId;
|
|
}
|
|
set
|
|
{
|
|
m_nGroupId = value;
|
|
}
|
|
}
|
|
|
|
private List<JsonArea> m_AreaList = new List<JsonArea>();
|
|
[JsonProperty]
|
|
public List<JsonArea> AreaList
|
|
{
|
|
get
|
|
{
|
|
return m_AreaList;
|
|
}
|
|
set
|
|
{
|
|
m_AreaList = value;
|
|
}
|
|
}
|
|
|
|
private AreaTypes m_AreaType;
|
|
[JsonProperty]
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public AreaTypes AreaType
|
|
{
|
|
get
|
|
{
|
|
return m_AreaType;
|
|
}
|
|
set
|
|
{
|
|
m_AreaType = value;
|
|
}
|
|
}
|
|
|
|
public JsonArea(AreaTypes AreaType)
|
|
{
|
|
m_AreaType = AreaType;
|
|
}
|
|
|
|
internal virtual Area? Deserialize(Area? ParentArea, Window ParentWindow)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public class JsonFrame : JsonArea
|
|
{
|
|
private Shapes m_Shape;
|
|
[JsonProperty]
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public Shapes Shape
|
|
{
|
|
get
|
|
{
|
|
return m_Shape;
|
|
}
|
|
set
|
|
{
|
|
m_Shape = value;
|
|
}
|
|
}
|
|
|
|
private List<JsonFrameDimension> m_DimensionList = new List<JsonFrameDimension>();
|
|
[JsonProperty]
|
|
public List<JsonFrameDimension> DimensionList
|
|
{
|
|
get
|
|
{
|
|
return m_DimensionList;
|
|
}
|
|
}
|
|
|
|
private List<JsonElementDimension> m_ElementDimensionList = new List<JsonElementDimension>();
|
|
[JsonProperty]
|
|
public List<JsonElementDimension> ElementDimensionList
|
|
{
|
|
get
|
|
{
|
|
return m_ElementDimensionList;
|
|
}
|
|
}
|
|
|
|
private List<JsonJoint> m_JointList = new List<JsonJoint>();
|
|
[JsonProperty]
|
|
public List<JsonJoint> JointList
|
|
{
|
|
get
|
|
{
|
|
return m_JointList;
|
|
}
|
|
set
|
|
{
|
|
m_JointList = value;
|
|
}
|
|
}
|
|
|
|
private string m_Threshold;
|
|
[JsonProperty]
|
|
public string Threshold
|
|
{
|
|
get
|
|
{
|
|
return m_Threshold;
|
|
}
|
|
set
|
|
{
|
|
m_Threshold = value;
|
|
}
|
|
}
|
|
|
|
private bool m_bBottomRail;
|
|
[JsonProperty]
|
|
public bool BottomRail
|
|
{
|
|
get
|
|
{
|
|
return m_bBottomRail;
|
|
}
|
|
set
|
|
{
|
|
m_bBottomRail = value;
|
|
}
|
|
}
|
|
|
|
private int m_nBottomRailQty;
|
|
[JsonProperty]
|
|
public int BottomRailQty
|
|
{
|
|
get
|
|
{
|
|
return m_nBottomRailQty;
|
|
}
|
|
set
|
|
{
|
|
m_nBottomRailQty = value;
|
|
}
|
|
}
|
|
|
|
private List<JsonElementDimension> m_BottomRailElemDimList = new List<JsonElementDimension>();
|
|
[JsonProperty]
|
|
public List<JsonElementDimension> BottomRailElemDimList
|
|
{
|
|
get
|
|
{
|
|
return m_BottomRailElemDimList;
|
|
}
|
|
}
|
|
|
|
//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, 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;
|
|
}
|
|
|
|
internal override Area Deserialize(Area? ParentArea, Window ParentWindow)
|
|
{
|
|
Frame newFrame = new Frame(null, ParentWindow);
|
|
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(m_nBottomRailQty > 1)
|
|
{
|
|
for (int i = 0; i < m_nBottomRailQty-1; i++)
|
|
{
|
|
newFrame.BottomRailElemDimList.Add(new ElementDimension(newFrame, BottomRailElemDimList[i].Index, BottomRailElemDimList[i].Value));
|
|
newFrame.BottomRailElemDimList.ElementAt(i).SetNameElement("Frame_Rail");
|
|
newFrame.BottomRailElemDimList.ElementAt(i).SetMinDimension(Window.m_ParameterList.GetValueOrDefault(newFrame.BottomRailElemDimList.ElementAt(i).sName + "_DimMin"));
|
|
newFrame.BottomRailElemDimList.ElementAt(i).SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(newFrame.BottomRailElemDimList.ElementAt(i).sName + "_DimMax"));
|
|
}
|
|
}
|
|
if (m_nBottomRailQty > 0)
|
|
{
|
|
newFrame.BottomRailElemDimList.Add(new ElementDimension(newFrame, BottomRailElemDimList.Last().Index, BottomRailElemDimList.Last().Value));
|
|
newFrame.BottomRailElemDimList.Last().SetNameElement("Frame_Fill_Rail");
|
|
newFrame.BottomRailElemDimList.Last().SetMinDimension(Window.m_ParameterList.GetValueOrDefault(newFrame.BottomRailElemDimList.Last().sName + "_DimMin"));
|
|
newFrame.BottomRailElemDimList.Last().SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(newFrame.BottomRailElemDimList.Last().sName + "_DimMax"));
|
|
}
|
|
//if(ArcElement != null)
|
|
// newFrame.SetFrameArcElem(ArcElement.Deserialize(newFrame, ParentWindow));
|
|
//Frame.AppliedDone();
|
|
for (var DimensionIndex = 0; DimensionIndex <= m_DimensionList.Count - 1; DimensionIndex++)
|
|
newFrame.DimensionList[DimensionIndex].SetDimension(m_DimensionList[DimensionIndex].Value);
|
|
for (var ElementIndex = 0; ElementIndex <= m_ElementDimensionList.Count - 1; ElementIndex++)
|
|
newFrame.ElementDimensionList[ElementIndex].SetDimension(ElementDimensionList[ElementIndex].Value);
|
|
for (var JointIndex = 0; JointIndex <= m_JointList.Count - 1; JointIndex++)
|
|
newFrame.JointList[JointIndex].SetSelJointType(m_JointList[JointIndex].JointType);
|
|
foreach (var Area in AreaList)
|
|
{
|
|
var aList = Area.Deserialize(newFrame, ParentWindow);
|
|
if (aList != null)
|
|
{
|
|
newFrame.AreaList.Add(aList);
|
|
}
|
|
}
|
|
return newFrame;
|
|
}
|
|
}
|
|
|
|
public class JsonSash : JsonArea
|
|
{
|
|
private bool m_bIsSashVertical;
|
|
[JsonProperty]
|
|
public bool IsSashVertical
|
|
{
|
|
get
|
|
{
|
|
return m_bIsSashVertical;
|
|
}
|
|
set
|
|
{
|
|
m_bIsSashVertical = value;
|
|
}
|
|
}
|
|
|
|
private bool m_bIsDimensionLight;
|
|
[JsonProperty]
|
|
public bool IsDimensionLight
|
|
{
|
|
get
|
|
{
|
|
return m_bIsDimensionLight;
|
|
}
|
|
set
|
|
{
|
|
m_bIsDimensionLight = value;
|
|
}
|
|
}
|
|
|
|
private List<JsonSashDimension> m_SashList = new List<JsonSashDimension>();
|
|
[JsonProperty]
|
|
public List<JsonSashDimension> SashList
|
|
{
|
|
get
|
|
{
|
|
return m_SashList;
|
|
}
|
|
set
|
|
{
|
|
m_SashList = value;
|
|
}
|
|
}
|
|
|
|
private SashTypes m_SashType;
|
|
[JsonProperty]
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public SashTypes SashType
|
|
{
|
|
get
|
|
{
|
|
return m_SashType;
|
|
}
|
|
set
|
|
{
|
|
m_SashType = value;
|
|
}
|
|
}
|
|
|
|
private bool m_bBottomRail;
|
|
[JsonProperty]
|
|
public bool BottomRail
|
|
{
|
|
get
|
|
{
|
|
return m_bBottomRail;
|
|
}
|
|
set
|
|
{
|
|
m_bBottomRail = value;
|
|
}
|
|
}
|
|
|
|
private int m_nBottomRailQty;
|
|
[JsonProperty]
|
|
public int BottomRailQty
|
|
{
|
|
get
|
|
{
|
|
return m_nBottomRailQty;
|
|
}
|
|
set
|
|
{
|
|
m_nBottomRailQty = value;
|
|
}
|
|
}
|
|
|
|
private List<JsonElementDimension> m_BottomRailElemDimList = new List<JsonElementDimension>();
|
|
[JsonProperty]
|
|
public List<JsonElementDimension> BottomRailElemDimList
|
|
{
|
|
get
|
|
{
|
|
return m_BottomRailElemDimList;
|
|
}
|
|
}
|
|
|
|
//private JsonSashArcElement m_SashArcElem;
|
|
//[JsonProperty]
|
|
//public JsonSashArcElement ArcElement
|
|
//{
|
|
// get
|
|
// {
|
|
// return m_SashArcElem;
|
|
// }
|
|
// set
|
|
// {
|
|
// m_SashArcElem = value;
|
|
// }
|
|
//}
|
|
|
|
private string m_Hardware;
|
|
[JsonProperty]
|
|
public string Hardware
|
|
{
|
|
get
|
|
{
|
|
return m_Hardware;
|
|
}
|
|
set
|
|
{
|
|
m_Hardware = value;
|
|
}
|
|
}
|
|
|
|
private List<JsonHwOption> m_HwOptionList = new List<JsonHwOption>();
|
|
[JsonProperty]
|
|
public List<JsonHwOption> HwOptionList
|
|
{
|
|
get
|
|
{
|
|
return m_HwOptionList;
|
|
}
|
|
set
|
|
{
|
|
m_HwOptionList = value;
|
|
}
|
|
}
|
|
|
|
public JsonSash() : base(AreaTypes.SASH)
|
|
{
|
|
}
|
|
|
|
public JsonSash(bool IsSashVertical, SashTypes SashType, bool SashBottomRail, int SashBottomRailQty, string Hardware, int GroupId, bool IsDimensionLight = false) : base(AreaTypes.SASH)
|
|
{
|
|
m_bIsSashVertical = IsSashVertical;
|
|
m_bIsDimensionLight = IsDimensionLight;
|
|
m_SashType = SashType;
|
|
m_bBottomRail = SashBottomRail;
|
|
m_nBottomRailQty = SashBottomRailQty;
|
|
m_Hardware = Hardware;
|
|
base.GroupId = GroupId;
|
|
}
|
|
|
|
internal override Area Deserialize(Area ParentArea, Window ParentWindow)
|
|
{
|
|
Sash newSash = new Sash(ParentArea, ParentWindow);
|
|
newSash.SetGroupId(GroupId);
|
|
newSash.SetAreaType(AreaTypes.SASH);
|
|
newSash.SetIsDimensionLight(IsDimensionLight);
|
|
newSash.SetSashQty(m_SashList.Count);
|
|
newSash.SetIsSashVertical(m_bIsSashVertical);
|
|
newSash.SetSashBottomRail(m_bBottomRail);
|
|
newSash.SetSashBottomRailQty(m_nBottomRailQty);
|
|
if (m_nBottomRailQty > 1)
|
|
{
|
|
for (int i = 0; i < m_nBottomRailQty - 1; i++)
|
|
{
|
|
newSash.BottomRailElemDimList.Add(new ElementDimension(newSash, BottomRailElemDimList[i].Index, BottomRailElemDimList[i].Value));
|
|
newSash.BottomRailElemDimList.ElementAt(i).SetNameElement("Sash_Rail");
|
|
newSash.BottomRailElemDimList.ElementAt(i).SetMinDimension(Window.m_ParameterList.GetValueOrDefault(newSash.BottomRailElemDimList.ElementAt(i).sName + "_DimMin"));
|
|
newSash.BottomRailElemDimList.ElementAt(i).SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(newSash.BottomRailElemDimList.ElementAt(i).sName + "_DimMax"));
|
|
}
|
|
}
|
|
if (m_nBottomRailQty > 0)
|
|
{
|
|
newSash.BottomRailElemDimList.Add(new ElementDimension(newSash, BottomRailElemDimList.Last().Index, BottomRailElemDimList.Last().Value));
|
|
newSash.BottomRailElemDimList.Last().SetNameElement("Sash_Fill_Rail");
|
|
newSash.BottomRailElemDimList.Last().SetMinDimension(Window.m_ParameterList.GetValueOrDefault(newSash.BottomRailElemDimList.Last().sName + "_DimMin"));
|
|
newSash.BottomRailElemDimList.Last().SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(newSash.BottomRailElemDimList.Last().sName + "_DimMax"));
|
|
}
|
|
for (var SashIndex = 0; SashIndex <= m_SashList.Count - 1; SashIndex++)
|
|
{
|
|
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(newSash));
|
|
foreach (var ElementDimension in m_SashList[SashIndex].ElementDimensionList)
|
|
newSash.SashList[SashIndex].ElementDimensionList.Add(ElementDimension.Deserialize(newSash));
|
|
}
|
|
newSash.SetSelFamilyHardwareFromIndex(Hardware);
|
|
//newSash.ReqRefreshShape();
|
|
newSash.SetSelHardwareFromId(Hardware);
|
|
foreach (var HwOption in m_HwOptionList)
|
|
newSash.SelHwOptionList.Add(HwOption.Name, HwOption.Value);
|
|
//if (ArcElement != null)
|
|
// newSash.SetSashArcElem(ArcElement.Deserialize(newSash, ParentWindow));
|
|
foreach (var Area in AreaList)
|
|
{
|
|
var AreaDeserealized = Area.Deserialize(newSash, ParentWindow);
|
|
if (AreaDeserealized != null)
|
|
{
|
|
newSash.AreaList.Add(AreaDeserealized);
|
|
}
|
|
}
|
|
return newSash;
|
|
}
|
|
}
|
|
|
|
public class JsonSplit : JsonArea
|
|
{
|
|
protected SplitShapes m_SplitShape;
|
|
[JsonProperty]
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
internal SplitShapes SplitShape
|
|
{
|
|
get
|
|
{
|
|
return m_SplitShape;
|
|
}
|
|
set
|
|
{
|
|
m_SplitShape = value;
|
|
}
|
|
}
|
|
|
|
protected bool m_SplitStartVert;
|
|
[JsonProperty]
|
|
public bool SplitStartVert
|
|
{
|
|
get
|
|
{
|
|
return m_SplitStartVert;
|
|
}
|
|
set
|
|
{
|
|
m_SplitStartVert = value;
|
|
}
|
|
}
|
|
|
|
protected List<JsonSplitDimension> m_SplitVertList = new List<JsonSplitDimension>();
|
|
[JsonProperty]
|
|
public List<JsonSplitDimension> SplitVertList
|
|
{
|
|
get
|
|
{
|
|
return m_SplitVertList;
|
|
}
|
|
set
|
|
{
|
|
m_SplitVertList = value;
|
|
}
|
|
}
|
|
|
|
protected List<JsonSplitDimension> m_SplitHorizList = new List<JsonSplitDimension>();
|
|
[JsonProperty]
|
|
public List<JsonSplitDimension> SplitHorizList
|
|
{
|
|
get
|
|
{
|
|
return m_SplitHorizList;
|
|
}
|
|
set
|
|
{
|
|
m_SplitHorizList = value;
|
|
}
|
|
}
|
|
|
|
|
|
protected List<JsonSplitElementDimension> m_ElemDimVertList = new List<JsonSplitElementDimension>();
|
|
[JsonProperty]
|
|
public List<JsonSplitElementDimension> ElementDimVertList
|
|
{
|
|
get
|
|
{
|
|
return m_ElemDimVertList;
|
|
}
|
|
}
|
|
|
|
protected List<JsonSplitElementDimension> m_ElemDimHorizList = new List<JsonSplitElementDimension>();
|
|
[JsonProperty]
|
|
public List<JsonSplitElementDimension> ElementDimHorizList
|
|
{
|
|
get
|
|
{
|
|
return m_ElemDimHorizList;
|
|
}
|
|
}
|
|
public JsonSplit() : base(AreaTypes.SPLIT)
|
|
{
|
|
}
|
|
|
|
public JsonSplit(SplitShapes SplitShape, int GroupId) : base(AreaTypes.SPLIT)
|
|
{
|
|
m_SplitShape = SplitShape;
|
|
base.GroupId = GroupId;
|
|
}
|
|
|
|
internal override Area Deserialize(Area ParentArea, Window ParentWindow)
|
|
{
|
|
Split split = new Split(ParentArea, ParentWindow);
|
|
split.SetGroupId(GroupId);
|
|
split.SetAreaType(AreaTypes.SPLIT);
|
|
split.SetSplitShape(m_SplitShape);
|
|
split.SetSplitStartVert(m_SplitStartVert);
|
|
if (m_SplitVertList.Count == 0)
|
|
split.SetSplitQtyVert(0, m_SplitHorizList.Count - 1);
|
|
else
|
|
{
|
|
split.SetSplitQtyVert(m_SplitVertList.Count - 1, m_SplitHorizList.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);
|
|
}
|
|
int subAreaMin = ElementDimVertList.Min(x => x.Area);
|
|
List<JsonSplitElementDimension> vertList = ElementDimVertList.Where(x => x.Area == subAreaMin).ToList();
|
|
for (int index = 0; index < vertList.Count; index++)
|
|
{
|
|
split.ElemDimVertList.ElementAt(index).SetSubArea(m_ElemDimVertList[index].Area);
|
|
split.ElemDimVertList.ElementAt(index).SetIndex(m_ElemDimVertList[index].Index);
|
|
split.ElemDimVertList.ElementAt(index).SetDimension(m_ElemDimVertList[index].Value);
|
|
}
|
|
}
|
|
if (m_SplitHorizList.Count == 0)
|
|
split.SetSplitQtyHoriz(0, m_SplitVertList.Count);
|
|
else
|
|
{
|
|
split.SetSplitQtyHoriz(m_SplitHorizList.Count - 1, m_SplitVertList.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);
|
|
}
|
|
int subAreaMin = ElementDimHorizList.Min(x => x.Area);
|
|
List<JsonSplitElementDimension> horizList = ElementDimHorizList.Where(x => x.Area == subAreaMin).ToList();
|
|
for (int index = 0; index < horizList.Count; index++)
|
|
{
|
|
split.ElemDimHorizList.ElementAt(index).SetSubArea(m_ElemDimHorizList[index].Area);
|
|
split.ElemDimHorizList.ElementAt(index).SetIndex(m_ElemDimHorizList[index].Index);
|
|
split.ElemDimHorizList.ElementAt(index).SetDimension(m_ElemDimHorizList[index].Value);
|
|
}
|
|
}
|
|
foreach (var Area in AreaList)
|
|
{
|
|
var AreaDeserealized = Area.Deserialize(split, ParentWindow);
|
|
if (AreaDeserealized != null)
|
|
{
|
|
split.AreaList.Add(AreaDeserealized);
|
|
}
|
|
}
|
|
return split;
|
|
}
|
|
}
|
|
|
|
public class JsonInglesina : JsonSplit
|
|
{
|
|
private SideInglesina m_Side;
|
|
[JsonProperty]
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public SideInglesina Side
|
|
{
|
|
get
|
|
{
|
|
return m_Side;
|
|
}
|
|
set
|
|
{
|
|
m_Side = value;
|
|
}
|
|
}
|
|
public JsonInglesina() : base(SplitShapes.NULL, 0)
|
|
{
|
|
AreaType = AreaTypes.INGLESINA;
|
|
}
|
|
|
|
public JsonInglesina(SideInglesina Side, SplitShapes SplitShape, int GroupId) : base(SplitShapes.NULL, GroupId)
|
|
{
|
|
m_Side = Side;
|
|
base.SplitShape = SplitShape;
|
|
AreaType = AreaTypes.INGLESINA;
|
|
base.GroupId = GroupId;
|
|
}
|
|
|
|
internal override Area Deserialize(Area ParentArea, Window ParentWindow)
|
|
{
|
|
Inglesina inglesina = new Inglesina(ParentArea, ParentWindow);
|
|
inglesina.SetGroupId(GroupId);
|
|
inglesina.SetAreaType(AreaTypes.INGLESINA);
|
|
inglesina.SetSelSide(m_Side);
|
|
inglesina.SetSplitShape(m_SplitShape);
|
|
inglesina.SetSplitStartVert(m_SplitStartVert);
|
|
if (m_SplitVertList.Count == 0)
|
|
inglesina.SetSplitQtyVert(0, m_SplitHorizList.Count - 1);
|
|
else
|
|
{
|
|
inglesina.SetSplitQtyVert(m_SplitVertList.Count - 1, m_SplitHorizList.Count - 1);
|
|
for (var SplitIndex = 0; SplitIndex <= m_SplitVertList.Count - 1; SplitIndex++)
|
|
{
|
|
inglesina.SplitVertList[SplitIndex].SetIsRelative(m_SplitVertList[SplitIndex].IsRelative);
|
|
inglesina.SplitVertList[SplitIndex].SetDimension(m_SplitVertList[SplitIndex].Dimension);
|
|
inglesina.SplitVertList[SplitIndex].SetMeasureType(m_SplitVertList[SplitIndex].MeasureType);
|
|
}
|
|
int subAreaMin = ElementDimVertList.Min(x => x.Area);
|
|
List<JsonSplitElementDimension> vertList = ElementDimVertList.Where(x => x.Area == subAreaMin).ToList();
|
|
for (int index = 0; index < vertList.Count; index++)
|
|
{
|
|
inglesina.ElemDimVertList.ElementAt(index).SetSubArea(m_ElemDimVertList[index].Area);
|
|
inglesina.ElemDimVertList.ElementAt(index).SetIndex(m_ElemDimVertList[index].Index);
|
|
inglesina.ElemDimVertList.ElementAt(index).SetDimension(m_ElemDimVertList[index].Value);
|
|
}
|
|
}
|
|
if (m_SplitHorizList.Count == 0)
|
|
inglesina.SetSplitQtyHoriz(0, m_SplitVertList.Count);
|
|
else
|
|
{
|
|
inglesina.SetSplitQtyHoriz(m_SplitHorizList.Count - 1, m_SplitVertList.Count - 1);
|
|
for (var SplitIndex = 0; SplitIndex <= m_SplitHorizList.Count - 1; SplitIndex++)
|
|
{
|
|
inglesina.SplitHorizList[SplitIndex].SetIsRelative(m_SplitHorizList[SplitIndex].IsRelative);
|
|
inglesina.SplitHorizList[SplitIndex].SetDimension(m_SplitHorizList[SplitIndex].Dimension);
|
|
inglesina.SplitHorizList[SplitIndex].SetMeasureType(m_SplitHorizList[SplitIndex].MeasureType);
|
|
}
|
|
int subAreaMin = ElementDimHorizList.Min(x => x.Area);
|
|
List<JsonSplitElementDimension> horizList = ElementDimHorizList.Where(x => x.Area == subAreaMin).ToList();
|
|
for (int index = 0; index < horizList.Count; index++)
|
|
{
|
|
inglesina.ElemDimHorizList.ElementAt(index).SetSubArea(m_ElemDimHorizList[index].Area);
|
|
inglesina.ElemDimHorizList.ElementAt(index).SetIndex(m_ElemDimHorizList[index].Index);
|
|
inglesina.ElemDimHorizList.ElementAt(index).SetDimension(m_ElemDimHorizList[index].Value);
|
|
}
|
|
}
|
|
foreach (var Area in AreaList)
|
|
{
|
|
var AreaDeserealized = Area.Deserialize(inglesina, ParentWindow);
|
|
if (AreaDeserealized != null)
|
|
{
|
|
inglesina.AreaList.Add(AreaDeserealized);
|
|
}
|
|
}
|
|
return inglesina;
|
|
}
|
|
}
|
|
|
|
public class JsonSplitted : JsonArea
|
|
{
|
|
public JsonSplitted() : base(AreaTypes.SPLITTED)
|
|
{
|
|
}
|
|
public JsonSplitted(int GroupId) : base(AreaTypes.SPLITTED)
|
|
{
|
|
base.GroupId = GroupId;
|
|
}
|
|
|
|
internal override Area Deserialize(Area ParentArea, Window ParentWindow)
|
|
{
|
|
Splitted newSplitted = new Splitted(ParentArea, ParentWindow);
|
|
newSplitted.SetGroupId(GroupId);
|
|
newSplitted.SetAreaType(AreaTypes.SPLITTED);
|
|
//Split.AppliedDone();
|
|
foreach (var Area in AreaList)
|
|
{
|
|
var AreaDeserealized = Area.Deserialize(newSplitted, ParentWindow);
|
|
if (AreaDeserealized != null)
|
|
{
|
|
newSplitted.AreaList.Add(AreaDeserealized);
|
|
}
|
|
}
|
|
|
|
return newSplitted;
|
|
}
|
|
}
|
|
|
|
public class JsonFill : JsonArea
|
|
{
|
|
private FillTypes m_FillType;
|
|
[JsonProperty]
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public FillTypes FillType
|
|
{
|
|
get
|
|
{
|
|
return m_FillType;
|
|
}
|
|
set
|
|
{
|
|
m_FillType = value;
|
|
}
|
|
}
|
|
|
|
public JsonFill() : base(AreaTypes.FILL)
|
|
{
|
|
}
|
|
|
|
public JsonFill(FillTypes FillType, int GroupId) : base(AreaTypes.FILL)
|
|
{
|
|
m_FillType = FillType;
|
|
base.GroupId = GroupId;
|
|
}
|
|
|
|
internal override Area Deserialize(Area ParentArea, Window ParentWindow)
|
|
{
|
|
Fill Fill = new Fill(ParentArea, ParentWindow);
|
|
Fill.SetGroupId(GroupId);
|
|
Fill.SetAreaType(AreaTypes.FILL);
|
|
Fill.SetFillType(m_FillType);
|
|
//Fill.AppliedDone();
|
|
foreach (var Area in AreaList)
|
|
{
|
|
var AreaDeserealized = Area.Deserialize(Fill, ParentWindow);
|
|
if (AreaDeserealized != null)
|
|
{
|
|
Fill.AreaList.Add(AreaDeserealized);
|
|
}
|
|
}
|
|
return Fill;
|
|
}
|
|
}
|
|
|
|
//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;
|
|
[JsonProperty]
|
|
public int Index
|
|
{
|
|
get
|
|
{
|
|
return m_nIndex;
|
|
}
|
|
}
|
|
|
|
private Joints m_JointType;
|
|
[JsonProperty]
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public Joints JointType
|
|
{
|
|
get
|
|
{
|
|
return m_JointType;
|
|
}
|
|
set
|
|
{
|
|
m_JointType = value;
|
|
}
|
|
}
|
|
|
|
public JsonJoint(int Index, Joints JointType)
|
|
{
|
|
m_nIndex = Index;
|
|
m_JointType = JointType;
|
|
}
|
|
|
|
internal Joint Deserialize(Area newArea)
|
|
{
|
|
Joint newJoint = new Joint(newArea, m_nIndex, m_JointType);
|
|
return newJoint;
|
|
}
|
|
}
|
|
|
|
public class JsonHwOption
|
|
{
|
|
private string m_Name;
|
|
[JsonProperty]
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
return m_Name;
|
|
}
|
|
set
|
|
{
|
|
m_Name = value;
|
|
}
|
|
}
|
|
|
|
private string m_Value;
|
|
[JsonProperty]
|
|
public string Value
|
|
{
|
|
get
|
|
{
|
|
return m_Value;
|
|
}
|
|
set
|
|
{
|
|
m_Value = value;
|
|
}
|
|
}
|
|
|
|
public JsonHwOption(string Name, string Value)
|
|
{
|
|
m_Name = Name;
|
|
m_Value = Value;
|
|
}
|
|
|
|
//internal AGBOption Deserialize()
|
|
//{
|
|
// AGBOption newOption = new AGBOption(m_Name, m_Value);
|
|
// return newOption;
|
|
//}
|
|
|
|
}
|
|
|
|
public class JsonElementDimension
|
|
{
|
|
private int m_nIndex;
|
|
[JsonProperty]
|
|
public int Index
|
|
{
|
|
get
|
|
{
|
|
return m_nIndex;
|
|
}
|
|
}
|
|
|
|
private double m_dValue;
|
|
[JsonProperty]
|
|
public double Value
|
|
{
|
|
get
|
|
{
|
|
return m_dValue;
|
|
}
|
|
set
|
|
{
|
|
m_dValue = value;
|
|
}
|
|
}
|
|
|
|
public JsonElementDimension(int Index, double Value)
|
|
{
|
|
m_nIndex = Index;
|
|
m_dValue = Value;
|
|
}
|
|
|
|
internal ElementDimension Deserialize(Area newArea)
|
|
{
|
|
ElementDimension newElementDimension = new ElementDimension(newArea, m_nIndex, m_dValue);
|
|
return newElementDimension;
|
|
}
|
|
}
|
|
public class JsonSplitElementDimension
|
|
{
|
|
private int m_nIndex;
|
|
[JsonProperty]
|
|
public int Index
|
|
{
|
|
get
|
|
{
|
|
return m_nIndex;
|
|
}
|
|
}
|
|
|
|
private double m_dValue;
|
|
[JsonProperty]
|
|
public double Value
|
|
{
|
|
get
|
|
{
|
|
return m_dValue;
|
|
}
|
|
set
|
|
{
|
|
m_dValue = value;
|
|
}
|
|
}
|
|
|
|
private int m_nSubArea;
|
|
[JsonProperty]
|
|
public int Area
|
|
{
|
|
get
|
|
{
|
|
return m_nSubArea;
|
|
}
|
|
set
|
|
{
|
|
m_nSubArea = value;
|
|
}
|
|
}
|
|
|
|
public JsonSplitElementDimension(int Index, double Value, int SubArea)
|
|
{
|
|
m_nIndex = Index;
|
|
m_dValue = Value;
|
|
m_nSubArea = SubArea;
|
|
}
|
|
|
|
internal SplitElementDimension Deserialize(Area newArea)
|
|
{
|
|
SplitElementDimension newSplitElementDimension = new SplitElementDimension(newArea, m_nIndex, m_dValue, m_nSubArea);
|
|
return newSplitElementDimension;
|
|
}
|
|
}
|
|
public class JsonFrameDimension
|
|
{
|
|
private int m_nIndex;
|
|
[JsonProperty]
|
|
public int Index
|
|
{
|
|
get
|
|
{
|
|
return m_nIndex;
|
|
}
|
|
}
|
|
|
|
private string m_sName;
|
|
[JsonProperty]
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
return m_sName;
|
|
}
|
|
}
|
|
|
|
private double m_dValue;
|
|
[JsonProperty]
|
|
public double Value
|
|
{
|
|
get
|
|
{
|
|
return m_dValue;
|
|
}
|
|
set
|
|
{
|
|
m_dValue = value;
|
|
}
|
|
}
|
|
|
|
public JsonFrameDimension(int Index, string Name, double Value)
|
|
{
|
|
m_nIndex = Index;
|
|
m_sName = Name;
|
|
m_dValue = Value;
|
|
}
|
|
}
|
|
|
|
public class JsonSashDimension
|
|
{
|
|
private int m_nSashId;
|
|
[JsonProperty]
|
|
public int SashId
|
|
{
|
|
get
|
|
{
|
|
return m_nSashId;
|
|
}
|
|
}
|
|
|
|
private Openings m_OpeningType;
|
|
[JsonProperty]
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public Openings OpeningType
|
|
{
|
|
get
|
|
{
|
|
return m_OpeningType;
|
|
}
|
|
}
|
|
|
|
private MeasureTypes m_MeasureType;
|
|
[JsonProperty]
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public MeasureTypes MeasureType
|
|
{
|
|
get
|
|
{
|
|
return m_MeasureType;
|
|
}
|
|
}
|
|
|
|
private double m_dDimension;
|
|
[JsonProperty]
|
|
public double Dimension
|
|
{
|
|
get
|
|
{
|
|
return m_dDimension;
|
|
}
|
|
set
|
|
{
|
|
m_dDimension = value;
|
|
}
|
|
}
|
|
|
|
private bool m_bHasHandle;
|
|
[JsonProperty]
|
|
public bool HasHandle
|
|
{
|
|
get
|
|
{
|
|
return m_bHasHandle;
|
|
}
|
|
set
|
|
{
|
|
m_bHasHandle = value;
|
|
}
|
|
}
|
|
|
|
private List<JsonElementDimension> m_ElementDimensionList = new List<JsonElementDimension>();
|
|
[JsonProperty]
|
|
public List<JsonElementDimension> ElementDimensionList
|
|
{
|
|
get
|
|
{
|
|
return m_ElementDimensionList;
|
|
}
|
|
}
|
|
|
|
private List<JsonJoint> m_JointList = new List<JsonJoint>();
|
|
[JsonProperty]
|
|
public List<JsonJoint> 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;
|
|
}
|
|
}
|
|
|
|
public class JsonSplitDimension
|
|
{
|
|
private bool m_bIsRelative = false;
|
|
[JsonProperty]
|
|
public bool IsRelative
|
|
{
|
|
get
|
|
{
|
|
return m_bIsRelative;
|
|
}
|
|
}
|
|
|
|
private double m_dDimension;
|
|
[JsonProperty]
|
|
public double Dimension
|
|
{
|
|
get
|
|
{
|
|
return m_dDimension;
|
|
}
|
|
set
|
|
{
|
|
m_dDimension = value;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
public class PolymorphicJsonConverter : JsonConverter
|
|
{
|
|
public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
|
|
{
|
|
// disambiguo il tipo JsonArea grazie al capo AreaType nelle classi giuste, e le popolo di dati
|
|
JObject item = JObject.Load(reader);
|
|
var RawType = (string?)item["AreaType"];
|
|
AreaTypes Type = AreaTypes.NULL;
|
|
Enum.TryParse<AreaTypes>(RawType, out Type);
|
|
JsonArea JsonArea = new JsonArea(AreaTypes.NULL);
|
|
switch (Type)
|
|
{
|
|
case AreaTypes.FRAME:
|
|
{
|
|
JsonArea = new JsonFrame();
|
|
break;
|
|
}
|
|
|
|
case AreaTypes.SASH:
|
|
{
|
|
JsonArea = new JsonSash();
|
|
break;
|
|
}
|
|
|
|
case AreaTypes.FILL:
|
|
{
|
|
JsonArea = new JsonFill();
|
|
break;
|
|
}
|
|
|
|
case AreaTypes.SPLIT:
|
|
{
|
|
JsonArea = new JsonSplit();
|
|
break;
|
|
}
|
|
|
|
case AreaTypes.INGLESINA:
|
|
{
|
|
JsonArea = new JsonInglesina();
|
|
break;
|
|
}
|
|
|
|
case AreaTypes.SPLITTED:
|
|
{
|
|
JsonArea = new JsonSplitted();
|
|
break;
|
|
}
|
|
}
|
|
if (!Information.IsNothing(JsonArea))
|
|
serializer.Populate(item.CreateReader(), JsonArea!);
|
|
return JsonArea!;
|
|
}
|
|
|
|
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override bool CanConvert(Type objectType)
|
|
{
|
|
// gestisco solo i tipi dericati da JsonArea
|
|
return typeof(JsonArea).IsAssignableFrom(objectType);
|
|
}
|
|
}
|
|
}
|