-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEbTable.cs
More file actions
345 lines (273 loc) · 11.6 KB
/
EbTable.cs
File metadata and controls
345 lines (273 loc) · 11.6 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
using ExpressBase.Common;
using ExpressBase.Common.Constants;
using ExpressBase.Common.Extensions;
using ExpressBase.Common.Objects;
using ExpressBase.Common.Objects.Attributes;
using ExpressBase.Common.Structures;
using ExpressBase.Objects;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
namespace ExpressBase.Objects
{
public enum VerticalAlign
{
Top = 0,
Middle = 1,
Bottom = 2
}
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
public class EbTableLayout : EbControlContainer
{
public override string UIchangeFns
{
get
{
return @"EbTable = {
padding : function(elementId, props) {
$(`#cont_${ elementId}>table>tbody>tr>td`).css('padding', `${props.Padding.Top}px ${props.Padding.Right}px ${props.Padding.Bottom}px ${props.Padding.Left}px`);
},
verticalAlign : function(elementId, props) {
$(`[ebsid=${props.EbSid}].form-render-table-Td>.tdInnerDiv`).css('justify-content',(props.VerticalAlign === 0 ? 'flex-start' : (props.VerticalAlign === 1 ? 'center': 'flex-end')));
}
}";
}
}
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
[PropertyEditor(PropertyEditorType.Collection)]
[Alias("Columns")]
[PropertyGroup("Core")]
[PropertyPriority(70)]
[ListType(typeof(EbTableTd))]
public override List<EbControl> Controls { get; set; }
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
[HideInPropertyGrid]
public override string TableName { get; set; }
[JsonIgnore]
public override string Label { get; set; }
[JsonIgnore]
public override string BackColor { get; set; }
[JsonIgnore]
public override string ForeColor { get; set; }
[JsonIgnore]
public override string LabelBackColor { get; set; }
[JsonIgnore]
public override string LabelForeColor { get; set; }
[JsonIgnore]
public override EbScript OnChangeFn { get; set; }
[JsonIgnore]
public override List<string> DependedValExp { get; set; }
[JsonIgnore]
public override List<string> DrDependents { get; set; }
[JsonIgnore]
public override List<string> HiddenExpDependants { get; set; }
[JsonIgnore]
public override List<string> DisableExpDependants { get; set; }
[JsonIgnore]
public override List<string> ValExpParams { get; set; }
[JsonIgnore]
public override List<string> DependedDG { get; set; }
[JsonIgnore]
public override string DBareHtml { get; set; }
[JsonIgnore]
public override string Info { get; set; }
[JsonIgnore]
public override string InfoIcon { get; set; }
[JsonIgnore]
public override EbScript _OnChange { get; set; }
[JsonIgnore]
public override EbFont LabelFontStyle { get; set; }
[JsonIgnore]
public override float FontSize { get; set; }
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
[PropertyEditor(PropertyEditorType.Expandable)]
[OnChangeUIFunction("EbTable.padding")]
[DefaultPropValue(0, 0, 0, 0)]
public override UISides Padding { get; set; }
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
[PropertyEditor(PropertyEditorType.Expandable)]
[PropertyGroup(PGConstants.APPEARANCE)]
[UIproperty]
[OnChangeUIFunction("Common.MARGIN")]
[DefaultPropValue(0, 0, 0, 0)]
public override UISides Margin { get; set; }
public EbTableLayout()
{
this.Controls = new List<EbControl>();
this.ObjType = this.GetType().Name.Substring(2, this.GetType().Name.Length - 2);
}
[HideInPropertyGrid]
[JsonIgnore]
public override string ToolIconHtml { get { return "<i class='fa fa-th-large'></i>"; } set { } }
//public override string GetToolHtml()
//{
// return @"<div eb-type='@toolName' class='tool'><i class='fa fa-table'></i> @toolName</div>".Replace("@toolName", this.GetType().Name.Substring(2));
//}
public override string GetDesignHtml()
{
this.Controls = new List<EbControl>();
this.Controls.Add(new EbTableTd { Name = "EbTable0_Td0", EbSid = "TableLayout1_Td0" });
this.Controls.Add(new EbTableTd { Name = "EbTable0_Td1", EbSid = "TableLayout1_Td1" });
return GetHtml().RemoveCR().DoubleQuoted();
}
public override string GetJsInitFunc()
{
return @"
this.Init = function(id){
this.Controls.$values.push(new EbObjects.EbTableTd(id + '_Td0'));
this.Controls.$values.push(new EbObjects.EbTableTd(id + '_Td1'));
};";
}
public override string GetHead()
{
string head = string.Empty;
if (base.Controls != null)
{
foreach (EbControl ec in base.Controls)
head += ec.GetHead();
}
return head;
}
public override string GetHtml()
{
string html = @"
<div id='cont_@ebsid@' ebsid='@ebsid@' class='Eb-ctrlContainer' Ctype='TableLayout'>
<@@table@@ id='@ebsid@' class='form-render-table' ><@@tr@@>";
foreach (EbControl ec in this.Controls)
html += ec.GetHtml();
return (html + "</@@tr@@></@@table@@></div>")
.Replace("@name@", this.Name)
.Replace("@ebsid@", this.EbSid_CtxId)
.Replace("@@table@@", this.IsRenderMode ? "div" : "table")
.Replace("@@tr@@", this.IsRenderMode ? "div" : "tr");
}
public void AdjustColumnWidth()
{
float widthSum = this.Controls.Select(e => (e as EbTableTd).WidthPercentage).Sum();
List<EbControl> zeroWidthTd = this.Controls.FindAll(e => (e as EbTableTd).WidthPercentage <= 0);
if (zeroWidthTd.Count > 0)
{
if (widthSum < 100)
{
float calcWidth = (100 - widthSum) / zeroWidthTd.Count;
foreach (EbControl ec in zeroWidthTd)
{
(ec as EbTableTd).WidthPercentage = calcWidth;
}
}
else
{
float calcWidth = 100 / this.Controls.Count;
foreach (EbTableTd ec in this.Controls)
{
ec.WidthPercentage = calcWidth;
}
}
}
else if (widthSum != 100)
{
foreach (EbTableTd column in this.Controls)
{
column.WidthPercentage = column.WidthPercentage * 100 / widthSum;
}
}
}
}
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
[HideInToolBox]
public class EbTableTd : EbControlContainer
{
public EbTableTd()
{
this.Controls = new List<EbControl>();
this.ObjType = this.GetType().Name.Substring(2, this.GetType().Name.Length - 2);
}
[JsonIgnore]
public override string Label { get; set; }
[JsonIgnore]
public override string LabelBackColor { get; set; }
[JsonIgnore]
public override string LabelForeColor { get; set; }
[JsonIgnore]
public override EbScript OnChangeFn { get; set; }
[JsonIgnore]
public override List<string> DependedValExp { get; set; }
[JsonIgnore]
public override List<string> DrDependents { get; set; }
[JsonIgnore]
public override List<string> HiddenExpDependants { get; set; }
[JsonIgnore]
public override List<string> DisableExpDependants { get; set; }
[JsonIgnore]
public override List<string> ValExpParams { get; set; }
[JsonIgnore]
public override List<string> DependedDG { get; set; }
[JsonIgnore]
public override string DBareHtml { get; set; }
[JsonIgnore]
public override string Info { get; set; }
[JsonIgnore]
public override string InfoIcon { get; set; }
[JsonIgnore]
public override EbScript _OnChange { get; set; }
[JsonIgnore]
public override EbFont LabelFontStyle { get; set; }
[JsonIgnore]
public override float FontSize { get; set; }
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
[HideInPropertyGrid]
public override string TableName { get; set; }
[PropertyGroup(PGConstants.APPEARANCE)]
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
public float WidthPercentage { get; set; }
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
[PropertyGroup(PGConstants.APPEARANCE)]
[UIproperty]
[OnChangeUIFunction("EbTable.verticalAlign")]
public VerticalAlign VerticalAlign { get; set; }
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
[HideInPropertyGrid]
public override List<EbControl> Controls { get; set; }
public override string GetHead()
{
string head = string.Empty;
if (base.Controls != null)
{
foreach (EbControl ec in base.Controls)
head += ec.GetHead();
}
return head;
}
public override string GetHtml()
{
string html = "<@@td@@ id='@name@' ctrl-ebsid='@ebsid@' ebsid='@ebsid@' style='width:@wperc@;' class='form-render-table-Td tdDropable ebResizable ebcont-ctrl ppbtn-cont'> <div class='tdInnerDiv ebcont-inner'>" +
"@ppbtn@";
foreach (EbControl ec in this.Controls)
html += ec.GetHtml();
return (html + "</div></@@td@@>")
.Replace("@ppbtn@", Common.HtmlConstants.CONT_PROP_BTN)
.Replace("@name@", this.Name)
.Replace("@wperc@", (this.WidthPercentage != 0) ? this.WidthPercentage.ToString() + "%" : "auto")
.Replace("@ebsid@", this.EbSid)
.Replace("@@td@@", this.IsRenderMode ? "div" : "td");
}
}
}
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
public class Position
{
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
[PropertyEditor(PropertyEditorType.Number)]
public int X { get; set; }
[EnableInBuilder(BuilderType.WebForm, BuilderType.FilterDialog, BuilderType.UserControl)]
[PropertyEditor(PropertyEditorType.Number)]
public int Y { get; set; }
public Position() { }
public string GetHtml()
{
return "";
}
}