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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user