Esempio n. 1
0
        public static IEnumerable <(int time, Command cmd)> ConvertToKeyFrame(CommandTimeline timeline)
        {
            //support events
            if (!SUPPORT_CONVERT_EVENTS.Contains(timeline.Event))
            {
                yield break;
            }

            if (timeline.Overlay)
            {
                throw new Exception("OVERLAY!");
            }

            for (int i = 0; i < timeline.Count; i++)
            {
                var cmd      = timeline[i];
                var next_cmd = i < timeline.Count - 1 ? timeline[i + 1] : null;

                //return relative code
                yield return(cmd.StartTime, cmd);

                yield return(cmd.EndTime, cmd);

                if (next_cmd != null)
                {
                    yield return(next_cmd.StartTime, cmd);
                }
            }
        }
        public TriggerSubTimelineCommand(TriggerCommand trigger_command, Event bind_event)
        {
            this.trigger_command = trigger_command;
            Event    = bind_event;
            timeline = trigger_command.SubCommands[bind_event];

            CostTime = timeline.Count != 0 ? timeline.Max(x => x.EndTime) : 0;

            RelativeLine = trigger_command.RelativeLine;
        }
Esempio n. 3
0
 /// <inheritdoc cref="IAdoNetProfiler.OnCommandError(DbCommand, Exception)" />
 public void OnCommandError(DbCommand command, Exception exception)
 {
     _commandTimeline.WriteTimelineMessage(true);
     _commandTimeline = null;
 }
Esempio n. 4
0
 /// <inheritdoc cref="IAdoNetProfiler.OnExecuteScalarFinish(DbCommand, object)" />
 public void OnExecuteScalarFinish(DbCommand command, object executionRestlt)
 {
     // Record is always 1.
     _commandTimeline.WriteTimelineMessage(1);
     _commandTimeline = null;
 }
Esempio n. 5
0
 /// <inheritdoc cref="IAdoNetProfiler.OnExecuteScalarStart(DbCommand)" />
 public void OnExecuteScalarStart(DbCommand command)
 {
     _commandTimeline = CommandInspector.CreateTimeline(command, _connectionId, _transactionLifetimeTimeline?.TransactionId);
 }
Esempio n. 6
0
 /// <inheritdoc cref="IAdoNetProfiler.OnExecuteNonQueryFinish(DbCommand, int)" />
 public void OnExecuteNonQueryFinish(DbCommand command, int executionRestlt)
 {
     _commandTimeline.WriteTimelineMessage(executionRestlt);
     _commandTimeline = null;
 }
Esempio n. 7
0
 /// <inheritdoc cref="IAdoNetProfiler.OnReaderFinish(DbDataReader, int)" />
 public void OnReaderFinish(DbDataReader reader, int records)
 {
     _commandTimeline.WriteTimelineMessage(records);
     _commandTimeline = null;
 }
Esempio n. 8
0
 public static bool CanConvert(CommandTimeline commands) => converters.ContainsKey(commands.Event);
Esempio n. 9
0
        public static (KeyFrames frames, int start_time, int duration) ConverterTimelineToKeyFrames(CommandTimeline storyboard_timeline, string name)
        {
            var command_value_converter = GetValueConverter(storyboard_timeline.Event);

            var extra_imm_timeline = new List <(long, int, IEnumerable <Property>)>();

            var keyframe_timeline = TimelineConvert.ConvertToKeyFrame(storyboard_timeline).Select(x => (x.time, command_value_converter.Convert(x.cmd, x.time)));

            int start_time = keyframe_timeline.Min(x => x.Item1);
            int end_time   = keyframe_timeline.Max(x => x.Item1);

            var duration = end_time - start_time;

            Log.User($"Build Frame {storyboard_timeline} -> {name} ");

            ProgressiveKeyFrames kf = new ProgressiveKeyFrames(name);

            foreach (var frame in keyframe_timeline)
            {
                var progress = CalculateInterploter(frame.Item1);

                kf.Timeline.Add(new ProgressiveFrame()
                {
                    NormalizeTime = progress, ChangedProperties = frame.Item2.ToList()
                });
            }

            Compressor.Compress(kf);
            ProgressiveFrameSeparater.Separate(kf);

            return(kf, start_time, duration); //todo

            float CalculateInterploter(float time)
            {
                float t;

                if (time <= start_time)
                {
                    t = 0;
                }
                else if (time >= end_time)
                {
                    t = 1;
                }
                else
                {
                    t = ((time - start_time) / (end_time - start_time));
                }

                return(t);
            }
        }