Changeset 5744
- Timestamp:
- 03/18/11 01:38:23 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.3/CrossValidationView.cs
r5445 r5744 317 317 private void algorithmTabPage_DragEnterOver(object sender, DragEventArgs e) { 318 318 e.Effect = DragDropEffects.None; 319 if (ReadOnly) return; 320 Type type = e.Data.GetData("Type") as Type; 321 IAlgorithm algorithm = e.Data.GetData("Value") as IAlgorithm; 322 if ((type != null) && (typeof(IAlgorithm).IsAssignableFrom(type)) && 323 algorithm != null && Content.ProblemType.IsAssignableFrom(algorithm.Problem.GetType())) { 319 IAlgorithm algorithm = e.Data.GetData("HeuristicLab") as IAlgorithm; 320 if (!ReadOnly && (algorithm != null) && Content.ProblemType.IsAssignableFrom(algorithm.Problem.GetType())) { 324 321 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 325 322 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 326 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;327 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;328 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;323 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 324 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 325 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 329 326 } 330 327 } 331 328 private void algorithmTabPage_DragDrop(object sender, DragEventArgs e) { 332 329 if (e.Effect != DragDropEffects.None) { 333 IAlgorithm algorithm = e.Data.GetData(" Value") as IAlgorithm;334 if ( (e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) algorithm = (IAlgorithm)algorithm.Clone();330 IAlgorithm algorithm = e.Data.GetData("HeuristicLab") as IAlgorithm; 331 if (e.Effect.HasFlag(DragDropEffects.Copy)) algorithm = (IAlgorithm)algorithm.Clone(); 335 332 Content.Algorithm = algorithm; 336 333 } … … 339 336 private void algorithmProblemTabPage_DragEnterOver(object sender, DragEventArgs e) { 340 337 e.Effect = DragDropEffects.None; 341 if (ReadOnly) return; 342 Type type = e.Data.GetData("Type") as Type; 343 if ((type != null) && (Content.ProblemType.IsAssignableFrom(type)) && 344 (Content.Algorithm.ProblemType.IsAssignableFrom(type))) { 338 Type type = e.Data.GetData("HeuristicLab") != null ? e.Data.GetData("HeuristicLab").GetType() : null; 339 if (!ReadOnly && (type != null) && Content.ProblemType.IsAssignableFrom(type) && Content.Algorithm.ProblemType.IsAssignableFrom(type)) { 345 340 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 346 341 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 347 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;348 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;349 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;342 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 343 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 344 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 350 345 } 351 346 } 352 347 private void algorithmProblemTabPage_DragDrop(object sender, DragEventArgs e) { 353 348 if (e.Effect != DragDropEffects.None) { 354 ISingleObjectiveDataAnalysisProblem problem = e.Data.GetData(" Value") as ISingleObjectiveDataAnalysisProblem;355 if ( (e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) problem = (ISingleObjectiveDataAnalysisProblem)problem.Clone();349 ISingleObjectiveDataAnalysisProblem problem = e.Data.GetData("HeuristicLab") as ISingleObjectiveDataAnalysisProblem; 350 if (e.Effect.HasFlag(DragDropEffects.Copy)) problem = (ISingleObjectiveDataAnalysisProblem)problem.Clone(); 356 351 Content.Problem = problem; 357 352 } -
trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.Designer.cs
r5445 r5744 74 74 this.listView.DoubleClick += new System.EventHandler(this.listView_DoubleClick); 75 75 this.listView.DragDrop += new System.Windows.Forms.DragEventHandler(this.listView_DragDrop); 76 this.listView.DragEnter += new System.Windows.Forms.DragEventHandler(this.listView_DragEnter Over);76 this.listView.DragEnter += new System.Windows.Forms.DragEventHandler(this.listView_DragEnter); 77 77 this.listView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listView_KeyDown); 78 78 this.listView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.listView_ItemDrag); 79 this.listView.DragOver += new System.Windows.Forms.DragEventHandler(this.listView_Drag EnterOver);79 this.listView.DragOver += new System.Windows.Forms.DragEventHandler(this.listView_DragOver); 80 80 // 81 81 // imageList -
trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.cs
r5445 r5744 21 21 22 22 using System; 23 using System.Collections; 23 24 using System.Collections.Generic; 24 25 using System.IO; … … 35 36 private TypeSelectorDialog typeSelectorDialog; 36 37 private Dictionary<T, ListViewItem> itemListViewItemMapping; 38 private bool validDragOperation; 39 private bool draggedItemsAlreadyContained; 37 40 38 41 private string itemsPath; … … 264 267 } 265 268 private void listView_ItemDrag(object sender, ItemDragEventArgs e) { 266 ListViewItem listViewItem = (ListViewItem)e.Item; 267 T item = (T)listViewItem.Tag; 268 DataObject data = new DataObject(); 269 data.SetData("Type", item.GetType()); 270 data.SetData("Value", item); 271 if (ReadOnly) { 272 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 273 } else { 274 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 275 if ((result & DragDropEffects.Move) == DragDropEffects.Move) { 276 RemoveItem(item); 277 RebuildImageList(); 278 } 279 } 280 } 281 private void listView_DragEnterOver(object sender, DragEventArgs e) { 269 List<T> items = new List<T>(); 270 foreach (ListViewItem listViewItem in listView.SelectedItems) { 271 T item = listViewItem.Tag as T; 272 if (item != null) items.Add(item); 273 } 274 275 if (items.Count > 0) { 276 DataObject data = new DataObject(); 277 if (items.Count == 1) data.SetData("HeuristicLab", items[0]); 278 else data.SetData("HeuristicLab", items); 279 if (ReadOnly) { 280 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 281 } else { 282 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 283 if ((result & DragDropEffects.Move) == DragDropEffects.Move) { 284 foreach (T item in items) RemoveItem(item); 285 RebuildImageList(); 286 } 287 } 288 } 289 } 290 private void listView_DragEnter(object sender, DragEventArgs e) { 291 validDragOperation = false; 292 draggedItemsAlreadyContained = false; 293 if (e.Data.GetData("HeuristicLab") is T) { 294 validDragOperation = true; 295 draggedItemsAlreadyContained = itemListViewItemMapping.ContainsKey((T)e.Data.GetData("HeuristicLab")); 296 } else if (e.Data.GetData("HeuristicLab") is IEnumerable) { 297 validDragOperation = true; 298 IEnumerable items = (IEnumerable)e.Data.GetData("HeuristicLab"); 299 foreach (object item in items) { 300 validDragOperation = validDragOperation && (item is T); 301 draggedItemsAlreadyContained = draggedItemsAlreadyContained || itemListViewItemMapping.ContainsKey((T)item); 302 } 303 } 304 validDragOperation = validDragOperation && !ReadOnly; 305 } 306 private void listView_DragOver(object sender, DragEventArgs e) { 282 307 e.Effect = DragDropEffects.None; 283 Type type = e.Data.GetData("Type") as Type; 284 T item = e.Data.GetData("Value") as T; 285 if (!ReadOnly && (type != null) && (item != null)) { 286 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 287 else if (((e.KeyState & 4) == 4) && !itemListViewItemMapping.ContainsKey(item)) e.Effect = DragDropEffects.Move; // SHIFT key 288 else if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy; 289 else if (((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) && !itemListViewItemMapping.ContainsKey(item)) e.Effect = DragDropEffects.Move; 290 else if (((e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) && !itemListViewItemMapping.ContainsKey(item)) e.Effect = DragDropEffects.Link; 308 if (validDragOperation) { 309 if (((e.KeyState & 32) == 32) && !draggedItemsAlreadyContained) e.Effect = DragDropEffects.Link; // ALT key 310 else if (((e.KeyState & 4) == 4) && !draggedItemsAlreadyContained) e.Effect = DragDropEffects.Move; // SHIFT key 311 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 312 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move) && !draggedItemsAlreadyContained) e.Effect = DragDropEffects.Move; 313 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link) && !draggedItemsAlreadyContained) e.Effect = DragDropEffects.Link; 291 314 } 292 315 } 293 316 private void listView_DragDrop(object sender, DragEventArgs e) { 294 317 if (e.Effect != DragDropEffects.None) { 295 T item = e.Data.GetData("Value") as T;296 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (T)item.Clone();297 318 try { 298 AddItem(item); 319 if (e.Data.GetData("HeuristicLab") is T) { 320 T item = (T)e.Data.GetData("HeuristicLab"); 321 AddItem(e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item); 322 } else if (e.Data.GetData("HeuristicLab") is IEnumerable) { 323 IEnumerable<T> items = ((IEnumerable)e.Data.GetData("HeuristicLab")).Cast<T>(); 324 foreach (T item in items) 325 AddItem(e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item); 326 } 299 327 } 300 328 catch (Exception ex) { -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.Designer.cs
r5445 r5744 149 149 this.itemsListView.SelectedIndexChanged += new System.EventHandler(this.itemsListView_SelectedIndexChanged); 150 150 this.itemsListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragDrop); 151 this.itemsListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragEnter Over);152 this.itemsListView.DragOver += new System.Windows.Forms.DragEventHandler(this.itemsListView_Drag EnterOver);151 this.itemsListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragEnter); 152 this.itemsListView.DragOver += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragOver); 153 153 this.itemsListView.DoubleClick += new System.EventHandler(this.itemsListView_DoubleClick); 154 154 this.itemsListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.itemsListView_KeyDown); -
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 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.Designer.cs
r5445 r5744 102 102 this.itemsListView.SelectedIndexChanged += new System.EventHandler(this.itemsListView_SelectedIndexChanged); 103 103 this.itemsListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragDrop); 104 this.itemsListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragEnter Over);105 this.itemsListView.DragOver += new System.Windows.Forms.DragEventHandler(this.itemsListView_Drag EnterOver);104 this.itemsListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragEnter); 105 this.itemsListView.DragOver += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragOver); 106 106 this.itemsListView.DoubleClick += new System.EventHandler(this.itemsListView_DoubleClick); 107 107 this.itemsListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.itemsListView_KeyDown); -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs
r5445 r5744 21 21 22 22 using System; 23 using System.Collections; 23 24 using System.Collections.Generic; 24 25 using System.Linq; … … 36 37 protected Dictionary<T, List<ListViewItem>> itemListViewItemMapping; 37 38 protected TypeSelectorDialog typeSelectorDialog; 39 protected bool validDragOperation; 38 40 39 41 public new IItemCollection<T> Content { … … 243 245 protected virtual void itemsListView_ItemDrag(object sender, ItemDragEventArgs e) { 244 246 if (!Locked) { 245 ListViewItem listViewItem = (ListViewItem)e.Item; 246 T item = listViewItem.Tag as T; 247 if (item != null) { 247 List<T> items = new List<T>(); 248 foreach (ListViewItem listViewItem in itemsListView.SelectedItems) { 249 T item = listViewItem.Tag as T; 250 if (item != null) items.Add(item); 251 } 252 253 if (items.Count > 0) { 248 254 DataObject data = new DataObject(); 249 data.SetData("Type", item.GetType());250 data.SetData("Value", item);255 if (items.Count == 1) data.SetData("HeuristicLab", items[0]); 256 else data.SetData("HeuristicLab", items); 251 257 if (Content.IsReadOnly || ReadOnly) { 252 258 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 253 259 } else { 254 260 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 255 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 256 Content.Remove(item); 261 if ((result & DragDropEffects.Move) == DragDropEffects.Move) { 262 foreach (T item in items) Content.Remove(item); 263 } 257 264 } 258 265 } 259 266 } 260 267 } 261 protected virtual void itemsListView_DragEnterOver(object sender, DragEventArgs e) { 268 protected virtual void itemsListView_DragEnter(object sender, DragEventArgs e) { 269 validDragOperation = false; 270 if (e.Data.GetData("HeuristicLab") is T) { 271 validDragOperation = true; 272 } else if (e.Data.GetData("HeuristicLab") is IEnumerable) { 273 validDragOperation = true; 274 IEnumerable items = (IEnumerable)e.Data.GetData("HeuristicLab"); 275 foreach (object item in items) 276 validDragOperation = validDragOperation && (item is T); 277 } 278 validDragOperation = validDragOperation && !Content.IsReadOnly && !ReadOnly; 279 } 280 protected virtual void itemsListView_DragOver(object sender, DragEventArgs e) { 262 281 e.Effect = DragDropEffects.None; 263 Type type = e.Data.GetData("Type") as Type; 264 if (!Content.IsReadOnly && !ReadOnly && (type != null) && (typeof(T).IsAssignableFrom(type))) { 282 if (validDragOperation) { 265 283 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 266 284 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 267 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;268 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;269 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;285 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 286 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 287 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 270 288 } 271 289 } 272 290 protected virtual void itemsListView_DragDrop(object sender, DragEventArgs e) { 273 291 if (e.Effect != DragDropEffects.None) { 274 T item = e.Data.GetData("Value") as T; 275 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (T)item.Clone(); 276 Content.Add(item); 292 if (e.Data.GetData("HeuristicLab") is T) { 293 T item = (T)e.Data.GetData("HeuristicLab"); 294 Content.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item); 295 } else if (e.Data.GetData("HeuristicLab") is IEnumerable) { 296 IEnumerable<T> items = ((IEnumerable)e.Data.GetData("HeuristicLab")).Cast<T>(); 297 foreach (T item in items) 298 Content.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item); 299 } 277 300 } 278 301 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.Designer.cs
r5445 r5744 151 151 this.itemsListView.SelectedIndexChanged += new System.EventHandler(this.itemsListView_SelectedIndexChanged); 152 152 this.itemsListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragDrop); 153 this.itemsListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragEnter Over);154 this.itemsListView.DragOver += new System.Windows.Forms.DragEventHandler(this.itemsListView_Drag EnterOver);153 this.itemsListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragEnter); 154 this.itemsListView.DragOver += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragOver); 155 155 this.itemsListView.DoubleClick += new System.EventHandler(this.itemsListView_DoubleClick); 156 156 this.itemsListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.itemsListView_KeyDown); -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.cs
r5445 r5744 21 21 22 22 using System; 23 using System.Collections; 23 24 using System.Collections.Generic; 24 25 using System.Drawing; … … 37 38 protected Dictionary<T, List<ListViewItem>> itemListViewItemMapping; 38 39 protected TypeSelectorDialog typeSelectorDialog; 40 protected bool validDragOperation; 39 41 40 42 public new IItemList<T> Content { … … 277 279 protected virtual void itemsListView_ItemDrag(object sender, ItemDragEventArgs e) { 278 280 if (!Locked) { 279 ListViewItem listViewItem = (ListViewItem)e.Item; 280 T item = listViewItem.Tag as T; 281 if (item != null) { 281 List<T> items = new List<T>(); 282 foreach (ListViewItem listViewItem in itemsListView.SelectedItems) { 283 T item = listViewItem.Tag as T; 284 if (item != null) items.Add(item); 285 } 286 287 if (items.Count > 0) { 282 288 DataObject data = new DataObject(); 283 data.SetData("Type", item.GetType());284 data.SetData("Value", item);289 if (items.Count == 1) data.SetData("HeuristicLab", items[0]); 290 else data.SetData("HeuristicLab", items); 285 291 if (Content.IsReadOnly || ReadOnly) { 286 292 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 287 293 } else { 288 294 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 289 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 290 Content.RemoveAt(listViewItem.Index); 295 if ((result & DragDropEffects.Move) == DragDropEffects.Move) { 296 foreach (ListViewItem listViewItem in itemsListView.SelectedItems.Cast<ListViewItem>().ToArray()) { 297 if (listViewItem.Tag != null) Content.RemoveAt(listViewItem.Index); 298 } 299 } 291 300 } 292 301 } 293 302 } 294 303 } 295 protected virtual void itemsListView_DragEnterOver(object sender, DragEventArgs e) { 304 protected virtual void itemsListView_DragEnter(object sender, DragEventArgs e) { 305 validDragOperation = false; 306 if (e.Data.GetData("HeuristicLab") is T) { 307 validDragOperation = true; 308 } else if (e.Data.GetData("HeuristicLab") is IEnumerable) { 309 validDragOperation = true; 310 IEnumerable items = (IEnumerable)e.Data.GetData("HeuristicLab"); 311 foreach (object item in items) 312 validDragOperation = validDragOperation && (item is T); 313 } 314 validDragOperation = validDragOperation && !Content.IsReadOnly && !ReadOnly; 315 } 316 protected virtual void itemsListView_DragOver(object sender, DragEventArgs e) { 296 317 e.Effect = DragDropEffects.None; 297 Type type = e.Data.GetData("Type") as Type; 298 if (!Content.IsReadOnly && !ReadOnly && (type != null) && (typeof(T).IsAssignableFrom(type))) { 318 if (validDragOperation) { 299 319 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 300 320 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;321 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 322 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 323 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 304 324 } 305 325 } 306 326 protected virtual void itemsListView_DragDrop(object sender, DragEventArgs e) { 307 327 if (e.Effect != DragDropEffects.None) { 308 T item = e.Data.GetData("Value") as T;309 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (T)item.Clone();310 311 328 Point p = itemsListView.PointToClient(new Point(e.X, e.Y)); 312 329 ListViewItem listViewItem = itemsListView.GetItemAt(p.X, p.Y); 313 if (listViewItem != null) Content.Insert(listViewItem.Index, item); 314 else Content.Add(item); 330 331 if (e.Data.GetData("HeuristicLab") is T) { 332 T item = (T)e.Data.GetData("HeuristicLab"); 333 if (listViewItem != null) Content.Insert(listViewItem.Index, e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item); 334 else Content.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item); 335 } else if (e.Data.GetData("HeuristicLab") is IEnumerable) { 336 IEnumerable<T> items = ((IEnumerable)e.Data.GetData("HeuristicLab")).Cast<T>(); 337 foreach (T item in items) { 338 if (listViewItem != null) Content.Insert(listViewItem.Index, e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item); 339 else Content.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item); 340 } 341 } 315 342 } 316 343 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemSetView.cs
r5445 r5744 20 20 #endregion 21 21 22 using System.Collections; 22 23 using System.Windows.Forms; 23 24 using HeuristicLab.MainForm; … … 28 29 [Content(typeof(IItemSet<>), false)] 29 30 public partial class ItemSetView<T> : ItemCollectionView<T> where T : class, IItem { 31 protected bool draggedItemsAlreadyContained; 32 30 33 public new IItemSet<T> Content { 31 34 get { return (IItemSet<T>)base.Content; } … … 37 40 } 38 41 39 protected override void itemsListView_DragEnterOver(object sender, DragEventArgs e) { 40 base.itemsListView_DragEnterOver(sender, e); 41 if (e.Effect == DragDropEffects.Link || e.Effect == DragDropEffects.Move) { 42 T item = e.Data.GetData("Value") as T; 43 if (Content.Contains(item)) e.Effect = DragDropEffects.None; 42 protected override void itemsListView_DragEnter(object sender, DragEventArgs e) { 43 base.itemsListView_DragEnter(sender, e); 44 draggedItemsAlreadyContained = false; 45 if (validDragOperation) { 46 if (e.Data.GetData("HeuristicLab") is T) { 47 draggedItemsAlreadyContained = Content.Contains((T)e.Data.GetData("HeuristicLab")); 48 } else if (e.Data.GetData("HeuristicLab") is IEnumerable) { 49 IEnumerable items = (IEnumerable)e.Data.GetData("HeuristicLab"); 50 foreach (object item in items) 51 draggedItemsAlreadyContained = draggedItemsAlreadyContained || Content.Contains((T)item); 52 } 53 } 54 } 55 protected override void itemsListView_DragOver(object sender, DragEventArgs e) { 56 e.Effect = DragDropEffects.None; 57 if (validDragOperation) { 58 if (((e.KeyState & 32) == 32) && !draggedItemsAlreadyContained) e.Effect = DragDropEffects.Link; // ALT key 59 else if (((e.KeyState & 4) == 4) && !draggedItemsAlreadyContained) e.Effect = DragDropEffects.Move; // SHIFT key 60 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 61 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move) && !draggedItemsAlreadyContained) e.Effect = DragDropEffects.Move; 62 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link) && !draggedItemsAlreadyContained) e.Effect = DragDropEffects.Link; 44 63 } 45 64 } -
trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemCollectionView.cs
r5445 r5744 20 20 #endregion 21 21 22 using System.Collections; 23 using System.Collections.Generic; 24 using System.Linq; 22 25 using System.Windows.Forms; 23 26 using HeuristicLab.Collections; … … 75 78 76 79 #region ListView Events 77 protected override void itemsListView_DragEnterOver(object sender, DragEventArgs e) { 78 base.itemsListView_DragEnterOver(sender, e); 79 if (e.Effect != DragDropEffects.None) { 80 T item = e.Data.GetData("Value") as T; 81 if ((item == null) || (Content.ContainsKey(item.Name))) 82 e.Effect = DragDropEffects.None; 80 protected override void itemsListView_DragEnter(object sender, DragEventArgs e) { 81 base.itemsListView_DragEnter(sender, e); 82 if (validDragOperation) { 83 if (e.Data.GetData("HeuristicLab") is T) { 84 validDragOperation = validDragOperation && !Content.ContainsKey(((T)e.Data.GetData("HeuristicLab")).Name); 85 } else if (e.Data.GetData("HeuristicLab") is IEnumerable) { 86 IEnumerable<T> items = ((IEnumerable)e.Data.GetData("HeuristicLab")).Cast<T>(); 87 foreach (T item in items) 88 validDragOperation = validDragOperation && !Content.ContainsKey(item.Name); 89 } 83 90 } 84 91 } -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorTreeView.cs
r5445 r5744 353 353 IOperator op = GetOperatorTag(node); 354 354 DataObject data = new DataObject(); 355 data.SetData("Type", op.GetType()); 356 data.SetData("Value", op); 355 data.SetData("HeuristicLab", op); 357 356 if (ReadOnly || (opParam == null)) { 358 357 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); … … 366 365 private void graphTreeView_DragEnterOver(object sender, DragEventArgs e) { 367 366 e.Effect = DragDropEffects.None; 368 Type type = e.Data.GetData("Type") as Type; 369 if (!ReadOnly && (type != null) && (typeof(IOperator).IsAssignableFrom(type))) { 367 if (!ReadOnly && (e.Data.GetData("HeuristicLab") is IOperator)) { 370 368 TreeNode node = graphTreeView.GetNodeAt(graphTreeView.PointToClient(new Point(e.X, e.Y))); 371 369 if ((node != null) && !node.IsExpanded) node.Expand(); … … 373 371 if ((e.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy; // CTRL key 374 372 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 375 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;376 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;377 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;373 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 374 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 375 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 378 376 } 379 377 } … … 381 379 private void graphTreeView_DragDrop(object sender, DragEventArgs e) { 382 380 if (e.Effect != DragDropEffects.None) { 383 IOperator op = e.Data.GetData(" Value") as IOperator;384 if ( (e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) op = (IOperator)op.Clone();381 IOperator op = e.Data.GetData("HeuristicLab") as IOperator; 382 if (e.Effect.HasFlag(DragDropEffects.Copy)) op = (IOperator)op.Clone(); 385 383 TreeNode node = graphTreeView.GetNodeAt(graphTreeView.PointToClient(new Point(e.X, e.Y))); 386 384 IValueParameter opParam = GetOperatorParameterTag(node); -
trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.cs
r5445 r5744 168 168 if (scope != null) { 169 169 DataObject data = new DataObject(); 170 data.SetData("Type", scope.GetType()); 171 data.SetData("Value", scope); 170 data.SetData("HeuristicLab", scope); 172 171 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 173 172 } -
trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.cs
r5445 r5744 137 137 imageList.Images.Add(type.FullName, item.ItemImage); 138 138 typeNode.ImageIndex = imageList.Images.IndexOfKey(type.FullName); 139 } catch (Exception) { } 139 } 140 catch (Exception) { } 140 141 } 141 142 typeNode.SelectedImageIndex = typeNode.ImageIndex; … … 317 318 object o = Activator.CreateInstance(type); 318 319 DataObject data = new DataObject(); 319 data.SetData("Type", type); 320 data.SetData("Value", o); 320 data.SetData("HeuristicLab", o); 321 321 DoDragDrop(data, DragDropEffects.Copy); 322 322 } -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableValueView.cs
r5445 r5744 88 88 protected virtual void VariableValueView_DragEnterOver(object sender, DragEventArgs e) { 89 89 e.Effect = DragDropEffects.None; 90 Type type = e.Data.GetData("Type") as Type; 91 if (!ReadOnly && (type != null) && (typeof(IItem).IsAssignableFrom(type))) { 90 if (!ReadOnly && (e.Data.GetData("HeuristicLab") is IItem)) { 92 91 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 93 92 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 94 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;95 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;96 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;93 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 94 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 95 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 97 96 } 98 97 } 99 98 protected virtual void VariableValueView_DragDrop(object sender, DragEventArgs e) { 100 99 if (e.Effect != DragDropEffects.None) { 101 IItem item = e.Data.GetData(" Value") as IItem;102 if ( (e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (IItem)item.Clone();100 IItem item = e.Data.GetData("HeuristicLab") as IItem; 101 if (e.Effect.HasFlag(DragDropEffects.Copy)) item = (IItem)item.Clone(); 103 102 Content.Value = item; 104 103 } -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.cs
r5445 r5744 135 135 protected virtual void valuePanel_DragEnterOver(object sender, DragEventArgs e) { 136 136 e.Effect = DragDropEffects.None; 137 Type type = e.Data.GetData("Type") as Type; 138 if (!ReadOnly && (type != null) && (typeof(IItem).IsAssignableFrom(type))) { 137 if (!ReadOnly && (e.Data.GetData("HeuristicLab") is IItem)) { 139 138 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 140 139 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 141 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;142 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;143 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;140 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 141 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 142 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 144 143 } 145 144 } 146 145 protected virtual void valuePanel_DragDrop(object sender, DragEventArgs e) { 147 146 if (e.Effect != DragDropEffects.None) { 148 IItem item = e.Data.GetData(" Value") as IItem;149 if ( (e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (IItem)item.Clone();147 IItem item = e.Data.GetData("HeuristicLab") as IItem; 148 if (e.Effect.HasFlag(DragDropEffects.Copy)) item = (IItem)item.Clone(); 150 149 Content.Value = item; 151 150 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.cs
r5463 r5744 281 281 if ((Control.MouseButtons & MouseButtons.Left) == MouseButtons.Left && startDragAndDrop) { 282 282 DataObject data = new DataObject(); 283 data.SetData("Type", Content.GetType()); 284 data.SetData("Value", Content); 283 data.SetData("HeuristicLab", Content); 285 284 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 286 285 } else -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphView.cs
r5445 r5744 204 204 private void OperatorGraphView_DragEnterOver(object sender, DragEventArgs e) { 205 205 e.Effect = DragDropEffects.None; 206 Type type = e.Data.GetData("Type") as Type; 207 if (!ReadOnly && (type != null) && (typeof(IOperator).IsAssignableFrom(type))) { 206 if (!ReadOnly && (e.Data.GetData("HeuristicLab") is IOperator)) { 208 207 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 209 208 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 210 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;211 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;212 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;209 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 210 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 211 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 213 212 } 214 213 } … … 216 215 private void OperatorGraphView_DragDrop(object sender, DragEventArgs e) { 217 216 if (e.Effect != DragDropEffects.None) { 218 IOperator op = e.Data.GetData(" Value") as IOperator;219 if ( (e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) op = (IOperator)op.Clone();217 IOperator op = e.Data.GetData("HeuristicLab") as IOperator; 218 if (e.Effect.HasFlag(DragDropEffects.Copy)) op = (IOperator)op.Clone(); 220 219 IOperatorShapeInfo shapeInfo = OperatorShapeInfoFactory.CreateOperatorShapeInfo(op); 221 220 Point mouse = new Point(MousePosition.X, MousePosition.Y); -
trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs
r5445 r5744 278 278 protected virtual void problemTabPage_DragEnterOver(object sender, DragEventArgs e) { 279 279 e.Effect = DragDropEffects.None; 280 Type type = e.Data.GetData("Type") as Type; 281 if ((type != null) && (Content.ProblemType.IsAssignableFrom(type))) { 280 if (!ReadOnly && (e.Data.GetData("HeuristicLab") != null) && Content.ProblemType.IsAssignableFrom(e.Data.GetData("HeuristicLab").GetType())) { 282 281 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 283 282 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 284 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;285 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;286 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;283 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 284 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 285 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 287 286 } 288 287 } 289 288 protected virtual void problemTabPage_DragDrop(object sender, DragEventArgs e) { 290 289 if (e.Effect != DragDropEffects.None) { 291 IProblem problem = e.Data.GetData(" Value") as IProblem;292 if ( (e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) problem = (IProblem)problem.Clone();290 IProblem problem = e.Data.GetData("HeuristicLab") as IProblem; 291 if (e.Effect.HasFlag(DragDropEffects.Copy)) problem = (IProblem)problem.Clone(); 293 292 Content.Problem = problem; 294 293 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs
r5445 r5744 253 253 private void optimizerTabPage_DragEnterOver(object sender, DragEventArgs e) { 254 254 e.Effect = DragDropEffects.None; 255 if (ReadOnly) 256 return; 257 Type type = e.Data.GetData("Type") as Type; 258 if ((type != null) && (typeof(IOptimizer).IsAssignableFrom(type))) { 255 if (!ReadOnly && (e.Data.GetData("HeuristicLab") is IOptimizer)) { 259 256 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 260 257 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 261 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;262 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;263 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;258 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 259 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 260 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 264 261 } 265 262 } 266 263 private void optimizerTabPage_DragDrop(object sender, DragEventArgs e) { 267 264 if (e.Effect != DragDropEffects.None) { 268 IOptimizer optimizer = e.Data.GetData(" Value") as IOptimizer;269 if ( (e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) optimizer = (IOptimizer)optimizer.Clone();265 IOptimizer optimizer = e.Data.GetData("HeuristicLab") as IOptimizer; 266 if (e.Effect.HasFlag(DragDropEffects.Copy)) optimizer = (IOptimizer)optimizer.Clone(); 270 267 Content.Optimizer = optimizer; 271 268 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs
r5445 r5744 452 452 if (this.draggedRun != null && h.ChartElementType != ChartElementType.DataPoint) { 453 453 DataObject data = new DataObject(); 454 data.SetData("Type", draggedRun.GetType()); 455 data.SetData("Value", draggedRun); 454 data.SetData("HeuristicLab", draggedRun); 456 455 if (ReadOnly) 457 456 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.Designer.cs
r5466 r5744 170 170 this.itemsListView.SelectedIndexChanged += new System.EventHandler(this.itemsListView_SelectedIndexChanged); 171 171 this.itemsListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragDrop); 172 this.itemsListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragEnter Over);173 this.itemsListView.DragOver += new System.Windows.Forms.DragEventHandler(this.itemsListView_Drag EnterOver);172 this.itemsListView.DragEnter += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragEnter); 173 this.itemsListView.DragOver += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragOver); 174 174 this.itemsListView.DoubleClick += new System.EventHandler(this.itemsListView_DoubleClick); 175 175 this.itemsListView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.itemsListView_KeyDown); -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r5702 r5744 21 21 22 22 using System; 23 using System.Collections; 23 24 using System.Collections.Generic; 24 25 using System.Drawing; … … 37 38 public sealed partial class RunCollectionView : ItemView { 38 39 private Dictionary<IRun, List<ListViewItem>> itemListViewItemMapping; 40 private bool validDragOperation; 39 41 40 42 public new IItemCollection<IRun> Content { … … 271 273 if (items.Count > 0) { 272 274 DataObject data = new DataObject(); 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 } 275 if (items.Count == 1) data.SetData("HeuristicLab", items[0]); 276 else data.SetData("HeuristicLab", items); 280 277 if (Content.IsReadOnly || ReadOnly) { 281 278 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 282 279 } else { 283 280 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 284 if ( (result & DragDropEffects.Move) == DragDropEffects.Move) {281 if (result.HasFlag(DragDropEffects.Move)) { 285 282 foreach (IRun item in items) Content.Remove(item); 286 283 } … … 289 286 } 290 287 } 291 private void itemsListView_DragEnterOver(object sender, DragEventArgs e) { 288 private void itemsListView_DragEnter(object sender, DragEventArgs e) { 289 validDragOperation = false; 290 if (e.Data.GetData("HeuristicLab") is IRun) { 291 validDragOperation = true; 292 } else if (e.Data.GetData("HeuristicLab") is IEnumerable) { 293 validDragOperation = true; 294 IEnumerable items = (IEnumerable)e.Data.GetData("HeuristicLab"); 295 foreach (object item in items) 296 validDragOperation = validDragOperation && (item is IRun); 297 } 298 validDragOperation = validDragOperation && !Content.IsReadOnly && !ReadOnly; 299 } 300 private void itemsListView_DragOver(object sender, DragEventArgs e) { 292 301 e.Effect = DragDropEffects.None; 293 Type type = e.Data.GetData("Type") as Type; 294 if (!Content.IsReadOnly && !ReadOnly && (type != null) && (typeof(IRun).IsAssignableFrom(type) || typeof(IEnumerable<IRun>).IsAssignableFrom(type))) { 302 if (validDragOperation) { 295 303 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 296 304 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 297 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;298 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;299 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;305 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 306 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 307 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 300 308 } 301 309 } 302 310 private void itemsListView_DragDrop(object sender, DragEventArgs e) { 303 311 if (e.Effect != DragDropEffects.None) { 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); 312 if (e.Data.GetData("HeuristicLab") is IRun) { 313 IRun item = (IRun)e.Data.GetData("HeuristicLab"); 314 Content.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (IRun)item.Clone() : item); 315 } else if (e.Data.GetData("HeuristicLab") is IEnumerable) { 316 IEnumerable<IRun> items = ((IEnumerable)e.Data.GetData("HeuristicLab")).Cast<IRun>(); 317 foreach (IRun item in items) 318 Content.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (IRun)item.Clone() : item); 314 319 } 315 320 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunView.cs
r5445 r5744 149 149 if (item != null) { 150 150 DataObject data = new DataObject(); 151 data.SetData("Type", item.GetType()); 152 data.SetData("Value", item); 151 data.SetData("HeuristicLab", item); 153 152 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy); 154 153 } -
trunk/sources/HeuristicLab.Optimizer/3.3/StartPage.cs
r5445 r5744 122 122 IItem item = (IItem)listViewItem.Tag; 123 123 DataObject data = new DataObject(); 124 data.SetData("Type", item.GetType()); 125 data.SetData("Value", item); 124 data.SetData("HeuristicLab", item); 126 125 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy); 127 126 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueLookupParameterView.cs
r5445 r5744 162 162 protected virtual void valueGroupBox_DragEnterOver(object sender, DragEventArgs e) { 163 163 e.Effect = DragDropEffects.None; 164 Type type = e.Data.GetData("Type") as Type; 165 if (!ReadOnly && (type != null) && (Content.DataType.IsAssignableFrom(type))) { 164 if (!ReadOnly && (e.Data.GetData("HeuristicLab") != null) && Content.DataType.IsAssignableFrom(e.Data.GetData("HeuristicLab").GetType())) { 166 165 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 167 166 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 168 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;169 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;170 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;167 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 168 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 169 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 171 170 } 172 171 } 173 172 protected virtual void valueGroupBox_DragDrop(object sender, DragEventArgs e) { 174 173 if (e.Effect != DragDropEffects.None) { 175 T value = e.Data.GetData(" Value") as T;176 if ( (e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) value = (T)value.Clone();174 T value = e.Data.GetData("HeuristicLab") as T; 175 if (e.Effect.HasFlag(DragDropEffects.Copy)) value = (T)value.Clone(); 177 176 Content.Value = value; 178 177 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.cs
r5445 r5744 148 148 protected virtual void valueGroupBox_DragEnterOver(object sender, DragEventArgs e) { 149 149 e.Effect = DragDropEffects.None; 150 Type type = e.Data.GetData("Type") as Type; 151 if (!ReadOnly && (type != null) && (Content.DataType.IsAssignableFrom(type))) { 150 if (!ReadOnly && (e.Data.GetData("HeuristicLab") != null) && Content.DataType.IsAssignableFrom(e.Data.GetData("HeuristicLab").GetType())) { 152 151 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 153 152 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key 154 else if ( (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;155 else if ( (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;156 else if ( (e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;153 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 154 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move; 155 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link; 157 156 } 158 157 } 159 158 protected virtual void valueGroupBox_DragDrop(object sender, DragEventArgs e) { 160 159 if (e.Effect != DragDropEffects.None) { 161 T value = e.Data.GetData(" Value") as T;162 if ( (e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) value = (T)value.Clone();160 T value = e.Data.GetData("HeuristicLab") as T; 161 if (e.Effect.HasFlag(DragDropEffects.Copy)) value = (T)value.Clone(); 163 162 Content.Value = value; 164 163 }
Note: See TracChangeset
for help on using the changeset viewer.