2859 lines
100 KiB
C#
2859 lines
100 KiB
C#
using Newtonsoft.Json;
|
||
using Newtonsoft.Json.Linq;
|
||
using System.Collections;
|
||
using System.Collections.ObjectModel;
|
||
using System.ComponentModel;
|
||
using System.Drawing;
|
||
using System.Runtime.Intrinsics.Arm;
|
||
using System.Xml.Linq;
|
||
using System.Xml.Serialization;
|
||
using WebWindowTest.Json;
|
||
using Egw.Window.Data;
|
||
using static WebWindowTest.Json.WindowConst;
|
||
using static WebWindowTest.ParametriOpzioni;
|
||
|
||
namespace WebWindowTest
|
||
{
|
||
|
||
public class Window
|
||
{
|
||
public event EventHandler<OnPreviewEventArgs> OnPreview = delegate { };
|
||
|
||
private string m_sProfilePath;
|
||
public string sProfilePath
|
||
{
|
||
get
|
||
{
|
||
return m_sProfilePath;
|
||
}
|
||
set
|
||
{
|
||
m_sProfilePath = value;
|
||
}
|
||
}
|
||
|
||
private string m_sMaterial;
|
||
public string sMaterial
|
||
{
|
||
get
|
||
{
|
||
return m_sMaterial;
|
||
}
|
||
set
|
||
{
|
||
m_sMaterial = value;
|
||
OnUpdatePreview(sSerialized());
|
||
}
|
||
}
|
||
|
||
private string m_sColorMaterial;
|
||
public string sColorMaterial
|
||
{
|
||
get
|
||
{
|
||
return m_sColorMaterial;
|
||
}
|
||
set
|
||
{
|
||
m_sColorMaterial = value;
|
||
OnUpdatePreview(sSerialized());
|
||
}
|
||
}
|
||
|
||
private string m_sGlass;
|
||
public string sGlass
|
||
{
|
||
get
|
||
{
|
||
return m_sGlass;
|
||
}
|
||
set
|
||
{
|
||
m_sGlass = value;
|
||
OnUpdatePreview(sSerialized());
|
||
}
|
||
}
|
||
|
||
private ObservableCollection<Frame> m_AreaList = new ObservableCollection<Frame>();
|
||
public ObservableCollection<Frame> AreaList
|
||
{
|
||
get
|
||
{
|
||
return m_AreaList;
|
||
}
|
||
set
|
||
{
|
||
m_AreaList = value;
|
||
}
|
||
}
|
||
|
||
internal JsonWindow Serialize()
|
||
{
|
||
JsonWindow JsonWindow = new JsonWindow(sProfilePath, sMaterial, sColorMaterial, sGlass);
|
||
foreach (var Area in AreaList)
|
||
JsonWindow.AreaList.Add(Area.Serialize());
|
||
return JsonWindow;
|
||
}
|
||
|
||
internal string sSerialized()
|
||
{
|
||
return JsonConvert.SerializeObject(Serialize(), Formatting.Indented);
|
||
}
|
||
|
||
internal void OnUpdatePreview(string sJwd)
|
||
{
|
||
OnPreviewEventArgs e = new OnPreviewEventArgs(sJwd);
|
||
EventHandler<OnPreviewEventArgs> handler = OnPreview;
|
||
if (handler != null)
|
||
{
|
||
handler(this, e);
|
||
}
|
||
}
|
||
}
|
||
|
||
public class OnPreviewEventArgs : EventArgs
|
||
{
|
||
public string sJwd;
|
||
|
||
public OnPreviewEventArgs(string sJwd)
|
||
{
|
||
this.sJwd = sJwd;
|
||
}
|
||
}
|
||
|
||
public abstract class Area
|
||
{
|
||
// Conteggio dei macro elementi
|
||
private static int m_CounterGroup = 0;
|
||
public static void AddCounterGroup()
|
||
{
|
||
m_CounterGroup++;
|
||
}
|
||
public static int nCounterGroup
|
||
{
|
||
get => m_CounterGroup;
|
||
set => m_CounterGroup = value;
|
||
}
|
||
|
||
private int m_IdGroup;
|
||
public int IdGroup
|
||
{
|
||
get
|
||
{
|
||
return m_IdGroup;
|
||
}
|
||
|
||
set
|
||
{
|
||
m_IdGroup = value;
|
||
}
|
||
}
|
||
public void SetIdGroup(int nIdGroup)
|
||
{
|
||
m_IdGroup = nIdGroup;
|
||
}
|
||
|
||
protected Window m_ParentWindow;
|
||
public Window ParentWindow
|
||
{
|
||
get
|
||
{
|
||
return m_ParentWindow;
|
||
}
|
||
}
|
||
|
||
protected int m_nAreaId = -1;
|
||
public int nAreaId
|
||
{
|
||
get
|
||
{
|
||
return m_nAreaId;
|
||
}
|
||
set
|
||
{
|
||
m_nAreaId = value;
|
||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||
}
|
||
}
|
||
|
||
private List<Area> m_AreaList = new List<Area>();
|
||
public List<Area> AreaList
|
||
{
|
||
get
|
||
{
|
||
return m_AreaList;
|
||
}
|
||
set
|
||
{
|
||
m_AreaList = value;
|
||
}
|
||
}
|
||
|
||
private AreaTypes m_AreaType;
|
||
public AreaTypes AreaType
|
||
{
|
||
get
|
||
{
|
||
return m_AreaType;
|
||
}
|
||
set
|
||
{
|
||
m_AreaType = value;
|
||
}
|
||
}
|
||
internal void SetAreaType(AreaTypes AreaType)
|
||
{
|
||
m_AreaType = AreaType;
|
||
}
|
||
|
||
private Area m_ParentArea;
|
||
public Area ParentArea
|
||
{
|
||
get
|
||
{
|
||
return m_ParentArea;
|
||
}
|
||
}
|
||
internal void SetParentArea(Area ParentArea)
|
||
{
|
||
m_ParentArea = ParentArea;
|
||
}
|
||
|
||
public Area(Area ParentArea, Window ParentWindow)
|
||
{
|
||
m_ParentWindow = ParentWindow;
|
||
m_ParentArea = ParentArea;
|
||
}
|
||
|
||
internal abstract JsonArea Serialize();
|
||
|
||
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 void AddSash()
|
||
{
|
||
List<Area> ContentArea = new List<Area>();
|
||
Area ParentArea = AreaList[0].ParentArea;
|
||
// Salvo gli oggetti già presenti e li cancello da AreaList
|
||
ContentArea.Add(AreaList[0]);
|
||
AreaList.Remove(AreaList[0]);
|
||
// Aggiungo Area sash di default
|
||
Sash SashArea = Sash.CreateSash(ParentArea);
|
||
Sash.s_SelFamilyHW = Sash.s_FamilyHardwareList.First();
|
||
SashArea.RefreshHardwareList();
|
||
SashArea.SetSelHardwareFromId(SashArea.HardwareList.First().Id);
|
||
// 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());
|
||
}
|
||
|
||
public void SwapAree()
|
||
{
|
||
Area tempArea;
|
||
if (this is Sash || this is Split)
|
||
{
|
||
tempArea = AreaList[0];
|
||
AreaList[0] = AreaList[1];
|
||
AreaList[1] = tempArea;
|
||
}
|
||
}
|
||
|
||
public abstract Area Copy(Area ParentArea);
|
||
}
|
||
|
||
public class Frame : Area
|
||
{
|
||
private ObservableCollection<IdNameStruct> m_ShapeList = new ObservableCollection<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")
|
||
};
|
||
public ObservableCollection<IdNameStruct> ShapeList
|
||
{
|
||
get
|
||
{
|
||
return m_ShapeList;
|
||
}
|
||
}
|
||
|
||
private Shapes m_Shape;
|
||
public Shapes Shape
|
||
{
|
||
get
|
||
{
|
||
return m_Shape;
|
||
}
|
||
}
|
||
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));
|
||
//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, 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());
|
||
}
|
||
}
|
||
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;
|
||
}
|
||
|
||
private ObservableCollection<FrameDimension> m_DimensionList = new ObservableCollection<FrameDimension>();
|
||
public ObservableCollection<FrameDimension> DimensionList
|
||
{
|
||
get
|
||
{
|
||
return m_DimensionList;
|
||
}
|
||
}
|
||
|
||
private ObservableCollection<Joint> m_JointList = new ObservableCollection<Joint>();
|
||
public ObservableCollection<Joint> JointList
|
||
{
|
||
get
|
||
{
|
||
return m_JointList;
|
||
}
|
||
set
|
||
{
|
||
m_JointList = value;
|
||
}
|
||
}
|
||
|
||
private bool m_bBottomRail;
|
||
public bool BottomRail
|
||
{
|
||
get
|
||
{
|
||
return m_bBottomRail;
|
||
}
|
||
set
|
||
{
|
||
m_bBottomRail = value;
|
||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||
}
|
||
}
|
||
internal void SetBottomRail(bool bBottomRail)
|
||
{
|
||
m_bBottomRail = bBottomRail;
|
||
}
|
||
|
||
private int m_nBottomRailQty = 0;
|
||
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());
|
||
}
|
||
}
|
||
internal void SetBottomRailQty(int nBottomRailQty)
|
||
{
|
||
m_nBottomRailQty = nBottomRailQty;
|
||
}
|
||
|
||
public Frame(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow)
|
||
{
|
||
}
|
||
|
||
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;
|
||
}
|
||
|
||
public override Frame Copy(Area ParentArea)
|
||
{
|
||
return null;
|
||
}
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
public class Sash : Area
|
||
{
|
||
// 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>();
|
||
// Macro famiglia hardware scelta dal chiamante
|
||
public static string s_SelFamilyHW = "";
|
||
|
||
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]);
|
||
|
||
//while (AreaList.Count > 0)
|
||
//{
|
||
// if (AreaList.Count == 1 & AreaList[0].AreaList.Count > 0)
|
||
// {
|
||
// foreach (Area selArea in AreaList[0].AreaList)
|
||
// {
|
||
// ContentArea.Add(selArea);
|
||
// }
|
||
// }
|
||
// AreaList.Remove(AreaList[AreaList.Count - 1]);
|
||
//}
|
||
//if (ContentArea.Count > 0)
|
||
//{
|
||
// AreaList = ContentArea;
|
||
//}
|
||
}
|
||
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());
|
||
}
|
||
}
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
|
||
private List<IdNameStruct> m_OrientationSashTypeList = new List<IdNameStruct>
|
||
{
|
||
new IdNameStruct((int)OrientationSash.VERTICAL, "Vertical"),
|
||
new IdNameStruct((int)OrientationSash.HORIZONTAL, "Horizontal"),
|
||
};
|
||
public List<IdNameStruct> OrientationSashTypeList
|
||
{
|
||
get
|
||
{
|
||
return m_OrientationSashTypeList;
|
||
}
|
||
}
|
||
|
||
private OrientationSash m_SelOrientationSashType;
|
||
public OrientationSash SelOrientationSashType
|
||
{
|
||
get
|
||
{
|
||
return m_SelOrientationSashType;
|
||
}
|
||
set
|
||
{
|
||
m_SelOrientationSashType = value;
|
||
}
|
||
}
|
||
|
||
public OrientationSash OrientationSashType
|
||
{
|
||
get
|
||
{
|
||
return (OrientationSash)m_SelOrientationSashType;
|
||
}
|
||
}
|
||
internal void SetOrientationSashType(OrientationSash value)
|
||
{
|
||
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());
|
||
}
|
||
}
|
||
|
||
private bool m_bIsSashVertical;
|
||
public bool bIsSashVertical
|
||
{
|
||
get
|
||
{
|
||
return m_bIsSashVertical;
|
||
}
|
||
set
|
||
{
|
||
m_bIsSashVertical = value;
|
||
}
|
||
}
|
||
internal void SetIsSashVertical(bool IsSashVertical)
|
||
{
|
||
m_bIsSashVertical = IsSashVertical;
|
||
if (IsSashVertical)
|
||
{
|
||
m_SelOrientationSashType = OrientationSash.VERTICAL;
|
||
}
|
||
else
|
||
{
|
||
m_SelOrientationSashType = OrientationSash.HORIZONTAL;
|
||
}
|
||
}
|
||
|
||
private bool m_bIsMeasureGlass;
|
||
public bool bIsMeasureGlass
|
||
{
|
||
get
|
||
{
|
||
return m_bIsMeasureGlass;
|
||
}
|
||
set
|
||
{
|
||
m_bIsMeasureGlass = value;
|
||
}
|
||
}
|
||
internal void SetIsMeasureGlass(bool IsMeasureGlass)
|
||
{
|
||
m_bIsMeasureGlass = IsMeasureGlass;
|
||
}
|
||
|
||
private ObservableCollection<SashDimension> m_SashList = new ObservableCollection<SashDimension>();
|
||
public ObservableCollection<SashDimension> SashList
|
||
{
|
||
get
|
||
{
|
||
return m_SashList;
|
||
}
|
||
set
|
||
{
|
||
m_SashList = value;
|
||
}
|
||
}
|
||
|
||
private SashTypes m_SashType;
|
||
public SashTypes SashType
|
||
{
|
||
get
|
||
{
|
||
return m_SashType;
|
||
}
|
||
set
|
||
{
|
||
m_SashType = value;
|
||
}
|
||
}
|
||
internal void SetSashType(SashTypes SashType)
|
||
{
|
||
m_SashType = SashType;
|
||
}
|
||
|
||
private ObservableCollection<Joint> m_JointList = new ObservableCollection<Joint>();
|
||
public ObservableCollection<Joint> JointList
|
||
{
|
||
get
|
||
{
|
||
return m_JointList;
|
||
}
|
||
set
|
||
{
|
||
m_JointList = value;
|
||
}
|
||
}
|
||
|
||
private bool m_bSashBottomRail;
|
||
public bool SashBottomRail
|
||
{
|
||
get
|
||
{
|
||
return m_bSashBottomRail;
|
||
}
|
||
set
|
||
{
|
||
m_bSashBottomRail = value;
|
||
}
|
||
}
|
||
internal void SetSashBottomRail(bool bBottomRail)
|
||
{
|
||
m_bSashBottomRail = bBottomRail;
|
||
}
|
||
|
||
private int m_nSashBottomRailQty;
|
||
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());
|
||
}
|
||
}
|
||
}
|
||
internal void SetSashBottomRailQty(int nBottomRailQty)
|
||
{
|
||
m_nSashBottomRailQty = nBottomRailQty;
|
||
}
|
||
|
||
private bool m_bIsPercentage = true;
|
||
public bool bIsPercentage
|
||
{
|
||
get
|
||
{
|
||
return m_bIsPercentage;
|
||
}
|
||
}
|
||
|
||
private ObservableCollection<Hardware> m_HardwareList = new ObservableCollection<Hardware>();
|
||
public ObservableCollection<Hardware> HardwareList
|
||
{
|
||
get
|
||
{
|
||
return m_HardwareList;
|
||
}
|
||
}
|
||
|
||
private Hardware m_SelHardware;
|
||
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");
|
||
// }
|
||
// }
|
||
}
|
||
}
|
||
|
||
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 == sId) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0);
|
||
else
|
||
m_SelHardware = m_HardwareList.FirstOrDefault(x => x.Id == sId) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0);
|
||
if (m_SelHardware == null)
|
||
m_SelHardware = m_HardwareList[0];
|
||
}
|
||
|
||
public int SelHardwareTypeIndex
|
||
{
|
||
get
|
||
{
|
||
for (int i = 0; i < m_HardwareList.Count; i++)
|
||
{
|
||
if (m_HardwareList[i].Equals(m_SelHardware))
|
||
return i;
|
||
}
|
||
return 0;
|
||
//return IdNameStruct.IndFromId((int)m_SelHardware, m_HardwareList);
|
||
}
|
||
set
|
||
{
|
||
m_SelHardware = m_HardwareList[value];
|
||
//m_SelOpeningType = (Openings)IdNameStruct.IdFromInd(value, m_OpeningTypeList);
|
||
ParentWindow.OnUpdatePreview(ParentWindow.sSerialized());
|
||
}
|
||
}
|
||
|
||
internal void SetFirstHardware()
|
||
{
|
||
if (m_HardwareList.Count > 0)
|
||
{
|
||
m_SelHardware = m_HardwareList[0];
|
||
}
|
||
}
|
||
|
||
private ObservableCollection<ParametriOpzioni> m_HwdOptionList = new ObservableCollection<ParametriOpzioni>();
|
||
public ObservableCollection<ParametriOpzioni> HwdOptionList
|
||
{
|
||
get
|
||
{
|
||
return m_HwdOptionList;
|
||
}
|
||
}
|
||
|
||
public Sash(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow)
|
||
{
|
||
}
|
||
|
||
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.RefreshHardwareList();
|
||
newSash.RefreshHardwareOptionList();
|
||
newSash.SetFirstHardware();
|
||
return newSash;
|
||
}
|
||
private string FindSashShape()
|
||
{
|
||
return "Rectangle";
|
||
}
|
||
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;
|
||
}
|
||
}
|
||
}
|
||
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;
|
||
}
|
||
|
||
public void RefreshHardwareList()
|
||
{
|
||
m_HardwareList.Clear();
|
||
string sSashShape = FindSashShape();
|
||
Enums.OpeningTypes sOpeningType = ConvertOpeningType();
|
||
var iComp = StringComparison.InvariantCultureIgnoreCase;
|
||
var rawList = m_HardwareCompleteList
|
||
.Where(x => x.Id == "000000" ||
|
||
(x.FamilyName.Equals(s_SelFamilyHW, iComp) && x.SashQty == nSashQty && x.Shape.Equals(sSashShape, iComp) && x.OpeningType.Equals(sOpeningType))
|
||
)
|
||
.ToList();
|
||
if (rawList != null && rawList.Count > 0)
|
||
{
|
||
m_HardwareList = new ObservableCollection<Hardware>(rawList);
|
||
}
|
||
else
|
||
{
|
||
m_HardwareList = new ObservableCollection<Hardware>();
|
||
}
|
||
}
|
||
|
||
internal void RefreshHardwareOptionList()
|
||
{
|
||
m_HwdOptionList.Clear();
|
||
}
|
||
|
||
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;
|
||
}
|
||
}
|
||
}
|
||
|
||
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.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 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());
|
||
}
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
public class Split : Area
|
||
{
|
||
private bool m_bSplitStartVert = true;
|
||
public bool bSplitStartVert
|
||
{
|
||
get
|
||
{
|
||
return m_bSplitStartVert;
|
||
}
|
||
set
|
||
{
|
||
m_bSplitStartVert = value;
|
||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||
}
|
||
}
|
||
internal void SetSplitStartVert(bool SplitStartVert)
|
||
{
|
||
bSplitStartVert = SplitStartVert;
|
||
}
|
||
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());
|
||
}
|
||
}
|
||
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);
|
||
}
|
||
}
|
||
|
||
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());
|
||
}
|
||
}
|
||
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);
|
||
}
|
||
}
|
||
|
||
private ObservableCollection<IdNameStruct> m_SplitShapeList = new ObservableCollection<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")
|
||
};
|
||
public ObservableCollection<IdNameStruct> SplitShapeList
|
||
{
|
||
get
|
||
{
|
||
return m_SplitShapeList;
|
||
}
|
||
}
|
||
|
||
private SplitShapes m_SelSplitShape;
|
||
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());
|
||
}
|
||
}
|
||
internal void SetSplitShape(SplitShapes Value, bool NotifyProperty = false)
|
||
{
|
||
m_SelSplitShape = Value;
|
||
}
|
||
internal SplitShapes SelSplitShape
|
||
{
|
||
get
|
||
{
|
||
return m_SelSplitShape;
|
||
}
|
||
}
|
||
|
||
private bool m_bIsPercentage = true;
|
||
public bool bIsPercentage
|
||
{
|
||
get
|
||
{
|
||
return m_bIsPercentage;
|
||
}
|
||
}
|
||
|
||
private ObservableCollection<SplitDimension> m_SplitPositionList = new ObservableCollection<SplitDimension>();
|
||
public ObservableCollection<SplitDimension> SplitPositionList
|
||
{
|
||
get
|
||
{
|
||
return m_SplitPositionList;
|
||
}
|
||
set
|
||
{
|
||
m_SplitPositionList = value;
|
||
}
|
||
}
|
||
|
||
private ObservableCollection<SplitDimension> m_SplitVertList = new ObservableCollection<SplitDimension>();
|
||
public ObservableCollection<SplitDimension> SplitVertList
|
||
{
|
||
get
|
||
{
|
||
return m_SplitVertList;
|
||
}
|
||
set
|
||
{
|
||
m_SplitVertList = value;
|
||
}
|
||
}
|
||
|
||
private ObservableCollection<SplitDimension> m_SplitHorizList = new ObservableCollection<SplitDimension>();
|
||
public ObservableCollection<SplitDimension> SplitHorizList
|
||
{
|
||
get
|
||
{
|
||
return m_SplitHorizList;
|
||
}
|
||
set
|
||
{
|
||
m_SplitHorizList = value;
|
||
}
|
||
}
|
||
|
||
public Split(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow)
|
||
{
|
||
}
|
||
|
||
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;
|
||
}
|
||
|
||
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());
|
||
}
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
public class Splitted : Area
|
||
{
|
||
public Splitted(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow)
|
||
{
|
||
}
|
||
|
||
internal static Splitted CreateSplitted(Area ParentArea)
|
||
{
|
||
Splitted Splitted = new Splitted(ParentArea, ParentArea.ParentWindow);
|
||
AddCounterGroup();
|
||
Splitted.SetIdGroup(nCounterGroup);
|
||
Splitted.SetAreaType(AreaTypes.SPLITTED);
|
||
return Splitted;
|
||
}
|
||
|
||
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;
|
||
}
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
public class Fill : Area
|
||
{
|
||
private List<IdNameStruct> m_FillTypeList = new List<IdNameStruct>
|
||
{
|
||
new IdNameStruct((int)FillTypes.GLASS, "Glass"),
|
||
new IdNameStruct((int)FillTypes.WOOD, "Wood")
|
||
};
|
||
public List<IdNameStruct> FillTypeList
|
||
{
|
||
get
|
||
{
|
||
return m_FillTypeList;
|
||
}
|
||
}
|
||
private FillTypes m_SelFillType;
|
||
public FillTypes SelFillType
|
||
{
|
||
get
|
||
{
|
||
return m_SelFillType;
|
||
}
|
||
set
|
||
{
|
||
m_SelFillType = value;
|
||
}
|
||
}
|
||
|
||
public FillTypes FillType
|
||
{
|
||
get
|
||
{
|
||
return (FillTypes)m_SelFillType;
|
||
}
|
||
}
|
||
internal void SetFillType(FillTypes value)
|
||
{
|
||
m_SelFillType = value;
|
||
m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized());
|
||
}
|
||
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());
|
||
}
|
||
}
|
||
|
||
public Fill(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow)
|
||
{
|
||
}
|
||
|
||
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;
|
||
}
|
||
|
||
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;
|
||
}
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
public class Joint
|
||
{
|
||
protected Area m_ParentArea;
|
||
public Area ParentArea
|
||
{
|
||
get
|
||
{
|
||
return m_ParentArea;
|
||
}
|
||
}
|
||
|
||
private int m_nIndex;
|
||
public int nIndex
|
||
{
|
||
get
|
||
{
|
||
return m_nIndex;
|
||
}
|
||
}
|
||
|
||
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")
|
||
};
|
||
public List<IdNameStruct> JointTypeList
|
||
{
|
||
get
|
||
{
|
||
return m_JointTypeList;
|
||
}
|
||
}
|
||
|
||
private Joints m_SelJointType;
|
||
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());
|
||
}
|
||
}
|
||
public Joints SelJointType
|
||
{
|
||
get
|
||
{
|
||
return m_SelJointType;
|
||
}
|
||
set
|
||
{
|
||
m_SelJointType = value;
|
||
}
|
||
}
|
||
internal void SetSelJointType(Joints value)
|
||
{
|
||
m_SelJointType = value;
|
||
//NotifyPropertyChanged(nameof(SelJointTypeIndex));
|
||
}
|
||
|
||
public Joint Copy()
|
||
{
|
||
Joint newJoint = new Joint(ParentArea, nIndex, SelJointType);
|
||
return newJoint;
|
||
}
|
||
|
||
public Joint(Area ParentArea, int nIndex, Joints SelJointType)
|
||
{
|
||
m_ParentArea = ParentArea;
|
||
m_nIndex = nIndex;
|
||
m_SelJointType = SelJointType;
|
||
}
|
||
|
||
internal JsonJoint Serialize()
|
||
{
|
||
JsonJoint JsonJoint = new JsonJoint(m_nIndex, m_SelJointType);
|
||
return JsonJoint;
|
||
}
|
||
}
|
||
|
||
public partial class ParametriOpzioni
|
||
{
|
||
public enum HDWOPTIONTYPES : int
|
||
{
|
||
TEXT = 1,
|
||
LENGHT = 2,
|
||
COMBO = 3
|
||
}
|
||
|
||
protected HDWOPTIONTYPES m_Type;
|
||
public HDWOPTIONTYPES Type
|
||
{
|
||
get
|
||
{
|
||
return m_Type;
|
||
}
|
||
}
|
||
|
||
private string m_sName;
|
||
public string sName
|
||
{
|
||
get
|
||
{
|
||
return m_sName;
|
||
}
|
||
}
|
||
|
||
private string m_sDescription;
|
||
public string sDescription
|
||
{
|
||
get
|
||
{
|
||
return m_sDescription;
|
||
}
|
||
}
|
||
|
||
private Visibility m_OptVisibility;
|
||
public Visibility OptVisibility
|
||
{
|
||
get
|
||
{
|
||
return m_OptVisibility;
|
||
}
|
||
}
|
||
|
||
public ParametriOpzioni(ParametriOpzioniParametri HdwOptionParam)
|
||
{
|
||
m_sName = HdwOptionParam.NomeParametro;
|
||
m_sDescription = HdwOptionParam.DescrizioneParametro;
|
||
m_OptVisibility = Visibility.VISIBLE;
|
||
// If(HdwOptionParam.Visible.ToLower = "true", Visibility.Visible, Visibility.Collapsed)
|
||
}
|
||
}
|
||
|
||
public class AGBOptionCombo : ParametriOpzioni
|
||
{
|
||
private List<AGBOptionParameter> m_ValueList = new List<AGBOptionParameter>();
|
||
public List<AGBOptionParameter> ValueList
|
||
{
|
||
get
|
||
{
|
||
return m_ValueList;
|
||
}
|
||
}
|
||
|
||
private AGBOptionParameter m_sValue;
|
||
public AGBOptionParameter sValue
|
||
{
|
||
get
|
||
{
|
||
return m_sValue;
|
||
}
|
||
set
|
||
{
|
||
m_sValue = value;
|
||
}
|
||
}
|
||
|
||
public AGBOptionCombo(ParametriOpzioniParametri HdwOptionParam) : base(HdwOptionParam)
|
||
{
|
||
m_Type = HDWOPTIONTYPES.COMBO;
|
||
foreach (var Value in HdwOptionParam.Opzioni)
|
||
m_ValueList.Add(new AGBOptionParameter(Value.Valore, Value.DescrizioneOpzione));
|
||
m_sValue = m_ValueList.FirstOrDefault(x => x.sValue == HdwOptionParam.ValoreCorrente) ?? new AGBOptionParameter("", "");
|
||
}
|
||
}
|
||
|
||
public class AGBOptionParameter
|
||
{
|
||
private string m_sValue;
|
||
public string sValue
|
||
{
|
||
get
|
||
{
|
||
return m_sValue;
|
||
}
|
||
}
|
||
|
||
private string m_sDescription;
|
||
public string sDescription
|
||
{
|
||
get
|
||
{
|
||
return m_sDescription;
|
||
}
|
||
}
|
||
|
||
public AGBOptionParameter(string sValue, string sDescription)
|
||
{
|
||
m_sValue = sValue;
|
||
m_sDescription = sDescription;
|
||
}
|
||
}
|
||
|
||
public class AGBOptionText : ParametriOpzioni
|
||
{
|
||
private string m_sValue;
|
||
public string sValue
|
||
{
|
||
get
|
||
{
|
||
return m_sValue;
|
||
}
|
||
set
|
||
{
|
||
m_sValue = value;
|
||
}
|
||
}
|
||
|
||
public AGBOptionText(ParametriOpzioniParametri HdwOptionParam) : base(HdwOptionParam)
|
||
{
|
||
m_Type = HDWOPTIONTYPES.TEXT;
|
||
m_sValue = HdwOptionParam.ValoreCorrente;
|
||
}
|
||
}
|
||
|
||
public class FrameDimension
|
||
{
|
||
// valore massimo e minimo della dimensione del frame
|
||
int MaxDim = 4000;
|
||
int MinDim = 600;
|
||
|
||
protected Frame m_ParentFrame;
|
||
public Frame ParentFrame
|
||
{
|
||
get
|
||
{
|
||
return m_ParentFrame;
|
||
}
|
||
}
|
||
|
||
private bool m_bIsLen = false;
|
||
|
||
private int m_nIndex;
|
||
public int nIndex
|
||
{
|
||
get
|
||
{
|
||
return m_nIndex;
|
||
}
|
||
}
|
||
|
||
private string m_sName;
|
||
public string sName
|
||
{
|
||
get
|
||
{
|
||
return m_sName;
|
||
}
|
||
}
|
||
|
||
private double m_dValue;
|
||
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 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;
|
||
}
|
||
|
||
internal JsonFrameDimension Serialize()
|
||
{
|
||
JsonFrameDimension JsonFrameDimension = new JsonFrameDimension(m_nIndex, m_sName, m_dValue);
|
||
return JsonFrameDimension;
|
||
}
|
||
}
|
||
|
||
public class SashDimension
|
||
{
|
||
// reference
|
||
private Sash m_Parent;
|
||
|
||
private int m_nSashId;
|
||
public int nSashId
|
||
{
|
||
get
|
||
{
|
||
return m_nSashId;
|
||
}
|
||
}
|
||
|
||
private bool m_bIsRelative = false;
|
||
public bool bIsRelative
|
||
{
|
||
get
|
||
{
|
||
return m_bIsRelative;
|
||
}
|
||
}
|
||
|
||
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, "←┐")
|
||
};
|
||
public List<IdNameStruct> OpeningTypeList
|
||
{
|
||
get
|
||
{
|
||
return m_OpeningTypeList;
|
||
}
|
||
}
|
||
|
||
private Openings m_SelOpeningType;
|
||
public Openings SelOpeningType
|
||
{
|
||
get
|
||
{
|
||
return m_SelOpeningType;
|
||
}
|
||
set
|
||
{
|
||
m_SelOpeningType = value;
|
||
m_Parent.RefreshHardwareList();
|
||
m_Parent.RefreshHardwareOptionList();
|
||
m_Parent.SetFirstHardware();
|
||
}
|
||
}
|
||
public Openings OpeningType
|
||
{
|
||
get
|
||
{
|
||
return (Openings)m_SelOpeningType;
|
||
}
|
||
}
|
||
internal void SetOpeningType(Openings value)
|
||
{
|
||
m_SelOpeningType = value;
|
||
}
|
||
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());
|
||
}
|
||
}
|
||
|
||
private bool m_bHasHandle;
|
||
public bool bHasHandle
|
||
{
|
||
get
|
||
{
|
||
return m_bHasHandle;
|
||
}
|
||
set
|
||
{
|
||
m_bHasHandle = value;
|
||
m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized());
|
||
}
|
||
}
|
||
internal void SetHasHandle(bool value)
|
||
{
|
||
m_bHasHandle = value;
|
||
}
|
||
|
||
private double m_dDimension;
|
||
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());
|
||
}
|
||
}
|
||
}
|
||
internal void SetDimension(double dValue)
|
||
{
|
||
m_dDimension = dValue;
|
||
}
|
||
|
||
public SashDimension Copy()
|
||
{
|
||
SashDimension newSashDim = new SashDimension(dDimension, bIsRelative, m_Parent, m_nSashId);
|
||
newSashDim.SetOpeningType(SelOpeningType);
|
||
newSashDim.SetHasHandle(bHasHandle);
|
||
return newSashDim;
|
||
}
|
||
|
||
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);
|
||
}
|
||
|
||
internal JsonSashDimension Serialize()
|
||
{
|
||
JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, m_bHasHandle, m_dDimension, m_nSashId);
|
||
return JsonSashDimension;
|
||
}
|
||
}
|
||
|
||
public class SplitDimension
|
||
{
|
||
// reference
|
||
private Split m_Parent;
|
||
|
||
private bool m_bIsRelative = false;
|
||
public bool bIsRelative
|
||
{
|
||
get
|
||
{
|
||
return m_bIsRelative;
|
||
}
|
||
}
|
||
internal void SetIsRelative(bool value)
|
||
{
|
||
m_bIsRelative = value;
|
||
}
|
||
|
||
private bool m_bIsVertListDim = false;
|
||
public bool bIsVertListDim
|
||
{
|
||
get
|
||
{
|
||
return m_bIsVertListDim;
|
||
}
|
||
}
|
||
internal void SetIsVertListDim(bool value)
|
||
{
|
||
m_bIsVertListDim = value;
|
||
}
|
||
|
||
|
||
private double m_dDimension;
|
||
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());
|
||
}
|
||
|
||
}
|
||
}
|
||
internal void SetDimension(double dValue)
|
||
{
|
||
m_dDimension = dValue;
|
||
}
|
||
|
||
public SplitDimension Copy()
|
||
{
|
||
SplitDimension newSplitDim = new SplitDimension(dDimension, bIsRelative, m_Parent, bIsVertListDim);
|
||
return newSplitDim;
|
||
}
|
||
public SplitDimension(double dDimension, bool bIsRelative, Split Parent, bool IsVertList)
|
||
{
|
||
m_dDimension = dDimension;
|
||
m_bIsRelative = bIsRelative;
|
||
m_Parent = Parent;
|
||
m_bIsVertListDim = IsVertList;
|
||
}
|
||
|
||
internal JsonSplitDimension Serialize()
|
||
{
|
||
JsonSplitDimension JsonSplitDimension = new JsonSplitDimension(m_bIsRelative, m_dDimension);
|
||
return JsonSplitDimension;
|
||
}
|
||
}
|
||
|
||
public struct IdNameStruct
|
||
{
|
||
private int m_Id;
|
||
|
||
private string m_Name;
|
||
|
||
public int Id
|
||
{
|
||
get
|
||
{
|
||
return m_Id;
|
||
}
|
||
set
|
||
{
|
||
m_Id = value;
|
||
}
|
||
}
|
||
|
||
public string Name
|
||
{
|
||
get
|
||
{
|
||
return m_Name;
|
||
}
|
||
set
|
||
{
|
||
m_Name = value;
|
||
}
|
||
}
|
||
|
||
public IdNameStruct(int Id, string Name)
|
||
{
|
||
this = default(IdNameStruct);
|
||
m_Id = Id;
|
||
m_Name = Name;
|
||
}
|
||
|
||
public override string ToString()
|
||
{
|
||
return Name;
|
||
}
|
||
|
||
public static int IndFromId(int Id, ObservableCollection<IdNameStruct> List)
|
||
{
|
||
checked
|
||
{
|
||
int num = List.Count - 1;
|
||
for (int i = 0; i <= num; i++)
|
||
{
|
||
if (List[i].Id == Id)
|
||
{
|
||
return i;
|
||
}
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
public static int IndFromId(int Id, List<IdNameStruct> List)
|
||
{
|
||
checked
|
||
{
|
||
int num = List.Count - 1;
|
||
for (int i = 0; i <= num; i++)
|
||
{
|
||
if (List[i].Id == Id)
|
||
{
|
||
return i;
|
||
}
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
public static int IdFromInd(int Ind, ObservableCollection<IdNameStruct> List)
|
||
{
|
||
return List[Ind].Id;
|
||
}
|
||
|
||
public static int IdFromInd(int Ind, List<IdNameStruct> List)
|
||
{
|
||
return List[Ind].Id;
|
||
}
|
||
|
||
public static int IndFromId(int Id, ObservableCollection<object> List)
|
||
{
|
||
checked
|
||
{
|
||
int num = List.Count - 1;
|
||
for (int i = 0; i <= num; i++)
|
||
{
|
||
if (List[i] is IdNameStruct && ((IdNameStruct)List[i]).Id == Id)
|
||
{
|
||
return i;
|
||
}
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
public static int IndFromId(int Id, List<object> List)
|
||
{
|
||
checked
|
||
{
|
||
int num = List.Count - 1;
|
||
for (int i = 0; i <= num; i++)
|
||
{
|
||
if (List[i] is IdNameStruct && ((IdNameStruct)List[i]).Id == Id)
|
||
{
|
||
return i;
|
||
}
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
public static int IdFromInd(int Ind, ObservableCollection<object> List)
|
||
{
|
||
if (List[Ind] is IdNameStruct)
|
||
{
|
||
return ((IdNameStruct)List[Ind]).Id;
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
public static int IdFromInd(int Ind, List<object> List)
|
||
{
|
||
if (List[Ind] is IdNameStruct)
|
||
{
|
||
return ((IdNameStruct)List[Ind]).Id;
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
public static int IdFromName(string Name, ObservableCollection<object> List)
|
||
{
|
||
checked
|
||
{
|
||
int num = List.Count - 1;
|
||
for (int i = 0; i <= num; i++)
|
||
{
|
||
if (string.Compare(((IdNameStruct)List[i]).Name, Name, false) == 0)
|
||
{
|
||
return ((IdNameStruct)List[i]).Id;
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
public static int IdFromName(string Name, List<object> List)
|
||
{
|
||
checked
|
||
{
|
||
int num = List.Count - 1;
|
||
for (int i = 0; i <= num; i++)
|
||
{
|
||
if (string.Compare(((IdNameStruct)List[i]).Name, Name, false) == 0)
|
||
{
|
||
return ((IdNameStruct)List[i]).Id;
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|