Exemplo n.º 1
0
        private void MergeDeferredTraces(InputTraceBase nextTrace)
        {
            if (this.deferredTraces == null)
            {
                return;
            }
            if (this.deferredTraces.Count == 0)
            {
                this.deferredTraces = null;
                return;
            }

            var dt = this.deferredTraces;

            this.deferredTraces = null;
            long timestamp;

            if (nextTrace != null)
            {
                timestamp = nextTrace.Timestamp - dt.Count;
            }
            else
            {
                timestamp = dt.Last().Timestamp - dt.Count;
            }
            foreach (var deferredTrace in dt)
            {
                deferredTrace.Timestamp = timestamp;
                ++timestamp;
                Add(deferredTrace);
            }
        }
Exemplo n.º 2
0
        //public void StartRecording(long timestamp)
        //{
        //    if (this.IsRecording)
        //    {
        //        throw new InvalidOperationException();
        //    }

        //    this.IsRecording = true;
        //    this.timeAsZero = timestamp;
        //}

        //public void Pause()
        //{
        //    this.timePaused = DateTimeOffset.UtcNow.Ticks;
        //}
        //public void Resume()
        //{
        //    var pauseDuration = DateTimeOffset.UtcNow.Ticks - this.timePaused;
        //    this.timeAsZero += pauseDuration;

        //    this.timePaused = -1;
        //}

        /// <summary>
        ///  入力を追加する.
        /// </summary>
        /// <param name="trace">追加される入力</param>
        public void Add(InputTraceBase trace)
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }
            if (this.IsPausing)
            {
                throw new InvalidOperationException();
            }

            MergeDeferredTraces(trace);

            if (/*!this.IsRecording &&*/ !this.HasTrace)
            {
                this.IsRecording = true;
                this.timeAsZero  = trace.Timestamp;
            }

            System.Diagnostics.Debug.WriteLine("{0} at {1} ({2})", trace.Kind.ToString(), trace.Timestamp, trace.Timestamp - this.timeAsZero);
            trace.Timestamp -= this.timeAsZero;
            this.traces.Add(trace);

            OnPropertyChanged("TotalDuration");
        }
Exemplo n.º 3
0
        /// <summary>
        ///  次に追加される入力の直前に発生したことにする入力.
        /// </summary>
        /// <param name="trace"></param>
        public void AddDeferredTrace(InputTraceBase trace)
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }
            if (this.deferredTraces == null)
            {
                this.deferredTraces = new List <InputTraceBase>();
            }

            this.deferredTraces.Add(trace);
        }
Exemplo n.º 4
0
        private static bool IsTraceWithFile(InputTraceBase trace)
        {
            System.Diagnostics.Debug.Assert(trace != null);

            return(trace.Kind == InputTraceKind.SetImage);
        }