示例#1
0
        internal bool Execute(ActionContext context, Func <ITimelineItem, ITimelineItem, double> gapBetweenItems)
        {
            List <ITimelineItem> items = new List <ITimelineItem>();

            items.AddRange(context.clips.Select(p => p.ToItem()));
            items.AddRange(context.markers.Select(p => p.ToItem()));
            List <ItemsPerTrack> selectedItems = items.ToItemsPerTrack().ToList();

            if (selectedItems.Any())
            {
                var requestedTime   = CalculateDuplicateTime(selectedItems, gapBetweenItems);
                var duplicatedItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, selectedItems, requestedTime, "Duplicate Items");

                TimelineHelpers.FrameItems(duplicatedItems);
                SelectionManager.RemoveTimelineSelection();
                foreach (var item in duplicatedItems)
                {
                    SelectionManager.Add(item);
                }
            }

            var tracks = context.tracks.ToArray();

            if (tracks.Length > 0)
            {
                tracks.Invoke <DuplicateTracks>();
            }

            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
            return(true);
        }
        internal bool Execute(WindowState state, Func <ITimelineItem, ITimelineItem, double> gapBetweenItems)
        {
            var selectedItems = SelectionManager.SelectedItems().ToItemsPerTrack().ToList();

            if (selectedItems.Any())
            {
                var requestedTime   = CalculateDuplicateTime(selectedItems, gapBetweenItems);
                var duplicatedItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(state, TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, selectedItems, requestedTime, "Duplicate Items");

                TimelineHelpers.FrameItems(state, duplicatedItems);
                SelectionManager.RemoveTimelineSelection();
                foreach (var item in duplicatedItems)
                {
                    SelectionManager.Add(item);
                }
            }

            var tracks = SelectionManager.SelectedTracks().ToArray();

            if (tracks.Length > 0)
            {
                TrackAction.Invoke <DuplicateTracks>(state, tracks);
            }

            state.Refresh();
            return(true);
        }
示例#3
0
        static void PasteItems(WindowState state, Vector2?mousePosition)
        {
            var copiedItems = TimelineEditor.clipboard.GetCopiedItems().ToList();
            var numberOfUniqueParentsInClipboard = copiedItems.Count();

            if (numberOfUniqueParentsInClipboard == 0)
            {
                return;
            }
            List <ITimelineItem> newItems;

            //if the copied items were on a single parent, then use the mouse position to get the parent OR the original parent
            if (numberOfUniqueParentsInClipboard == 1)
            {
                var        itemsGroup = copiedItems.First();
                TrackAsset target;
                if (mousePosition.HasValue)
                {
                    target = state.spacePartitioner.GetItemsAtPosition <IRowGUI>(mousePosition.Value).First().asset;
                }
                else
                {
                    target = FindSuitableParentForSingleTrackPasteWithoutMouse(itemsGroup);
                }

                var candidateTime = TimelineHelpers.GetCandidateTime(state, mousePosition, target);
                newItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(state, itemsGroup, target, candidateTime, "Paste Items").ToList();
            }
            //if copied items were on multiple parents, then the destination parents are the same as the original parents
            else
            {
                var time = TimelineHelpers.GetCandidateTime(state, mousePosition, copiedItems.Select(c => c.targetTrack).ToArray());
                newItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(state, copiedItems, time, "Paste Items").ToList();
            }


            TimelineHelpers.FrameItems(state, newItems);

            SelectionManager.RemoveTimelineSelection();
            foreach (var item in newItems)
            {
                SelectionManager.Add(item);
            }
        }
示例#4
0
        static void PasteItems(double?invocationTime)
        {
            var copiedItems = TimelineEditor.clipboard.GetCopiedItems().ToList();
            var numberOfUniqueParentsInClipboard = copiedItems.Count();

            if (numberOfUniqueParentsInClipboard == 0)
            {
                return;
            }
            List <ITimelineItem> newItems;

            //if the copied items were on a single parent, then use the mouse position to get the parent OR the original parent
            if (numberOfUniqueParentsInClipboard == 1)
            {
                var        itemsGroup = copiedItems.First();
                TrackAsset target     = null;
                if (invocationTime.HasValue)
                {
                    target = GetPickedTrack();
                }
                if (target == null)
                {
                    target = FindSuitableParentForSingleTrackPasteWithoutMouse(itemsGroup);
                }

                var candidateTime = invocationTime ?? TimelineHelpers.GetCandidateTime(null, target);
                newItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(TimelineEditor.clipboard.exposedPropertyTable, TimelineEditor.inspectedDirector, itemsGroup, target, candidateTime, "Paste Items").ToList();
            }
            //if copied items were on multiple parents, then the destination parents are the same as the original parents
            else
            {
                var time = invocationTime ?? TimelineHelpers.GetCandidateTime(null, copiedItems.Select(c => c.targetTrack).ToArray());
                newItems = TimelineHelpers.DuplicateItemsUsingCurrentEditMode(TimelineEditor.clipboard.exposedPropertyTable, TimelineEditor.inspectedDirector, copiedItems, time, "Paste Items").ToList();
            }

            TimelineHelpers.FrameItems(newItems);
            SelectionManager.RemoveTimelineSelection();
            foreach (var item in newItems)
            {
                SelectionManager.Add(item);
            }
        }