forked from extnet/Ext.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDropTarget.cs
More file actions
298 lines (271 loc) · 12 KB
/
DropTarget.cs
File metadata and controls
298 lines (271 loc) · 12 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
/********
* @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.ComponentModel;
using System.Drawing;
using System.Web.UI;
using Ext.Net.Utilities;
namespace Ext.Net
{
/// <summary>
/// A simple class that provides the basic implementation needed to make any element a drop target that can have draggable items dropped onto it. The drop has no effect until an implementation of notifyDrop is provided.
/// </summary>
[Meta]
[ToolboxItem(true)]
[Designer(typeof(EmptyDesigner))]
[ToolboxData("<{0}:DropTarget runat=\"server\"></{0}:DropTarget>")]
[ToolboxBitmap(typeof(DropTarget), "Build.ToolboxIcons.DragDrop.bmp")]
[Designer(typeof(EmptyDesigner))]
[Description("A simple class that provides the basic implementation needed to make any element a drop target that can have draggable items dropped onto it. The drop has no effect until an implementation of notifyDrop is provided.")]
public partial class DropTarget : DDTarget
{
/// <summary>
///
/// </summary>
public DropTarget()
{
}
/// <summary>
///
/// </summary>
[Category("0. About")]
[Description("")]
public override string InstanceOf
{
get
{
return "Ext.dd.DropTarget";
}
}
/// <summary>
///
/// </summary>
[Description("")]
public override string ToScript(Control owner)
{
string script = "new Ext.net.ProxyDDCreator({{target: {0}, config: {1}, type: {2}}}){3}".FormatWith(
this.ParsedTarget,
new ClientConfig().Serialize(this, true),
this.InstanceOf,
this.IsLazy ? "" : ";"
);
return this.IsIdRequired ? string.Concat("window.", this.ClientID, "=", script) : script;
}
/// <summary>
/// A named drag drop group to which this object belongs. If a group is specified, then this object will only interact with other drag drop objects in the same group (defaults to undefined).
/// </summary>
[Meta]
[ConfigOption("ddGroup")]
[Category("5. DropTarget")]
[DefaultValue("")]
[Description("A named drag drop group to which this object belongs. If a group is specified, then this object will only interact with other drag drop objects in the same group (defaults to undefined).")]
public override string Group
{
get
{
return this.State.Get<string>("Group", "");
}
set
{
this.State.Set("Group", value);
}
}
/// <summary>
/// The CSS class returned to the drag source when drop is allowed (defaults to "x-dd-drop-ok").
/// </summary>
[Meta]
[ConfigOption]
[Category("5. DropTarget")]
[DefaultValue("x-dd-drop-ok")]
[Description("The CSS class returned to the drag source when drop is allowed (defaults to \"x-dd-drop-ok\").")]
public virtual string DropAllowed
{
get
{
return this.State.Get<string>("DropAllowed", "x-dd-drop-ok");
}
set
{
this.State.Set("DropAllowed", value);
}
}
/// <summary>
/// The CSS class returned to the drag source when drop is not allowed (defaults to "x-dd-drop-nodrop").
/// </summary>
[Meta]
[ConfigOption]
[Category("5. DropTarget")]
[DefaultValue("x-dd-drop-nodrop")]
[Description("The CSS class returned to the drag source when drop is not allowed (defaults to \"x-dd-drop-nodrop\").")]
public virtual string DropNotAllowed
{
get
{
return this.State.Get<string>("DropNotAllowed", "x-dd-drop-nodrop");
}
set
{
this.State.Set("DropNotAllowed", value);
}
}
/// <summary>
/// The CSS class applied to the drop target element while the drag source is over it (defaults to "").
/// </summary>
[Meta]
[ConfigOption]
[Category("5. DropTarget")]
[DefaultValue("")]
[Description("The CSS class applied to the drop target element while the drag source is over it (defaults to \"\").")]
public virtual string OverClass
{
get
{
return this.State.Get<string>("OverClass", "");
}
set
{
this.State.Set("OverClass", value);
}
}
/// <summary>
/// True to register this container with the Scrollmanager for auto scrolling during drag operations.
/// </summary>
[Meta]
[ConfigOption]
[Category("5. DropTarget")]
[DefaultValue(false)]
[NotifyParentProperty(true)]
[Description("True to register this container with the Scrollmanager for auto scrolling during drag operations.")]
public virtual bool ContainerScroll
{
get
{
return this.State.Get<bool>("ContainerScroll", false);
}
set
{
this.State.Set("ContainerScroll", value);
}
}
private JFunction notifyDrop;
/// <summary>
/// The function a Ext.dd.DragSource calls once to notify this drop target that the dragged item has been dropped on it. This method has no default implementation and returns false, so you must provide an implementation that does something to process the drop event and returns true so that the drag source's repair action does not run.
/// Parameters:
/// source : The drag source that was dragged over this drop target
/// e : The event
/// data : An object containing arbitrary data supplied by the drag source
/// </summary>
[ConfigOption(JsonMode.Raw)]
[Category("5. DropTarget")]
[Meta]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TypeConverter(typeof(ExpandableObjectConverter))]
[Description("The function a Ext.dd.DragSource calls once to notify this drop target that the dragged item has been dropped on it. This method has no default implementation and returns false, so you must provide an implementation that does something to process the drop event and returns true so that the drag source's repair action does not run.")]
public virtual JFunction NotifyDrop
{
get
{
if (this.notifyDrop == null)
{
this.notifyDrop = new JFunction();
if (!this.DesignMode)
{
this.notifyDrop.Args = new string[] {"source", "e", "data"};
}
}
return this.notifyDrop;
}
}
private JFunction notifyEnter;
/// <summary>
/// The function a Ext.dd.DragSource calls once to notify this drop target that the source is now over the target. This default implementation adds the CSS class specified by overClass (if any) to the drop element and returns the dropAllowed config value. This method should be overridden if drop validation is required.
/// Parameters:
/// source : The drag source that was dragged over this drop target
/// e : The event
/// data : An object containing arbitrary data supplied by the drag source
/// </summary>
[ConfigOption(JsonMode.Raw)]
[Category("5. DropTarget")]
[Meta]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TypeConverter(typeof(ExpandableObjectConverter))]
[Description("The function a Ext.dd.DragSource calls once to notify this drop target that the source is now over the target. This default implementation adds the CSS class specified by overClass (if any) to the drop element and returns the dropAllowed config value. This method should be overridden if drop validation is required.")]
public virtual JFunction NotifyEnter
{
get
{
if (this.notifyEnter == null)
{
this.notifyEnter = new JFunction();
if (!this.DesignMode)
{
this.notifyEnter.Args = new string[] {"source", "e", "data"};
}
}
return this.notifyEnter;
}
}
private JFunction notifyOut;
/// <summary>
/// The function a Ext.dd.DragSource calls once to notify this drop target that the source has been dragged out of the target without dropping. This default implementation simply removes the CSS class specified by overClass (if any) from the drop element.
/// Parameters:
/// source : The drag source that was dragged over this drop target
/// e : The event
/// data : An object containing arbitrary data supplied by the drag source
/// </summary>
[ConfigOption(JsonMode.Raw)]
[Category("5. DropTarget")]
[Meta]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TypeConverter(typeof(ExpandableObjectConverter))]
[Description("The function a Ext.dd.DragSource calls once to notify this drop target that the source has been dragged out of the target without dropping. This default implementation simply removes the CSS class specified by overClass (if any) from the drop element.")]
public virtual JFunction NotifyOut
{
get
{
if (this.notifyOut == null)
{
this.notifyOut = new JFunction();
if (!this.DesignMode)
{
this.notifyOut.Args = new string[] {"source", "e", "data"};
}
}
return this.notifyOut;
}
}
private JFunction notifyOver;
/// <summary>
/// The function a Ext.dd.DragSource calls continuously while it is being dragged over the target. This method will be called on every mouse movement while the drag source is over the drop target. This default implementation simply returns the dropAllowed config value.
/// Parameters:
/// source : The drag source that was dragged over this drop target
/// e : The event
/// data : An object containing arbitrary data supplied by the drag source
/// </summary>
[ConfigOption(JsonMode.Raw)]
[Category("5. DropTarget")]
[Meta]
[PersistenceMode(PersistenceMode.InnerProperty)]
[TypeConverter(typeof(ExpandableObjectConverter))]
[Description("The function a Ext.dd.DragSource calls continuously while it is being dragged over the target. This method will be called on every mouse movement while the drag source is over the drop target. This default implementation simply returns the dropAllowed config value.")]
public virtual JFunction NotifyOver
{
get
{
if (this.notifyOver == null)
{
this.notifyOver = new JFunction();
if (!this.DesignMode)
{
this.notifyOver.Args = new string[] {"source", "e", "data"};
}
}
return this.notifyOver;
}
}
}
}