- Timestamp:
- 03/18/11 01:38:23 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.cs
r5445 r5744 37 37 protected Dictionary<T, List<ListViewItem>> itemListViewItemMapping; 38 38 protected TypeSelectorDialog typeSelectorDialog; 39 protected bool validDragOperation; 39 40 40 41 public new IItemArray<T> Content { … … 274 275 protected virtual void itemsListView_ItemDrag(object sender, ItemDragEventArgs e) { 275 276 if (!Locked) { 276 ListViewItem listViewItem = (ListViewItem)e.Item; 277 T item = listViewItem.Tag as T; 278 if (item != null) { 277 List<T> items = new List<T>(); 278 foreach (ListViewItem listViewItem in itemsListView.SelectedItems) { 279 T item = listViewItem.Tag as T; 280 if (item != null) items.Add(item); 281 } 282 283 if (items.Count > 0) { 279 284 DataObject data = new DataObject(); 280 data.SetData("Type", item.GetType());281 data.SetData("Value", item);285 if (items.Count == 1) data.SetData("HeuristicLab", items[0]); 286 else data.SetData("HeuristicLab", items); 282 287 if (Content.IsReadOnly || ReadOnly) { 283 288 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 284 289 } else { 285 290 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 286 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 287 Content[listViewItem.Index] = null; 291 if ((result & DragDropEffects.Move) == DragDropEffects.Move) { 292 foreach (ListViewItem listViewItem in itemsListView.SelectedItems.Cast<ListViewItem>().ToArray()) 293 Content[listViewItem.Index] = null; 294 } 288 295 } 289 296 } 290 297 } 291 298 } 292 protected virtual void itemsListView_DragEnterOver(object sender, DragEventArgs e) { 299 protected virtual void itemsListView_DragEnter(object sender, DragEventArgs e) { 300 validDragOperation = !Content.IsReadOnly && !ReadOnly && e.Data.GetData("HeuristicLab") is T; 301 } 302 protected virtual void itemsListView_DragOver(object sender, DragEventArgs e) { 293 303 e.Effect = DragDropEffects.None; 294 Type type = e.Data.GetData("Type") as Type; 295 if (!Content.IsReadOnly && !ReadOnly && (type != null) && (typeof(T).IsAssignableFrom(type))) { 304 if (validDragOperation) { 296 305 Point p = itemsListView.PointToClient(new Point(e.X, e.Y)); 297 306 ListViewItem listViewItem = itemsListView.GetItemAt(p.X, p.Y); … … 299 308 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 300 309 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 301 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;302 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;303 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;310 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 311 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 312 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 304 313 } 305 314 } … … 307 316 protected virtual void itemsListView_DragDrop(object sender, DragEventArgs e) { 308 317 if (e.Effect != DragDropEffects.None) { 309 T item = e.Data.GetData("Value") as T;310 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (T)item.Clone();311 312 318 Point p = itemsListView.PointToClient(new Point(e.X, e.Y)); 313 319 ListViewItem listViewItem = itemsListView.GetItemAt(p.X, p.Y); 314 Content[listViewItem.Index] = item; 320 T item = e.Data.GetData("HeuristicLab") as T; 321 Content[listViewItem.Index] = e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item; 315 322 } 316 323 }
Note: See TracChangeset
for help on using the changeset viewer.