private CustomTimer[] CreateAndStartTimers()
        {
            var timerSettings = TimerSettings.CreateFromAppSettings();

            var balloonTipAdapter = new NotifyIconBalloonTipAdapter(_notify);
            var timers            = TimerSettings.CreateTimers(timerSettings, balloonTipAdapter).ToArray();

            foreach (var timer in timers)
            {
                timer.Start();
            }

            return(timers);
        }
Exemple #2
0
        public static IEnumerable<TimerSettings> CreateFromAppSettings()
        {
            var appSettingEntries = ReadAppSettingEntries();

            var settings = new List<TimerSettings>();

            foreach (var entry in appSettingEntries)
            {
                var elements = entry.Split(';');

                var startTimeElement = elements.ElementAt(0);
                var intervalElement = elements.ElementAt(1);
                var intervalUnitElement = elements.ElementAt(2);
                var headerElement = elements.ElementAt(3);
                var textElement = elements.ElementAt(4);

                var startTime = ParseAndValidateStartTime(startTimeElement);
                var interval = ParseAndValidateInterval(intervalElement);
                var intervalUnit = ParseAndValidateIntervalUnit(intervalUnitElement);
                var intervalInMilliseconds = TimeConverters.GetMillisecondsForIntervalUnit(intervalUnit, interval);
                var headerText = ParseAndValidateHeaderText(headerElement);
                var text = ParseAndValidateText(textElement);

                var settingEntry = new TimerSettings
                {
                    StartTime = startTime,
                    IntervalInMs = intervalInMilliseconds,
                    IntervalRaw = interval,
                    Header = headerText,
                    Text = text,
                    IntervalUnit = intervalUnit
                };

                settings.Add(settingEntry);
            }

            return settings;
        }
Exemple #3
0
        public static IEnumerable <TimerSettings> CreateFromAppSettings()
        {
            var appSettingEntries = ReadAppSettingEntries();

            var settings = new List <TimerSettings>();

            foreach (var entry in appSettingEntries)
            {
                var elements = entry.Split(';');

                var startTimeElement    = elements.ElementAt(0);
                var intervalElement     = elements.ElementAt(1);
                var intervalUnitElement = elements.ElementAt(2);
                var headerElement       = elements.ElementAt(3);
                var textElement         = elements.ElementAt(4);

                var startTime              = ParseAndValidateStartTime(startTimeElement);
                var interval               = ParseAndValidateInterval(intervalElement);
                var intervalUnit           = ParseAndValidateIntervalUnit(intervalUnitElement);
                var intervalInMilliseconds = TimeConverters.GetMillisecondsForIntervalUnit(intervalUnit, interval);
                var headerText             = ParseAndValidateHeaderText(headerElement);
                var text = ParseAndValidateText(textElement);

                var settingEntry = new TimerSettings
                {
                    StartTime    = startTime,
                    IntervalInMs = intervalInMilliseconds,
                    IntervalRaw  = interval,
                    Header       = headerText,
                    Text         = text,
                    IntervalUnit = intervalUnit
                };

                settings.Add(settingEntry);
            }

            return(settings);
        }
Exemple #4
0
 public CustomTimer(TimerSettings settings)
     : base(settings.IntervalInMs)
 {
     Settings = settings;
 }
Exemple #5
0
 public CustomTimer(TimerSettings settings) : base(settings.IntervalInMs)
 {
     Settings = settings;
 }