ManagerElement.cs
5.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Vrh.XmlProcessing;
namespace Vrh.iScheduler
{
/// <summary>
/// A "Manager" elem leképezése.
/// </summary>
public class ManagerElement : XmlLinqBase
{
#region Built'in classes
#region ElementNames class
/// <summary>
/// Az XML fájlban ilyen elem nevek találhatóak egy "Button" elemben.
/// </summary>
public new class ElementNames : XmlLinqBase.ElementNames
{
/// <summary>
/// 'Button' elem név.
/// </summary>
public const string BUTTON = "Button";
/// <summary>
/// 'Buttons' elem név.
/// </summary>
public const string BUTTONS = "Buttons";
/// <summary>
/// 'Options' elem név.
/// </summary>
public const string OPTIONS = "Options";
}
#endregion ElementNames class
#region AttributeNames static class
/// <summary>
/// Az XML fájlban ilyen attribútum nevek találhatóak egy 'Button' elemben.
/// </summary>
public static class AttributeNames
{
/// <summary>
/// 'DefaultDisplayMode' attribútum név.
/// </summary>
public const string DEFAULTDISPLAYMODE = "DefaultDisplayMode";
}
#endregion AttributeNames static class
#endregion Built'in classes
#region Properties
/// <summary>
/// A kezelőgombok elhelyezéséhez hány sor fog kelleni.
/// </summary>
public int ButtonRows { get; set; } = 0;
/// <summary>
/// A kezelőgombok elhelyezéséhez hány oszlop fog kelleni.
/// </summary>
public int ButtonCols { get; set; } = 0;
/// <summary>
/// Kezelő gombok listája.
/// </summary>
public List<ButtonElement> Buttons { get; set; }
/// <summary>
/// Alapértelmezett nézet.
/// </summary>
public DisplayMode DefaultDisplayMode { get; set; }
#endregion Properties
#region Constructors
/// <summary>
/// Példányosítás egy 'Manager' XElement alapján.
/// </summary>
/// <param name="xelement">A 'Manager' elem XElement objektuma.</param>
/// <param name="lcid">A környezetben érvényes nyelvi kód.</param>
/// <param name="wordCodePrefix">
/// A gomboknál lévő szókód lesz hozzáfűzve.
/// Így alkotják a gomb megjelenő nevének szókódját.
/// </param>
//public ManagerElement(XElement xelement, string lcid, string wordCodePrefix)
public ManagerElement(XElement xelement, string lcid)
{
if (xelement != null)
{
#region DefaultDisplayMode beállítása
XAttribute xa = xelement.Element(ElementNames.OPTIONS)?.Attribute(AttributeNames.DEFAULTDISPLAYMODE);
if (xa == null)
{
this.DefaultDisplayMode = DisplayMode.List;
}
else
{
this.DefaultDisplayMode = GetEnumValue(xa, DisplayMode.List);
}
#endregion DefaultDisplayMode beállítása
#region Buttons beállítása
XElement xe = xelement.Element(ElementNames.BUTTONS);
if (xe != null)
{
IEnumerable<XElement> buttonsXE = xe.Elements(ElementNames.BUTTON);
if (buttonsXE != null && buttonsXE.Any())
{
this.Buttons = new List<ButtonElement>();
foreach (var buttonXE in buttonsXE)
{
//using (var newbttn = new ButtonElement(buttonXE, lcid, wordCodePrefix))
using (var newbttn = new ButtonElement(buttonXE, lcid))
{
if (this.Buttons.Any(x => x.Name == newbttn.Name))
{
throw new ApplicationException(string.Format(
"The 'Button.Name' attribute is not unique in the buttons! Name={0}", newbttn.Name
));
}
if (this.Buttons.Any(x => x.Row == newbttn.Row && x.Col == newbttn.Col))
{
throw new ApplicationException(string.Format(
"The 'Row' and 'Col' attribute is not unique in the buttons! Name='{0}', Row={1}, Col={2}", newbttn.Name, newbttn.Row, newbttn.Col
));
}
this.ButtonRows = this.ButtonRows < (newbttn.Row + newbttn.RowSpan - 1) ? (newbttn.Row + newbttn.RowSpan - 1) : this.ButtonRows;
this.ButtonCols = this.ButtonCols < (newbttn.Col + newbttn.ColSpan - 1) ? (newbttn.Col + newbttn.ColSpan - 1) : this.ButtonCols;
this.Buttons.Add(newbttn);
}
}
}
}
#endregion Buttons beállítása
}
}
#endregion Constructors
}
}