forked from extnet/Ext.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuPanel.cs
More file actions
316 lines (283 loc) · 9.35 KB
/
MenuPanel.cs
File metadata and controls
316 lines (283 loc) · 9.35 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
/********
* @version : 2.1.1 - Ext.NET Pro License
* @author : Ext.NET, Inc. http://www.ext.net/
* @date : 2012-12-10
* @copyright : Copyright (c) 2007-2012, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
* @license : See license.txt and http://www.ext.net/license/.
********/
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
using System.Web.UI;
using Ext.Net.Utilities;
namespace Ext.Net
{
/// <summary>
///
/// </summary>
[Meta]
[ToolboxData("<{0}:MenuPanel runat=\"server\" Title=\"Menu\" Height=\"300\" Width=\"185\"><Menu><Items><ext:MenuItem runat=\"server\" Text=\"Item1\"><Menu><ext:Menu runat=\"server\"><Items><ext:MenuItem runat=\"server\" Text=\"SubItem1\" /><ext:MenuItem runat=\"server\" Text=\"SubItem2\" /></Items></ext:Menu></Menu></ext:MenuItem><ext:MenuItem runat=\"server\" Text=\"Item2\" /><ext:MenuItem runat=\"server\" Text=\"Item3\" /><ext:MenuItem runat=\"server\" Text=\"Item4\" /></Items></Menu></{0}:MenuPanel>")]
[ToolboxBitmap(typeof(MenuPanel), "Build.ToolboxIcons.MenuPanel.bmp")]
[Designer(typeof(EmptyDesigner))]
[Description("")]
public partial class MenuPanel : AbstractPanel
{
/// <summary>
///
/// </summary>
[Description("")]
public MenuPanel() { }
/// <summary>
///
/// </summary>
[Category("0. About")]
[Description("")]
public override string XType
{
get
{
return "netmenupanel";
}
}
/// <summary>
///
/// </summary>
[Category("0. About")]
[Description("")]
public override string InstanceOf
{
get
{
return "Ext.net.MenuPanel";
}
}
private static readonly object EventSelectedItemChanged = new object();
/// <summary>
///
/// </summary>
[Category("Action")]
[Description("Fires when the selected Item has been changed")]
public event EventHandler SelectedItemChanged
{
add
{
this.CheckForceId();
Events.AddHandler(EventSelectedItemChanged, value);
}
remove
{
Events.RemoveHandler(EventSelectedItemChanged, value);
}
}
/// <summary>
///
/// </summary>
/// <param name="e"></param>
[Description("")]
protected virtual void OnSelectedItemChanged(EventArgs e)
{
EventHandler handler = (EventHandler)Events[EventSelectedItemChanged];
if (handler != null)
{
handler(this, e);
}
}
/// <summary>
///
/// </summary>
[Description("")]
protected override void RaisePostDataChangedEvent()
{
if (this.baseLoadPostData)
{
base.RaisePostDataChangedEvent();
}
if (this.thisLoadPostData)
{
this.OnSelectedItemChanged(EventArgs.Empty);
}
}
private bool baseLoadPostData;
private bool thisLoadPostData;
/// <summary>
///
/// </summary>
/// <param name="postDataKey"></param>
/// <param name="postCollection"></param>
/// <returns></returns>
[Description("")]
protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
{
this.baseLoadPostData = base.LoadPostData(postDataKey, postCollection);
string index = postCollection[this.ConfigID.ConcatWith("_SelIndex")] ?? "";
if (index.IsNotEmpty())
{
try
{
this.SuspendScripting();
int tmpIndex;
if (int.TryParse(index, out tmpIndex))
{
if (tmpIndex != this.SelectedIndex)
{
this.SelectedIndex = tmpIndex;
this.thisLoadPostData = true;
return true;
}
}
}
finally
{
this.ResumeScripting();
}
}
return this.baseLoadPostData;
}
/// <summary>
/// Items Collection
/// </summary>
[ConfigOption(JsonMode.Ignore)]
[Browsable(false)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Description("")]
public override ItemsCollection<AbstractComponent> Items
{
get
{
return base.Items;
}
}
private Menu menu;
/// <summary>
/// Standard menu attribute consisting of a reference to a menu object, a menu id or a menu config blob
/// </summary>
[Meta]
[ConfigOption("menu", typeof(LazyControlJsonConverter))]
[Category("7. MenuPanel")]
[NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Description("Standard menu attribute consisting of a reference to a menu object, a menu id or a menu config blob")]
public virtual Menu Menu
{
get
{
if (this.menu == null)
{
this.menu = new Menu();
this.Controls.Add(this.menu);
this.LazyItems.Add(this.menu);
this.menu.Floating = false;
this.menu.RenderEmptyMenu = true;
}
return this.menu;
}
}
/// <summary>
/// Save selection after click
/// </summary>
[Meta]
[ConfigOption]
[Category("7. MenuPanel")]
[DefaultValue(true)]
[NotifyParentProperty(true)]
[Description("Save selection after click")]
public virtual bool SaveSelection
{
get
{
return this.State.Get<bool>("SaveSelection", true);
}
set
{
this.State.Set("SaveSelection", value);
}
}
/// <summary>
/// Index of selected item
/// </summary>
[Meta]
[ConfigOption]
[DirectEventUpdate(MethodName = "SetSelectedIndex")]
[Category("7. MenuPanel")]
[DefaultValue(-1)]
[NotifyParentProperty(true)]
[Description("Index of selected item")]
public virtual int SelectedIndex
{
get
{
return this.State.Get<int>("SelectedIndex", -1);
}
set
{
this.State.Set("SelectedIndex", value);
}
}
private PanelListeners listeners;
/// <summary>
/// Client-side JavaScript Event Handlers
/// </summary>
[Meta]
[ConfigOption("listeners", JsonMode.Object)]
[Category("2. Observable")]
[NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Description("Client-side JavaScript Event Handlers")]
public PanelListeners Listeners
{
get
{
if (this.listeners == null)
{
this.listeners = new PanelListeners();
}
return this.listeners;
}
}
private PanelDirectEvents directEvents;
/// <summary>
/// Server-side Ajax Event Handlers
/// </summary>
[Meta]
[Category("2. Observable")]
[NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[ConfigOption("directEvents", JsonMode.Object)]
[Description("Server-side Ajax Event Handlers")]
public PanelDirectEvents DirectEvents
{
get
{
if (this.directEvents == null)
{
this.directEvents = new PanelDirectEvents(this);
}
return this.directEvents;
}
}
/* Public Methods
-----------------------------------------------------------------------------------------------*/
/// <summary>
///
/// </summary>
/// <param name="index"></param>
[Meta]
[Description("")]
public void SetSelectedIndex(int index)
{
this.Call("setSelectedIndex", index);
}
/// <summary>
///
/// </summary>
[Meta]
[Description("")]
public void ClearSelection()
{
this.Call("clearSelection");
}
}
}