Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6472


Ignore:
Timestamp:
06/22/11 17:25:52 (12 years ago)
Author:
mkommend
Message:

#1564: Corrected cloning bug in drop method of collection views.

Location:
trunk/sources/HeuristicLab.Core.Views/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs

    r5839 r6472  
    2626using System.Windows.Forms;
    2727using HeuristicLab.Collections;
     28using HeuristicLab.Common;
    2829using HeuristicLab.MainForm;
    2930using HeuristicLab.MainForm.WindowsForms;
     
    294295        } else if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable) {
    295296          IEnumerable<T> items = ((IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat)).Cast<T>();
     297          if (e.Effect.HasFlag(DragDropEffects.Copy)) {
     298            Cloner cloner = new Cloner();
     299            items = items.Select(i => (T)i.Clone(cloner));
     300          }
    296301          foreach (T item in items)
    297             Content.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item);
     302            Content.Add(item);
    298303        }
    299304      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.cs

    r5928 r6472  
    2727using System.Windows.Forms;
    2828using HeuristicLab.Collections;
     29using HeuristicLab.Common;
    2930using HeuristicLab.MainForm;
    3031using HeuristicLab.MainForm.WindowsForms;
     
    334335        } else if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable) {
    335336          IEnumerable<T> items = ((IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat)).Cast<T>();
     337          if (e.Effect.HasFlag(DragDropEffects.Copy)) {
     338            Cloner cloner = new Cloner();
     339            items = items.Select(i => (T)i.Clone(cloner));
     340          }
    336341          foreach (T item in items) {
    337             if (listViewItem != null) Content.Insert(listViewItem.Index, e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item);
    338             else Content.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item);
     342            if (listViewItem != null) Content.Insert(listViewItem.Index, item);
     343            else Content.Add(item);
    339344          }
    340345        }
Note: See TracChangeset for help on using the changeset viewer.