Changeset 10577 for trunk/sources/HeuristicLab.Scripting.Views
- Timestamp:
- 03/12/14 14:40:08 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Scripting.Views/3.3/VariableStoreView.cs
r10506 r10577 220 220 221 221 if (items.Count > 0) { 222 DataObjectdata = new DataObject();222 var data = new DataObject(); 223 223 if (items.Count == 1) data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, items[0]); 224 224 else data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, items); 225 225 if (ReadOnly) { 226 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link);226 DoDragDrop(data, DragDropEffects.Copy); 227 227 } else { 228 DragDropEffectsresult = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move);228 var result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 229 229 if ((result & DragDropEffects.Move) == DragDropEffects.Move) { 230 230 foreach (string item in items) Content.Remove(item); … … 235 235 } 236 236 protected virtual void variableListView_DragEnter(object sender, DragEventArgs e) { 237 validDragOperation = false; 238 if (!Locked && !ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is object)) { 239 validDragOperation = true; 240 } else if (!Locked && !ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable)) { 241 validDragOperation = true; 242 IEnumerable items = (IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 243 foreach (object item in items) 244 validDragOperation = validDragOperation && (item is object); 245 } 237 validDragOperation = !Locked && !ReadOnly && e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) != null; 246 238 } 247 239 protected virtual void variableListView_DragOver(object sender, DragEventArgs e) { … … 257 249 protected virtual void variableListView_DragDrop(object sender, DragEventArgs e) { 258 250 if (e.Effect != DragDropEffects.None) { 259 if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable) { 260 IEnumerable<object> items = ((IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat)).Cast<object>(); 261 if (e.Effect.HasFlag(DragDropEffects.Copy)) { 262 var cloner = new Cloner(); 263 var clonedItems = new List<object>(); 264 foreach (var item in items) { 265 var dc = item as IDeepCloneable; 266 clonedItems.Add(dc != null ? cloner.Clone(dc) : item); 267 } 268 items = clonedItems; 269 } 270 foreach (var item in items) { 271 string name = GenerateNewVariableName(); 272 Content.Add(name, item); 273 var listViewItem = variableListView.FindItemWithText(name); 274 listViewItem.BeginEdit(); 275 } 276 } else { 277 object item = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 278 if (e.Effect.HasFlag(DragDropEffects.Copy)) { 279 var cloner = new Cloner(); 280 var dc = item as IDeepCloneable; 281 if (dc != null) item = cloner.Clone(dc); 282 } 283 string name = GenerateNewVariableName(); 284 Content.Add(name, item); 285 var listViewItem = variableListView.FindItemWithText(name); 286 listViewItem.BeginEdit(); 287 } 251 object item = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 252 if (e.Effect.HasFlag(DragDropEffects.Copy)) { 253 var cloner = new Cloner(); 254 var dc = item as IDeepCloneable; 255 if (dc != null) item = cloner.Clone(dc); 256 } 257 string name = GenerateNewVariableName(); 258 Content.Add(name, item); 259 var listViewItem = variableListView.FindItemWithText(name); 260 listViewItem.BeginEdit(); 288 261 } 289 262 }
Note: See TracChangeset
for help on using the changeset viewer.