예제 #1
0
        public static void MoveElement(ElementStep elementStep)
        {
            if (!elementStep.Selector.IsValid() || elementStep.Selector.ElementType == ElementType.None || elementStep.Selector.ElementType == ElementType.Track)
            {
                return;
            }
            TrackEvent eventToMove = SelectorService.GetEvent(elementStep.Selector);
            Timecode   timecode    = Timecode.FromString(elementStep.DataPropertyList[DataPropertyHolder.TIMECODE].Value);

            eventToMove.Start = timecode;
        }
예제 #2
0
 public static void RemoveElement(ElementStep elementStep)
 {
     if (!elementStep.Selector.IsValid() || elementStep.Selector.ElementType == ElementType.None)
     {
         return;
     }
     if (elementStep.Selector.ElementType == ElementType.Event)
     {
         TrackEvent eventToRemove = SelectorService.GetEvent(elementStep.Selector);
         if (eventToRemove != null)
         {
             eventToRemove.Track.Events.Remove(eventToRemove);
         }
     }
     if (elementStep.Selector.ElementType == ElementType.Track)
     {
         Track track = SelectorService.GetTrack(elementStep.Selector);
         track.Project.Tracks.Remove(track);
     }
 }
예제 #3
0
        public static void SetEffectToElement(ElementStep elementStep)
        {
            if (!elementStep.Selector.IsValid() || elementStep.Selector.ElementType == ElementType.None)
            {
                return;
            }

            if (elementStep.Selector.ElementType == ElementType.Event)
            {
                TrackEvent trackEvent  = SelectorService.GetEvent(elementStep.Selector);
                PlugInNode pin         = SelectorService.GetPlugIn(elementStep.DataPropertyList[DataPropertyHolder.EFFECT_NAME].Value);
                string     effectPrest = string.IsNullOrEmpty(elementStep.DataPropertyList[DataPropertyHolder.EFFECT_PRESET_NAME].Value)
                    ? SelectorService.GetPresets(pin)[0]
                    : elementStep.DataPropertyList[DataPropertyHolder.EFFECT_PRESET_NAME].Value;
                Effect effect = new Effect(pin);
                if (elementStep.Selector.IsAudio())
                {
                    (trackEvent as AudioEvent).Effects.Add(effect);
                }
                if (elementStep.Selector.IsVideo())
                {
                    (trackEvent as VideoEvent).Effects.Add(effect);
                }
                effect.Preset = effectPrest;
            }
            if (elementStep.Selector.ElementType == ElementType.Track)
            {
                Track      track       = SelectorService.GetTrack(elementStep.Selector);
                PlugInNode pin         = SelectorService.GetPlugIn(elementStep.DataPropertyList[DataPropertyHolder.EFFECT_NAME].Value);
                string     effectPrest = string.IsNullOrEmpty(elementStep.DataPropertyList[DataPropertyHolder.EFFECT_PRESET_NAME].Value)
                    ? SelectorService.GetPresets(pin)[0]
                    : elementStep.DataPropertyList[DataPropertyHolder.EFFECT_PRESET_NAME].Value;
                Effect effect = new Effect(pin);
                track.Effects.Add(effect);
                effect.Preset = effectPrest;
            }
        }
예제 #4
0
        public static void AddElement(ElementStep elementStep)
        {
            if (!elementStep.Selector.IsValid() || elementStep.Selector.ElementType == ElementType.None)
            {
                return;
            }

            if (elementStep.Selector.ElementType == ElementType.Event)
            {
                Track track      = SelectorService.GetTrack(elementStep.Selector);
                var   trackRegEx = new Regex(elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                Media media      = MainContainer.Vegas.Project.MediaPool.Cast <Media>().FirstOrDefault(x =>
                                                                                                       trackRegEx.IsMatch(Path.GetFileName(x.FilePath)));
                if (elementStep.Selector.IsAudio() && media.Streams.Any(x => x.MediaType == MediaType.Audio))
                {
                    TrackEvent trackEvent = new AudioEvent(
                        Timecode.FromString(elementStep.DataPropertyList[DataPropertyHolder.TIMECODE].Value),
                        media.Length,
                        elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                    track.Events.Add(trackEvent);
                    trackEvent.AddTake(media.Streams[0], true, elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                }
                if (elementStep.Selector.IsVideo() && media.Streams.Any(x => x.MediaType == MediaType.Video))
                {
                    TrackEvent trackEvent = new VideoEvent(Timecode.FromString(elementStep.DataPropertyList[DataPropertyHolder.TIMECODE].Value),
                                                           media.Length,
                                                           elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                    if (media.Streams.Any(x => x.MediaType == MediaType.Audio))
                    {
                        elementStep.Selector.ElementMediaType = ElementMediaType.Audio;
                        AudioTrack  syncAudioTrack = SelectorService.GetTrack(elementStep.Selector) as AudioTrack;
                        MediaStream audioStream    = media.Streams.FirstOrDefault(x => x.MediaType == MediaType.Audio);
                        MediaStream videoStream    = media.Streams.FirstOrDefault(x => x.MediaType == MediaType.Video);
                        var         audioEvent     = new AudioEvent(
                            Timecode.FromString(elementStep.DataPropertyList[DataPropertyHolder.TIMECODE].Value),
                            media.Length,
                            elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                        track.Events.Add(trackEvent);
                        trackEvent.AddTake(videoStream, true, elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                        syncAudioTrack.Events.Add(audioEvent);
                        audioEvent.AddTake(audioStream, true, elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                    }
                    else
                    {
                        track.Events.Add(trackEvent);
                        trackEvent.AddTake(media.Streams[0], true, elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                    }
                }
            }
            if (elementStep.Selector.ElementType == ElementType.Track)
            {
                if (elementStep.Selector.IsAudio())
                {
                    MainContainer.Vegas.Project.AddAudioTrack().Name = elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value;
                }
                if (elementStep.Selector.IsVideo())
                {
                    MainContainer.Vegas.Project.AddVideoTrack().Name = elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value;
                }
            }
        }