e8cecb3113
- Aggiornato readme
221 lines
5.9 KiB
C#
221 lines
5.9 KiB
C#
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 GroupId
|
|
{
|
|
get
|
|
{
|
|
return m_GroupId;
|
|
}
|
|
|
|
set
|
|
{
|
|
m_GroupId = 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 void AddFirstSash()
|
|
{
|
|
// Salvo il parent
|
|
Area ParentArea = AreaList[0].ParentArea;
|
|
// Creo area sash di default
|
|
Sash SashArea = Sash.CreateSash(ParentArea);
|
|
// Inserisco famiglia hardware vuota
|
|
SashArea.SetSelFamilyHardware("");
|
|
// Inserisco hardware di default
|
|
SashArea.SetSelHardwareFromId("000000");
|
|
// 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);
|
|
// Inserisco il riempimento precedente
|
|
AreaList[0].AreaList.Add(ContentArea[0]);
|
|
AreaList[0].AreaList[0].SetParentArea(AreaList[0]);
|
|
// Richiesta SVG con hardware di default
|
|
ParentWindow.OnUpdatePreview(ParentWindow.sSerialized());
|
|
}
|
|
|
|
public void AddSplit()
|
|
{
|
|
// Salvo il parent
|
|
Area ParentArea = AreaList[0].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 SetGroupId(int nGroupId)
|
|
{
|
|
m_GroupId = nGroupId;
|
|
}
|
|
|
|
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(bool hideHw);
|
|
|
|
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_GroupId;
|
|
private Area m_ParentArea;
|
|
|
|
#endregion Private Fields
|
|
|
|
|
|
}
|
|
} |