Example #1
0
        protected AbstractRenderer(ITimeline timeline)
        {
            if (timeline == null)
            {
                throw new ArgumentNullException(TimelineParameterName);
            }

            _timeline = timeline;

            int hr = 0;

            // create the render engine
            _renderEngine = (IRenderEngine) new RenderEngine();
            _cleanup.Add(_renderEngine);

            // tell the render engine about the timeline it should use
            hr = _renderEngine.SetTimelineObject(_timeline.DesTimeline);
            DESError.ThrowExceptionForHR(hr);

            // connect up the front end
            hr = _renderEngine.ConnectFrontEnd();
            DESError.ThrowExceptionForHR(hr);

            // Get the filtergraph - used all over the place
            hr = _renderEngine.GetFilterGraph(out _graph);
            _cleanup.Add(Graph);
            DESError.ThrowExceptionForHR(hr);

            // find the first (and usually last) audio and video group, we use these
            // when rendering to track progress
            _firstAudioGroup = _timeline.FindFirstGroupOfType(GroupType.Audio);
            _firstVideoGroup = _timeline.FindFirstGroupOfType(GroupType.Video);
        }
Example #2
0
        public override void FixedUpdate(ITimeline time)
        {
            World.Step(Math.Min((float)time.DeltaTime.TotalSeconds, (1f / 30f)));

            Camera.Update(time);
            Game.FixedUpdate(time);
        }
Example #3
0
        protected virtual void DisposeRenderer(bool disposing)
        {
            if (disposing)
            {
                if (_cleanup != null)
                {
                    (_cleanup).Dispose();
                    _cleanup = null;
                }

                if (_timeline != null)
                {
                    _timeline.Dispose();
                    _timeline = null;
                }
            }

            if (_renderEngine != null)
            {
                Marshal.ReleaseComObject(_renderEngine);
                _renderEngine = null;
            }

            if (_mediaControl != null)
            {
                Marshal.ReleaseComObject(_mediaControl);
                _mediaControl = null;
            }

            if (Graph != null)
            {
                Marshal.ReleaseComObject(Graph);
                _graph = null;
            }
        }
Example #4
0
 public TrackingShot(Timeline position_timeline, Timeline lookat_timeline, Timeline upvec_timeline)
 {
     this.position_timeline           = position_timeline;
     this.lookat_timeline             = lookat_timeline;
     this.upvec_timeline              = upvec_timeline;
     this.lookat_by_position_timeline = new RelativeTimeline(this.position_timeline, this.lookat_timeline);
 }
Example #5
0
        /// <summary>
        /// Gets the animation time for the specified time value on the timeline. (This helper method
        /// can be used for animations which start at time 0 and run with normal speed.)
        /// </summary>
        /// <param name="timeline">The timeline.</param>
        /// <param name="time">The time on the timeline.</param>
        /// <returns>
        /// The animation time. (Or <see langword="null"/> if the animation is not active at
        /// <paramref name="time"/>.)
        /// </returns>
        internal static TimeSpan?GetAnimationTime(ITimeline timeline, TimeSpan time)
        {
            if (time < TimeSpan.Zero)
            {
                // The animation has not started.
                return(null);
            }

            TimeSpan duration = timeline.GetTotalDuration();

            if (time > duration)
            {
                if (timeline.FillBehavior == FillBehavior.Stop)
                {
                    // The animation has stopped.
                    return(null);
                }

                // The animation holds the final value.
                Debug.Assert(timeline.FillBehavior == FillBehavior.Hold);
                return(duration);
            }

            return(time);
        }
Example #6
0
        /// <summary>
        /// Gets the state of the animation for the specified time on the timeline. (This helper method
        /// can be used for animations which start at time 0 and run with normal speed.)
        /// </summary>
        /// <param name="timeline">The timeline.</param>
        /// <param name="time">The time on the timeline.</param>
        /// <returns>The animation state.</returns>
        internal static AnimationState GetState(ITimeline timeline, TimeSpan time)
        {
            if (time < TimeSpan.Zero)
            {
                // The animation has not started.
                return(AnimationState.Delayed);
            }

            TimeSpan duration = timeline.GetTotalDuration();

            if (time > duration)
            {
                if (timeline.FillBehavior == FillBehavior.Stop)
                {
                    // The animation has stopped.
                    return(AnimationState.Stopped);
                }

                // The animation holds the last value.
                Debug.Assert(timeline.FillBehavior == FillBehavior.Hold);
                return(AnimationState.Filling);
            }

            return(AnimationState.Playing);
        }
Example #7
0
        public void CopyTo()
        {
            var blendGroup = new BlendGroup();

            ITimeline[] array = new ITimeline[0];
            Assert.That(() => ((IList <ITimeline>)blendGroup).CopyTo(null, 0), Throws.TypeOf <ArgumentNullException>());
            Assert.That(() => ((IList <ITimeline>)blendGroup).CopyTo(array, -1), Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(() => ((IList <ITimeline>)blendGroup).CopyTo(array, 1), Throws.ArgumentException);
            Assert.That(() => ((IList <ITimeline>)blendGroup).CopyTo(array, 0), Throws.Nothing);

            var animation0 = new SingleFromToByAnimation();
            var animation1 = new SingleFromToByAnimation();

            blendGroup = new BlendGroup {
                animation0, animation1
            };

            array = new ITimeline[1];
            Assert.That(() => ((IList <ITimeline>)blendGroup).CopyTo(array, 0), Throws.ArgumentException);

            array = new ITimeline[2];
            ((IList <ITimeline>)blendGroup).CopyTo(array, 0);
            Assert.AreEqual(animation0, array[0]);
            Assert.AreEqual(animation1, array[1]);

            array = new ITimeline[3];
            ((IList <ITimeline>)blendGroup).CopyTo(array, 1);
            Assert.AreEqual(null, array[0]);
            Assert.AreEqual(animation0, array[1]);
            Assert.AreEqual(animation1, array[2]);
        }
Example #8
0
        public object Load(IContentManager contentManager)
        {
            Animation animation = new Animation();

            animation.Mode       = Mode;
            animation.Direction  = Direction;
            animation.Fps        = Fps;
            animation.FrameCount = FrameCount;

            if (Timelines.Count > 1)
            {
                ParallelTimeline parallelTimeline = new ParallelTimeline();
                parallelTimeline.BeginTime = 0;
                parallelTimeline.EndTime   = 1;
                parallelTimeline.Duration  = 1;

                for (int i = 0; i < Timelines.Count; i++)
                {
                    ITimeline timeline = (ITimeline)Timelines[i].Load(contentManager);

                    parallelTimeline.Children.Add(timeline);
                }

                animation.Timeline = parallelTimeline;
            }
            else if (Timelines.Count > 0)
            {
                animation.Timeline = (ITimeline)Timelines[0].Load(contentManager);
            }

            return(animation);
        }
Example #9
0
        public override void Update(float time)
        {
            time = NormalizeTime(time);

            if (time < _lastTime)
            {
                for (int i = _lastIndex; i >= 0; i--)
                {
                    ITimeline child = Children[i];
                    if (child.BeginTime <= time && time <= child.EndTime)
                    {
                        _lastIndex = i;
                        _lastTime  = time;

                        child.Update(time);
                        break;
                    }
                }
            }
            else
            {
                for (int i = _lastIndex; i < Children.Count; i++)
                {
                    ITimeline child = Children[i];
                    if (child.BeginTime <= time && time <= child.EndTime)
                    {
                        _lastIndex = i;
                        _lastTime  = time;

                        child.Update(time);
                        break;
                    }
                }
            }
        }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Mutation"/> class.
 /// </summary>
 /// <param name="bus">Bus service</param>
 /// <param name="log">Log service</param>
 /// <param name="manager">Branch manager</param>
 /// <param name="timeline">Timeline</param>
 public Mutation(IBus bus, ILog log, IBranchManager manager, ITimeline timeline)
     : base(bus, log, manager)
 {
     _bus         = bus;
     _queries     = new Query(bus);
     _coreQueries = new Core.Config.Query(bus, timeline);
 }
Example #11
0
        /// <summary>
        /// Creates an instance of the <see cref="AnimationInstance"/> class. (This method reuses a
        /// previously recycled instance or allocates a new instance if necessary.)
        /// </summary>
        /// <param name="animation">The animation timeline.</param>
        /// <returns>
        /// A new or reusable instance of the <see cref="AnimationInstance"/> class.
        /// </returns>
        /// <remarks>
        /// <para>
        /// This method tries to obtain a previously recycled instance from a resource pool if resource
        /// pooling is enabled (see <see cref="ResourcePool.Enabled">ResourcePool.Enabled</see>). If no
        /// object is available, a new instance is automatically allocated on the heap.
        /// </para>
        /// <para>
        /// The owner of the object should call <see cref="Recycle"/> when the instance is no longer
        /// needed.
        /// </para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="animation"/> is <see langword="null"/>.
        /// </exception>
        public static AnimationInstance Create(ITimeline animation)
        {
            var animationInstance = Pool.Obtain();

            animationInstance.Initialize(animation);
            return(animationInstance);
        }
Example #12
0
        public void Stop()
        {
            if (_trace.IsEnabled)
            {
                _trace.WriteEventActivity(
                    eventId: TraceProvider.StoryBoard_Stop,
                    opCode: EventOpcode.Stop,
                    activity: _traceActivity,
                    payload: new object[] { Target?.GetType().ToString(), PropertyInfo?.Path }
                    );
            }

            State = TimelineState.Stopped;
            _hasFillingChildren = false;

            if (Children != null)
            {
                for (int i = 0; i < Children.Count; i++)
                {
                    ITimeline child = Children[i];

                    child.Stop();
                    DisposeChildRegistrations(child);
                }
            }
            _runningChildren = 0;
        }
        public static string renderVideo(this ITimeline timeline, string outputFile)
        {
            try
            {
                if (outputFile.fileExists())
                {
                    Files.deleteFile(outputFile);
                }

                //var renderer = new WindowsMediaRenderer(timeline, outputFile, WindowsMediaProfiles.HighQualityVideo);
                var renderer = new WindowsMediaRenderer(timeline, outputFile, WindowsMediaProfiles.BiggerHighQualityVideo);

                "[API_Cropper] starting video rendering process".info();
                renderer.Render();
                "[API_Cropper] video rendering complete".debug();
                if (outputFile.fileExists())
                {
                    "[API_Cropper] video saved to {0}".info(outputFile);
                    return(outputFile);
                }

                "[API_Cropper] video file was not created".error();
                return("");
            }
            catch (Exception ex)
            {
                ex.log("in API_Cropper videoTrack renderVideo");
                return("");
            }
        }
Example #14
0
        private void Play()
        {
            if (Children != null && Children.Count > 0)
            {
                for (int i = 0; i < Children.Count; i++)
                {
                    ITimeline child = Children[i];

                    DisposeChildRegistrations(child);

                    _runningChildren++;
                    child.RegisterListener(this);

                    child.Begin();
                }
            }
            else
            {
                Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    // No children, so we complete immediately
                    State = TimelineState.Stopped;
                    OnCompleted();
                });
            }
        }
Example #15
0
 protected void PrepareToExecute(ITimeline timeline, string expectedXml)
 {
     using (var renderer = new NullRenderer(timeline))
     {
         PrepareToExecute(renderer, expectedXml);
     }
 }
Example #16
0
        public NullRenderer(ITimeline timeline, IDESCombineCB audioCallback, IDESCombineCB videoCallback)
            : base(timeline)
        {
            RenderToNullRenderer(audioCallback, videoCallback);

            ChangeState(RendererState.Initialized);
        }
Example #17
0
 public AvaliadorDeTweets(IMenções menções, ITweetsParaProcessar tweetsParaProcessar, IRespostasParaRetuitar respostasParaRetuitar, ITimeline timeline)
 {
     _menções = menções;
     _tweetsParaProcessar = tweetsParaProcessar;
     _respostasParaRetuitar = respostasParaRetuitar;
     _timeline = timeline;
 }
Example #18
0
        private void Play()
        {
            if (Children != null && Children.Count > 0)
            {
                for (int i = 0; i < Children.Count; i++)
                {
                    ITimeline child = Children[i];

                    DisposeChildRegistrations(child);

                    _runningChildren++;
                    child.Completed += Child_Completed;
                    child.Failed    += Child_Failed;

                    _childrenSubscriptions.Add(
                        child,
                        Disposable.Create(() => {
                        child.Completed -= Child_Completed;
                        child.Failed    -= Child_Failed;
                    })
                        );

                    child.Begin();
                }
            }
            else
            {
                Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    // No children, so we complete immediately
                    State = TimelineState.Stopped;
                    OnCompleted();
                });
            }
        }
Example #19
0
            public ChangesFlow(ITimeline currentBranch, ConcurrentDictionary <IStream, int> streams)
                : base(Configuration.DataflowOptions)
            {
                _inputBlock = new ActionBlock <IStream>(
                    s =>
                {
                    var version = ExpectedVersion.EmptyStream;
                    var parent  = s.Parent;
                    while (parent != null && parent.Version > ExpectedVersion.EmptyStream)
                    {
                        version = parent.Version;

                        if (s.Version == version)
                        {
                            return;
                        }

                        if (parent.Timeline == currentBranch?.Id)
                        {
                            break;
                        }

                        parent = parent.Parent;
                    }

                    var stream = parent ?? s.Branch(s.Timeline, version);
                    streams.TryAdd(stream, s.Version - version);
                }, Configuration.DataflowOptions.ToDataflowBlockOptions(true));     // ToExecutionBlockOption(true));

                RegisterChild(_inputBlock);
            }
Example #20
0
        public void Dispose()
        {
            if (_dc != null)
            {
                ((IDisposable)_dc).Dispose();
                _dc = null;
            }

            if (_timeline != null)
            {
                _timeline.Dispose();
                _timeline = null;
            }

            if (_renderEngine != null)
            {
                Marshal.ReleaseComObject(_renderEngine);
                _renderEngine = null;
            }

            if (_mediaControl != null)
            {
                Marshal.ReleaseComObject(_mediaControl);
                _mediaControl = null;
            }

            if (_graph != null)
            {
                Marshal.ReleaseComObject(_graph);
                _graph = null;
            }
        }
Example #21
0
        /// <summary>
        /// Use the timeline to determine if the user has "pushed" enough to indicate they want to try and click
        /// </summary>
        /// <param name="timeline"></param>
        /// <returns></returns>
        protected override bool IsFulfilled(ITimeline <IEmotivState> timeline)
        {
            var lastRecorded = timeline.Latest();

            if (lastRecorded == null)
            {
                return(false);
            }

            IEnumerable <IEmotivState> dataSet = timeline[lastRecorded.Time - RefreshInterval, lastRecorded.Time].ToArray();

            if (dataSet == null || dataSet.Count() == 0)
            {
                return(false);
            }

            float targetRate = ((float)dataSet.Where(s => s.Command == TargetCommand).Count()) / dataSet.Count();

            if (targetRate >= ThreashHold)
            {
                return(true);
            }

            return(false);
        }
Example #22
0
    // REDO ME
    private void updateUI()
    {
        ITimeline active_tl = __displayedTimeline;

        if (active_tl == null)
        {
            return;
        }
        bool is_previous_tl = (active_tl as PlayerTimeline).IsPrevious();

        // to update time units sprites
        Transform current_tick_square_transform = null;

        if (null == __time_units)
        {
            if (!tryRefreshTimeUnits())
            {
                return;
            }
        }


        for (int i = 0; i < __time_units.Length; i++)
        {
            bool            square_is_active = active_tl.IsCursorValuable(i);
            UITimelineInput curr_unit        = __time_units[i];

            // show enabled or disabled for curr unit
            if (!square_is_active)
            {
                __time_units[i].showDisabled();
                continue;
            }

            __time_units[i].showEnabled();

            updateSquareInputImage(i, (active_tl.GetCursorValue(i) as PlayerTimelineValue).GetValue());

            // RECORD exclusive logic for current timeline
            if (__WM.IM.CurrentMode == InputManager.Mode.RECORD && !is_previous_tl)
            {
                // Hide forward squares
                if (i > (active_tl as PlayerTimeline).getTickForTimeUnits())
                {
                    curr_unit.hide();
                }
                // Show none as next input at the last_tick position
                else if (i == active_tl.GetCursorIndex() + 1)
                {
                    if (Constants.ShowDefaultTileOnCursor)
                    {
                        __time_units[i].changeSprite(ui_input_none);
                    }
                }
            }
        }//! for time units
        // update timeline animator
        update_time(active_tl.GetCursorIndex() + 1);
    }//! updateUI
Example #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Project"/> class.
        /// </summary>
        /// <param name="timeline">The timeline for the current project.</param>
        /// <param name="distributor">
        /// The function which returns a <see cref="DistributionPlan"/> for a given
        /// <see cref="DatasetActivationRequest"/>.
        /// </param>
        /// <param name="dataStorageProxyBuilder">The function which returns a storage proxy for a newly loaded dataset.</param>
        /// <param name="notifications">The object that stores the notifications for the user interface.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <param name="persistenceInfo">
        /// The object that describes how the project was persisted.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="timeline"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="distributor"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="dataStorageProxyBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="notifications"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public Project(
            ITimeline timeline,
            Func <DatasetActivationRequest, CancellationToken, IEnumerable <DistributionPlan> > distributor,
            Func <DatasetOnlineInformation, DatasetStorageProxy> dataStorageProxyBuilder,
            ICollectNotifications notifications,
            SystemDiagnostics diagnostics,
            IPersistenceInformation persistenceInfo)
        {
            {
                Lokad.Enforce.Argument(() => timeline);
                Lokad.Enforce.Argument(() => distributor);
                Lokad.Enforce.Argument(() => dataStorageProxyBuilder);
                Lokad.Enforce.Argument(() => notifications);
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Timeline = timeline;
            m_Timeline.ForgetAllHistory();

            m_Timeline.OnRolledBack    += OnTimelineRolledBack;
            m_Timeline.OnRolledForward += OnTimelineRolledForward;

            m_ProjectInformation = m_Timeline.AddToTimeline(ProjectHistoryStorage.CreateInstance);
            m_Datasets           = m_Timeline.AddToTimeline(DatasetHistoryStorage.CreateInstance);

            m_DatasetDistributor      = distributor;
            m_DataStorageProxyBuilder = dataStorageProxyBuilder;

            m_Notifications = notifications;
            m_Diagnostics   = diagnostics;

            if (persistenceInfo != null)
            {
                RestoreFromStore(persistenceInfo);
            }

            // Create a root dataset if there isn't one
            if (m_RootDataset == null)
            {
                var dataset = CreateDataset(
                    null,
                    new DatasetCreationInformation
                {
                    CreatedOnRequestOf = DatasetCreator.System,
                    LoadFrom           = new NullPersistenceInformation(),
                    CanBeDeleted       = false,
                    CanBeCopied        = false,
                    CanBecomeParent    = true,
                    CanBeAdopted       = false,
                    IsRoot             = true,
                });

                m_RootDataset   = dataset.Id;
                dataset.Name    = Resources.Projects_Dataset_RootDatasetName;
                dataset.Summary = Resources.Projects_Dataset_RootDatasetSummary;
            }

            m_Timeline.SetCurrentAsDefault();
        }
Example #24
0
        public WavFileRenderer(ITimeline timeline, string outputFile, IBaseFilter audioCompressor, AMMediaType mediaType,
                               ICallbackParticipant[] audioParticipants)
            : base(timeline)
        {
            RenderToWavDest(outputFile, audioCompressor, mediaType, audioParticipants);

            ChangeState(RendererState.Initialized);
        }
Example #25
0
        public NullRenderer(ITimeline timeline, ICallbackParticipant[] audioParticipants,
                            ICallbackParticipant[] videoParticipants)
            : base(timeline)
        {
            RenderToNullRenderer(audioParticipants, videoParticipants);

            ChangeState(RendererState.Initialized);
        }
Example #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandLog"/> class.
 /// </summary>
 /// <param name="streamStore">Underlying stream store</param>
 /// <param name="serializer">Serializer</param>
 /// <param name="timeline">Current timeline tracker</param>
 /// <param name="log">Application log</param>
 public CommandLog(IStreamStore streamStore, ISerializer <ICommand> serializer, ITimeline timeline, ILog log)
 {
     _streamStore = streamStore;
     _serializer  = serializer;
     _timeline    = timeline;
     _log         = log;
     _failedCommandsSingleHolders = new ConcurrentDictionary <string, FailedCommandsSingleHolder>();
 }
Example #27
0
 public static timelineEntity initialize(ITimeline new_timeline)
 {
     if (timeline_entity == null)
     {
         timeline_entity = new timelineEntity(new_timeline);
     }
     return(timeline_entity);
 }
        public WavFileRenderer(ITimeline timeline, string outputFile, IBaseFilter audioCompressor, AMMediaType mediaType,
                               ICallbackParticipant[] audioParticipants)
            : base(timeline)
        {
            RenderToWavDest(outputFile, audioCompressor, mediaType, audioParticipants);

            ChangeState(RendererState.Initialized);
        }
Example #29
0
        public NullRenderer(ITimeline timeline, ICallbackParticipant[] audioParticipants,
                            ICallbackParticipant[] videoParticipants)
            : base(timeline)
        {
            RenderToNullRenderer(audioParticipants, videoParticipants);

            ChangeState(RendererState.Initialized);
        }
Example #30
0
       public StartTabPanelViewModel(CompositionContainer container)
       {
           timeline = container.GetExportedValueOrDefault<ITimeline>();
           AppState.StartPanelTabItems.CollectionChanged += StartPanelTabItemsCollectionChanged;
 
           AppState.FilteredStartTabItems.CollectionChanged += FilteredStartTabItems_CollectionChanged;
           AppState.ExcludedStartTabItems.CollectionChanged += ExcludedStartTabItems_CollectionChanged;
       }
Example #31
0
        public WavFileRenderer(ITimeline timeline, string outputFile, IBaseFilter audioCompressor, AMMediaType mediaType,
                               IDESCombineCB audioCallback)
            : base(timeline)
        {
            RenderToWavDest(outputFile, audioCompressor, mediaType, audioCallback);

            ChangeState(RendererState.Initialized);
        }
Example #32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RecordLog"/> class.
        /// </summary>
        /// <param name="timeline">Timeline</param>
        /// <param name="log">Application log</param>
        public RecordLog(ITimeline timeline, ILog log)
        {
            _timeline = timeline;
            _log      = log;

            _logFile  = new Lazy <string>(() => $"ZES_{_timeline.Now.ToString("yyyyMMddHHmmss", null)}.json");
            _scenario = new Lazy <Scenario>();
        }
Example #33
0
        public WindowsMediaRenderer(ITimeline timeline, string file, string profileData, IDESCombineCB pVideoCallback,
                                    IDESCombineCB pAudioCallback)
            : base(timeline)
        {
            RenderToAsfWriter(file, profileData, pVideoCallback, pAudioCallback);

            ChangeState(RendererState.Initialized);
        }
        public static ITrack add_VideoTrack(this ITimeline timeline)
        {
            //var group = timeline.AddVideoGroup(32 /*bitCount*/, 160 /*width*/ ,100 /*height*/);
            var group      = timeline.AddVideoGroup(32 /*bitCount*/, 640 /*width*/, 480 /*height*/);
            var videoTrack = group.AddTrack();

            return(videoTrack);
        }
Example #35
0
        public WindowsMediaRenderer(ITimeline timeline, string file, string profileData,
                                    ICallbackParticipant[] videoParticipants,
                                    ICallbackParticipant[] audioParticipants)
            : base(timeline)
        {
            RenderToAsfWriter(file, profileData, videoParticipants, audioParticipants);

            ChangeState(RendererState.Initialized);
        }
Example #36
0
        public AviFileRenderer(ITimeline timeline, string outputFile, IBaseFilter videoCompressor,
                               IBaseFilter audioCompressor, ICallbackParticipant[] videoParticipants,
                               ICallbackParticipant[] audioParticipants)
            : base(timeline)
        {
            RenderToAVI(outputFile, videoCompressor, audioCompressor, videoParticipants, audioParticipants);

            ChangeState(RendererState.Initialized);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MarkHistoryVertexProcessor"/> class.
        /// </summary>
        /// <param name="timeline">The timeline that stores the history marks.</param>
        /// <param name="onMarkerStorage">The function used to store the generated time markers.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="timeline"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="onMarkerStorage"/> is <see langword="null" />.
        /// </exception>
        public MarkHistoryVertexProcessor(ITimeline timeline, Action<TimeMarker> onMarkerStorage)
        {
            {
                Lokad.Enforce.Argument(() => timeline);
                Lokad.Enforce.Argument(() => onMarkerStorage);
            }

            m_Timeline = timeline;
            m_OnMarkerStorage = onMarkerStorage;
        }
Example #38
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="type">The type of group this is</param>
        /// <param name="mediaType">Media type of the new group</param>
        /// <param name="timeline">Timeline to use for the group</param>
        /// <param name="fps">Fps for the group</param>
        public Group(ITimeline timeline, GroupType type, AMMediaType mediaType, string name, double fps)
            : base(timeline, name, -1)
        {
            if (timeline == null) throw new ArgumentNullException("timeline");
            if (mediaType == null) throw new ArgumentNullException("mediaType");
            if (fps <= 0) throw new SplicerException(Resources.ErrorFramesPerSecondMustBeGreaterThenZero);

            _timeline = timeline;
            _type = type;
            _fps = fps;

            _group = TimelineBuilder.InsertGroup(_timeline.DesTimeline, mediaType, name);
            TimelineComposition = (IAMTimelineComp) _group;
        }
Example #39
0
    public BakedAnimationSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      SampleFramework.IsMouseVisible = false;

      // Add a custom game object which controls the camera.
      _cameraObject = new CameraObject(Services);
      _cameraObject.ResetPose(new Vector3F(0, 1, -3), ConstantsF.Pi, 0);
      GameObjectService.Objects.Add(_cameraObject);

      // Create a random avatar.
      _avatarDescription = AvatarDescription.CreateRandom();
      _avatarRenderer = new AvatarRenderer(_avatarDescription);

      // Convert animation.
      _waveAnimation = BakeAnimation(new AvatarAnimation(AvatarAnimationPreset.Clap));
    }
Example #40
0
    public CharacterCrossFadeSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      var modelNode = ContentManager.Load<ModelNode>("Marine/PlayerMarine");
      _meshNode = modelNode.GetSubtree().OfType<MeshNode>().First().Clone();
      SampleHelper.EnablePerPixelLighting(_meshNode);
      GraphicsScreen.Scene.Children.Add(_meshNode);

      Dictionary<string, SkeletonKeyFrameAnimation> animations = _meshNode.Mesh.Animations;

      // Create a looping 'Idle' animation.
      _idleAnimation = new AnimationClip<SkeletonPose>(animations["Idle"])
      {
        LoopBehavior = LoopBehavior.Cycle,
        Duration = TimeSpan.MaxValue,
      };

      // Create a looping 'Run' animation.
      _runAnimation = new AnimationClip<SkeletonPose>(animations["Run"])
      {
        LoopBehavior = LoopBehavior.Cycle,
        Duration = TimeSpan.MaxValue,
      };

      // Combine the 'Aim' and 'Shoot' animation. The 'Aim' animation should start immediately. 
      // The 'Shoot' animation should start after 0.3 seconds.
      // (Animations can be combined by creating timeline groups. All timelines/animations 
      // in a timeline group are played simultaneously. AnimationClips can be used to 
      // arrange animations on a timeline. The property Delay, for example, can be used to
      // set the begin time.)
      _aimAndShootAnimation = new TimelineGroup();
      _aimAndShootAnimation.Add(animations["Aim"]);
      _aimAndShootAnimation.Add(new AnimationClip<SkeletonPose>(animations["Shoot"]) { Delay = TimeSpan.FromSeconds(0.3) });

      // Start 'Idle' animation. We use a Replace transition with a fade-in.
      _idleAnimationController = AnimationService.StartAnimation(
        _idleAnimation,
        (IAnimatableProperty)_meshNode.SkeletonPose,
        AnimationTransitions.Replace(TimeSpan.FromSeconds(0.5)));

      _idleAnimationController.AutoRecycle();
    }
Example #41
0
        public WavFileRenderer(ITimeline timeline, string outputFile, AudioFormat format,
                               ICallbackParticipant[] audioParticipants)
            : base(timeline)
        {
            AudioCompressor compressor = null;

            try
            {
                compressor = AudioCompressorFactory.Create(format);

                Cleanup.Add(compressor.Filter);

                RenderToWavDest(outputFile, compressor.Filter, compressor.MediaType, audioParticipants);

                ChangeState(RendererState.Initialized);
            }
            finally
            {
                if ((compressor != null) && (compressor.MediaType != null))
                {
                    DsUtils.FreeAMMediaType(compressor.MediaType);
                }
            }
        }
Example #42
0
 public TimelineHub(ITimeline timeline, ILoggerFactory loggerFactory )
 {
     _logger = loggerFactory.CreateLogger(typeof(TimelineHub).Name);
     _logger.LogInformation("Hub created");
     _timeline = timeline;
 }
Example #43
0
        private void Bind(ITimeline timeline, Dictionary<string, INode> nodeDictionary)
        {
            IPropertyTimeline propertyTimeline = timeline as IPropertyTimeline;
            if (propertyTimeline != null && !string.IsNullOrEmpty(propertyTimeline.TargetName))
            {
                INode node;
                nodeDictionary.TryGetValue(propertyTimeline.TargetName, out node);
                propertyTimeline.Target = node;
            }

            ICompositeTimeline compositeTimeline = timeline as ICompositeTimeline;
            if (compositeTimeline != null)
            {
                for (int i = 0; i < compositeTimeline.Children.Count; i++)
                {
                    Bind(compositeTimeline.Children[i], nodeDictionary);
                }
            }
        }
Example #44
0
        protected override void LoadContent()
        {
            _model = Game.Content.Load<Model>("PlayerMarine");
              var additionalData = (Dictionary<string, object>)_model.Tag;
              var skeleton = (Skeleton)additionalData["Skeleton"];
              _skeletonPose = SkeletonPose.Create(skeleton);
              var animations = (Dictionary<string, SkeletonKeyFrameAnimation>)additionalData["Animations"];

              // Create a looping 'Idle' animation.
              _idleAnimation = new AnimationClip<SkeletonPose>(animations["Idle"])
              {
            LoopBehavior = LoopBehavior.Cycle,
            Duration = TimeSpan.MaxValue,
              };

              // Create a looping 'Run' animation.
              _runAnimation = new AnimationClip<SkeletonPose>(animations["Run"])
              {
            LoopBehavior = LoopBehavior.Cycle,
            Duration = TimeSpan.MaxValue,
              };

              // Combine the 'Aim' and 'Shoot' animation. The 'Aim' animation should start immediately.
              // The 'Shoot' animation should start after 0.3 seconds.
              // (Animations can be combined by creating timeline groups. All timelines/animations
              // in a timeline group are played simultaneously. AnimationClips can be used to
              // arrange animations on a timeline. The property Delay, for example, can be used to
              // set the begin time.)
              _aimAndShootAnimation = new TimelineGroup();
              _aimAndShootAnimation.Add(animations["Aim"]);
              _aimAndShootAnimation.Add(new AnimationClip<SkeletonPose>(animations["Shoot"]) { Delay = TimeSpan.FromSeconds(0.3) });

              // Start 'Idle' animation. We use a Replace transition with a fade-in.
              _idleAnimationController = AnimationService.StartAnimation(
            _idleAnimation,
            (IAnimatableProperty)_skeletonPose,
            AnimationTransitions.Replace(TimeSpan.FromSeconds(0.5)));

              _idleAnimationController.AutoRecycle();

              base.LoadContent();
        }
Example #45
0
        private void PickSubTimeline(
            TimelinePath root,
            ITimeline timeline,
            RectangleF pickRect,
            Context c,
            TimelineLayout layout,
            List<HitRecord> result)
        {
            if (timeline == null)
                return;

            RectangleF clipBounds = c.Graphics.ClipBounds;
            RectangleF clientRectangle = c.ClientRectangle;
            RectangleF bounds;
            HitType hitType;

            foreach (IMarker marker in timeline.Markers)
            {
                if (!layout.TryGetBounds(root + marker, out bounds))
                    continue;
                if (bounds.IntersectsWith(clipBounds) && pickRect.Right >= HeaderWidth)
                {
                    hitType = Pick(marker, bounds, pickRect, c);
                    if (hitType != HitType.None)
                        result.Add(new HitRecord(hitType, root + marker));
                }
            }

            // If the pick is on the timescale, then let's stop here.
            if (pickRect.Left > HeaderWidth &&
                pickRect.Right < clientRectangle.Width &&
                pickRect.Bottom > 0 &&
                pickRect.Bottom < TimeScaleHeight)
            {
                if ((result.Count == 0) && (pickRect.Height <= 2 * PickTolerance) && (pickRect.Width <= 2 * PickTolerance))
                    result.Add(new HitRecord(HitType.TimeScale, null));
                return;
            }

            IList<IGroup> groups = timeline.Groups;
            for (int i = groups.Count - 1; i >= 0; i--)
            {
                IGroup group = groups[i];
                if (!layout.ContainsPath(root + group))
                    continue;
                IList<ITrack> tracks = group.Tracks;
                bool expanded = group.Expanded;
                bool collapsible = tracks.Count > 1;
                bool collapsed = collapsible && !expanded;
                if (!collapsed)
                {
                    for (int j = tracks.Count - 1; j >= 0; j--)
                    {
                        ITrack track = tracks[j];
                        IList<IKey> keys = track.Keys;
                        for (int k = keys.Count - 1; k >= 0; k--)
                        {
                            IKey key = keys[k];
                            if (!layout.TryGetBounds(root + key, out bounds))
                                continue;
                            if (bounds.IntersectsWith(clipBounds) && pickRect.Right >= HeaderWidth)
                            {
                                hitType = Pick(key, bounds, pickRect, c);
                                if (hitType != HitType.None)
                                    result.Add(new HitRecord(hitType, root + key));
                            }
                        }

                        IList<IInterval> intervals = track.Intervals;
                        for (int k = intervals.Count - 1; k >= 0; k--)
                        {
                            IInterval interval = intervals[k];
                            if (!layout.TryGetBounds(root + interval, out bounds))
                                continue;
                            if (bounds.IntersectsWith(clipBounds) && pickRect.Right >= HeaderWidth)
                            {
                                hitType = Pick(interval, bounds, pickRect, c);
                                if (hitType != HitType.None)
                                    result.Add(new HitRecord(hitType, root + interval));
                            }
                        }

                        if (!layout.TryGetBounds(root + track, out bounds))
                            continue;
                        if (bounds.IntersectsWith(clipBounds))
                        {
                            RectangleF handleRect = GetTrackHandleRect(bounds);
                            if (handleRect.IntersectsWith(pickRect))
                            {
                                result.Add(new HitRecord(HitType.TrackMove, root + track));
                            }
                            else if (bounds.IntersectsWith(pickRect))
                            {
                                result.Add(new HitRecord(HitType.Track, root + track));
                            }
                        }
                    }
                }

                if (!layout.TryGetBounds(root + group, out bounds))
                    continue;
                if (bounds.IntersectsWith(clipBounds))
                {
                    RectangleF handleRect = GetGroupHandleRect(bounds, collapsed);
                    RectangleF expanderRect = GetExpanderRect(handleRect);

                    if (collapsible && expanderRect.IntersectsWith(pickRect))
                    {
                        result.Add(new HitRecord(HitType.GroupExpand, root + group));
                    }
                    else if (handleRect.IntersectsWith(pickRect))
                    {
                        result.Add(new HitRecord(HitType.GroupMove, root + group));
                    }
                    else if (bounds.IntersectsWith(pickRect))
                    {
                        result.Add(new HitRecord(HitType.Group, root + group));
                    }
                }
            }

            if (pickRect.Left < HeaderWidth && HeaderWidth < pickRect.Right)
            {
                result.Add(new HitRecord(HitType.HeaderResize, null));
            }
        }
Example #46
0
    public AdvancedAvatarRagdollSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      SampleFramework.IsMouseVisible = false;

      // This sample uses for a DebugRenderer to draw text and rigid bodies.
      _debugRenderer = new DebugRenderer(GraphicsService, SpriteFont)
      {
        DefaultColor = Color.Black,
        DefaultTextPosition = new Vector2F(10),
      };

      // Add a custom game object which controls the camera.
      _cameraObject = new CameraObject(Services);
      _cameraObject.ResetPose(new Vector3F(0, 1, -3), ConstantsF.Pi, 0);
      GameObjectService.Objects.Add(_cameraObject);

      // Add some objects which allow the user to interact with the rigid bodies.
      _grabObject = new GrabObject(Services);
      _ballShooterObject = new BallShooterObject(Services) { Speed = 20 };
      GameObjectService.Objects.Add(_grabObject);
      GameObjectService.Objects.Add(_ballShooterObject);

      // Add some default force effects.
      Simulation.ForceEffects.Add(new Gravity());
      Simulation.ForceEffects.Add(new Damping());

      // Create a random avatar.
      _avatarDescription = AvatarDescription.CreateRandom();
      _avatarRenderer = new AvatarRenderer(_avatarDescription);

      // Use the "Wave" animation preset.
      var avatarAnimation = new AvatarAnimation(AvatarAnimationPreset.Wave);
      _expressionAnimation = new AnimationClip<AvatarExpression>(new WrappedAvatarExpressionAnimation(avatarAnimation))
      {
        LoopBehavior = LoopBehavior.Cycle,
        Duration = TimeSpan.MaxValue,
      };
      _skeletonAnimation = new AnimationClip<SkeletonPose>(new WrappedAvatarSkeletonAnimation(avatarAnimation))
      {
        LoopBehavior = LoopBehavior.Cycle,
        Duration = TimeSpan.MaxValue,
      };

      // Add a ground plane in the simulation.
      Simulation.RigidBodies.Add(new RigidBody(new PlaneShape(Vector3F.UnitY, 0)) { MotionType = MotionType.Static });

      // Distribute a few dynamic spheres and boxes across the landscape.
      SphereShape sphereShape = new SphereShape(0.3f);
      for (int i = 0; i < 10; i++)
      {
        Vector3F position = RandomHelper.Random.NextVector3F(-10, 10);
        position.Y = 1;
        Simulation.RigidBodies.Add(new RigidBody(sphereShape) { Pose = new Pose(position) });
      }

      BoxShape boxShape = new BoxShape(0.6f, 0.6f, 0.6f);
      for (int i = 0; i < 10; i++)
      {
        Vector3F position = RandomHelper.Random.NextVector3F(-10, 10);
        position.Y = 1;
        Simulation.RigidBodies.Add(new RigidBody(boxShape) { Pose = new Pose(position) });
      }
    }
Example #47
0
 /// <summary>
 /// Draws the timeline to the display</summary>
 /// <param name="timeline">Timeline</param>
 /// <param name="selection">Selected timeline objects</param>
 /// <param name="activeGroup">Currently active group, or null</param>
 /// <param name="activeTrack">Currently active track, or null</param>
 /// <param name="transform">Transform taking timeline objects to display coordinates</param>
 /// <param name="clientRectangle">Bounds of displayed area of timeline, in screen space</param>
 /// <param name="marginBounds">Page coordinate bounding rectangle for printing</param>
 public void Print(
     ITimeline timeline,
     ISelectionContext selection,
     TimelinePath activeGroup,
     TimelinePath activeTrack,
     Matrix transform,
     RectangleF clientRectangle,
     Rectangle marginBounds)
 {
     m_marginBounds = marginBounds;
     try
     {
         m_printing = true;
         Draw(timeline, selection, activeGroup, activeTrack, transform, clientRectangle);
     }
     finally
     {
         m_printing = false;
     }
 }
Example #48
0
        /// <summary>
        /// Draws the timeline to the display</summary>
        /// <param name="timeline">Timeline</param>
        /// <param name="selection">Selected timeline objects</param>
        /// <param name="activeGroup">Currently active group, or null</param>
        /// <param name="activeTrack">Currently active track, or null</param>
        /// <param name="transform">Transform taking timeline objects to display coordinates</param>
        /// <param name="clientRectangle">Bounds of displayed area of timeline, in screen space</param>
        /// <returns>Bounding rectangles for all timeline objects, organized in a dictionary of TimelinePath/RectangleF pairs</returns>
        public virtual TimelineLayout Draw(
            ITimeline timeline,
            ISelectionContext selection,
            TimelinePath activeGroup,
            TimelinePath activeTrack,
            Matrix transform,
            RectangleF clientRectangle)
        {
            Context c = new Context(this, transform, clientRectangle, m_graphics);
            TimelineLayout layout = Layout(timeline, c);
            c.ClearRecursionData();

            try
            {
                if (m_printing)
                {
                    transform.Translate(m_marginBounds.Left, m_marginBounds.Top, MatrixOrder.Append);
                    m_graphics.PushAxisAlignedClip(m_marginBounds);
                }

                // Clear the header column.
                m_graphics.FillRectangle(new RectangleF(0, 0, HeaderWidth, c.ClientRectangle.Height), m_headerBrush);

                // Draw the main timeline and then any sub-timelines.
                DrawSubTimeline(null, timeline, false, true, selection, activeGroup, activeTrack, layout, c);
                foreach (TimelinePath path in D2dTimelineControl.GetHierarchy(timeline))
                    DrawSubTimeline(path, selection, activeGroup, activeTrack, layout, c);

                // Draw the dark vertical line on the header that separates the groups and tracks.
                m_graphics.DrawLine(new PointF(TrackIndent, m_timeScaleHeight), new PointF(TrackIndent, c.ClientRectangle.Height), m_headerLineBrush);

                // Draw the dark vertical line on the right-side of the header, separating it from the canvas.
                m_graphics.DrawLine(new PointF(HeaderWidth, m_timeScaleHeight), new PointF(HeaderWidth, c.ClientRectangle.Height), m_headerLineBrush);

                // draw scales, etc.
                if (m_printing)
                    c.Graphics.TranslateTransform(0, m_marginBounds.Top);
                DrawEventOverlay(c);

                // Draw the dark horizontal line underneath the scale.
                m_graphics.DrawLine(new PointF(0, m_timeScaleHeight), new PointF(HeaderWidth, m_timeScaleHeight), m_scaleLineBrush);
            }
            finally
            {
                if (m_printing)
                    m_graphics.PopAxisAlignedClip();
            }

            // Give the Markers in the main timeline precedence over the scale and canvas
            RectangleF clipBounds = m_graphics.ClipBounds;
            clipBounds.X = HeaderWidth;
            //var clipBounds = new RectangleF(HeaderWidth, 0, m_graphics.Size.Width, m_graphics.Size.Height);
            DrawMarkers(null, timeline, selection, c, layout, clipBounds);

            return layout;
        }
Example #49
0
        /// <summary>
        /// Provides the timeline which tracks the changes to the project over time.
        /// </summary>
        /// <param name="timeline">The timeline.</param>
        /// <returns>
        /// The current builder instance with the timeline stored.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="timeline"/> is <see langword="null" />.
        /// </exception>
        public IBuildProjects WithTimeline(ITimeline timeline)
        {
            {
                Lokad.Enforce.Argument(() => timeline);
            }

            m_Timeline = timeline;
            return this;
        }
Example #50
0
        private void DrawSubTimeline(
            TimelinePath path,
            ITimeline timeline,
            bool subTimeline,
            bool expandedTimeline,
            ISelectionContext selection,
            TimelinePath activeGroup,
            TimelinePath activeTrack,
            TimelineLayout layout,
            Context c)
        {
            //if (c.TestRecursion(timeline))
            //    return;

            if (!subTimeline)
                m_offsetX = c.Transform.OffsetX;

            RectangleF clipBounds = m_graphics.ClipBounds;

            DrawGroupsAndTracks(path, timeline, expandedTimeline, selection, c, layout, clipBounds);

            // draw markers over keys, intervals, tracks, and group
            if (subTimeline)
            {
                // Give the Markers in the main timeline precedence; draw on top of everything.
                clipBounds.X = HeaderWidth;
                clipBounds.Width -= HeaderWidth;
                DrawMarkers(path, timeline, selection, c, layout, clipBounds);
            }

            // Draw the group and track handles only if the owning timeline is expanded.
            if (expandedTimeline)
            {
                if (m_printing)
                    c.Graphics.TranslateTransform(m_marginBounds.Left, 0);
                RectangleF bounds;
                foreach (IGroup group in timeline.Groups)
                {
                    IList<ITrack> tracks = group.Tracks;
                    TimelinePath groupPath = path + group;
                    bounds = layout.GetBounds(groupPath);
                    bounds = GetGroupHandleRect(bounds, !group.Expanded);
                    RectangleF groupLabelBounds = new RectangleF(bounds.X, bounds.Y, HeaderWidth, bounds.Height);

                    // Draw group's move handle.
                    DrawMoveHandle(bounds, selection.SelectionContains(groupPath), groupPath == activeGroup);

                    // Draw expander?
                    if (tracks.Count > 1)
                    {
                        RectangleF expanderRect = GetExpanderRect(bounds);
                        m_graphics.DrawExpander(
                            expanderRect.X,
                            expanderRect.Y,
                            expanderRect.Width,
                            m_expanderBrush,
                            group.Expanded);

                        groupLabelBounds.X += TrackIndent;
                        groupLabelBounds.Width -= TrackIndent;
                    }

                    // Draw tracks' move handles?
                    if (group.Expanded || tracks.Count == 1)
                    {
                        foreach (ITrack track in tracks)
                        {
                            TimelinePath trackPath = path + track;
                            bounds = layout.GetBounds(trackPath);
                            bounds = GetTrackHandleRect(bounds);
                            DrawMoveHandle(bounds, selection.SelectionContains(trackPath), trackPath == activeTrack);
                            if (bounds.Width > 0f)
                                m_graphics.DrawText(track.Name, m_trackTextFormat, bounds, m_nameBrush);
                        }
                    }

                    // Draw group name.
                    if (groupLabelBounds.Width > 0)
                        m_graphics.DrawText(group.Name, c.TextFormat, groupLabelBounds, m_nameBrush);
                }
                if (m_printing)
                    c.Graphics.TranslateTransform(-m_marginBounds.Left, 0);
            }

            return;
        }
Example #51
0
 private void DrawMarkers(TimelinePath path, ITimeline timeline, ISelectionContext selection,
     Context c, TimelineLayout layout, RectangleF clipBounds)
 {
     RectangleF bounds;
     foreach (IMarker marker in timeline.Markers)
     {
         TimelinePath markerPath = path + marker;
         if (!layout.TryGetBounds(markerPath, out bounds))
             continue;
         if (bounds.IntersectsWith(clipBounds))
         {
             DrawMode drawMode = DrawMode.Normal;
             if (selection.SelectionContains(markerPath))
                 drawMode |= DrawMode.Selected;
             Draw(marker, bounds, drawMode, c);
         }
     }
 }
Example #52
0
        private void DrawGroupsAndTracks(TimelinePath path, ITimeline timeline, bool expandedTimeline,
            ISelectionContext selection, Context c, TimelineLayout layout, RectangleF clipBounds)
        {
            RectangleF canvasBounds = clipBounds; //clipBounds minus the left-side header
            canvasBounds.X = HeaderWidth;
            canvasBounds.Width -= HeaderWidth;

            RectangleF bounds;
            foreach (IGroup group in timeline.Groups)
            {
                TimelinePath groupPath = path + group;
                if (!layout.TryGetBounds(groupPath, out bounds))
                    continue;
                if (bounds.IntersectsWith(clipBounds))
                {
                    DrawMode drawMode = DrawMode.Normal;
                    if (selection.SelectionContains(groupPath))
                        drawMode |= DrawMode.Selected;
                    if (expandedTimeline)
                        Draw(group, bounds, drawMode, c);

                    IList<ITrack> tracks = group.Tracks;
                    bool collapsed = !expandedTimeline || (!group.Expanded && tracks.Count > 1);
                    foreach (ITrack track in tracks)
                    {
                        TimelinePath trackPath = path + track;
                        bounds = layout.GetBounds(trackPath);
                        if (bounds.IntersectsWith(clipBounds))
                        {
                            drawMode = DrawMode.Normal;
                            if (selection.SelectionContains(trackPath))
                                drawMode |= DrawMode.Selected;
                            if (collapsed)
                                drawMode = DrawMode.Collapsed;
                            Draw(track, bounds, drawMode, c);

                            foreach (IInterval interval in track.Intervals)
                            {
                                TimelinePath intervalPath = path + interval;
                                bounds = layout.GetBounds(intervalPath);
                                if (bounds.IntersectsWith(canvasBounds))
                                {
                                    drawMode = DrawMode.Normal;
                                    if (selection.SelectionContains(intervalPath))
                                        drawMode |= DrawMode.Selected;
                                    if (collapsed)
                                        drawMode = DrawMode.Collapsed;
                                    Draw(interval, bounds, drawMode, c);
                                }
                            }

                            foreach (IKey key in track.Keys)
                            {
                                TimelinePath keyPath = path + key;
                                bounds = layout.GetBounds(keyPath);
                                if (bounds.IntersectsWith(canvasBounds))
                                {
                                    drawMode = DrawMode.Normal;
                                    if (selection.SelectionContains(keyPath))
                                        drawMode |= DrawMode.Selected;
                                    if (collapsed)
                                        drawMode = DrawMode.Collapsed;
                                    Draw(key, bounds, drawMode, c);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #53
0
 public AviFileRenderer(ITimeline timeline, string outputFile)
     : this(timeline, outputFile, null, null, null, null)
 {
 }
Example #54
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Project"/> class.
 /// </summary>
 /// <param name="timeline">The timeline for the current project.</param>
 /// <param name="distributor">
 /// The function which returns a <see cref="DistributionPlan"/> for a given
 /// <see cref="DatasetActivationRequest"/>.
 /// </param>
 /// <param name="dataStorageProxyBuilder">The function which returns a storage proxy for a newly loaded dataset.</param>
 /// <param name="notifications">The object that stores the notifications for the user interface.</param>
 /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
 /// <exception cref="ArgumentNullException">
 ///     Thrown when <paramref name="distributor"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown when <paramref name="dataStorageProxyBuilder"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown when <paramref name="notifications"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown when <paramref name="diagnostics"/> is <see langword="null" />.
 /// </exception>
 public Project(
     ITimeline timeline,
     Func<DatasetActivationRequest, CancellationToken, IEnumerable<DistributionPlan>> distributor,
     Func<DatasetOnlineInformation, DatasetStorageProxy> dataStorageProxyBuilder,
     ICollectNotifications notifications,
     SystemDiagnostics diagnostics)
     : this(timeline, distributor, dataStorageProxyBuilder, notifications, diagnostics, null)
 {
 }
Example #55
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Project"/> class.
        /// </summary>
        /// <param name="timeline">The timeline for the current project.</param>
        /// <param name="distributor">
        /// The function which returns a <see cref="DistributionPlan"/> for a given
        /// <see cref="DatasetActivationRequest"/>.
        /// </param>
        /// <param name="dataStorageProxyBuilder">The function which returns a storage proxy for a newly loaded dataset.</param>
        /// <param name="notifications">The object that stores the notifications for the user interface.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <param name="persistenceInfo">
        /// The object that describes how the project was persisted.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="timeline"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="distributor"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="dataStorageProxyBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="notifications"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public Project(
            ITimeline timeline,
            Func<DatasetActivationRequest, CancellationToken, IEnumerable<DistributionPlan>> distributor,
            Func<DatasetOnlineInformation, DatasetStorageProxy> dataStorageProxyBuilder,
            ICollectNotifications notifications,
            SystemDiagnostics diagnostics,
            IPersistenceInformation persistenceInfo)
        {
            {
                Lokad.Enforce.Argument(() => timeline);
                Lokad.Enforce.Argument(() => distributor);
                Lokad.Enforce.Argument(() => dataStorageProxyBuilder);
                Lokad.Enforce.Argument(() => notifications);
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Timeline = timeline;
            m_Timeline.ForgetAllHistory();

            m_Timeline.OnRolledBack += OnTimelineRolledBack;
            m_Timeline.OnRolledForward += OnTimelineRolledForward;

            m_ProjectInformation = m_Timeline.AddToTimeline(ProjectHistoryStorage.CreateInstance);
            m_Datasets = m_Timeline.AddToTimeline(DatasetHistoryStorage.CreateInstance);

            m_DatasetDistributor = distributor;
            m_DataStorageProxyBuilder = dataStorageProxyBuilder;

            m_Notifications = notifications;
            m_Diagnostics = diagnostics;

            if (persistenceInfo != null)
            {
                RestoreFromStore(persistenceInfo);
            }

            // Create a root dataset if there isn't one
            if (m_RootDataset == null)
            {
                var dataset = CreateDataset(
                    null,
                    new DatasetCreationInformation
                        {
                            CreatedOnRequestOf = DatasetCreator.System,
                            LoadFrom = new NullPersistenceInformation(),
                            CanBeDeleted = false,
                            CanBeCopied = false,
                            CanBecomeParent = true,
                            CanBeAdopted = false,
                            IsRoot = true,
                        });

                m_RootDataset = dataset.Id;
                dataset.Name = Resources.Projects_Dataset_RootDatasetName;
                dataset.Summary = Resources.Projects_Dataset_RootDatasetSummary;
            }

            m_Timeline.SetCurrentAsDefault();
        }
Example #56
0
 /// <summary>
 /// Gets bounding rectangles in Windows client space for all timeline objects, organized
 /// in a dictionary</summary>
 /// <param name="timeline">Timeline</param>
 /// <param name="transform">Transform taking timeline objects to display coordinates</param>
 /// <param name="clientRectangle">Bounds of displayed area of timeline, in screen space</param>
 /// <returns>Bounding rectangles for all timeline objects, organized in a dictionary of TimelinePath/RectangleF pairs</returns>
 public TimelineLayout GetLayout(
     ITimeline timeline,
     Matrix transform,
     Rectangle clientRectangle)
 {
     Context c = new Context(this, transform, clientRectangle, m_graphics);
     TimelineLayout layout = Layout(timeline, c);
     return layout;
 }
Example #57
0
        // documentTop is in timeline coordinates
        private void LayoutSubTimeline(
            TimelinePath path,
            ITimeline timeline, ref float documentTop, bool expandedTimeline, Context c,
            TimelineLayout result)
        {
            //if (c.TestRecursion(timeline))
            //    return;

            RectangleF bounds;
            SizeF pixelSize = c.PixelSize;
            float margin = pixelSize.Height * m_margin;

            float groupTop = documentTop;
            float documentBottom = groupTop;

            foreach (IGroup group in timeline.Groups)
            {
                bool expanded = expandedTimeline && group.Expanded;

                float groupBottom = groupTop;
                float trackTop = groupTop;
                foreach (ITrack track in group.Tracks)
                {
                    float eventTop = trackTop + margin;
                    float trackBottom = eventTop;

                    foreach (IInterval interval in track.Intervals)
                    {
                        bounds = GetBounds(interval, eventTop, c);
                        trackBottom = Math.Max(trackBottom, bounds.Bottom);
                        bounds = GdiUtil.Transform(c.Transform, bounds);
                        // add it, even if 'expandedTimeline' is false, to get the shadow effect
                        result.Add(path + interval, bounds);
                    }

                    foreach (IKey key in track.Keys)
                    {
                        bounds = GetBounds(key, eventTop, c);
                        trackBottom = Math.Max(trackBottom, bounds.Bottom);
                        bounds = GdiUtil.Transform(c.Transform, bounds);
                        // add it, even if 'expandedTimeline' is false, to get the shadow effect
                        result.Add(path + key, bounds);
                    }

                    trackBottom += margin;
                    trackBottom = Math.Max(trackBottom, trackTop + MinimumTrackSize); // need height for track, even if it's empty

                    bounds = new RectangleF(c.Bounds.X, trackTop, c.Bounds.Width, trackBottom - trackTop);
                    bounds = GdiUtil.Transform(c.Transform, bounds);
                    bounds.X = c.ClientRectangle.X;
                    // add it, even if 'expandedTimeline' is false, to get the shadow effect
                    result.Add(path + track, bounds);

                    if (expanded)
                        trackTop = trackBottom;

                    groupBottom = Math.Max(groupBottom, trackBottom);
                }

                // need height for group, even if it's empty
                groupBottom = Math.Max(groupBottom, groupTop + Math.Max(margin*2, MinimumTrackSize));

                float groupHeight = groupBottom - groupTop;
                bounds = new RectangleF(0, groupTop, c.Bounds.Width, groupHeight);
                bounds = GdiUtil.Transform(c.Transform, bounds);
                bounds.X = c.ClientRectangle.X;
                // add it, even if 'expandedTimeline' is false, to get the shadow effect
                result.Add(path + group, bounds);
                if (expandedTimeline)
                    groupTop = groupBottom;
                documentBottom = Math.Max(documentBottom, groupBottom);
            }

            if (expandedTimeline)
            {
                // Draw Markers, but limit them to be within the owning timeline.
                RectangleF originalBounds = c.Bounds;
                c.Bounds.Height = documentBottom - c.Bounds.Y;
                foreach (IMarker marker in timeline.Markers)
                {
                    bounds = GetBounds(marker, c);
                    bounds = GdiUtil.Transform(c.Transform, bounds);
                    result.Add(path + marker, bounds);
                }
                c.Bounds = originalBounds;
            }

            documentTop = documentBottom;
        }
Example #58
0
        /// <summary>
        /// Calculates and returns the rectangles of the objects in Windows client coordinates.
        /// Depending on collapse/expanded states, not every ITimelineObject may be in the dictionary.
        /// Consider calling GetCachedLayout() for picking purposes.</summary>
        /// <param name="timeline">The timeline to be laid out</param>
        /// <param name="c">The editing context</param>
        /// <returns>A dictionary mapping every timeline object in the timeline to its bounding box</returns>
        protected TimelineLayout Layout(ITimeline timeline, Context c)
        {
            TimelineLayout result = new TimelineLayout();
            SizeF pixelSize = c.PixelSize;
            float documentTop = pixelSize.Height * m_timeScaleHeight;

            LayoutSubTimeline(null, timeline, ref documentTop, true, c, result);

            foreach (TimelinePath path in D2dTimelineControl.GetHierarchy(timeline))
                LayoutSubTimeline(path, ref documentTop, c, result);

            m_cachedLayout.First = timeline;
            m_cachedLayout.Second = result;

            return result;
        }
Example #59
0
 /// <summary>Gets the last layout dictionary calculated by a call to Layout. Use for picking,
 /// for example. Creates the layout dictionary if necessary.</summary>
 /// <param name="timeline">Timeline</param>
 /// <param name="c">The editing context</param>
 /// <returns>Last layout dictionary</returns>
 protected TimelineLayout GetCachedLayout(ITimeline timeline, Context c)
 {
     if (m_cachedLayout.First == timeline)
         return m_cachedLayout.Second;
     return Layout(timeline, c);
 }
Example #60
0
        /// <summary>
        /// Finds the list of hits on timeline objects that intersect the given rectangle</summary>
        /// <param name="timeline">Timeline</param>
        /// <param name="pickRect">Picking rectangle</param>
        /// <param name="transform">Transform taking timeline objects to display coordinates</param>
        /// <param name="clientRectangle">Bounds of displayed area of timeline, in screen space</param>
        /// <returns>List of hits on timeline objects that intersect the given rectangle</returns>
        public virtual IList<HitRecord> Pick(
            ITimeline timeline,
            RectangleF pickRect,
            Matrix transform,
            Rectangle clientRectangle)
        {
            List<HitRecord> result = new List<HitRecord>();
            Context c = new Context(this, transform, clientRectangle, m_graphics);
            TimelineLayout layout = GetCachedLayout(timeline, c);

            PickSubTimeline(null, timeline, pickRect, c, layout, result);

            // If the pick is on the timescale, then there's no point in looking at sub-timelines.
            if (!(
                pickRect.Left > HeaderWidth &&
                pickRect.Right < clientRectangle.Width &&
                pickRect.Bottom > 0 &&
                pickRect.Bottom < TimeScaleHeight))
            {
                foreach (TimelinePath path in D2dTimelineControl.GetHierarchy(timeline))
                    PickSubTimeline(path, pickRect, c, layout, result);
            }

            PrioritizeHits(result, layout, pickRect);

            return result;
        }