コード例 #1
0
        //private readonly ILog _logger = LogManager.GetLogger("Runtime");


        /// <summary>
        /// Create the Runtime object to combine all the various components of the livetiming.
        /// </summary>
        /// <param name="liveStream">A stream used to represent the incoming data of the live stream.</param>
        /// <param name="authKeyService">Provider for authorization key requests.</param>
        /// <param name="keyFrameService">Provider for keyframes.</param>
        /// <param name="messageDispatch">A receiver for messages.</param>
        public Runtime(Stream liveStream, IAuthKey authKeyService, IKeyFrame keyFrameService, IMessageDispatch messageDispatch)
        {
            _decryptor       = new DataDecryptor();
            _packetReader    = new PacketReader(liveStream, new DecryptStreamDecorator(liveStream, _decryptor));
            _messageDispatch = messageDispatch;
            _authKeyService  = authKeyService;
            _keyFrameService = keyFrameService;
        }
コード例 #2
0
        /// <summary>
        ///   Calculate the bounding rectangle for a track in screen-space.
        /// </summary>
        /// <param name="track">
        ///   The track for which to calculate the bounding rectangle.
        /// </param>
        /// <param name="timeline">The timeline the track lives on.</param>
        /// <returns>The bounding rectangle for the given track.</returns>
        internal static RectangleF GetTrackExtents(ITimelineTrack track, TimelineControl timeline)
        {
            int       trackIndex = timeline.TrackIndexForTrack(track);
            IKeyFrame firstKF    = track.KeyFrames.First();
            IKeyFrame lastKF     = track.KeyFrames.Last();

            return(RectangleToTrackExtents(new RectangleF(firstKF.T, 0, lastKF.T - firstKF.T, 0), timeline, trackIndex));
        }
コード例 #3
0
ファイル: Runtime.cs プロジェクト: visual14ph/f1livetiming
 //private readonly ILog _logger = LogManager.GetLogger("Runtime");
 /// <summary>
 /// Create the Runtime object to combine all the various components of the livetiming.
 /// </summary>
 /// <param name="liveStream">A stream used to represent the incoming data of the live stream.</param>
 /// <param name="authKeyService">Provider for authorization key requests.</param>
 /// <param name="keyFrameService">Provider for keyframes.</param>
 /// <param name="messageDispatch">A receiver for messages.</param>
 public Runtime(Stream liveStream, IAuthKey authKeyService, IKeyFrame keyFrameService, IMessageDispatch messageDispatch)
 {
     _decryptor = new DataDecryptor();
     _packetReader = new PacketReader(liveStream, new DecryptStreamDecorator(liveStream, _decryptor));
     _messageDispatch = messageDispatch;
     _authKeyService = authKeyService;
     _keyFrameService = keyFrameService;
 }
コード例 #4
0
        public KeyFrameDriver(IKeyFrame provider, Runtime.Runtime runtime)
            : base(false)
        {
            _runtime        = runtime;
            _runtime.Driver = this;
            _provider       = provider;

            Start();
        }
コード例 #5
0
        public KeyFrameDriver(IKeyFrame provider, Runtime.Runtime runtime)
            : base(false)
        {
            _runtime = runtime;
            _runtime.Driver = this;
            _provider = provider;

            Start();
        }
コード例 #6
0
 /// <summary>
 /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1" />.
 /// </summary>
 /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
 /// <returns>
 /// true if <paramref name="item" /> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false. This method also returns false if <paramref name="item" /> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1" />.
 /// </returns>
 public bool Remove(IKeyFrame item)
 {
     Times.Remove(item.Time);
     if (_track != null)
     {
         _track.SetupSpline();
     }
     return(_keyFrames.Remove(item));
 }
コード例 #7
0
ファイル: IKeyFrame.cs プロジェクト: nastys/PD_Tool_Archived
 public IKeyFrame <TKey, TVal> ToKeyFrameT2(IKeyFrame <TKey, TVal>
                                            Previous, out KeyFrameT2 <TKey, TVal> Current)
 {
     if (Previous is KeyFrameT2 <TKey, TVal> PreviousT2)
     {
         Current = new KeyFrameT2 <TKey, TVal> {
             Frame = PreviousT2.Frame,
             Value = PreviousT2.Value, Interpolation = Interpolation1
         }
     }
     ;
コード例 #8
0
 private void CreateDriver(string liveDataPath, IKeyFrame keyFrameService, MemoryStream memStream)
 {
     if (string.IsNullOrEmpty(liveDataPath))
     {
         _connection = new KeyFrameDriver(keyFrameService, _runtime);
     }
     else
     {
         _connection = new FileCapDriver(liveDataPath, memStream, _runtime);
     }
 }
コード例 #9
0
        /// <summary>
        /// Inserts an item to the <see cref="T:System.Collections.Generic.IList`1" /> at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which <paramref name="item" /> should be inserted.</param>
        /// <param name="item">The object to insert into the <see cref="T:System.Collections.Generic.IList`1" />.</param>
        /// <exception cref="System.ArgumentException">Thrown when a key frame already exists in the collection with the specified time index.</exception>
        public void Insert(int index, IKeyFrame item)
        {
            if (Contains(item.Time))
            {
                throw new ArgumentException(string.Format(Resources.GORANM_KEY_EXISTS_AT_TIME, item.Time));
            }

            _keyFrames.Insert(index, item);
            Times.Add(item.Time, item);
            if (_track != null)
            {
                _track.SetupSpline();
            }
        }
コード例 #10
0
        /// <summary>
        ///   Calculate the bounding rectangle for a KeyFrame in screen-space.
        /// </summary>
        /// <param name="track">
        ///   The track which the keyframe is a part of
        /// </param>
        /// <param name="kf">
        ///   The keyframe in question
        /// </param>
        /// <param name="timeline">The timeline the track lives on.</param>
        /// <returns>The bounding rectangle for the given keyframe.</returns>
        internal static RectangleF GetKeyFrameExtents(ITimelineTrack track, IKeyFrame kf, TimelineControl timeline)
        {
            Rectangle trackAreaBounds = timeline.GetTrackAreaBounds();
            int       trackIndex      = timeline.TrackIndexForTrack(track);

            RectangleF kfRectangle = new RectangleF();

            kfRectangle.X      = trackAreaBounds.X + (kf.T * timeline.RenderingScale.X) - timeline.KeyFrameWidth / 2 + timeline.RenderingOffset.X;
            kfRectangle.Width  = timeline.KeyFrameWidth;
            kfRectangle.Height = (timeline.TrackHeight) * timeline.RenderingScale.Y;
            kfRectangle.Y      = trackAreaBounds.Y + ((kfRectangle.Height + timeline.TrackSpacing) * trackIndex) + timeline.RenderingOffset.Y;

            return(kfRectangle);
        }
コード例 #11
0
        /// <summary>
        /// Function to read the track data from a data chunk.
        /// </summary>
        /// <param name="chunk">Chunk to read.</param>
        internal void FromChunk(GorgonChunkReader chunk)
        {
            InterpolationMode = chunk.Read <TrackInterpolationMode>();

            // Load all key frames from this track.
            while (chunk.HasChunk("KEYFRAME"))
            {
                IKeyFrame key = MakeKey();

                chunk.Begin("KEYFRAME");
                key.FromChunk(chunk);
                chunk.End();

                KeyFrames.Add(key);
            }
        }
コード例 #12
0
        private void CreateDriver(IKeyFrame keyFrameService, MemoryStream memStream)
        {
            try
            {
#if WINRT
                _connection = new W8ConnectionDriver(_runtime, memStream);
#elif WINDOWS_PHONE
                _connection = new Wp7ConnectionDriver(_runtime, memStream);
#else
                _connection = new AsyncConnectionDriver(_runtime, memStream);
#endif
            }
            catch (ConnectionException)
            {
                _connection = new KeyFrameDriver(keyFrameService, _runtime);
            }
        }
コード例 #13
0
ファイル: IKeyFrame.cs プロジェクト: nastys/PD_Tool_Archived
 public IKeyFrame <TKey, TVal> ToKeyFrameT2(IKeyFrame <TKey, TVal>
                                            Previous, out IKeyFrame <TKey, TVal> Current)
 {
     Current = Previous is KeyFrameT2 <TKey, TVal> PreviousT2
         ? new KeyFrameT2 <TKey, TVal> {
         Frame = PreviousT2.Frame,
         Value = PreviousT2.Value, Interpolation = Interpolation1
     }
         : new KeyFrameT2 <TKey, TVal> {
         Frame = Frame,
         Value = Value, Interpolation = Interpolation1
     };
     return(new KeyFrameT2 <TKey, TVal> {
         Frame = Frame,
         Value = Value, Interpolation = Interpolation2
     });
 }
コード例 #14
0
        /// <summary>
        /// Function to apply the key value to the object properties.
        /// </summary>
        /// <param name="key">Key to apply to the properties.</param>
        protected internal override void ApplyKey(ref IKeyFrame key)
        {
            var             value          = (GorgonKeyTexture2D)key;
            GorgonTexture2D currentTexture = _getTextureProperty(Animation.AnimationController.AnimatedObject);

            // If there's no texture on this key, then try to find it.
            if ((value.Value == null) && (!value.GetTexture()))
            {
                value = new GorgonKeyTexture2D(value.Time, currentTexture, value.TextureRegion);
            }

            if (currentTexture != value.Value)
            {
                _setTextureProperty(Animation.AnimationController.AnimatedObject, value.Value);
            }

            _setTextureRegionProperty(Animation.AnimationController.AnimatedObject, value.TextureRegion);
        }
コード例 #15
0
        /// <summary>
        /// This method should be called immediately after InitializeComponent() in most cases, or whenever you modify the animation parameters.
        /// </summary>
        public void Render()
        {
            Dictionary <ObjectPropertyPair, AnimationTimeline> index = new Dictionary <ObjectPropertyPair, AnimationTimeline>();

            Frames.OrderBy <Frame, KeyTime>(delegate(Frame target)
            {
                return(target.KeyTime);
            });

            // The trick here is to turn time-dominant form into property-dominant form.
            foreach (Frame frame in Frames)
            {
                foreach (Setter setter in frame)
                {
                    ObjectPropertyPair pair = new ObjectPropertyPair(setter.TargetName, setter.Property);

                    AnimationTimeline animation;
                    if (!index.ContainsKey(pair))
                    {
                        animation = CreateAnimationFromType(setter.Property.PropertyType);
                        Storyboard.SetTargetName(animation, setter.TargetName);
                        Storyboard.SetTargetProperty(animation, new PropertyPath(setter.Property));
                        animation.Duration = this.Duration;

                        index.Add(pair, animation);
                    }
                    animation = index[pair];

                    ((IKeyFrameAnimation)animation).KeyFrames.Add(CreateKeyFrameFromType(setter.Property.PropertyType, setter.Value, frame.KeyTime));
                }
            }

            foreach (AnimationTimeline animation in index.Values)
            {
                if (LoopAnimation)
                {
                    // Finally, tie each animation closed by projecting its initial frame into the future so that interpolations will be smooth.
                    IKeyFrame firstFrame = (IKeyFrame)((IKeyFrameAnimation)animation).KeyFrames[0]; // Assume there will always be at least one frame.
                    ((IKeyFrameAnimation)animation).KeyFrames.Add(CreateKeyFrameFromType(firstFrame.Value.GetType(), firstFrame.Value.ToString(), KeyTime.FromTimeSpan(firstFrame.KeyTime.TimeSpan + this.Duration.TimeSpan)));
                }

                this.Children.Add(animation);
            }
        }
コード例 #16
0
        /// <summary>
        /// Property to add a key frame to the collection.
        /// </summary>
        /// <param name="item">Keyframe to add.</param>
        /// <exception cref="System.ArgumentException">Thrown when a key frame already exists in the collection with the specified time index.</exception>
        public void Add(IKeyFrame item)
        {
            if (item.DataType != _track.DataType)
            {
                throw new InvalidCastException(string.Format(Resources.GORANM_KEY_TRACK_TYPE_MISMATCH,
                                                             item.GetType().FullName, _track.GetType().FullName));
            }

            if (Contains(item.Time))
            {
                throw new ArgumentException(string.Format(Resources.GORANM_KEY_EXISTS_AT_TIME, item.Time));
            }

            _keyFrames.Add(item);
            Times.Add(item.Time, item);
            if (_track != null)
            {
                _track.SetupSpline();
            }
        }
コード例 #17
0
        /// <summary>
        /// キーフレーム配列が時刻順に並んでいるか調べます。
        /// </summary>
        /// <remarks>
        /// <paramref name="keyFrames"/>の各要素がKeyTime順に並んでいるか調べ、
        /// もし並んでいなかったら例外を返します。
        /// </remarks>
        public static void ValidateKeyFrames(IEnumerable <IKeyFrame> keyFrames)
        {
            IKeyFrame prev = null;

            foreach (var curr in keyFrames)
            {
                if (prev != null)
                {
                    if (prev.KeyTime > curr.KeyTime)
                    {
                        throw new EffectException(
                                  "KeyFrame配列がKeyTimeの順序通りに並んでいません。");
                    }
                }

                prev = curr;
            }

            // ここまで来たということは問題ないということ。
        }
コード例 #18
0
ファイル: GorgonAnimation.cs プロジェクト: tmp7701/Gorgon
        /// <summary>
        /// Function to update the owner of the animation.
        /// </summary>
        internal void UpdateObject()
        {
            if (AnimationController == null)
            {
                return;
            }

            // Notify each track to update their animation to the current time.
            foreach (var track in Tracks)
            {
                if ((track.KeyFrames.Count <= 0) ||
                    ((track.TimeUpdatedCallback != null) &&
                     (!track.TimeUpdatedCallback(_controller.AnimatedObject, Time))))
                {
                    continue;
                }

                IKeyFrame key = track.GetKeyAtTime(_time);
                track.ApplyKey(ref key);
            }
        }
コード例 #19
0
 private void CreateDriver(string liveDataPath, IKeyFrame keyFrameService, MemoryStream memStream)
 {
     if (string.IsNullOrEmpty(liveDataPath))
     {
         _connection = new KeyFrameDriver(keyFrameService, _runtime);
     }
     else
     {
         _connection = new FileCapDriver(liveDataPath, memStream, _runtime);
     }
 }
コード例 #20
0
        /// <summary>
        /// Function to apply the key value to the object properties.
        /// </summary>
        /// <param name="key">Key to apply to the properties.</param>
        protected internal override void ApplyKey(ref IKeyFrame key)
        {
            var value = (GorgonKeyUInt32)key;

            _setProperty(Animation.AnimationController.AnimatedObject, value.Value);
        }
コード例 #21
0
 /// <summary>
 /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1" /> contains a specific value.
 /// </summary>
 /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
 /// <returns>
 /// true if <paramref name="item" /> is found in the <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false.
 /// </returns>
 public bool Contains(IKeyFrame item)
 {
     return(_keyFrames.Contains(item));
 }
コード例 #22
0
 /// <summary>
 /// Determines the index of a specific item in the <see cref="T:System.Collections.Generic.IList`1" />.
 /// </summary>
 /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.IList`1" />.</param>
 /// <returns>
 /// The index of <paramref name="item" /> if found in the list; otherwise, -1.
 /// </returns>
 public int IndexOf(IKeyFrame item)
 {
     return(_keyFrames.IndexOf(item));
 }
コード例 #23
0
 /// <summary>
 /// Compares two objects and returns a value indicating whether one is less than, equal to, or
 /// greater than the other.
 /// </summary>
 /// <param name="x">The first object to compare.</param>
 /// <param name="y">The second object to compare.</param>
 /// <returns>
 /// A signed integer that indicates the relative values of x and y, as shown in the following
 /// table.
 /// <list type="table">
 /// <listheader>
 /// <term>Value</term>
 /// <description>Meaning</description>
 /// </listheader>
 /// <item>
 /// <term>Less than zero</term>
 /// <description><paramref name="x"/> is less than <paramref name="y"/>.</description>
 /// </item>
 /// <item>
 /// <term>Zero</term>
 /// <description><paramref name="x"/> equals <paramref name="y"/>.</description>
 /// </item>
 /// <item>
 /// <term>Greater than zero</term>
 /// <description><paramref name="x"/> is greater than <paramref name="y"/>.</description>
 /// </item>
 /// </list>
 /// </returns>
 public int Compare(IKeyFrame <T> x, IKeyFrame <T> y)
 {
     return(x.Time.CompareTo(y.Time));
 }
コード例 #24
0
ファイル: LiveTiming.cs プロジェクト: visual14ph/f1livetiming
 private void CreateDriver(IKeyFrame keyFrameService, MemoryStream memStream)
 {
     try
     {
     #if WINRT
         _connection = new W8ConnectionDriver(_runtime, memStream);
     #elif WINDOWS_PHONE
         _connection = new Wp7ConnectionDriver(_runtime, memStream);
     #else
         _connection = new AsyncConnectionDriver(_runtime, memStream);
     #endif
     }
     catch (ConnectionException)
     {
         _connection = new KeyFrameDriver(keyFrameService, _runtime);
     }
 }
コード例 #25
0
            /// <summary>
            /// Constructor.
            /// </summary>
            /// <param name="owner">Owning track.</param>
            /// <param name="requestedTime">Track time requested.</param>
            internal NearestKeys(GorgonAnimationTrack <T> owner, float requestedTime)
            {
                float animationLength = owner.Animation.Length;                     // Animation length.
                int   i;                                                            // Loop.

#if DEBUG
                if (owner.KeyFrames.Count < 1)
                {
                    throw new ArgumentException(Resources.GORANM_TRACK_HAS_NO_KEYS, "owner");
                }
#endif

                // Initialize.
                PreviousKeyIndex = 0;
                PreviousKey      = owner.KeyFrames[0];
                NextKeyIndex     = -1;
                NextKey          = null;
                KeyTimeDelta     = 0;

                // Wrap around.
                while (requestedTime > animationLength)
                {
                    requestedTime -= animationLength;
                }

                // Find previous key.
                if (owner.KeyFrames[0].Time <= requestedTime)
                {
                    for (i = 0; i < owner.KeyFrames.Count; i++)
                    {
                        if ((!(owner.KeyFrames[i].Time > requestedTime)) || (i <= 0))
                        {
                            continue;
                        }

                        PreviousKey      = owner.KeyFrames[i - 1];
                        PreviousKeyIndex = i - 1;
                        break;
                    }
                }
                else
                {
                    i = 1;
                }

                // Wrap to the first key if we went through the entire list.
                if (i >= owner.KeyFrames.Count)
                {
                    if (!owner.Animation.IsLooped)
                    {
                        NextKey      = owner.KeyFrames[owner.KeyFrames.Count - 1];
                        NextKeyIndex = owner.KeyFrames.Count - 1;
                    }
                    else
                    {
                        NextKey      = owner.KeyFrames[0];
                        NextKeyIndex = 0;
                    }
                    KeyTimeDelta = animationLength;
                }
                else
                {
                    NextKey      = owner.KeyFrames[i];
                    NextKeyIndex = i;
                    KeyTimeDelta = NextKey.Time;
                }

                // Same frame.
                if (PreviousKey.Time.EqualsEpsilon(KeyTimeDelta, 0.001f))
                {
                    KeyTimeDelta = 0;
                }
                else
                {
                    KeyTimeDelta = (requestedTime - PreviousKey.Time) / (KeyTimeDelta - PreviousKey.Time);
                }

                // We can't have negative time.
                if (KeyTimeDelta < 0)
                {
                    KeyTimeDelta = 0;
                }
                TrackTimePosition = requestedTime;
            }
コード例 #26
0
 /// <summary>
 /// Function to apply the key value to the object properties.
 /// </summary>
 /// <param name="key">Key to apply to the properties.</param>
 protected abstract internal void ApplyKey(ref IKeyFrame key);
コード例 #27
0
ファイル: IKeyFrame.cs プロジェクト: nastys/PD_Tool_Archived
 public IKeyFrame <TKey, TVal> ToKeyFrameT3(IKeyFrame <TKey, TVal> Previous) =>
 Previous is KeyFrameT2 <TKey, TVal> PreviousT2 ?
コード例 #28
0
 /// <summary>
 /// Creates a copy of a keyframe
 /// </summary>
 /// <param name="substituteFor">Substitutes keyframe</param>
 public KeyFrameSurrogate(IKeyFrame substituteFor)
 {
     SubstituteFor = substituteFor;
     Point         = substituteFor.Point;
     T             = substituteFor.T;
 }
コード例 #29
0
 /// <summary>
 /// Copy surrogates values to target
 /// </summary>
 /// <param name="target"></param>
 public void CopyTo(IKeyFrame target)
 {
     target.Point = Point;
     target.T     = T;
 }