internal static void CopyEvents(IList <AnimationEvent> allEvents, bool[] selected, int explicitIndex = -1) { var copyEvents = new List <AnimationWindowEventClipboard>(); // If a selection already exists, copy selection instead of clicked index if (Array.Exists(selected, s => s)) { for (var i = 0; i < selected.Length; ++i) { if (selected[i]) { copyEvents.Add(new AnimationWindowEventClipboard(allEvents[i])); } } } // Else, only copy the clicked animation event else if (explicitIndex >= 0) { copyEvents.Add(new AnimationWindowEventClipboard(allEvents[explicitIndex])); } var data = new AnimationWindowEventsClipboard { events = copyEvents.ToArray() }; // Animation keyframes right now do not go through regular clipboard machinery, // so when copying Events, make sure Keyframes are cleared from the clipboard, or things // get confusing. AnimationWindowState.ClearKeyframeClipboard(); Clipboard.SetCustomValue(data); }