Beispiel #1
0
        public void TrackAddEffectBubblesToComposition()
        {
            int beforeCount = 0;
            int afterCount  = 0;

            using (ITimeline timeline = new DefaultTimeline())
            {
                IGroup       group       = timeline.AddVideoGroup(24, 100, 100);
                IComposition composition = group.AddComposition();

                composition.BeforeEffectAdded += new EventHandler(delegate
                {
                    beforeCount++;
                });

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

                ITrack track = composition.AddTrack();
                track.AddEffect("test", -1, 1, 2, StandardEffects.CreateBlurEffect(2, 2, 10));

                Assert.AreEqual(1, beforeCount);
                Assert.AreEqual(1, afterCount);
            }
        }
Beispiel #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);
            }
        }
Beispiel #3
0
        public void AddTransition()
        {
            using (ITimeline timeline = new DefaultTimeline())
            {
                IGroup       group       = timeline.AddVideoGroup(24, 100, 100);
                IComposition composition = group.AddComposition();

                bool firedBefore = false;
                bool firedAfter  = false;

                composition.BeforeTransitionAdded += new EventHandler(delegate
                {
                    firedBefore = true;
                });

                composition.AfterTransitionAdded += new EventHandler <AfterTransitionAddedEventArgs>(delegate
                {
                    firedAfter = true;
                });

                ITransition transition =
                    composition.AddTransition("test", 0, 2, StandardTransitions.CreateFade(), false);
                Assert.AreEqual(1, composition.Transitions.Count);
                Assert.AreEqual("test", transition.Name);
                Assert.AreEqual(0, transition.Offset);
                Assert.AreEqual(2, transition.Duration);
                Assert.IsTrue(firedBefore);
                Assert.IsTrue(firedAfter);
            }
        }
Beispiel #4
0
        public void AddEffect()
        {
            using (ITimeline timeline = new DefaultTimeline())
            {
                IGroup       group       = timeline.AddVideoGroup(24, 100, 100);
                IComposition composition = group.AddComposition();

                bool firedBefore = false;
                bool firedAfter  = false;

                composition.BeforeEffectAdded += new EventHandler(delegate
                {
                    firedBefore = true;
                });

                composition.AfterEffectAdded += new EventHandler <AfterEffectAddedEventArgs>(delegate
                {
                    firedAfter = true;
                });

                IEffect effect = composition.AddEffect("test", -1, 1, 2, StandardEffects.CreateBlurEffect(2, 2, 10));
                Assert.AreEqual("test", effect.Name);
                Assert.AreEqual(1, effect.Offset);
                Assert.AreEqual(2, effect.Duration);
                Assert.AreEqual(1, composition.Effects.Count);
                Assert.IsTrue(firedBefore);
                Assert.IsTrue(firedAfter);
            }
        }
Beispiel #5
0
        public void AddComposition()
        {
            using (ITimeline timeline = new DefaultTimeline())
            {
                IGroup       group       = timeline.AddAudioGroup();
                IComposition composition = group.AddComposition();
                Assert.AreSame(group, composition.Container);
                Assert.AreSame(group, composition.Group);

                bool firedBefore = false;
                bool firedAfter  = false;

                composition.BeforeCompositionAdded += new EventHandler(delegate
                {
                    firedBefore = true;
                });

                composition.AfterCompositionAdded += new EventHandler <AfterCompositionAddedEventArgs>(delegate
                {
                    firedAfter = true;
                });

                IComposition childComposition = composition.AddComposition();
                Assert.AreSame(composition, childComposition.Container);
                Assert.AreSame(group, childComposition.Group);
                Assert.AreEqual(1, composition.Compositions.Count);
                Assert.IsTrue(firedBefore);
                Assert.IsTrue(firedAfter);
            }
        }
Beispiel #6
0
        public void AddTrack()
        {
            using (ITimeline timeline = new DefaultTimeline())
            {
                IGroup       group       = timeline.AddAudioGroup();
                IComposition composition = group.AddComposition();

                bool firedBefore = false;
                bool firedAfter  = false;

                composition.BeforeTrackAdded += new EventHandler(delegate
                {
                    firedBefore = true;
                });

                composition.AfterTrackAdded += new EventHandler <AfterTrackAddedEventArgs>(delegate
                {
                    firedAfter = true;
                });

                ITrack track = composition.AddTrack();
                Assert.AreEqual(1, composition.Tracks.Count);
                Assert.IsTrue(firedBefore);
                Assert.IsTrue(firedAfter);
            }
        }
Beispiel #7
0
 public void CompositionPriorities()
 {
     using (ITimeline timeline = new DefaultTimeline())
     {
         IGroup       group  = timeline.AddAudioGroup();
         IComposition first  = group.AddComposition("first", -1);
         IComposition second = group.AddComposition("second", 0);
         IComposition third  = group.AddComposition("third", 1);
         IComposition fourth = group.AddComposition("fourth", -1);
         IComposition fifth  = group.AddComposition("fifth", 2);
         Assert.AreEqual(3, first.Priority);
         Assert.AreEqual(0, second.Priority);
         Assert.AreEqual(1, third.Priority);
         Assert.AreEqual(4, fourth.Priority);
         Assert.AreEqual(2, fifth.Priority);
     }
 }
Beispiel #8
0
 public void AddCompositionWithName()
 {
     using (ITimeline timeline = new DefaultTimeline())
     {
         IGroup       group       = timeline.AddAudioGroup();
         IComposition composition = group.AddComposition("named", -1);
         Assert.AreEqual("named", composition.Name);
     }
 }
        public void GroupAddCompositionBubblesToTimeline()
        {
            int beforeCount = 0;
            int afterCount  = 0;

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

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

                IGroup group = timeline.AddAudioGroup();
                group.AddComposition();
            }

            Assert.AreEqual(1, beforeCount);
            Assert.AreEqual(1, afterCount);
        }
        public void AddTrack()
        {
            using (ITimeline timeline = new DefaultTimeline())
            {
                IGroup       group       = timeline.AddAudioGroup();
                IComposition composition = group.AddComposition();

                bool firedBefore = false;
                bool firedAfter  = false;

                composition.AddingTrack += delegate { firedBefore = true; };

                composition.AddedTrack += delegate { firedAfter = true; };

                ITrack track = composition.AddTrack();
                Assert.AreEqual(1, composition.Tracks.Count);
                Assert.IsTrue(firedBefore);
                Assert.IsTrue(firedAfter);
            }
        }
        public void AddTransitionSetsAppropriateContainerAndGroup()
        {
            using (ITimeline timeline = new DefaultTimeline())
            {
                TransitionDefinition def = StandardTransitions.CreateIris();

                IGroup      group           = timeline.AddAudioGroup();
                ITransition groupTransition = group.AddTransition(0, 0, def);
                Assert.AreSame(group, groupTransition.Container);
                Assert.AreSame(group, groupTransition.Group);

                ITrack      track           = group.AddTrack();
                ITransition trackTransition = track.AddTransition(0, 0, def);
                Assert.AreSame(track, trackTransition.Container);
                Assert.AreSame(group, trackTransition.Group);

                IComposition composition           = group.AddComposition();
                ITransition  compositionTransition = composition.AddTransition(0, 0, def);
                Assert.AreSame(composition, compositionTransition.Container);
                Assert.AreSame(group, compositionTransition.Group);
            }
        }
        public void GroupAddCompositionBubblesToTimeline()
        {
            int beforeCount = 0;
            int afterCount  = 0;

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

                timeline.AfterCompositionAdded += new EventHandler <AfterCompositionAddedEventArgs>(delegate
                {
                    afterCount++;
                });

                IGroup group = timeline.AddAudioGroup();
                group.AddComposition();
            }

            Assert.AreEqual(1, beforeCount);
            Assert.AreEqual(1, afterCount);
        }
        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++; };

            EventHandler <AddedGroupEventArgs> incrementForAfterGroupAdded =
                delegate { count++; };

            using (ITimeline timeline = new DefaultTimeline())
            {
                timeline.AddedComposition += incrementForAfterCompositionAdded;
                timeline.AddedEffect      += incrementForAfterEffectAdded;
                timeline.AddedTrack       += incrementForAfterTrackAdded;
                timeline.AddedTransition  += incrementForAfterTransitionAdded;
                timeline.AddedClip        += incrementForAfterClipAdded;
                timeline.AddedGroup       += incrementForAfterGroupAdded;

                timeline.AddingComposition += increment;
                timeline.AddingEffect      += increment;
                timeline.AddingTrack       += increment;
                timeline.AddingTransition  += increment;
                timeline.AddingClip        += increment;
                timeline.AddingGroup       += increment;

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

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

                timeline.AddedComposition -= incrementForAfterCompositionAdded;
                timeline.AddedEffect      -= incrementForAfterEffectAdded;
                timeline.AddedTrack       -= incrementForAfterTrackAdded;
                timeline.AddedTransition  -= incrementForAfterTransitionAdded;
                timeline.AddedClip        -= incrementForAfterClipAdded;
                timeline.AddedGroup       -= incrementForAfterGroupAdded;

                timeline.AddingComposition -= increment;
                timeline.AddingEffect      -= increment;
                timeline.AddingTrack       -= increment;
                timeline.AddingTransition  -= increment;
                timeline.AddingClip        -= increment;
                timeline.AddingGroup       -= increment;

                IGroup group2 = timeline.AddAudioGroup();
                group2.AddComposition();
                group2.AddEffect(0, 2, StandardEffects.CreateDefaultBlur());
                group2.AddTrack().AddClip("testinput.wav", GroupMediaType.Audio, InsertPosition.Relative, 0, 0, 1);
                group2.AddTransition(2, 2, StandardTransitions.CreateFade());

                Assert.AreEqual(0, count);
            }
        }