コード例 #1
0
        public ProlongedActivityWarning FindProlongedActivity(VisualElement visualElement)
        {
            if (visualElement.Commands.Any(c => c is TriggerCommand))
            {
                return(null);
            }

            var visibleTimes = VisibilityAnalyser.GetVisibleTimes(AnalysingHelper.ResolveTriggers(AnalysingHelper.ResolveLoops(visualElement.Commands)));

            double timeProlonged;

            if (visibleTimes.Count() > 0)
            {
                timeProlonged = (visibleTimes.First().Item1 - visualElement.StartTime) + (visualElement.EndTime - visibleTimes.Last().Item2);
            }
            else
            {
                timeProlonged = visualElement.Duration;
            }

            if (timeProlonged == 0)
            {
                return(null);
            }
            else
            {
                return(new ProlongedActivityWarning()
                {
                    OffendingLine = visualElement.Line,
                    timeProlonged = timeProlonged,
                    percentageProlonged = timeProlonged / visualElement.Duration,
                    WarningLevel = GetWarningLevel(visualElement, timeProlonged),
                });
            }
        }
コード例 #2
0
        public FadeOutWarning FindExcessiveFadeOutTimes(VisualElement visualElement)
        {
            if (visualElement.Commands.Any(c => c is TriggerCommand))
            {
                return(null);
            }

            var visibleTimes = VisibilityAnalyser.GetVisibleTimes(AnalysingHelper.ResolveTriggers(AnalysingHelper.ResolveLoops(visualElement.Commands)));

            double timeInvisible;

            if (visibleTimes.Count() > 0)
            {
                timeInvisible = visualElement.Duration - visibleTimes.Sum(t => t.Item2 - t.Item1);
            }
            else
            {
                timeInvisible = visualElement.Duration;
            }

            if (timeInvisible < visualElement.Duration * 0.35)
            {
                return(null);
            }
            else
            {
                return(new FadeOutWarning()
                {
                    OffendingLine = visualElement.Line,
                    timeInvisible = timeInvisible,
                    percentageInvisible = timeInvisible / visualElement.Duration,
                    WarningLevel = GetWarningLevel(visualElement.Duration, timeInvisible),
                });
            }
        }
コード例 #3
0
        public void ResolveTriggersTest1()
        {
            var result = AnalysingHelper.ResolveTriggers(resolveTriggerCmds);

            Assert.True(result.Count() == 3);
            Assert.True(result.ElementAt(2).EndTime == 36677);
        }
コード例 #4
0
        public List <StoryboardWarning> FindConflicts(VisualElement visualElement)
        {
            List <StoryboardWarning> conflictingCommandsWarnings = new List <StoryboardWarning>();
            var commands = AnalysingHelper.ResolveLoops(visualElement.Commands);

            commands = AnalysingHelper.ResolveTriggers(commands);

            var spriteCommandGroups = commands.Where(c => c is IOsbSpriteCommand)
                                      .Select(c => (IOsbSpriteCommand)c)
                                      .GroupBy(c => c.Identifier);

            foreach (var group in spriteCommandGroups)
            {
                for (int i = 0; i < group.Count(); i++)
                {
                    for (int j = i + 1; j < group.Count(); j++)
                    {
                        var warning = FindConflictingTimes(group.ElementAt(i), group.ElementAt(j));
                        if (warning != null)
                        {
                            conflictingCommandsWarnings.Add(warning);
                        }
                    }
                }
            }

            conflictingCommandsWarnings.AddRange(FindConflictingCommandTypes(visualElement));

            return(conflictingCommandsWarnings);
        }
コード例 #5
0
        public void ResolveLoopsTest2()
        {
            var result = AnalysingHelper.ResolveLoops(resolveLoopsCmds2);

            Assert.True(result.Count() == 5 * 64);
            Assert.True(result.OrderBy(c => c.StartTime).First().StartTime == 9736);
            Assert.True(result.OrderBy(c => c.EndTime).Last().EndTime == 9736 + 64 * 1395); // = 99016
        }
コード例 #6
0
        public void ResolveLoopsTest1()
        {
            var result = AnalysingHelper.ResolveLoops(resolveLoopCmds);

            Assert.True(result.Count() == 49);
            Assert.True(result.ElementAt(4).StartTime == 13047);
            Assert.True(result.ElementAt(5).StartTime == 13671);
            Assert.True(result.ElementAt(48).Identifier == "M");
        }
コード例 #7
0
        private List <StoryboardWarning> FindIllogicalCommands(VisualElement visualElement)
        {
            List <StoryboardWarning> illogicalCommandWarnings = new List <StoryboardWarning>();

            var commands = AnalysingHelper.ResolveLoops(visualElement.Commands);

            commands = AnalysingHelper.ResolveTriggers(commands);

            foreach (var cmd in commands)
            {
                if (cmd.EndTime < cmd.StartTime)
                {
                    illogicalCommandWarnings.Add(new IllogicalCommandWarning()
                    {
                        OffendingLine = cmd.Line,
                        WarningLevel  = Contracts.Warnings.WarningLevel.Critical,
                    });
                }
            }

            return(illogicalCommandWarnings);
        }