~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/xwt/Xwt/Xwt/DragEventArgs.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// DragEventArgs.cs
 
3
//  
 
4
// Author:
 
5
//       Lluis Sanchez <lluis@xamarin.com>
 
6
// 
 
7
// Copyright (c) 2011 Xamarin Inc
 
8
// 
 
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
10
// of this software and associated documentation files (the "Software"), to deal
 
11
// in the Software without restriction, including without limitation the rights
 
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
13
// copies of the Software, and to permit persons to whom the Software is
 
14
// furnished to do so, subject to the following conditions:
 
15
// 
 
16
// The above copyright notice and this permission notice shall be included in
 
17
// all copies or substantial portions of the Software.
 
18
// 
 
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
25
// THE SOFTWARE.
 
26
 
 
27
using System;
 
28
 
 
29
namespace Xwt
 
30
{
 
31
        public class DragCheckEventArgs: EventArgs
 
32
        {
 
33
                public DragCheckEventArgs (Point position, TransferDataType[] types, DragDropAction action)
 
34
                {
 
35
                        DataTypes = types;
 
36
                        Action = action;
 
37
                        Position = position;
 
38
                        Result = DragDropResult.None;
 
39
                }
 
40
                
 
41
                public TransferDataType[] DataTypes { get; private set; }
 
42
                
 
43
                public Point Position { get; private set; }
 
44
                
 
45
                public DragDropAction Action { get; private set; }
 
46
                
 
47
                public DragDropResult Result { get; set; }
 
48
        }
 
49
 
 
50
        public class DragEventArgs: EventArgs
 
51
        {
 
52
                public DragEventArgs (Point position, Xwt.Backends.TransferDataStore dataStore, DragDropAction action)
 
53
                {
 
54
                        Data = dataStore;
 
55
                        Position = position;
 
56
                        Action = action;
 
57
                        Success = false;
 
58
                }
 
59
                
 
60
                public ITransferData Data { get; private set; }
 
61
                
 
62
                public Point Position { get; private set; }
 
63
                
 
64
                public DragDropAction Action { get; private set; }
 
65
                
 
66
                public bool Success { get; set; }
 
67
        }
 
68
        
 
69
        public class DragOverCheckEventArgs: EventArgs
 
70
        {
 
71
                DragDropAction allowedAction;
 
72
                
 
73
                public DragOverCheckEventArgs (Point position, TransferDataType[] types, DragDropAction action)
 
74
                {
 
75
                        DataTypes = types;
 
76
                        Action = action;
 
77
                        Position = position;
 
78
                        AllowedAction = DragDropAction.Default;
 
79
                }
 
80
                
 
81
                /// <summary>
 
82
                /// Type of the data being dropped
 
83
                /// </summary>
 
84
                public TransferDataType[] DataTypes { get; private set; }
 
85
                
 
86
                /// <summary>
 
87
                /// Drop coordinates (in widget coordinates)
 
88
                /// </summary>
 
89
                public Point Position { get; private set; }
 
90
                
 
91
                /// <summary>
 
92
                /// Proposed drop action, which depends on the control keys being pressed
 
93
                /// </summary>
 
94
                public DragDropAction Action { get; private set; }
 
95
 
 
96
                /// <summary>
 
97
                /// Allowed action
 
98
                /// </summary>
 
99
                /// <remarks>
 
100
                /// To be set by the handler of the event. Specifies the action that will be performed if the item is dropped.
 
101
                /// If not specified or set to Default, the action will be determined by the handler of DragOver.
 
102
                /// </remarks>
 
103
                public DragDropAction AllowedAction {
 
104
                        get { return allowedAction; }
 
105
                        set {
 
106
                                switch (value) {
 
107
                                case DragDropAction.Copy:
 
108
                                case Xwt.DragDropAction.Default:
 
109
                                case Xwt.DragDropAction.Link:
 
110
                                case Xwt.DragDropAction.Move:
 
111
                                case Xwt.DragDropAction.None:
 
112
                                        allowedAction = value;
 
113
                                        break;
 
114
                                default:
 
115
                                        throw new ArgumentException ("Allowed action must be one of Copy, Link, Move, None or Default");
 
116
                                }
 
117
                        }
 
118
                }
 
119
        }
 
120
 
 
121
        public class DragOverEventArgs: EventArgs
 
122
        {
 
123
                public DragOverEventArgs (Point position, ITransferData dataStore, DragDropAction action)
 
124
                {
 
125
                        Position = position;
 
126
                        Data = dataStore;
 
127
                        Action = action;
 
128
                        AllowedAction = DragDropAction.Default;
 
129
                }
 
130
                
 
131
                public ITransferData Data { get; private set; }
 
132
                
 
133
                /// <summary>
 
134
                /// Drop coordinates (in widget coordinates)
 
135
                /// </summary>
 
136
                public Point Position { get; private set; }
 
137
                
 
138
                /// <summary>
 
139
                /// Proposed drop action, which depends on the control keys being pressed
 
140
                /// </summary>
 
141
                public DragDropAction Action { get; private set; }
 
142
                
 
143
                /// <summary>
 
144
                /// Allowed action
 
145
                /// </summary>
 
146
                /// <remarks>
 
147
                /// To be set by the handler of the event. Specifies the action that will be performed if the item is dropped.
 
148
                /// If not specified or set to Default, the action will be determined by the handler of DragDropCheck.
 
149
                /// </remarks>
 
150
                public DragDropAction AllowedAction { get; set; }
 
151
        }
 
152
        
 
153
        public class DragFinishedEventArgs: EventArgs
 
154
        {
 
155
                public DragFinishedEventArgs (bool deleteSource)
 
156
                {
 
157
                        DeleteSource = deleteSource;
 
158
                }
 
159
                
 
160
                public bool DeleteSource { get; private set; }
 
161
        }
 
162
        
 
163
        public class DragStartedEventArgs: EventArgs
 
164
        {
 
165
                public DragOperation DragOperation { get; internal set; }
 
166
        }
 
167
        
 
168
        public enum DragDropResult
 
169
        {
 
170
                Success,
 
171
                Canceled,
 
172
                None
 
173
        }
 
174
}
 
175