369 lines
8.5 KiB
C#
369 lines
8.5 KiB
C#
using Egw.Window.Data;
|
|
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.Security.Cryptography;
|
|
using System.Xml.Linq;
|
|
using System.Xml.Serialization;
|
|
using WebWindowComplex.Json;
|
|
using static WebWindowComplex.Json.WindowConst;
|
|
using static WebWindowComplex.ParametriOpzioni;
|
|
|
|
namespace WebWindowComplex.Models
|
|
{
|
|
|
|
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 List<Frame> m_AreaList = new List<Frame>();
|
|
public List<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 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 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, 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, List<IdNameStruct> List)
|
|
{
|
|
return List[Ind].Id;
|
|
}
|
|
|
|
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, List<object> List)
|
|
{
|
|
if (List[Ind] is IdNameStruct)
|
|
{
|
|
return ((IdNameStruct)List[Ind]).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;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|