private void itemsListView_DragDrop(object sender, DragEventArgs e) { if (e.Effect != DragDropEffects.None) { if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IRun) { IRun item = (IRun)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); Content.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (IRun)item.Clone() : item); } else if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable) { IEnumerable <IRun> items = ((IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat)).Cast <IRun>(); if (e.Effect.HasFlag(DragDropEffects.Copy)) { Cloner cloner = new Cloner(); items = items.Select(x => cloner.Clone(x)); } if (RunCollection != null) { RunCollection.AddRange(items); } else // the content is an IItemCollection<IRun> { foreach (IRun item in items) { Content.Add(item); } } } } }
public void Save(IRun run, Stream stream) { var obj = (IRun)run.Clone(); foreach (var segment in obj) { segment.SplitTime = default(Time); } var formatter = new BinaryFormatter(); formatter.Serialize(stream, obj); }