예제 #1
0
        public void RemoveEvents()
        {
            int count = 0;

            EventHandler increment = new EventHandler(delegate
            {
                count++;
            });

            EventHandler <AfterEffectAddedEventArgs> incrementForAfterEffectAdded =
                new EventHandler <AfterEffectAddedEventArgs>(delegate
            {
                count++;
            });

            EventHandler <AfterTransitionAddedEventArgs> incrementForAfterTransitionAdded =
                new EventHandler <AfterTransitionAddedEventArgs>(delegate
            {
                count++;
            });

            EventHandler <AfterClipAddedEventArgs> incrementForAfterClipAdded =
                new EventHandler <AfterClipAddedEventArgs>(delegate
            {
                count++;
            });

            using (ITimeline timeline = new DefaultTimeline())
            {
                ITrack track = timeline.AddAudioGroup().AddTrack();

                track.AfterEffectAdded     += incrementForAfterEffectAdded;
                track.AfterTransitionAdded += incrementForAfterTransitionAdded;
                track.AfterClipAdded       += incrementForAfterClipAdded;

                track.BeforeEffectAdded     += increment;
                track.BeforeTransitionAdded += increment;
                track.BeforeClipAdded       += increment;

                track.AddEffect(0, 2, StandardEffects.CreateDefaultBlur());
                track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absoloute, 0, 0, 1);
                track.AddTransition(0, 2, StandardTransitions.CreateFade());

                Assert.AreEqual(6, count);
                count = 0;

                track.AfterEffectAdded      -= incrementForAfterEffectAdded;
                track.AfterTransitionAdded  -= incrementForAfterTransitionAdded;
                track.AfterClipAdded        -= incrementForAfterClipAdded;
                track.BeforeEffectAdded     -= increment;
                track.BeforeTransitionAdded -= increment;
                track.BeforeClipAdded       -= increment;

                track.AddEffect(0, 2, StandardEffects.CreateDefaultBlur());
                track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Relative, 0, 0, 1);
                track.AddTransition(2, 2, StandardTransitions.CreateFade());

                Assert.AreEqual(0, count);
            }
        }
예제 #2
0
        public void AddEffectSetsApropriateContainer()
        {
            using (ITimeline timeline = new DefaultTimeline())
            {
                EffectDefinition def = StandardEffects.CreateDefaultBlur();

                IGroup  group       = timeline.AddVideoGroup(24, 100, 100);
                IEffect groupEffect = group.AddEffect(0, 10, def);
                Assert.AreSame(group, groupEffect.Group);
                Assert.AreSame(group, groupEffect.Container);

                ITrack  track       = group.AddTrack();
                IEffect trackEffect = track.AddEffect(0, 10, def);
                Assert.AreSame(group, trackEffect.Group);
                Assert.AreSame(track, trackEffect.Container);

                IComposition composition       = group.AddComposition();
                IEffect      compositionEffect = composition.AddEffect(0, 10, def);
                Assert.AreSame(group, compositionEffect.Group);
                Assert.AreSame(composition, compositionEffect.Container);

                IClip   clip       = track.AddClip("..\\..\\image1.jpg", GroupMediaType.Image, InsertPosition.Absolute, 0, 0, 10);
                IEffect clipEffect = clip.AddEffect(0, 10, def);
                Assert.AreSame(group, clip.Group);
                Assert.AreSame(clip, clipEffect.Container);
            }
        }
예제 #3
0
        public void EnsureClipBubblesBeforeAndAfterEffectAddedUp()
        {
            int beforeCount = 0;
            int afterCount  = 0;

            using (ITimeline timeline = new DefaultTimeline())
            {
                IGroup group = timeline.AddAudioGroup();
                ITrack track = group.AddTrack();
                track.BeforeEffectAdded += new EventHandler(delegate
                {
                    beforeCount++;
                });
                track.AfterEffectAdded += new EventHandler <AfterEffectAddedEventArgs>(delegate
                {
                    afterCount++;
                });

                IClip clip = track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absoloute, 0, 0, -1);
                clip.AddEffect(0, 1, StandardEffects.CreateDefaultBlur());

                Assert.AreEqual(1, beforeCount);
                Assert.AreEqual(1, afterCount);
            }
        }
예제 #4
0
        public void RemoveClipEventHandlers()
        {
            int count = 0;

            EventHandler incrementBefore = delegate { count++; };

            EventHandler <AddedEffectEventArgs> incrementAfter =
                delegate { count++; };

            using (ITimeline timeline = new DefaultTimeline())
            {
                IClip clip =
                    timeline.AddAudioGroup().AddTrack().AddClip("testinput.wav", GroupMediaType.Audio,
                                                                InsertPosition.Absolute, 0, 0, -1);
                clip.AddedEffect  += incrementAfter;
                clip.AddingEffect += incrementBefore;

                clip.AddEffect(0, 2, StandardEffects.CreateDefaultBlur());
                Assert.AreEqual(2, count);

                count              = 0;
                clip.AddedEffect  -= incrementAfter;
                clip.AddingEffect -= incrementBefore;

                clip.AddEffect(0, 2, StandardEffects.CreateDefaultBlur());

                Assert.AreEqual(0, count);
            }
        }
예제 #5
0
        public void RemoveEvents()
        {
            int count = 0;

            EventHandler increment = delegate { count++; };
            EventHandler <AddedCompositionEventArgs> incrementForAfterCompositionAdded =
                delegate { count++; };
            EventHandler <AddedEffectEventArgs> incrementForAfterEffectAdded =
                delegate { count++; };
            EventHandler <AddedTrackEventArgs> incrementForAfterTrackAdded =
                delegate { count++; };
            EventHandler <AddedTransitionEventArgs> incrementForAfterTransitionAdded =
                delegate { count++; };
            EventHandler <AddedClipEventArgs> incrementForAfterClipAdded =
                delegate { count++; };

            using (ITimeline timeline = new DefaultTimeline())
            {
                IComposition composition = timeline.AddAudioGroup().AddComposition();
                composition.AddedComposition  += incrementForAfterCompositionAdded;
                composition.AddedEffect       += incrementForAfterEffectAdded;
                composition.AddedTrack        += incrementForAfterTrackAdded;
                composition.AddedTransition   += incrementForAfterTransitionAdded;
                composition.AddedClip         += incrementForAfterClipAdded;
                composition.AddingComposition += increment;
                composition.AddingEffect      += increment;
                composition.AddingTrack       += increment;
                composition.AddingTransition  += increment;
                composition.AddingClip        += increment;

                composition.AddComposition();
                composition.AddEffect(0, 2, StandardEffects.CreateDefaultBlur());
                composition.AddTrack().AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absolute, 0, 0, 1);
                composition.AddTransition(0, 2, StandardTransitions.CreateFade());

                Assert.AreEqual(10, count);
                count = 0;

                composition.AddedComposition  -= incrementForAfterCompositionAdded;
                composition.AddedEffect       -= incrementForAfterEffectAdded;
                composition.AddedTrack        -= incrementForAfterTrackAdded;
                composition.AddedTransition   -= incrementForAfterTransitionAdded;
                composition.AddedClip         -= incrementForAfterClipAdded;
                composition.AddingComposition -= increment;
                composition.AddingEffect      -= increment;
                composition.AddingTrack       -= increment;
                composition.AddingTransition  -= increment;
                composition.AddingClip        -= increment;

                composition.AddComposition();
                composition.AddEffect(0, 2, StandardEffects.CreateDefaultBlur());
                composition.AddTrack();
                composition.AddTransition(2, 2, StandardTransitions.CreateFade());

                Assert.AreEqual(0, count);
            }
        }
        public void GroupAddEffectBubblesToTimeline()
        {
            int beforeCount = 0;
            int afterCount  = 0;

            using (ITimeline timeline = new DefaultTimeline(12))
            {
                timeline.AddingEffect += delegate { beforeCount++; };

                timeline.AddedEffect += delegate { afterCount++; };

                IGroup group = timeline.AddAudioGroup();
                group.AddEffect(0, 1, StandardEffects.CreateDefaultBlur());
            }

            Assert.AreEqual(1, beforeCount);
            Assert.AreEqual(1, afterCount);
        }
예제 #7
0
        public void GroupAddEffectBubblesToTimeline()
        {
            int beforeCount = 0;
            int afterCount  = 0;

            using (ITimeline timeline = new DefaultTimeline(12))
            {
                timeline.BeforeEffectAdded += new EventHandler(delegate
                {
                    beforeCount++;
                });

                timeline.AfterEffectAdded += new EventHandler <AfterEffectAddedEventArgs>(delegate
                {
                    afterCount++;
                });

                IGroup group = timeline.AddAudioGroup();
                group.AddEffect(0, 1, StandardEffects.CreateDefaultBlur());
            }

            Assert.AreEqual(1, beforeCount);
            Assert.AreEqual(1, afterCount);
        }