Пример #1
0
        private static ActiveHours GetHours()
        {
            int?hoursStart = (int?)Registry.GetValue(RegistryKey, ActiveHoursStartValueName, null);
            int?hoursEnd   = (int?)Registry.GetValue(RegistryKey, ActiveHoursEndValueName, null);

            var result = new ActiveHours(hoursStart ?? -1, hoursEnd ?? -1);

            return(result);
        }
Пример #2
0
        public ActiveHours Slide()
        {
            var now       = DateTime.Now;
            var beyondNow = DateTime.Now.AddHours(12);
            var hours     = GetHours();

            // Don't apply if already set to the correct active hours window
            if ((hours.Start > -1 && hours.Start == now.Hour) && (hours.End > -1 && hours.End == beyondNow.Hour))
            {
                return(null);
            }

            var start = now.Hour;
            var end   = beyondNow.Hour;

            SetHours(start, end);

            var result = new ActiveHours(start, end);

            return(result);
        }