private void PosAlignByMarkers()
        {
            var selectedByTrack = myVegas.Project.GetSelectedEvents().GroupBy(item => item.Track);

            if (selectedByTrack.Count() < 2)
            {
                return;
            }

            var guideEvents = selectedByTrack.First();

            var punchpoints = (guideEvents.Select(Ev => new { Ev, mmk = Ev.FindCurrentMetaMarker() }).Select(T => T.Ev.Start + T.mmk.GlobalMarkerOffset)).ToList();

            selectedByTrack = selectedByTrack.Skip(1);             // don't adjust the guide track

            using (var undo = new UndoBlock("Align by markers"))
            {
                foreach (var group in selectedByTrack)
                {
                    var events = new List <TrackEvent>();
                    events.AddRange(group);
                    for (int i = 0; i <= events.Count - 1; i++)
                    {
                        if (i > punchpoints.Count - 1)
                        {
                            break;
                        }
                        TrackEvent ev       = events[i];
                        MetaMarker mmk      = ev.FindCurrentMetaMarker();
                        Timecode   newMkPos = punchpoints[i];
                        ev.Start = newMkPos - mmk.GlobalMarkerOffset;
                    }
                }
            }
        }
        private void SplitEvent()
        {
            List <TrackEvent> Events = myVegas.Project.GetSelectedEvents();

            if (Events.Count == 0)
            {
                return;
            }

            using (var undo = new UndoBlock("Split Events by MetaTakes"))
            {
                foreach (TrackEvent ev in Events)
                {
                    TrackEvent curEv = ev;
                    foreach (MediaMarker mk in ev.ActiveTake.Media.Markers)
                    {
                        if (curEv == null)
                        {
                            break;                             // dun goofed
                        }
                        var mmk = new MetaMarker(mk, curEv);

                        if (!mmk.IsWithinEventBounds)
                        {
                            continue;
                        }
                        curEv = curEv.Split(mmk.GlobalMarkerOffset);
                    }
                }
            }
        }
Beispiel #3
0
        internal static Marker FindCurrentMarker(this TrackEvent Event)
        {
            MetaMarker mmk = Event.FindCurrentMetaMarker();

            if (mmk != null)
            {
                return(mmk.Marker);
            }
            return(null);
        }
        private void SetCurrentMarkerOffset(TrackEvent Event, Timecode Offset)
        {
            MetaMarker mmk = Event.FindCurrentMetaMarker();

            if (mmk == null)
            {
                return;
            }
            Event.ActiveTake.Offset = mmk.LocalMarkerOffset - Offset;
        }
        public void SetMetaTake(TrackEvent TrackEvent, Marker TargetMarker)
        {
            MetaMarker currentMmk = TrackEvent.FindCurrentMetaMarker();

            if (currentMmk == null)
            {
                return;
            }

            var targetMmk = new MetaMarker(TargetMarker, TrackEvent);

            TrackEvent.ActiveTake.Offset = targetMmk.GlobalMarkerPosition - currentMmk.GlobalMarkerOffset;
        }
        private void ResetMarkerOffset()
        {
            List <TrackEvent> selected = myVegas.Project.GetSelectedEvents();

            using (var undo = new UndoBlock("Reset marker offset"))
            {
                foreach (TrackEvent ev in selected)
                {
                    MetaMarker mmk = ev.FindCurrentMetaMarker();
                    if (mmk == null)
                    {
                        continue;
                    }
                    ev.ActiveTake.Offset = mmk.GlobalMarkerPosition;
                }
            }
        }
Beispiel #7
0
        internal static MetaMarker FindCurrentMetaMarker(this TrackEvent Event)
        {
            List <MetaMarker> metamarkers = Event.ActiveTake.Media.Markers.Select(mk => new MetaMarker(mk, Event)).ToList();

            if (metamarkers.Count == 0)
            {
                return(null);
            }

            if (metamarkers.Count == 1)
            {
                return(metamarkers[0]);
            }

            List <MetaMarker> relevantMarkers = metamarkers.Where(item => item.IsWithinEventBounds).ToList();

            // select only visible markers

            if (!relevantMarkers.Any())
            {
                relevantMarkers = metamarkers;
            }

            relevantMarkers.Sort(delegate(MetaMarker A, MetaMarker B)
            {
                if (Math.Abs(A.LocalMarkerOffset.Nanos) < Math.Abs(B.LocalMarkerOffset.Nanos))
                {
                    return(-1);
                }
                return(1);
            });

            MetaMarker mmk = relevantMarkers[0];

            return(mmk);
        }