Changeset 5702
- Timestamp:
- 03/16/11 01:08:19 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r5445 r5702 263 263 private void itemsListView_ItemDrag(object sender, ItemDragEventArgs e) { 264 264 if (!Locked) { 265 ListViewItem listViewItem = (ListViewItem)e.Item; 266 IRun item = listViewItem.Tag as IRun; 267 if (item != null) { 265 List<IRun> items = new List<IRun>(); 266 foreach (ListViewItem listViewItem in itemsListView.SelectedItems) { 267 IRun item = listViewItem.Tag as IRun; 268 if (item != null) items.Add(item); 269 } 270 271 if (items.Count > 0) { 268 272 DataObject data = new DataObject(); 269 data.SetData("Type", item.GetType()); 270 data.SetData("Value", item); 273 if (items.Count == 1) { 274 data.SetData("Type", items[0].GetType()); 275 data.SetData("Value", items[0]); 276 } else { 277 data.SetData("Type", typeof(IEnumerable<IRun>)); 278 data.SetData("Value", items); 279 } 271 280 if (Content.IsReadOnly || ReadOnly) { 272 281 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 273 282 } else { 274 283 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 275 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 276 Content.Remove(item); 284 if ((result & DragDropEffects.Move) == DragDropEffects.Move) { 285 foreach (IRun item in items) Content.Remove(item); 286 } 277 287 } 278 288 } … … 282 292 e.Effect = DragDropEffects.None; 283 293 Type type = e.Data.GetData("Type") as Type; 284 if (!Content.IsReadOnly && !ReadOnly && (type != null) && (typeof(IRun).IsAssignableFrom(type) )) {294 if (!Content.IsReadOnly && !ReadOnly && (type != null) && (typeof(IRun).IsAssignableFrom(type) || typeof(IEnumerable<IRun>).IsAssignableFrom(type))) { 285 295 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 286 296 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key … … 292 302 private void itemsListView_DragDrop(object sender, DragEventArgs e) { 293 303 if (e.Effect != DragDropEffects.None) { 294 IRun item = e.Data.GetData("Value") as IRun; 295 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (IRun)item.Clone(); 296 Content.Add(item); 304 object value = e.Data.GetData("Value"); 305 IEnumerable<IRun> items = Enumerable.Empty<IRun>(); 306 if (value is IRun) 307 items = new IRun[] { (IRun)value }; 308 else if (value is IEnumerable<IRun>) 309 items = (IEnumerable<IRun>)value; 310 311 foreach (IRun item in items) { 312 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) Content.Add((IRun)item.Clone()); 313 else Content.Add(item); 314 } 297 315 } 298 316 }
Note: See TracChangeset
for help on using the changeset viewer.