Files
webwindowconfigurator/WebWindowComplex/Models/Frame.cs
T
2025-11-05 16:12:43 +01:00

428 lines
16 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebWindowComplex.Json;
using static WebWindowComplex.Json.WindowConst;
namespace WebWindowComplex.Models
{
public class Frame : Area
{
#region Public Constructors
public Frame(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow)
{
}
#endregion Public Constructors
#region Public Properties
public bool BottomRail
{
get
{
return m_bBottomRail;
}
set
{
m_bBottomRail = value;
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
}
}
public int BottomRailQty
{
get
{
return m_nBottomRailQty;
}
set
{
if (m_nBottomRailQty >= 0)
{
m_nBottomRailQty = value;
if (m_nBottomRailQty > 0)
{
m_bBottomRail = true;
}
else
{
m_bBottomRail = false;
}
}
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
}
}
public List<FrameDimension> DimensionList
{
get => m_DimensionList;
set => m_DimensionList = value;
}
public List<Joint> JointList
{
get
{
return m_JointList;
}
set
{
m_JointList = value;
}
}
public int SelShapeIndex
{
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)
{
// salvo vecchie dimensioni
List<FrameDimension> oldDimensionList = new List<FrameDimension>(DimensionList);
// verifico parametri Dimension
DimensionList.Clear();
double widthVal = oldDimensionList.Where(x => x.sName.Equals("Width")).Select(x => x.dValue).First();
// aggiungo Dimensioni
switch (SelShape)
{
case Shapes.RECTANGLE:
case Shapes.ARC_FULL:
{
DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true));
DimensionList.Add(new FrameDimension(this, 2, "Height", 1800, true));
break;
}
case Shapes.RIGHTCHAMFER:
{
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));
break;
}
case Shapes.LEFTCHAMFER:
{
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));
break;
}
case Shapes.DOUBLECHAMFER:
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, 3, "Full Height", 1800, true));
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, 3, "Full Height", 2400, true));
break;
}
case Shapes.THREECENTERARC:
{
DimensionList.Add(new FrameDimension(this, 1, "Width", 2000, true));
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));
break;
}
case Shapes.TRIANGLE:
{
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));
break;
}
case Shapes.CUSTOM:
{
DimensionList.Clear();
break;
}
}
// salvo tipo Joint
List<Joint> oldJointType = new List<Joint>(JointList);
// aggiungo Joint
m_JointList.Clear();
switch (SelShape)
{
case Shapes.RECTANGLE:
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));
break;
}
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.THREECENTERARC:
{
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.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));
break;
}
case Shapes.CUSTOM:
{
JointList.Clear();
break;
}
}
m_Shape = SelShape;
}
//m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
}
}
public Shapes Shape
{
get
{
return m_Shape;
}
}
public List<IdNameStruct> ShapeList
{
get
{
return m_ShapeList;
}
}
#endregion Public Properties
#region Public Methods
public override Frame Copy(Area ParentArea)
{
return null;
}
#endregion Public Methods
#region Internal Methods
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;
}
internal override JsonArea Serialize(bool hideHw)
{
Area.nCounterGroup = 0;
if (nCounterGroup < GroupId)
Area.nCounterGroup = GroupId;
JsonFrame JsonFrame = new JsonFrame(m_Shape, m_bBottomRail, m_nBottomRailQty, GroupId);
foreach (var Dimension in DimensionList)
JsonFrame.DimensionList.Add(Dimension.Serialize());
foreach (var Joint in JointList)
JsonFrame.JointList.Add(Joint.Serialize());
foreach (var Area in AreaList)
JsonFrame.AreaList.Add(Area.Serialize(hideHw));
return JsonFrame;
}
internal void SetBottomRail(bool bBottomRail)
{
m_bBottomRail = bBottomRail;
}
internal void SetBottomRailQty(int nBottomRailQty)
{
m_nBottomRailQty = nBottomRailQty;
}
internal void SetSelShape(Shapes Value)
{
DimensionList.Clear();
// aggiungo Dimension
switch (Value)
{
case Shapes.RECTANGLE:
case Shapes.ARC_FULL:
{
DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true));
DimensionList.Add(new FrameDimension(this, 2, "Height", 1800, true));
break;
}
case Shapes.RIGHTCHAMFER:
{
DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true));
DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1800, true));
DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1500, true));
break;
}
case Shapes.LEFTCHAMFER:
{
DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true));
DimensionList.Add(new FrameDimension(this, 2, "Left Height", 1500, true));
DimensionList.Add(new FrameDimension(this, 3, "Right Height", 1800, true));
break;
}
case Shapes.DOUBLECHAMFER:
case Shapes.ARC:
{
DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true));
DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true));
DimensionList.Add(new FrameDimension(this, 3, "Full Height", 1800, true));
break;
}
case Shapes.DOUBLEARC:
{
DimensionList.Add(new FrameDimension(this, 1, "Width", 1500, true));
DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true));
DimensionList.Add(new FrameDimension(this, 3, "Full Height", 2400, true));
break;
}
case Shapes.THREECENTERARC:
{
DimensionList.Add(new FrameDimension(this, 1, "Width", 800, true));
DimensionList.Add(new FrameDimension(this, 2, "Height", 2100, true));
DimensionList.Add(new FrameDimension(this, 3, "Full Height", 2400, true));
DimensionList.Add(new FrameDimension(this, 4, "Radius", 100, true));
break;
}
case Shapes.TRIANGLE:
{
DimensionList.Add(new FrameDimension(this, 1, "Width", 2000, true));
DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true));
DimensionList.Add(new FrameDimension(this, 3, "Height projection", 0, true));
break;
}
case Shapes.CUSTOM:
{
DimensionList.Clear();
break;
}
}
// aggiungo Joint
//int nJointQty = 4;
switch (Value)
{
case Shapes.RECTANGLE:
case Shapes.RIGHTCHAMFER:
case Shapes.LEFTCHAMFER:
case Shapes.DOUBLECHAMFER:
case Shapes.ARC:
case Shapes.DOUBLEARC:
{
JointList.Add(new Joint(this, 1, Joints.FULL_H));
JointList.Add(new Joint(this, 2, Joints.FULL_H));
JointList.Add(new Joint(this, 3, Joints.FULL_H));
JointList.Add(new Joint(this, 4, Joints.FULL_H));
break;
}
case Shapes.ARC_FULL:
case Shapes.THREECENTERARC:
{
JointList.Add(new Joint(this, 1, Joints.FULL_H));
JointList.Add(new Joint(this, 2, Joints.FULL_H));
JointList.Add(new Joint(this, 3, Joints.ANGLED));
JointList.Add(new Joint(this, 4, Joints.ANGLED));
break;
}
case Shapes.TRIANGLE:
{
JointList.Add(new Joint(this, 1, Joints.FULL_H));
JointList.Add(new Joint(this, 2, Joints.FULL_H));
JointList.Add(new Joint(this, 3, Joints.ANGLED));
break;
}
case Shapes.CUSTOM:
{
JointList.Clear();
break;
}
}
m_Shape = Value;
}
#endregion Internal Methods
#region Private Fields
private bool m_bBottomRail;
private List<FrameDimension> m_DimensionList = new List<FrameDimension>();
private List<Joint> m_JointList = new List<Joint>();
private int m_nBottomRailQty = 0;
private Shapes m_Shape;
private List<IdNameStruct> m_ShapeList = new List<IdNameStruct>
{
new IdNameStruct((int)Shapes.RECTANGLE, "Rectangle"),
new IdNameStruct((int)Shapes.RIGHTCHAMFER, "Right Chamfer"),
new IdNameStruct((int)Shapes.LEFTCHAMFER, "Left Chamfer"),
new IdNameStruct((int)Shapes.DOUBLECHAMFER, "Double Chamfer"),
new IdNameStruct((int)Shapes.ARC, "Arc"),
new IdNameStruct((int)Shapes.ARC_FULL, "Arc Full"),
new IdNameStruct((int)Shapes.DOUBLEARC, "Double Arc"),
new IdNameStruct((int)Shapes.THREECENTERARC, "Three Center Arc"),
new IdNameStruct((int)Shapes.TRIANGLE, "Triangle")
};
#endregion Private Fields
}
}