Inizio spacchettamento file window delle classi di base del modello
This commit is contained in:
@@ -0,0 +1,264 @@
|
||||
using WebWindowComplex.Json;
|
||||
using static WebWindowComplex.Json.WindowConst;
|
||||
|
||||
namespace WebWindowComplex.Models
|
||||
{
|
||||
public abstract class Area
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public Area(Area ParentArea, Window ParentWindow)
|
||||
{
|
||||
m_ParentWindow = ParentWindow;
|
||||
m_ParentArea = ParentArea;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static int nCounterGroup
|
||||
{
|
||||
get => m_CounterGroup;
|
||||
set => m_CounterGroup = value;
|
||||
}
|
||||
|
||||
public List<Area> AreaList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_AreaList;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_AreaList = value;
|
||||
}
|
||||
}
|
||||
|
||||
public AreaTypes AreaType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_AreaType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_AreaType = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int IdGroup
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_IdGroup;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
m_IdGroup = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int nAreaId
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_nAreaId;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_nAreaId = value;
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
public Area ParentArea
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ParentArea;
|
||||
}
|
||||
}
|
||||
|
||||
public Window ParentWindow
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ParentWindow;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public static void AddCounterGroup()
|
||||
{
|
||||
m_CounterGroup++;
|
||||
}
|
||||
|
||||
public bool AddFirstSash()
|
||||
{
|
||||
bool answ = false;
|
||||
// Salvo il parent
|
||||
Area ParentArea = AreaList[0].ParentArea;
|
||||
// Creo area sash di default
|
||||
Sash SashArea = Sash.CreateSash(ParentArea);
|
||||
// ricerco tra ttuti gli hw disponibili...
|
||||
string sShape = FindSashShape();
|
||||
var listHwValid = Sash
|
||||
.m_HardwareCompleteList
|
||||
.Where(x => x.Shape == sShape && x.SashQty == 1)
|
||||
.FirstOrDefault();
|
||||
if (listHwValid != null)
|
||||
{
|
||||
// seleziono la famiglia del primo hw trovato...
|
||||
SashArea.SelFamilyHardware = listHwValid.FamilyName;
|
||||
SashArea.RefreshHardwareList();
|
||||
if (SashArea.HardwareList.Count == 0)
|
||||
{
|
||||
SashArea.Remove();
|
||||
answ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SashArea.SetSelHardwareFromId(SashArea.HardwareList.First().Id);
|
||||
// Salvo gli oggetti già presenti e li cancello da AreaList
|
||||
List<Area> ContentArea = new List<Area>();
|
||||
ContentArea.Add(AreaList[0]);
|
||||
AreaList.Remove(AreaList[0]);
|
||||
// Aggiungo area
|
||||
AreaList.Add(SashArea);
|
||||
if (SashArea.nSashQty == 1)
|
||||
{
|
||||
// Inserisco il riempimento precedente
|
||||
AreaList[0].AreaList.Add(ContentArea[0]);
|
||||
AreaList[0].AreaList[0].SetParentArea(AreaList[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// All'area Sash aggiunto uno Splitted per ogni anta
|
||||
for (int i = 1; i < SashArea.nSashQty; i++)
|
||||
{
|
||||
AreaList[0].AreaList.Add(Splitted.CreateSplitted(SashArea));
|
||||
}
|
||||
Fill fill2 = (Fill)ContentArea[0];
|
||||
for (int i = 1; i < SashArea.nSashQty; i++)
|
||||
{
|
||||
AreaList[0].AreaList[1].AreaList.Add(Fill.CreateFill(AreaList[0].AreaList[1], fill2.FillType));
|
||||
}
|
||||
}
|
||||
ParentWindow.OnUpdatePreview(ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void AddSplit(Area ParentArea)
|
||||
{
|
||||
List<Area> ContentArea = new List<Area>();
|
||||
// Salvo gli oggetti già presenti e li cancello da AreaList
|
||||
ContentArea.Add(AreaList[0]);
|
||||
AreaList.Remove(AreaList[0]);
|
||||
// Aggiungo Area split di default
|
||||
Split SplitArea = Split.CreateSplit(this, SplitShapes.HORIZONTAL);
|
||||
// imposto i parametri di default
|
||||
SplitArea.SetSplitQtyHoriz(1);
|
||||
SplitArea.SetSplitStartVert(false);
|
||||
// Aggiungo area
|
||||
AreaList.Add(SplitArea);
|
||||
// Creo le due aree Splitted
|
||||
List<Splitted> newSplittedList = new List<Splitted>();
|
||||
for (int i = 0; i < 2; i++)
|
||||
newSplittedList.Add(Splitted.CreateSplitted(SplitArea));
|
||||
// Inserisco nelle aree Splitted il Fill salvato e un Fill uguale (e setto ParentArea del fill)
|
||||
ContentArea[0].SetParentArea(newSplittedList[0]);
|
||||
newSplittedList[0].AreaList.Add(ContentArea[0]);
|
||||
if (ContentArea[0] is Fill)
|
||||
{
|
||||
Fill fill1 = (Fill)ContentArea[0];
|
||||
Fill fill2 = Fill.CreateFill(newSplittedList[1], fill1.FillType);
|
||||
newSplittedList[1].AreaList.Add(fill2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Fill fill2 = Fill.CreateFill(newSplittedList[1], FillTypes.GLASS);
|
||||
newSplittedList[1].AreaList.Add(fill2);
|
||||
}
|
||||
// All'area Split aggiunto le due aree Splitted
|
||||
for (int i = 0; i < 2; i++)
|
||||
AreaList[0].AreaList.Add(newSplittedList[i]);
|
||||
ParentWindow.OnUpdatePreview(ParentWindow.sSerialized());
|
||||
}
|
||||
|
||||
public abstract Area Copy(Area ParentArea);
|
||||
|
||||
public void SetIdGroup(int nIdGroup)
|
||||
{
|
||||
m_IdGroup = nIdGroup;
|
||||
}
|
||||
|
||||
public void SwapAree()
|
||||
{
|
||||
Area tempArea;
|
||||
if (this is Sash || this is Split)
|
||||
{
|
||||
tempArea = AreaList[0];
|
||||
AreaList[0] = AreaList[1];
|
||||
AreaList[1] = tempArea;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal abstract JsonArea Serialize();
|
||||
|
||||
internal void SetAreaType(AreaTypes AreaType)
|
||||
{
|
||||
m_AreaType = AreaType;
|
||||
}
|
||||
|
||||
internal void SetParentArea(Area ParentArea)
|
||||
{
|
||||
m_ParentArea = ParentArea;
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int m_nAreaId = -1;
|
||||
|
||||
protected Window m_ParentWindow;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
// Conteggio dei macro elementi
|
||||
private static int m_CounterGroup = 0;
|
||||
|
||||
private List<Area> m_AreaList = new List<Area>();
|
||||
private AreaTypes m_AreaType;
|
||||
private int m_IdGroup;
|
||||
private Area m_ParentArea;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// MockUp chiamata a c++ x scelta forma sash per Hw
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string FindSashShape()
|
||||
{
|
||||
return "Rectangular";
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
using WebWindowComplex.Json;
|
||||
using static WebWindowComplex.Json.WindowConst;
|
||||
|
||||
namespace WebWindowComplex.Models
|
||||
{
|
||||
public class Fill : Area
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public Fill(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public FillTypes FillType
|
||||
{
|
||||
get
|
||||
{
|
||||
return (FillTypes)m_SelFillType;
|
||||
}
|
||||
}
|
||||
|
||||
public List<IdNameStruct> FillTypeList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_FillTypeList;
|
||||
}
|
||||
}
|
||||
|
||||
public FillTypes SelFillType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SelFillType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelFillType = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int SelFillTypeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return IdNameStruct.IndFromId((int)m_SelFillType, m_FillTypeList);
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelFillType = (FillTypes)IdNameStruct.IdFromInd(value, m_FillTypeList);
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public override Fill Copy(Area newParentArea)
|
||||
{
|
||||
Fill newFill = new Fill(newParentArea, m_ParentWindow);
|
||||
AddCounterGroup();
|
||||
newFill.SetIdGroup(nCounterGroup);
|
||||
newFill.SetFillType(SelFillType);
|
||||
newFill.SetAreaType(AreaType);
|
||||
return newFill;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal static Fill CreateFill(Area AreaParent, FillTypes FillType)
|
||||
{
|
||||
Fill Fill = new Fill(AreaParent, AreaParent.ParentWindow);
|
||||
AddCounterGroup();
|
||||
Fill.SetIdGroup(nCounterGroup);
|
||||
Fill.SetAreaType(AreaTypes.FILL);
|
||||
Fill.SetFillType(FillType);
|
||||
return Fill;
|
||||
}
|
||||
|
||||
internal override JsonArea Serialize()
|
||||
{
|
||||
if (nCounterGroup < IdGroup)
|
||||
Area.nCounterGroup = IdGroup;
|
||||
JsonFill JsonFill = new JsonFill(FillType, IdGroup);
|
||||
foreach (var Area in AreaList)
|
||||
JsonFill.AreaList.Add(Area.Serialize());
|
||||
return JsonFill;
|
||||
}
|
||||
|
||||
internal void SetFillType(FillTypes value)
|
||||
{
|
||||
m_SelFillType = value;
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private List<IdNameStruct> m_FillTypeList = new List<IdNameStruct>
|
||||
{
|
||||
new IdNameStruct((int)FillTypes.GLASS, "SvgPreview"),
|
||||
new IdNameStruct((int)FillTypes.WOOD, "Wood")
|
||||
};
|
||||
|
||||
private FillTypes m_SelFillType;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,397 @@
|
||||
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
|
||||
{
|
||||
return m_DimensionList;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Joint> JointList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_JointList;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_JointList = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int SelShapeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return IdNameStruct.IndFromId((int)m_Shape, m_ShapeList);
|
||||
}
|
||||
set
|
||||
{
|
||||
Shapes SelShape = (Shapes)IdNameStruct.IdFromInd(value, m_ShapeList);
|
||||
if (m_Shape != SelShape)
|
||||
{
|
||||
// verifico parametri Dimension
|
||||
DimensionList.Clear();
|
||||
// aggiungo Dimensioni
|
||||
switch (SelShape)
|
||||
{
|
||||
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.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;
|
||||
}
|
||||
}
|
||||
// salvo tipo Joint
|
||||
Joints oldJointType = JointList[0].SelJointType;
|
||||
// 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));
|
||||
JointList.Add(new Joint(this, 2, oldJointType));
|
||||
JointList.Add(new Joint(this, 3, oldJointType));
|
||||
JointList.Add(new Joint(this, 4, oldJointType));
|
||||
break;
|
||||
}
|
||||
|
||||
case Shapes.ARC_FULL:
|
||||
{
|
||||
JointList.Add(new Joint(this, 1, oldJointType));
|
||||
JointList.Add(new Joint(this, 2, oldJointType));
|
||||
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));
|
||||
JointList.Add(new Joint(this, 2, oldJointType));
|
||||
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()
|
||||
{
|
||||
Area.nCounterGroup = 0;
|
||||
if (nCounterGroup < IdGroup)
|
||||
Area.nCounterGroup = IdGroup;
|
||||
JsonFrame JsonFrame = new JsonFrame(m_Shape, m_bBottomRail, m_nBottomRailQty, IdGroup);
|
||||
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());
|
||||
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.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:
|
||||
{
|
||||
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.TRIANGLE, "Triangle")
|
||||
};
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WebWindowComplex.Json;
|
||||
|
||||
namespace WebWindowComplex.Models
|
||||
{
|
||||
public class FrameDimension
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public FrameDimension(Frame ParentFrame, int nIndex, string sName, double dValue, bool bIsLen)
|
||||
{
|
||||
m_ParentFrame = ParentFrame;
|
||||
m_nIndex = nIndex;
|
||||
m_sName = sName;
|
||||
m_dValue = dValue;
|
||||
m_bIsLen = bIsLen;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public double dValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_dValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_dValue = value;
|
||||
if (value > MaxDim)
|
||||
{
|
||||
m_dValue = MaxDim;
|
||||
}
|
||||
else if (value < MinDim)
|
||||
{
|
||||
m_dValue = MinDim;
|
||||
}
|
||||
m_ParentFrame.ParentWindow.OnUpdatePreview(m_ParentFrame.ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
public int nIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_nIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public Frame ParentFrame
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ParentFrame;
|
||||
}
|
||||
}
|
||||
|
||||
public string sName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_sName;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal JsonFrameDimension Serialize()
|
||||
{
|
||||
JsonFrameDimension JsonFrameDimension = new JsonFrameDimension(m_nIndex, m_sName, m_dValue);
|
||||
return JsonFrameDimension;
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected Frame m_ParentFrame;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private bool m_bIsLen = false;
|
||||
|
||||
private double m_dValue;
|
||||
|
||||
private int m_nIndex;
|
||||
|
||||
private string m_sName;
|
||||
|
||||
// valore massimo e minimo della dimensione del frame
|
||||
private int MaxDim = 4000;
|
||||
|
||||
private int MinDim = 600;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
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 Joint
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public Joint(Area ParentArea, int nIndex, Joints SelJointType)
|
||||
{
|
||||
m_ParentArea = ParentArea;
|
||||
m_nIndex = nIndex;
|
||||
m_SelJointType = SelJointType;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public List<IdNameStruct> JointTypeList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_JointTypeList;
|
||||
}
|
||||
}
|
||||
|
||||
public int nIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_nIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public Area ParentArea
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ParentArea;
|
||||
}
|
||||
}
|
||||
|
||||
public Joints SelJointType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SelJointType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelJointType = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int SelJointTypeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return IdNameStruct.IndFromId((int)m_SelJointType, m_JointTypeList);
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelJointType = (Joints)IdNameStruct.IdFromInd(value, m_JointTypeList);
|
||||
m_ParentArea.ParentWindow.OnUpdatePreview(m_ParentArea.ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public Joint Copy()
|
||||
{
|
||||
Joint newJoint = new Joint(ParentArea, nIndex, SelJointType);
|
||||
return newJoint;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal JsonJoint Serialize()
|
||||
{
|
||||
JsonJoint JsonJoint = new JsonJoint(m_nIndex, m_SelJointType);
|
||||
return JsonJoint;
|
||||
}
|
||||
|
||||
internal void SetSelJointType(Joints value)
|
||||
{
|
||||
m_SelJointType = value;
|
||||
//NotifyPropertyChanged(nameof(SelJointTypeIndex));
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected Area m_ParentArea;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private List<IdNameStruct> m_JointTypeList = new List<IdNameStruct>
|
||||
{
|
||||
new IdNameStruct((int)Joints.ANGLED, "Angled"),
|
||||
new IdNameStruct((int)Joints.FULL_H, "Full H"),
|
||||
new IdNameStruct((int)Joints.FULL_V, "Full V")
|
||||
};
|
||||
|
||||
private int m_nIndex;
|
||||
private Joints m_SelJointType;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,801 @@
|
||||
using Egw.Window.Data;
|
||||
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 Sash : Area
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
// Lista hardware completa passata dal chiamante del componente
|
||||
public static List<Hardware> m_HardwareCompleteList = new List<Hardware>();
|
||||
|
||||
// Lista hardware completa passata dal chiamante del componente
|
||||
public static List<string> s_FamilyHardwareList = new List<string>();
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public Sash(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public bool bIsMeasureGlass
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bIsMeasureGlass;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bIsMeasureGlass = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool bIsPercentage
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bIsPercentage;
|
||||
}
|
||||
}
|
||||
|
||||
public bool bIsSashVertical
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bIsSashVertical;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bIsSashVertical = value;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Hardware> HardwareList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_HardwareList;
|
||||
}
|
||||
}
|
||||
|
||||
public List<ParametriOpzioni> HwdOptionList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_HwdOptionList;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Joint> JointList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_JointList;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_JointList = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int nSashQty
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SashList.Count > 0 ? m_SashList.Count : 1;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value >= 0 && value <= 4)
|
||||
{
|
||||
if (value > m_SashList.Count)
|
||||
{
|
||||
// recupero larghezza ultimo
|
||||
double dLastDimension = 100;
|
||||
double dNewDimension = 100;
|
||||
if (m_SashList.Count > 0)
|
||||
{
|
||||
dLastDimension = m_SashList[m_SashList.Count - 1].dDimension;
|
||||
dNewDimension = dLastDimension / (value + 1 - nSashQty);
|
||||
m_SashList[m_SashList.Count - 1].SetDimension(dNewDimension);
|
||||
}
|
||||
else
|
||||
dNewDimension = dLastDimension / (value + 1 - nSashQty);
|
||||
// aggiungo area Sash di default
|
||||
for (var SplitIndex = m_SashList.Count; SplitIndex <= value - 1; SplitIndex++)
|
||||
{
|
||||
SashList.Add(new SashDimension(dNewDimension, true, this, SplitIndex + 1));
|
||||
}
|
||||
}
|
||||
else if (value < m_SashList.Count)
|
||||
{
|
||||
if (value > 0)
|
||||
{
|
||||
double dLastDimension = 0;
|
||||
for (var SplitIndex = m_SashList.Count - 1; SplitIndex >= value; SplitIndex += -1)
|
||||
{
|
||||
dLastDimension += m_SashList[SplitIndex].dDimension;
|
||||
SashList.RemoveAt(SplitIndex);
|
||||
}
|
||||
dLastDimension += m_SashList[SashList.Count - 1].dDimension;
|
||||
SashList[SashList.Count - 1].SetDimension(dLastDimension);
|
||||
if (value == 1)
|
||||
SashList[0].SetHasHandle(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SashList.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
if (m_SashList.Count == 0)
|
||||
{
|
||||
Area child = AreaList[0];
|
||||
// Se nella singola anta ho uno split
|
||||
if (!(child is Fill))
|
||||
{
|
||||
child = child.AreaList[0].AreaList[0];
|
||||
}
|
||||
child.SetParentArea(this.ParentArea);
|
||||
this.ParentArea.AreaList.Remove(this);
|
||||
this.ParentArea.AreaList.Add(child);
|
||||
}
|
||||
// Se ho singola anta
|
||||
else if (m_SashList.Count == 1)
|
||||
{
|
||||
// Metto come padre dell'area nello splitted l'anta stessa
|
||||
List<Area> ContentArea = new List<Area>();
|
||||
ContentArea.Add(AreaList[0].AreaList[0]);
|
||||
ContentArea[0].SetParentArea(this);
|
||||
AreaList.Clear();
|
||||
AreaList.Add(ContentArea[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Se aggiungo ante
|
||||
if (SashList.Count > AreaList.Count)
|
||||
{
|
||||
List<Area> ContentArea = new List<Area>();
|
||||
// Salvo in ContentArea il sottoalbero delle singole aree che mantengo
|
||||
if (AreaList.Count >= 1 & SashList.Count > AreaList.Count)
|
||||
{
|
||||
foreach (Area area in AreaList)
|
||||
{
|
||||
if (area is Splitted)
|
||||
ContentArea.Add(area.AreaList[0]);
|
||||
else
|
||||
ContentArea.Add(area);
|
||||
}
|
||||
AreaList.Clear();
|
||||
}
|
||||
for (int SplitIndex = AreaList.Count; SplitIndex <= SashList.Count - 1; SplitIndex++)
|
||||
{
|
||||
AreaList.Add(Splitted.CreateSplitted(this));
|
||||
}
|
||||
// Riaggiungo i sottoalberi che avevo salvato
|
||||
for (int i = 0; i < AreaList.Count - 1; i++)
|
||||
{
|
||||
if (AreaList.Count == 2)
|
||||
{
|
||||
ContentArea[i].SetParentArea(AreaList[i]);
|
||||
}
|
||||
AreaList[i].AreaList.Add(ContentArea[i]);
|
||||
}
|
||||
// Aggiungo all'ultimo Splitted l'area di vetro
|
||||
Fill newFill = Fill.CreateFill(AreaList[1], FillTypes.GLASS);
|
||||
//Fill newFill = new Fill(AreaList[1], ParentWindow);
|
||||
//newFill.SetFillType(FillTypes.GLASS);
|
||||
newFill.SetAreaType(AreaTypes.FILL);
|
||||
AreaList[AreaList.Count - 1].AreaList.Add(newFill);
|
||||
}
|
||||
// Se tolgo anta
|
||||
else
|
||||
{
|
||||
for (int SplitIndex = SashList.Count; SplitIndex <= AreaList.Count() - 1; SplitIndex++)
|
||||
{
|
||||
AreaList.Remove(AreaList[AreaList.Count - 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RefreshHardwareList();
|
||||
RefreshHardwareOptionList();
|
||||
SetFirstHardware();
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
public OrientationSash OrientationSashType
|
||||
{
|
||||
get
|
||||
{
|
||||
return (OrientationSash)m_SelOrientationSashType;
|
||||
}
|
||||
}
|
||||
|
||||
public List<IdNameStruct> OrientationSashTypeList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OrientationSashTypeList;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SashBottomRail
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bSashBottomRail;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bSashBottomRail = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int SashBottomRailQty
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_nSashBottomRailQty;
|
||||
}
|
||||
set
|
||||
{
|
||||
// Controllo che il valore inserito sia positivo
|
||||
if (value >= 0)
|
||||
{
|
||||
m_nSashBottomRailQty = value;
|
||||
if (m_nSashBottomRailQty > 0)
|
||||
{
|
||||
m_bSashBottomRail = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bSashBottomRail = false;
|
||||
}
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<SashDimension> SashList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SashList;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SashList = value;
|
||||
}
|
||||
}
|
||||
|
||||
public SashTypes SashType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SashType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SashType = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string SelFamilyHardware
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SelFamilyHardware;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelFamilyHardware = value;
|
||||
RefreshHardwareList();
|
||||
RefreshHardwareOptionList();
|
||||
SetFirstHardware();
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
public Hardware SelHardware
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SelHardware;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelHardware = value;
|
||||
// if (m_SelHardware != null && m_SelHardware.sId != "000000")
|
||||
// {
|
||||
// string sHwdOptPath = "";
|
||||
// var gf = EgtLuaCreateGlobTable("WDG");
|
||||
// var tft = EgtLuaSetGlobIntVar("WDG.AREAID", m_nAreaId);
|
||||
// var tfy = EgtLuaSetGlobStringVar("WDG.HDWFAVOURITE", value.sId);
|
||||
// SashDimension HandleSash = m_SashList.FirstOrDefault(x => x.bHasHandle);
|
||||
// string sHandle = "Dx";
|
||||
// switch (GetOpeningSide(HandleSash.OpeningType))
|
||||
// {
|
||||
// case object _ when OpeningSides.LEFT:
|
||||
// {
|
||||
// sHandle = "Sx";
|
||||
// break;
|
||||
// }
|
||||
|
||||
// case object _ when OpeningSides.RIGHT:
|
||||
// {
|
||||
// sHandle = "Dx";
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// var tfd = EgtLuaSetGlobStringVar("WDG.HDWHANDLE", sHandle);
|
||||
// var tlt = EgtLuaCallFunction("WinCreate_GetHardwareOptionPath");
|
||||
// var tltf = EgtLuaGetGlobStringVar("WDG.HWDOPTPATH", sHwdOptPath);
|
||||
// if (!string.IsNullOrWhiteSpace(sHwdOptPath))
|
||||
// {
|
||||
// XmlSerializer serializer = new XmlSerializer(typeof(ParametriOpzioni));
|
||||
// ParametriOpzioni HwdOptions = null/* TODO Change to default(_) if this is not a reference type */;
|
||||
// string sHdwOptPath = Path.ChangeExtension(sHwdOptPath, ".opt");
|
||||
// bool bHdwOptFound = false;
|
||||
// for (var WaitIndex = 0; WaitIndex <= 100; WaitIndex++)
|
||||
// {
|
||||
// if (File.Exists(sHdwOptPath))
|
||||
// {
|
||||
// bHdwOptFound = true;
|
||||
// break;
|
||||
// }
|
||||
// System.Threading.Thread.Sleep(100);
|
||||
// }
|
||||
// if (bHdwOptFound)
|
||||
// {
|
||||
// string sHwdOptText = "";
|
||||
// try
|
||||
// {
|
||||
// sHwdOptText = File.ReadAllText(sHdwOptPath);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// EgtOutLog("Hardware file opt not found or read!");
|
||||
// }
|
||||
// if (!string.IsNullOrWhiteSpace(sHwdOptText))
|
||||
// {
|
||||
// using (TextReader reader = new StringReader(sHwdOptText))
|
||||
// {
|
||||
// HwdOptions = serializer.Deserialize(reader);
|
||||
// }
|
||||
// if (!IsNothing(HwdOptions))
|
||||
// {
|
||||
// m_HwdOptionList.Clear();
|
||||
// foreach (var HdwOption in HwdOptions.Items)
|
||||
// m_HwdOptionList.Add(new AGBOption(HdwOption));
|
||||
// NotifyPropertyChanged(nameof(HwdOptionList));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// var ud = EgtLuaResetGlobVar("WDG");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public string SelHardwareFromId
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SelHardware.Id;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelHardware = m_HardwareList.FirstOrDefault(x => !string.IsNullOrEmpty(value) && x.Id.Equals(value)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0);
|
||||
ParentWindow.OnUpdatePreview(ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
public OrientationSash SelOrientationSashType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SelOrientationSashType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelOrientationSashType = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int SelOrientationSashTypeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return IdNameStruct.IndFromId((int)m_SelOrientationSashType, m_OrientationSashTypeList);
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelOrientationSashType = (OrientationSash)IdNameStruct.IdFromInd(value, m_OrientationSashTypeList);
|
||||
if (value == 0)
|
||||
{
|
||||
m_bIsSashVertical = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bIsSashVertical = false;
|
||||
}
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public override Sash Copy(Area newParentArea)
|
||||
{
|
||||
Sash newSash = new Sash(newParentArea, m_ParentWindow);
|
||||
AddCounterGroup();
|
||||
newSash.SetIdGroup(nCounterGroup);
|
||||
newSash.SetAreaType(AreaType);
|
||||
// Imposta la quantità di ante e definisce SashDimension di ogni anta ai valori di default
|
||||
newSash.SetSashQty(nSashQty);
|
||||
newSash.SetIsSashVertical(bIsSashVertical);
|
||||
newSash.SetOrientationSashType(OrientationSashType);
|
||||
newSash.SetSashBottomRailQty(SashBottomRailQty);
|
||||
newSash.SetSelFamilyHardwareFromIndex(SelHardware.Id);
|
||||
newSash.RefreshHardwareList();
|
||||
newSash.RefreshHardwareOptionList();
|
||||
newSash.SetSelHardware(SelHardware);
|
||||
for (int i = 0; i < SashList.Count; i++)
|
||||
{
|
||||
//Cancello SashDimension di default e aggiungo la copia
|
||||
newSash.SashList.RemoveAt(i);
|
||||
SashDimension newSashDim = SashList[i].Copy();
|
||||
newSash.SashList.Insert(i, newSashDim);
|
||||
}
|
||||
foreach (var item in JointList)
|
||||
{
|
||||
Joint newJoint = item.Copy();
|
||||
newSash.JointList.Add(newJoint);
|
||||
}
|
||||
foreach (var item in AreaList)
|
||||
{
|
||||
Area newArea = item.Copy(newSash);
|
||||
newSash.AreaList.Add(newArea);
|
||||
}
|
||||
return newSash;
|
||||
}
|
||||
|
||||
public void RefreshHardwareList()
|
||||
{
|
||||
if (m_HardwareCompleteList != null && m_HardwareCompleteList.Count > 0)
|
||||
{
|
||||
m_HardwareList.Clear();
|
||||
string sSashShape = FindSashShape();
|
||||
Enums.OpeningTypes sOpeningType = ConvertOpeningType();
|
||||
var iComp = StringComparison.InvariantCultureIgnoreCase;
|
||||
var rawList = m_HardwareCompleteList
|
||||
.Where(x => x.Id == "000000" ||
|
||||
(!string.IsNullOrEmpty(m_SelFamilyHardware) && x.FamilyName.Equals(m_SelFamilyHardware, iComp) && x.SashQty == nSashQty && x.Shape.Equals(sSashShape, iComp) && x.OpeningType == sOpeningType)
|
||||
)
|
||||
.ToList();
|
||||
if (rawList != null && rawList.Count > 0)
|
||||
{
|
||||
m_HardwareList = new List<Hardware>(rawList);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_HardwareList = new List<Hardware>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
ParentArea.AreaList.Remove(this);
|
||||
Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS);
|
||||
newFill.SetAreaType(AreaTypes.FILL);
|
||||
ParentArea.AreaList.Add(newFill);
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal static Sash CreateSash(Area Area)
|
||||
{
|
||||
Sash newSash = new Sash(Area, Area.ParentWindow);
|
||||
AddCounterGroup();
|
||||
newSash.SetIdGroup(nCounterGroup);
|
||||
newSash.SetAreaType(AreaTypes.SASH);
|
||||
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));
|
||||
newSash.SetSashBottomRail(false);
|
||||
newSash.SetSashBottomRailQty(0);
|
||||
newSash.SelFamilyHardware = Sash.s_FamilyHardwareList.First();
|
||||
newSash.RefreshHardwareList();
|
||||
newSash.RefreshHardwareOptionList();
|
||||
newSash.SetFirstHardware();
|
||||
return newSash;
|
||||
}
|
||||
|
||||
internal OpeningSides GetOpeningSide(Openings OpeningType)
|
||||
{
|
||||
switch (OpeningType)
|
||||
{
|
||||
case Openings.TURNONLY_LEFT:
|
||||
case Openings.TILTTURN_LEFT:
|
||||
case Openings.TILTONLY_TOP:
|
||||
case Openings.COMPLANARSLIDE_LEFT:
|
||||
case Openings.LIFTSLIDE_LEFT:
|
||||
{
|
||||
return OpeningSides.LEFT;
|
||||
}
|
||||
|
||||
case Openings.TURNONLY_RIGHT:
|
||||
case Openings.TILTTURN_RIGHT:
|
||||
case Openings.TILTONLY_BOTTOM:
|
||||
case Openings.COMPLANARSLIDE_RIGHT:
|
||||
case Openings.LIFTSLIDE_RIGHT:
|
||||
{
|
||||
return OpeningSides.RIGHT;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return OpeningSides.NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal Enums.OpeningTypes GetOpeningType(Openings OpeningType)
|
||||
{
|
||||
switch (OpeningType)
|
||||
{
|
||||
case Openings.TURNONLY_LEFT:
|
||||
case Openings.TURNONLY_RIGHT:
|
||||
{
|
||||
return Enums.OpeningTypes.TurnOnly;
|
||||
}
|
||||
|
||||
case Openings.TILTTURN_LEFT:
|
||||
case Openings.TILTTURN_RIGHT:
|
||||
{
|
||||
return Enums.OpeningTypes.TiltTurn;
|
||||
}
|
||||
|
||||
case Openings.TILTONLY_TOP:
|
||||
case Openings.TILTONLY_BOTTOM:
|
||||
{
|
||||
return Enums.OpeningTypes.TiltOnly;
|
||||
}
|
||||
|
||||
case Openings.PIVOT:
|
||||
{
|
||||
return Enums.OpeningTypes.Pivot;
|
||||
}
|
||||
|
||||
case Openings.FIXED:
|
||||
{
|
||||
return Enums.OpeningTypes.Fixed;
|
||||
}
|
||||
|
||||
case Openings.COMPLANARSLIDE_LEFT:
|
||||
case Openings.COMPLANARSLIDE_RIGHT:
|
||||
{
|
||||
return Enums.OpeningTypes.ComplanarSlide;
|
||||
}
|
||||
|
||||
case Openings.LIFTSLIDE_LEFT:
|
||||
case Openings.LIFTSLIDE_RIGHT:
|
||||
{
|
||||
return Enums.OpeningTypes.LiftSlide;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return Enums.OpeningTypes.Null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void RefreshHardwareOptionList()
|
||||
{
|
||||
m_HwdOptionList.Clear();
|
||||
}
|
||||
|
||||
internal override JsonArea Serialize()
|
||||
{
|
||||
if (nCounterGroup < IdGroup)
|
||||
Area.nCounterGroup = IdGroup;
|
||||
JsonSash JsonSash = new JsonSash(m_bIsSashVertical, m_SashType, m_bSashBottomRail, m_nSashBottomRailQty, m_SelHardware.Id, IdGroup);
|
||||
foreach (var SashDimension in SashList)
|
||||
JsonSash.SashList.Add(SashDimension.Serialize());
|
||||
foreach (var Joint in JointList)
|
||||
JsonSash.JointList.Add(Joint.Serialize());
|
||||
foreach (var Area in AreaList)
|
||||
JsonSash.AreaList.Add(Area.Serialize());
|
||||
return JsonSash;
|
||||
}
|
||||
|
||||
internal void SetFirstHardware()
|
||||
{
|
||||
if (m_HardwareList.Count > 0)
|
||||
{
|
||||
m_SelHardware = m_HardwareList[0];
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetIsMeasureGlass(bool IsMeasureGlass)
|
||||
{
|
||||
m_bIsMeasureGlass = IsMeasureGlass;
|
||||
}
|
||||
|
||||
internal void SetIsSashVertical(bool IsSashVertical)
|
||||
{
|
||||
m_bIsSashVertical = IsSashVertical;
|
||||
if (IsSashVertical)
|
||||
{
|
||||
m_SelOrientationSashType = OrientationSash.VERTICAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_SelOrientationSashType = OrientationSash.HORIZONTAL;
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetOrientationSashType(OrientationSash value)
|
||||
{
|
||||
m_SelOrientationSashType = value;
|
||||
}
|
||||
|
||||
internal void SetSashBottomRail(bool bBottomRail)
|
||||
{
|
||||
m_bSashBottomRail = bBottomRail;
|
||||
}
|
||||
|
||||
internal void SetSashBottomRailQty(int nBottomRailQty)
|
||||
{
|
||||
m_nSashBottomRailQty = nBottomRailQty;
|
||||
}
|
||||
|
||||
internal void SetSashQty(int Qty)
|
||||
{
|
||||
if (Qty >= 0 && Qty <= 4)
|
||||
{
|
||||
if (Qty > m_SashList.Count)
|
||||
{
|
||||
// recupero larghezza ultimo
|
||||
double dLastDimension = 100;
|
||||
double dNewDimension = 100;
|
||||
if (m_SashList.Count > 0)
|
||||
{
|
||||
dLastDimension = m_SashList[m_SashList.Count - 1].dDimension;
|
||||
dNewDimension = dLastDimension / (Qty + 1 - nSashQty);
|
||||
m_SashList[m_SashList.Count - 1].dDimension = dNewDimension;
|
||||
}
|
||||
else
|
||||
dNewDimension = dLastDimension / (Qty + 1 - nSashQty);
|
||||
// aggiungo area Sash di default
|
||||
for (var SplitIndex = m_SashList.Count; SplitIndex <= Qty - 1; SplitIndex++)
|
||||
SashList.Add(new SashDimension(dNewDimension, true, this, SplitIndex + 1));
|
||||
}
|
||||
else if (Qty < m_SashList.Count)
|
||||
{
|
||||
for (var SplitIndex = m_SashList.Count - 1; SplitIndex >= Qty; SplitIndex += -1)
|
||||
SashList.RemoveAt(SplitIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetSashType(SashTypes SashType)
|
||||
{
|
||||
m_SashType = SashType;
|
||||
}
|
||||
|
||||
internal string SetSelFamilyHardwareFromIndex(string codHardware)
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_SelFamilyHardware))
|
||||
{
|
||||
SelFamilyHardware = (m_HardwareCompleteList
|
||||
.Where(x => x.Id == codHardware)
|
||||
.First()).FamilyName;
|
||||
}
|
||||
return SelFamilyHardware;
|
||||
}
|
||||
|
||||
internal void SetSelHardware(Hardware value)
|
||||
{
|
||||
m_SelHardware = value;
|
||||
}
|
||||
|
||||
internal void SetSelHardwareFromId(string sId)
|
||||
{
|
||||
if (m_HardwareList.Count == 0)
|
||||
m_SelHardware = m_HardwareCompleteList.FirstOrDefault(x => x.Id.Equals(sId)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0);
|
||||
else
|
||||
m_SelHardware = m_HardwareList.FirstOrDefault(x => x.Id.Equals(sId)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0);
|
||||
if (m_SelHardware == null)
|
||||
m_SelHardware = m_HardwareList[0];
|
||||
//SelFamilyHardware = m_SelHardware.FamilyName;
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private bool m_bIsMeasureGlass;
|
||||
|
||||
private bool m_bIsPercentage = true;
|
||||
|
||||
private bool m_bIsSashVertical;
|
||||
|
||||
private bool m_bSashBottomRail;
|
||||
|
||||
private List<Hardware> m_HardwareList = new List<Hardware>();
|
||||
|
||||
private List<ParametriOpzioni> m_HwdOptionList = new List<ParametriOpzioni>();
|
||||
|
||||
private List<Joint> m_JointList = new List<Joint>();
|
||||
|
||||
private int m_nSashBottomRailQty;
|
||||
|
||||
private List<IdNameStruct> m_OrientationSashTypeList = new List<IdNameStruct>
|
||||
{
|
||||
new IdNameStruct((int)OrientationSash.VERTICAL, "Vertical"),
|
||||
new IdNameStruct((int)OrientationSash.HORIZONTAL, "Horizontal"),
|
||||
};
|
||||
|
||||
private List<SashDimension> m_SashList = new List<SashDimension>();
|
||||
private SashTypes m_SashType;
|
||||
private string m_SelFamilyHardware;
|
||||
private Hardware m_SelHardware;
|
||||
private OrientationSash m_SelOrientationSashType;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private Enums.OpeningTypes ConvertOpeningType()
|
||||
{
|
||||
var answ = Enums.OpeningTypes.Null;
|
||||
if (m_SashList.Count > 1)
|
||||
{
|
||||
for (int i = 0; i < m_SashList.Count; i++)
|
||||
{
|
||||
if (m_SashList[i].bHasHandle)
|
||||
{
|
||||
answ = GetOpeningType(m_SashList[i].OpeningType);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = GetOpeningType(m_SashList[0].OpeningType);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
private string FindSashShape()
|
||||
{
|
||||
return "Rectangular";
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
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 SashDimension
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public SashDimension(double dDimension, bool bIsRelative, Sash Parent, int nSashId)
|
||||
{
|
||||
m_dDimension = dDimension;
|
||||
m_bIsRelative = bIsRelative;
|
||||
m_Parent = Parent;
|
||||
m_nSashId = nSashId;
|
||||
// assengno maniglia
|
||||
if (Parent.SashList.Count == 0 || !Parent.SashList.Any(x => x.bHasHandle))
|
||||
m_bHasHandle = true;
|
||||
// assegno tipo di anta
|
||||
if (Parent.SashList.Count == 0)
|
||||
SetOpeningType(Openings.TILTTURN_LEFT);
|
||||
else if (Parent.SashList.Count == 1)
|
||||
{
|
||||
switch (Parent.SashList[0].OpeningType)
|
||||
{
|
||||
case Openings.TURNONLY_LEFT:
|
||||
{
|
||||
SetOpeningType(Openings.TURNONLY_RIGHT);
|
||||
break;
|
||||
}
|
||||
|
||||
case Openings.TURNONLY_RIGHT:
|
||||
{
|
||||
SetOpeningType(Openings.TURNONLY_LEFT);
|
||||
break;
|
||||
}
|
||||
|
||||
case Openings.TILTTURN_LEFT:
|
||||
{
|
||||
SetOpeningType(Openings.TURNONLY_RIGHT);
|
||||
break;
|
||||
}
|
||||
|
||||
case Openings.TILTTURN_RIGHT:
|
||||
{
|
||||
SetOpeningType(Openings.TURNONLY_LEFT);
|
||||
break;
|
||||
}
|
||||
|
||||
case Openings.TILTONLY_TOP:
|
||||
{
|
||||
SetOpeningType(Openings.TILTONLY_BOTTOM);
|
||||
break;
|
||||
}
|
||||
|
||||
case Openings.TILTONLY_BOTTOM:
|
||||
{
|
||||
SetOpeningType(Openings.TILTONLY_TOP);
|
||||
break;
|
||||
}
|
||||
|
||||
case Openings.COMPLANARSLIDE_LEFT:
|
||||
{
|
||||
SetOpeningType(Openings.COMPLANARSLIDE_RIGHT);
|
||||
break;
|
||||
}
|
||||
|
||||
case Openings.COMPLANARSLIDE_RIGHT:
|
||||
{
|
||||
SetOpeningType(Openings.COMPLANARSLIDE_LEFT);
|
||||
break;
|
||||
}
|
||||
|
||||
case Openings.LIFTSLIDE_LEFT:
|
||||
{
|
||||
SetOpeningType(Openings.LIFTSLIDE_RIGHT);
|
||||
break;
|
||||
}
|
||||
|
||||
case Openings.LIFTSLIDE_RIGHT:
|
||||
{
|
||||
SetOpeningType(Openings.LIFTSLIDE_LEFT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
SetOpeningType(Parent.SashList[Parent.SashList.Count - 1].OpeningType);
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public bool bHasHandle
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bHasHandle;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bHasHandle = value;
|
||||
m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
public bool bIsRelative
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bIsRelative;
|
||||
}
|
||||
}
|
||||
|
||||
public double dDimension
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_dDimension;
|
||||
}
|
||||
set
|
||||
{
|
||||
// Controllo che il valore inserito sia compreso tra 0 e 100
|
||||
if (value > 0 && value < 100)
|
||||
{
|
||||
// se sono in percentuale
|
||||
if (m_bIsRelative)
|
||||
{
|
||||
// verifico se ci sono assoluti
|
||||
List<SashDimension> RelativeDimList = m_Parent.SashList.Where(x => x.bIsRelative).ToList();
|
||||
if (RelativeDimList.Count > 0)
|
||||
{
|
||||
if (m_Parent.bIsPercentage)
|
||||
{
|
||||
int nIndex = RelativeDimList.IndexOf(this);
|
||||
// se diminuisce dimensione
|
||||
if (value < m_dDimension)
|
||||
{
|
||||
if (nIndex < RelativeDimList.Count - 1)
|
||||
RelativeDimList[nIndex + 1].SetDimension(RelativeDimList[nIndex + 1].dDimension + (m_dDimension - value));
|
||||
else if (RelativeDimList.Count > 1)
|
||||
RelativeDimList[nIndex - 1].SetDimension(RelativeDimList[nIndex - 1].dDimension + (m_dDimension - value));
|
||||
else
|
||||
{
|
||||
m_dDimension = 100;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// se aumenta dimensione
|
||||
else
|
||||
{
|
||||
double dRes = value;
|
||||
// se non ultima anta
|
||||
if (nIndex < RelativeDimList.Count - 1)
|
||||
{
|
||||
for (var nInd = 0; nInd <= nIndex - 1; nInd++)
|
||||
dRes += RelativeDimList[nInd].dDimension;
|
||||
dRes = (100 - dRes) / (RelativeDimList.Count - nIndex - 1);
|
||||
for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++)
|
||||
RelativeDimList[Ind].SetDimension(dRes);
|
||||
}
|
||||
// se ultima anta
|
||||
else if (RelativeDimList.Count > 1)
|
||||
{
|
||||
if (RelativeDimList.Count > 2)
|
||||
{
|
||||
for (var Ind = 0; Ind <= nIndex - 2; Ind++)
|
||||
dRes += RelativeDimList[Ind].dDimension;
|
||||
}
|
||||
|
||||
//for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++)
|
||||
// dRes += RelativeDimList[Ind].dDimension;
|
||||
dRes = (100 - dRes);
|
||||
RelativeDimList[nIndex - 1].SetDimension(dRes);
|
||||
//for (var nInd = 0; nInd <= nIndex - 1; nInd++)
|
||||
// RelativeDimList[nInd].SetDimension(dRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dDimension = 100;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_dDimension = value;
|
||||
m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int nSashId
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_nSashId;
|
||||
}
|
||||
}
|
||||
|
||||
public Openings OpeningType
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Openings)m_SelOpeningType;
|
||||
}
|
||||
}
|
||||
|
||||
public List<IdNameStruct> OpeningTypeList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OpeningTypeList;
|
||||
}
|
||||
}
|
||||
|
||||
public Openings SelOpeningType
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SelOpeningType;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelOpeningType = value;
|
||||
m_Parent.RefreshHardwareList();
|
||||
m_Parent.RefreshHardwareOptionList();
|
||||
m_Parent.SetFirstHardware();
|
||||
}
|
||||
}
|
||||
|
||||
public int SelOpeningTypeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return IdNameStruct.IndFromId((int)m_SelOpeningType, m_OpeningTypeList);
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelOpeningType = (Openings)IdNameStruct.IdFromInd(value, m_OpeningTypeList);
|
||||
m_Parent.RefreshHardwareList();
|
||||
m_Parent.RefreshHardwareOptionList();
|
||||
m_Parent.SetFirstHardware();
|
||||
m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public SashDimension Copy()
|
||||
{
|
||||
SashDimension newSashDim = new SashDimension(dDimension, bIsRelative, m_Parent, m_nSashId);
|
||||
newSashDim.SetOpeningType(SelOpeningType);
|
||||
newSashDim.SetHasHandle(bHasHandle);
|
||||
return newSashDim;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal JsonSashDimension Serialize()
|
||||
{
|
||||
JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, m_bHasHandle, m_dDimension, m_nSashId);
|
||||
return JsonSashDimension;
|
||||
}
|
||||
|
||||
internal void SetDimension(double dValue)
|
||||
{
|
||||
m_dDimension = dValue;
|
||||
}
|
||||
|
||||
internal void SetHasHandle(bool value)
|
||||
{
|
||||
m_bHasHandle = value;
|
||||
}
|
||||
|
||||
internal void SetOpeningType(Openings value)
|
||||
{
|
||||
m_SelOpeningType = value;
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private bool m_bHasHandle;
|
||||
|
||||
private bool m_bIsRelative = false;
|
||||
|
||||
private double m_dDimension;
|
||||
|
||||
private int m_nSashId;
|
||||
|
||||
private List<IdNameStruct> m_OpeningTypeList = new List<IdNameStruct>
|
||||
{
|
||||
new IdNameStruct((int)Openings.TURNONLY_LEFT, ">"),
|
||||
new IdNameStruct((int)Openings.TURNONLY_RIGHT, "<"),
|
||||
new IdNameStruct((int)Openings.TILTTURN_LEFT, ">*"),
|
||||
new IdNameStruct((int)Openings.TILTTURN_RIGHT, "<*"),
|
||||
new IdNameStruct((int)Openings.TILTONLY_TOP, "˄"),
|
||||
new IdNameStruct((int)Openings.TILTONLY_BOTTOM, "˅"),
|
||||
new IdNameStruct((int)Openings.PIVOT, "◊"),
|
||||
new IdNameStruct((int)Openings.FIXED, "X"),
|
||||
new IdNameStruct((int)Openings.COMPLANARSLIDE_LEFT, "-→"),
|
||||
new IdNameStruct((int)Openings.COMPLANARSLIDE_RIGHT, "←-"),
|
||||
new IdNameStruct((int)Openings.LIFTSLIDE_LEFT, "┌→"),
|
||||
new IdNameStruct((int)Openings.LIFTSLIDE_RIGHT, "←┐")
|
||||
};
|
||||
|
||||
// reference
|
||||
private Sash m_Parent;
|
||||
|
||||
private Openings m_SelOpeningType;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,471 @@
|
||||
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 Split : Area
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public Split(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public bool bIsPercentage
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bIsPercentage;
|
||||
}
|
||||
}
|
||||
|
||||
public bool bSplitStartVert
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bSplitStartVert;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bSplitStartVert = value;
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
public int nSplitQtyHoriz
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count - 1 : 0;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value; SplitIndex += -1)
|
||||
m_SplitHorizList.RemoveAt(SplitIndex);
|
||||
if (nSplitQtyVert == 0)
|
||||
{
|
||||
ParentArea.AreaList.Remove(this);
|
||||
Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS);
|
||||
newFill.SetAreaType(AreaTypes.FILL);
|
||||
ParentArea.AreaList.Add(newFill);
|
||||
}
|
||||
else
|
||||
SetSplitShape(SplitShapes.VERTICAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ricalcolo dimensioni aggiungendo split
|
||||
if (value > m_SplitHorizList.Count - 1)
|
||||
{
|
||||
// recupero larghezza ultimo
|
||||
double dLastDimension = 100;
|
||||
double dNewDimension = 100;
|
||||
if (m_SplitHorizList.Count > 0)
|
||||
{
|
||||
dLastDimension = m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension;
|
||||
dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz);
|
||||
m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dNewDimension);
|
||||
}
|
||||
else
|
||||
dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz);
|
||||
// aggiungo area Split di default
|
||||
for (var SplitIndex = m_SplitHorizList.Count; SplitIndex <= value; SplitIndex++)
|
||||
m_SplitHorizList.Add(new SplitDimension(dNewDimension, true, this, false));
|
||||
}
|
||||
// Ricalcolo dimensioni rimuovendo split
|
||||
else
|
||||
{
|
||||
double dLastDimension = 0;
|
||||
for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1)
|
||||
{
|
||||
dLastDimension += m_SplitHorizList[SplitIndex].dDimension;
|
||||
m_SplitHorizList.RemoveAt(SplitIndex);
|
||||
}
|
||||
dLastDimension += m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension;
|
||||
m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dLastDimension);
|
||||
}
|
||||
// Controllo quanti split verticali ci sono
|
||||
int nVert = m_SplitVertList.Count > 0 ? m_SplitVertList.Count : 1;
|
||||
// Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta
|
||||
for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitHorizList.Count * nVert) - 1; SplitIndex++)
|
||||
{
|
||||
AreaList.Add(Splitted.CreateSplitted(this));
|
||||
Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS);
|
||||
newFill.SetAreaType(AreaTypes.FILL);
|
||||
AreaList[AreaList.Count - 1].AreaList.Add(newFill);
|
||||
}
|
||||
// Se ho più di uno split, elimino l'ultimo
|
||||
if (AreaList.Count > 2)
|
||||
{
|
||||
int nAreaList = AreaList.Count - 1;
|
||||
for (var SplitIndex = (m_SplitHorizList.Count * nVert); SplitIndex <= nAreaList; SplitIndex++)
|
||||
{
|
||||
AreaList.Remove(AreaList[AreaList.Count - 1]);
|
||||
}
|
||||
}
|
||||
// Se elimino l'unico split presente
|
||||
else
|
||||
{
|
||||
Splitted s = (Splitted)AreaList[0];
|
||||
s.SetParentArea(ParentArea);
|
||||
ParentArea.AreaList.Add(s);
|
||||
ParentArea.AreaList.Remove(this);
|
||||
}
|
||||
}
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
public int nSplitQtyVert
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SplitVertList.Count > 0 ? m_SplitVertList.Count - 1 : 0;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value; SplitIndex += -1)
|
||||
m_SplitVertList.RemoveAt(SplitIndex);
|
||||
if (nSplitQtyHoriz == 0)
|
||||
{
|
||||
ParentArea.AreaList.Remove(this);
|
||||
Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS);
|
||||
newFill.SetAreaType(AreaTypes.FILL);
|
||||
ParentArea.AreaList.Add(newFill);
|
||||
}
|
||||
else
|
||||
SetSplitShape(SplitShapes.HORIZONTAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ricalcolo dimensioni aggiungendo split
|
||||
if (value > m_SplitVertList.Count - 1)
|
||||
{
|
||||
// recupero larghezza ultimo
|
||||
double dLastDimension = 100;
|
||||
double dNewDimension = 100;
|
||||
if (m_SplitVertList.Count > 0)
|
||||
{
|
||||
dLastDimension = m_SplitVertList[m_SplitVertList.Count - 1].dDimension;
|
||||
dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert);
|
||||
m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dNewDimension);
|
||||
}
|
||||
else
|
||||
dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert);
|
||||
// aggiungo area Split di default
|
||||
for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= value; SplitIndex++)
|
||||
m_SplitVertList.Add(new SplitDimension(dNewDimension, true, this, true));
|
||||
}
|
||||
else if (value == 0)
|
||||
{
|
||||
m_SplitVertList.RemoveAt(1);
|
||||
m_SplitVertList.RemoveAt(0);
|
||||
}
|
||||
// Ricalcolo dimensioni rimuovendo split
|
||||
else
|
||||
{
|
||||
double dLastDimension = 0;
|
||||
for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1)
|
||||
{
|
||||
dLastDimension += m_SplitVertList[SplitIndex].dDimension;
|
||||
m_SplitVertList.RemoveAt(SplitIndex);
|
||||
}
|
||||
dLastDimension += m_SplitVertList[m_SplitVertList.Count - 1].dDimension;
|
||||
m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dLastDimension);
|
||||
}
|
||||
// Controllo quanti split orizzontali ci sono
|
||||
int nHoriz = m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count : 1;
|
||||
// Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta
|
||||
for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitVertList.Count * nHoriz) - 1; SplitIndex++)
|
||||
{
|
||||
AreaList.Add(Splitted.CreateSplitted(this));
|
||||
Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS);
|
||||
newFill.SetAreaType(AreaTypes.FILL);
|
||||
AreaList[AreaList.Count - 1].AreaList.Add(newFill);
|
||||
}
|
||||
// Se ho più di uno split, elimino l'ultimo
|
||||
if (AreaList.Count > 2)
|
||||
{
|
||||
int nAreaList = AreaList.Count - 1;
|
||||
for (var SplitIndex = (m_SplitVertList.Count * nHoriz); SplitIndex <= nAreaList; SplitIndex++)
|
||||
{
|
||||
AreaList.Remove(AreaList[AreaList.Count - 1]);
|
||||
}
|
||||
}
|
||||
// Se elimino l'unico split presente
|
||||
else
|
||||
{
|
||||
Splitted s = (Splitted)AreaList[0];
|
||||
s.SetParentArea(ParentArea);
|
||||
ParentArea.AreaList.Add(s);
|
||||
ParentArea.AreaList.Remove(this);
|
||||
}
|
||||
}
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
public int SelSplitShapeIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return IdNameStruct.IndFromId((int)m_SelSplitShape, m_SplitShapeList);
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SelSplitShape = (SplitShapes)IdNameStruct.IdFromInd(value, m_SplitShapeList);
|
||||
// Cancello elementi nello split e azzero quantità orizzontale e verticale
|
||||
AreaList.Clear();
|
||||
SetSplitQtyVert(0);
|
||||
SetSplitQtyHoriz(0);
|
||||
if (m_SelSplitShape == SplitShapes.VERTICAL)
|
||||
{
|
||||
// Inserisco valori di default
|
||||
SetSplitQtyVert(1);
|
||||
SetSplitStartVert(true);
|
||||
}
|
||||
else if (m_SelSplitShape == SplitShapes.HORIZONTAL)
|
||||
{
|
||||
// Inserisco valori di default
|
||||
SetSplitQtyHoriz(1);
|
||||
SetSplitStartVert(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Inserisco valori di default
|
||||
SetSplitQtyVert(1);
|
||||
SetSplitQtyHoriz(1);
|
||||
SetSplitStartVert(true);
|
||||
}
|
||||
// Aggiungo area Splitted e vetro
|
||||
int nVert = m_SplitVertList.Count > 0 ? m_SplitVertList.Count : 1;
|
||||
int nHoriz = m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count : 1;
|
||||
for (var SplitIndex = 0; SplitIndex <= (nVert * nHoriz) - 1; SplitIndex++)
|
||||
{
|
||||
AreaList.Add(Splitted.CreateSplitted(this));
|
||||
Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS);
|
||||
newFill.SetAreaType(AreaTypes.FILL);
|
||||
AreaList[SplitIndex].AreaList.Add(newFill);
|
||||
}
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
|
||||
public List<SplitDimension> SplitHorizList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SplitHorizList;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SplitHorizList = value;
|
||||
}
|
||||
}
|
||||
|
||||
public List<SplitDimension> SplitPositionList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SplitPositionList;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SplitPositionList = value;
|
||||
}
|
||||
}
|
||||
|
||||
public List<IdNameStruct> SplitShapeList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SplitShapeList;
|
||||
}
|
||||
}
|
||||
|
||||
public List<SplitDimension> SplitVertList
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SplitVertList;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SplitVertList = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public override Split Copy(Area newParentArea)
|
||||
{
|
||||
Split newSplit = new Split(newParentArea, ParentWindow);
|
||||
AddCounterGroup();
|
||||
newSplit.SetIdGroup(nCounterGroup);
|
||||
newSplit.SetSplitStartVert(bSplitStartVert);
|
||||
newSplit.SetSplitQtyVert(nSplitQtyVert);
|
||||
newSplit.SetSplitQtyHoriz(nSplitQtyHoriz);
|
||||
newSplit.SetSplitShape(SelSplitShape, true);
|
||||
newSplit.SetAreaType(AreaType);
|
||||
foreach (var item in AreaList)
|
||||
{
|
||||
Area a = item.Copy(newSplit);
|
||||
newSplit.AreaList.Add(a);
|
||||
}
|
||||
return newSplit;
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
ParentArea.AreaList.Remove(this);
|
||||
Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS);
|
||||
newFill.SetAreaType(AreaTypes.FILL);
|
||||
ParentArea.AreaList.Add(newFill);
|
||||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Properties
|
||||
|
||||
internal SplitShapes SelSplitShape
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SelSplitShape;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Internal Properties
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal static Split CreateSplit(Area Area, SplitShapes SplitShape)
|
||||
{
|
||||
Split Split = new Split(Area, Area.ParentWindow);
|
||||
AddCounterGroup();
|
||||
Split.SetIdGroup(nCounterGroup);
|
||||
Split.SetAreaType(AreaTypes.SPLIT);
|
||||
Split.SetSplitShape(SplitShape, true);
|
||||
return Split;
|
||||
}
|
||||
|
||||
internal override JsonArea Serialize()
|
||||
{
|
||||
if (nCounterGroup < IdGroup)
|
||||
Area.nCounterGroup = IdGroup;
|
||||
JsonSplit JsonSplit = new JsonSplit(m_SelSplitShape, IdGroup);
|
||||
//foreach (var SplitPosition in m_SplitPositionList)
|
||||
// JsonSplit.SplitPositionList.Add(SplitPosition.Serialize());
|
||||
JsonSplit.SplitStartVert = bSplitStartVert;
|
||||
foreach (var SplitVert in m_SplitVertList)
|
||||
JsonSplit.SplitVertList.Add(SplitVert.Serialize());
|
||||
foreach (var SplitHoriz in m_SplitHorizList)
|
||||
JsonSplit.SplitHorizList.Add(SplitHoriz.Serialize());
|
||||
foreach (var Area in AreaList)
|
||||
JsonSplit.AreaList.Add(Area.Serialize());
|
||||
return JsonSplit;
|
||||
}
|
||||
|
||||
internal void SetSplitQtyHoriz(int QtyHoriz, bool NotifyProperty = false)
|
||||
{
|
||||
if (QtyHoriz > m_SplitHorizList.Count)
|
||||
{
|
||||
// recupero larghezza ultimo
|
||||
double dLastDimension = 100;
|
||||
double dNewDimension = 100;
|
||||
if (m_SplitHorizList.Count > 0)
|
||||
{
|
||||
dLastDimension = m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension;
|
||||
dNewDimension = dLastDimension / (QtyHoriz + 1 - nSplitQtyHoriz);
|
||||
m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension = dNewDimension;
|
||||
}
|
||||
else
|
||||
dNewDimension = dLastDimension / (QtyHoriz + 1 - nSplitQtyHoriz);
|
||||
// aggiungo area Split di default
|
||||
for (var SplitIndex = m_SplitHorizList.Count; SplitIndex <= QtyHoriz; SplitIndex++)
|
||||
m_SplitHorizList.Add(new SplitDimension(dNewDimension, true, this, false));
|
||||
}
|
||||
else if (QtyHoriz < m_SplitHorizList.Count)
|
||||
{
|
||||
for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= QtyHoriz; SplitIndex += -1)
|
||||
m_SplitHorizList.RemoveAt(SplitIndex);
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetSplitQtyVert(int QtyVert, bool NotifyProperty = false)
|
||||
{
|
||||
if (QtyVert > m_SplitVertList.Count)
|
||||
{
|
||||
// recupero larghezza ultimo
|
||||
double dLastDimension = 100;
|
||||
double dNewDimension = 100;
|
||||
if (m_SplitVertList.Count > 0)
|
||||
{
|
||||
dLastDimension = m_SplitVertList[m_SplitVertList.Count - 1].dDimension;
|
||||
dNewDimension = dLastDimension / (QtyVert + 1 - nSplitQtyVert);
|
||||
m_SplitVertList[m_SplitVertList.Count - 1].dDimension = dNewDimension;
|
||||
}
|
||||
else
|
||||
dNewDimension = dLastDimension / (QtyVert + 1 - nSplitQtyVert);
|
||||
// aggiungo area Split di default
|
||||
for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= QtyVert; SplitIndex++)
|
||||
m_SplitVertList.Add(new SplitDimension(dNewDimension, true, this, true));
|
||||
}
|
||||
else if (QtyVert < m_SplitVertList.Count)
|
||||
{
|
||||
for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= QtyVert; SplitIndex += -1)
|
||||
m_SplitVertList.RemoveAt(SplitIndex);
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetSplitShape(SplitShapes Value, bool NotifyProperty = false)
|
||||
{
|
||||
m_SelSplitShape = Value;
|
||||
}
|
||||
|
||||
internal void SetSplitStartVert(bool SplitStartVert)
|
||||
{
|
||||
bSplitStartVert = SplitStartVert;
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private bool m_bIsPercentage = true;
|
||||
private bool m_bSplitStartVert = true;
|
||||
private SplitShapes m_SelSplitShape;
|
||||
|
||||
private List<SplitDimension> m_SplitHorizList = new List<SplitDimension>();
|
||||
|
||||
private List<SplitDimension> m_SplitPositionList = new List<SplitDimension>();
|
||||
|
||||
private List<IdNameStruct> m_SplitShapeList = new List<IdNameStruct>
|
||||
{
|
||||
new IdNameStruct((int)SplitShapes.VERTICAL, "Vertical"),
|
||||
new IdNameStruct((int)SplitShapes.HORIZONTAL, "Horizontal"),
|
||||
new IdNameStruct((int)SplitShapes.GRID, "Grid"),
|
||||
new IdNameStruct((int)SplitShapes.CUSTOM, "Custom")
|
||||
};
|
||||
|
||||
private List<SplitDimension> m_SplitVertList = new List<SplitDimension>();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WebWindowComplex.Json;
|
||||
|
||||
namespace WebWindowComplex.Models
|
||||
{
|
||||
public class SplitDimension
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public SplitDimension(double dDimension, bool bIsRelative, Split Parent, bool IsVertList)
|
||||
{
|
||||
m_dDimension = dDimension;
|
||||
m_bIsRelative = bIsRelative;
|
||||
m_Parent = Parent;
|
||||
m_bIsVertListDim = IsVertList;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public bool bIsRelative
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bIsRelative;
|
||||
}
|
||||
}
|
||||
|
||||
public bool bIsVertListDim
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bIsVertListDim;
|
||||
}
|
||||
}
|
||||
|
||||
public double dDimension
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_dDimension;
|
||||
}
|
||||
set
|
||||
{
|
||||
// Controllo che il valore inserito sia compreso tra 0 e 100
|
||||
if (value > 0 && value < 100)
|
||||
{
|
||||
// se sono in percentuale
|
||||
if (m_bIsRelative)
|
||||
{
|
||||
List<SplitDimension> RelativeDimList = new List<SplitDimension>();
|
||||
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<SplitDimension> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public SplitDimension Copy()
|
||||
{
|
||||
SplitDimension newSplitDim = new SplitDimension(dDimension, bIsRelative, m_Parent, bIsVertListDim);
|
||||
return newSplitDim;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal JsonSplitDimension Serialize()
|
||||
{
|
||||
JsonSplitDimension JsonSplitDimension = new JsonSplitDimension(m_bIsRelative, m_dDimension);
|
||||
return JsonSplitDimension;
|
||||
}
|
||||
|
||||
internal void SetDimension(double dValue)
|
||||
{
|
||||
m_dDimension = dValue;
|
||||
}
|
||||
|
||||
internal void SetIsRelative(bool value)
|
||||
{
|
||||
m_bIsRelative = value;
|
||||
}
|
||||
|
||||
internal void SetIsVertListDim(bool value)
|
||||
{
|
||||
m_bIsVertListDim = value;
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private bool m_bIsRelative = false;
|
||||
|
||||
private bool m_bIsVertListDim = false;
|
||||
|
||||
private double m_dDimension;
|
||||
|
||||
// reference
|
||||
private Split m_Parent;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using WebWindowComplex.Json;
|
||||
using static WebWindowComplex.Json.WindowConst;
|
||||
|
||||
namespace WebWindowComplex.Models
|
||||
{
|
||||
public class Splitted : Area
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public Splitted(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public override Splitted Copy(Area newParentArea)
|
||||
{
|
||||
Splitted newSplitted = new Splitted(newParentArea, ParentWindow);
|
||||
AddCounterGroup();
|
||||
newSplitted.SetIdGroup(nCounterGroup);
|
||||
newSplitted.SetAreaType(AreaType);
|
||||
foreach (var item in AreaList)
|
||||
{
|
||||
Area a = item.Copy(newSplitted);
|
||||
newSplitted.AreaList.Add(a);
|
||||
}
|
||||
return newSplitted;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
internal static Splitted CreateSplitted(Area ParentArea)
|
||||
{
|
||||
Splitted Splitted = new Splitted(ParentArea, ParentArea.ParentWindow);
|
||||
AddCounterGroup();
|
||||
Splitted.SetIdGroup(nCounterGroup);
|
||||
Splitted.SetAreaType(AreaTypes.SPLITTED);
|
||||
return Splitted;
|
||||
}
|
||||
|
||||
internal override JsonArea Serialize()
|
||||
{
|
||||
if (nCounterGroup < IdGroup)
|
||||
Area.nCounterGroup = IdGroup;
|
||||
JsonSplitted JsonSplitted = new JsonSplitted(IdGroup);
|
||||
foreach (var Area in AreaList)
|
||||
JsonSplitted.AreaList.Add(Area.Serialize());
|
||||
return JsonSplitted;
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user