Exemplo n.º 1
0
        private IEnumerable <Point> InitialAutomaton()
        {
            _logger.LogStart("Calculates points");
            IEnumerable <Point> points;

            switch (Settings.InitialAutomatonType)
            {
            case InitialAutomatonType.Previous:
                if (Settings.CurrentPoints == null || Settings.CurrentPoints.Length == 0)
                {
                    points = GenerateRandomPoints();
                }
                else
                {
                    points = new List <Point>(Settings.CurrentPoints);
                    // presave random points
                    Settings.CurrentPoints = GenerateRandomPoints().ToArray();
                }
                break;

            case InitialAutomatonType.DateTime:
            case InitialAutomatonType.UtcDateTime:
            {
                var dateTime = Settings.InitialAutomatonType == InitialAutomatonType.DateTime ? DateTime.Now : DateTime.UtcNow;
                var values   = new[] { dateTime.ToShortDateString(), dateTime.ToLongTimeString() };

                using (var textFont = new Font("Lucida Console", 10, FontStyle.Bold))
                    using (var textImage = GraphicsHelpers.DrawTextImage(values, AutomatonWidth, AutomatonHeight,
                                                                         textFont, Color.Black, Color.White))
                    {
                        points = GraphicsHelpers.ConvertToPoints(textImage);
                    }
            }
            break;

            case InitialAutomatonType.Random:
            default:
                points = GenerateRandomPoints();
                break;
            }

            _logger.LogEnd("Completed");
            return(points);
        }