Files
webwindowconfigurator/WebWindowComplex/Models/FrameDimension.cs
T
2025-11-18 15:42:58 +01:00

219 lines
7.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebWindowComplex.Json;
using static WebWindowComplex.Json.WindowConst;
namespace WebWindowComplex.Models
{
public class FrameDimension
{
#region Public Constructors
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;
}
#endregion Public Constructors
#region Public Properties
public double dValue
{
get
{
return m_dValue;
}
set
{
m_dValue = value;
if (value > MaxDim)
{
m_dValue = MaxDim;
}
else if (value < MinDim && !m_sName.Equals("Radius"))
{
m_dValue = MinDim;
}
//if(ParentFrame.AreaList.Count > 0)
// SearchAreaList(ParentFrame);
m_ParentFrame.ParentWindow.OnUpdatePreview(m_ParentFrame.ParentWindow.sSerialized());
}
}
public int nIndex
{
get
{
return m_nIndex;
}
}
public Frame ParentFrame
{
get
{
return m_ParentFrame;
}
}
public string sName
{
get
{
return m_sName;
}
}
#endregion Public Properties
#region Internal Methods
/// <summary>
/// Cerca nell'albero gli oggetti Sash e Split per associare la larghezza
/// </summary>
/// <param name="node"></param>
//protected void SearchAreaList(Area node)
//{
// if (node != null)
// {
// if(node.AreaType.Equals(AreaTypes.SASH))
// calculateWidth((Sash)node);
// else if(node.AreaType.Equals(AreaTypes.SPLIT))
// calculateWidth((Split)node);
// foreach (var item in node.AreaList)
// {
// SearchAreaList(item);
// }
// }
//}
/// <summary>
/// Ricalcolo larghezza Sash e SPlit
/// </summary>
/// <param name="area"></param>
//protected void calculateWidth(Area area)
//{
// if (area is Sash)
// {
// Sash sash = (Sash)area;
// if (area.ParentArea is Frame)
// {
// Frame frame = (Frame)area.ParentArea;
// sash.Width = (frame.DimensionList.Where(x => x.sName == "Width").FirstOrDefault())!.dValue;
// }
// else if (sash.ParentArea.ParentArea is Split)
// {
// Split split = (Split)sash.ParentArea.ParentArea;
// if (split.SplitVertList.Count > 0)
// {
// int indexSplit = 0;
// for (int i = 0; i < split.AreaList.Count; i++)
// {
// if (split.AreaList.ElementAt(i).AreaList.First().Equals(sash))
// indexSplit = i;
// }
// switch (split.SplitVertList.ElementAt(indexSplit).MeasureType)
// {
// case MeasureTypes.ABSOLUT:
// {
// sash.Width = split.SplitVertList.ElementAt(indexSplit).dDimension;
// break;
// }
// case MeasureTypes.PROPORTIONAL:
// {
// /// TO DO!!!!!
// break;
// }
// case MeasureTypes.PERCENTAGE:
// {
// sash.Width = split.SplitVertList.ElementAt(indexSplit).dDimension / 100 * split.Width;
// break;
// }
// }
// }
// else
// {
// Frame frame = (Frame)sash.ParentWindow.AreaList[0];
// sash.Width = (frame.DimensionList.Where(x => x.sName == "Width").FirstOrDefault())!.dValue;
// }
// }
// }
// else if (area is Split)
// {
// Split split = (Split)area;
// if (area.ParentArea is Frame)
// {
// Frame frame = (Frame)area.ParentArea;
// split.Width = (frame.DimensionList.Where(x => x.sName == "Width").FirstOrDefault())!.dValue;
// }
// else if (split.ParentArea.ParentArea is Sash)
// {
// Sash sash = (Sash)split.ParentArea.ParentArea;
// int indexSash = 0;
// for (int i = 0; i < sash.AreaList.Count; i++)
// {
// if (sash.AreaList.ElementAt(i).AreaList.First().Equals(split))
// indexSash = i;
// }
// switch (sash.SashList.ElementAt(indexSash).MeasureType)
// {
// case MeasureTypes.ABSOLUT:
// {
// split.Width = sash.SashList.ElementAt(indexSash).dDimension;
// break;
// }
// case MeasureTypes.PROPORTIONAL:
// {
// /// TO DO!!!!!
// break;
// }
// case MeasureTypes.PERCENTAGE:
// {
// split.Width = sash.SashList.ElementAt(indexSash).dDimension / 100 * sash.Width;
// break;
// }
// }
// }
// }
//}
internal JsonFrameDimension Serialize()
{
JsonFrameDimension JsonFrameDimension = new JsonFrameDimension(m_nIndex, m_sName, m_dValue);
return JsonFrameDimension;
}
#endregion Internal Methods
#region Protected Fields
protected Frame m_ParentFrame;
#endregion Protected Fields
#region Private Fields
private bool m_bIsLen = false;
private double m_dValue;
private int m_nIndex;
private string m_sName;
// valore massimo della dimensione del frame
private int MaxDim = 4000;
// valore minimo della dimensione del frame
private int MinDim = 600;
#endregion Private Fields
}
}