- Inizio gestione opzioni hardware
- Aggiunta chiamata per opzioni hardware - Aggiunto componente per AGBOptionCombo
This commit is contained in:
@@ -7,11 +7,11 @@ using static WebWindowComplex.Json.WindowConst;
|
||||
|
||||
namespace WebWindowComplex.Models
|
||||
{
|
||||
public partial class ParametriOpzioni
|
||||
public partial class AGBOption
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public ParametriOpzioni(ParametriOpzioniParametri HdwOptionParam)
|
||||
public AGBOption(ParametriOpzioniParametri HdwOptionParam)
|
||||
{
|
||||
m_sName = HdwOptionParam.NomeParametro;
|
||||
m_sDescription = HdwOptionParam.DescrizioneParametro;
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace WebWindowComplex.Models
|
||||
{
|
||||
public class AGBOptionCombo : ParametriOpzioni
|
||||
public class AGBOptionCombo : AGBOption
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace WebWindowComplex.Models
|
||||
{
|
||||
public class AGBOptionText : ParametriOpzioni
|
||||
public class AGBOptionText : AGBOption
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
|
||||
@@ -98,67 +98,86 @@ namespace WebWindowComplex.Models
|
||||
m_CounterGroup++;
|
||||
}
|
||||
|
||||
public bool AddFirstSash()
|
||||
public void AddFirstSash()
|
||||
{
|
||||
bool answ = false;
|
||||
// Salvo il parent
|
||||
Area ParentArea = AreaList[0].ParentArea;
|
||||
// Creo area sash di default
|
||||
Sash SashArea = Sash.CreateSash(ParentArea);
|
||||
// ricerco tra tutti 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.SetSelFamilyHardware(listHwValid.FamilyName);
|
||||
#if false
|
||||
SashArea.ReqRefreshShape();
|
||||
#endif
|
||||
SashArea.RefreshHardwareList();
|
||||
if (SashArea.HardwareList.Count == 0)
|
||||
{
|
||||
//answ = true;
|
||||
SashArea.SetSelHardwareFromId("000000");
|
||||
}
|
||||
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;
|
||||
// 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]);
|
||||
ParentWindow.OnUpdatePreview(ParentWindow.sSerialized());
|
||||
}
|
||||
|
||||
// public void AddFirstSash()
|
||||
// {
|
||||
// // Salvo il parent
|
||||
// Area ParentArea = AreaList[0].ParentArea;
|
||||
// // Creo area sash di default
|
||||
// Sash SashArea = Sash.CreateSash(ParentArea);
|
||||
// // ricerco tra tutti 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.SetSelFamilyHardware(listHwValid.FamilyName);
|
||||
//#if false
|
||||
// SashArea.ReqRefreshShape();
|
||||
//#endif
|
||||
// SashArea.RefreshHardwareList();
|
||||
// if (SashArea.HardwareList.Count == 0)
|
||||
// {
|
||||
// //answ = true;
|
||||
// SashArea.SetSelHardwareFromId("000000");
|
||||
// }
|
||||
// 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());
|
||||
// }
|
||||
// }
|
||||
|
||||
public void AddSplit()
|
||||
{
|
||||
// Salvo il parent
|
||||
@@ -254,17 +273,6 @@ namespace WebWindowComplex.Models
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// MockUp chiamata a c++ x scelta forma sash per Hw
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string FindSashShape()
|
||||
{
|
||||
return "Rectangle";
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WebWindowComplex.Models
|
||||
{
|
||||
public class OnReqHwOptEventArgs : EventArgs
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
public string sJwd;
|
||||
public string sCodHw;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public OnReqHwOptEventArgs(string sJwd, string sCodHw)
|
||||
{
|
||||
this.sJwd = sJwd;
|
||||
this.sCodHw = sCodHw;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
using Egw.Window.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using WebWindowComplex.Json;
|
||||
using static WebWindowComplex.Json.WindowConst;
|
||||
|
||||
@@ -32,6 +34,7 @@ namespace WebWindowComplex.Models
|
||||
#region Public Events
|
||||
|
||||
public event EventHandler<OnReqShapeEventArgs> OnReqShape = delegate { };
|
||||
public event EventHandler<OnReqHwOptEventArgs> OnReqHwOption = delegate { };
|
||||
|
||||
#endregion Public Events
|
||||
|
||||
@@ -77,7 +80,7 @@ namespace WebWindowComplex.Models
|
||||
}
|
||||
}
|
||||
|
||||
public List<ParametriOpzioni> HwdOptionList
|
||||
public List<AGBOption> HwdOptionList
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -323,75 +326,7 @@ namespace WebWindowComplex.Models
|
||||
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");
|
||||
// }
|
||||
// }
|
||||
ReqRefreshHwOption();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,6 +339,7 @@ namespace WebWindowComplex.Models
|
||||
set
|
||||
{
|
||||
m_SelHardware = m_HardwareList.FirstOrDefault(x => !string.IsNullOrEmpty(value) && x.Id.Equals(value)) ?? new Hardware("", "", "", Enums.OpeningTypes.Null, "", 0, 0);
|
||||
ReqRefreshHwOption();
|
||||
ParentWindow.OnUpdatePreview(ParentWindow.sSerialized());
|
||||
}
|
||||
}
|
||||
@@ -537,6 +473,16 @@ namespace WebWindowComplex.Models
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Richiesta calcolo hardware option list
|
||||
/// </summary>
|
||||
public void ReqRefreshHwOption()
|
||||
{
|
||||
HwdOptionList.Clear();
|
||||
// chiamata evento calcolo opzioni hardware
|
||||
OnReqHwOptionPreview(m_ParentWindow.sSerialized(), SelHardware.Id);
|
||||
}
|
||||
|
||||
public void SetSelFamilyHardware(string sFamilyHw)
|
||||
{
|
||||
m_SelFamilyHardware = sFamilyHw;
|
||||
@@ -556,7 +502,19 @@ namespace WebWindowComplex.Models
|
||||
public void UpdateShape(string newShape)
|
||||
{
|
||||
m_CurrShape = newShape;
|
||||
// la famiglia hw è vuota seleziono il primo hardware valido e utilizzo la sua famiglia
|
||||
if(string.IsNullOrEmpty(m_SelFamilyHardware) || m_SelFamilyHardware == "")
|
||||
{
|
||||
var listHwValid = Sash
|
||||
.m_HardwareCompleteList
|
||||
.Where(x => x.Shape == m_CurrShape && x.SashQty == nSashQty && x.OpeningType == ConvertOpeningType())
|
||||
.FirstOrDefault();
|
||||
SetSelFamilyHardware(listHwValid.FamilyName);
|
||||
}
|
||||
RefreshHardwareList();
|
||||
// se il vecchio hw selezionato non va più bene viene selezionato il primo della lista
|
||||
if(!HardwareList.Contains(m_SelHardware) && m_SelHardware.Shape != m_CurrShape)
|
||||
SetFirstHardware();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
@@ -673,6 +631,16 @@ namespace WebWindowComplex.Models
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnReqHwOptionPreview(string sJwd, string codHw)
|
||||
{
|
||||
OnReqHwOptEventArgs e = new OnReqHwOptEventArgs(sJwd, codHw);
|
||||
EventHandler<OnReqHwOptEventArgs> handler = OnReqHwOption;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
internal void RefreshHardwareOptionList()
|
||||
{
|
||||
m_HwdOptionList.Clear();
|
||||
@@ -697,6 +665,7 @@ namespace WebWindowComplex.Models
|
||||
if (m_HardwareList.Count > 0)
|
||||
{
|
||||
m_SelHardware = m_HardwareList.First();
|
||||
ReqRefreshHwOption();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -718,6 +687,37 @@ namespace WebWindowComplex.Models
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetHardwareOption(string OptionXml)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(OptionXml))
|
||||
{
|
||||
ParametriOpzioni HwdOptions = null;
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(ParametriOpzioni));
|
||||
StringReader reader = new StringReader(OptionXml);
|
||||
HwdOptions = (ParametriOpzioni)serializer.Deserialize(reader);
|
||||
if (HwdOptions.Items != null)
|
||||
{
|
||||
m_HwdOptionList.Clear();
|
||||
foreach (var HdwOption in HwdOptions.Items)
|
||||
{
|
||||
switch (HdwOption.Tipo)
|
||||
{
|
||||
case "Text":
|
||||
{
|
||||
m_HwdOptionList.Add(new AGBOptionText(HdwOption));
|
||||
break;
|
||||
}
|
||||
case "List":
|
||||
{
|
||||
m_HwdOptionList.Add(new AGBOptionCombo(HdwOption));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetOrientationSashType(OrientationSash value)
|
||||
{
|
||||
m_SelOrientationSashType = value;
|
||||
@@ -794,6 +794,7 @@ namespace WebWindowComplex.Models
|
||||
SelHardware = m_HardwareList.FirstOrDefault(x => x.Id.Equals(sId)) ?? new Hardware(CustomHwId, "", "", Enums.OpeningTypes.Null, "", 0, 0);
|
||||
if (SelHardware.Id == "")
|
||||
SelHardware = m_HardwareList.First();
|
||||
ReqRefreshHwOption();
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
@@ -816,7 +817,7 @@ namespace WebWindowComplex.Models
|
||||
private string m_CurrShape = "";
|
||||
private List<Hardware> m_HardwareList = new List<Hardware>();
|
||||
|
||||
private List<ParametriOpzioni> m_HwdOptionList = new List<ParametriOpzioni>();
|
||||
private List<AGBOption> m_HwdOptionList = new List<AGBOption>();
|
||||
|
||||
private List<Joint> m_JointList = new List<Joint>();
|
||||
|
||||
@@ -858,11 +859,6 @@ namespace WebWindowComplex.Models
|
||||
return answ;
|
||||
}
|
||||
|
||||
private string FindSashShape()
|
||||
{
|
||||
return "Rectangle";
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user