示例#1
0
        internal static ClockRow CreateClockRow(ClockFaceElement clockFaceElement)
        {
            switch (clockFaceElement)
            {
            case ClockFaceElement.SecondsRow:
                //There is just one seconds lamp for every even number of seconds gets switched on to Yellow
                return(new ClockRow(1, dt => dt.Second, OneLampForEveryEvenNumber, SwitchOnLampToYellow));

            case ClockFaceElement.UpperHourRow:
                //The first hour row of 4 lamps, each lamp representing <TimeFactor> number of hours and gets set to Red
                return(new ClockRow(4, dt => dt.Hour, GetCountOfTimeMultiples, SwitchOnLampToRed));

            case ClockFaceElement.LowerHourRow:
                //The second hour row of 4 lamps, each lamp representing 1 hour and gets set to Red
                return(new ClockRow(4, dt => dt.Hour, GetRemainderFromTimeMultiples, SwitchOnLampToRed));

            case ClockFaceElement.UpperMinutesRow:
                //The first minute row of 11 lamps, each lamp representing <TimeFactor> number of minutes and
                //has red lamps in the quarter hour position and the remaining lamps are all yellow
                return(new ClockRow(11, dt => dt.Minute, GetCountOfTimeMultiples, SwitchOnMinuteHandsLamps));

            case ClockFaceElement.LowerMinutesRow:
                //The second minute row of 4 lamps, each lamp representing 1 minute and gets set to Yellow
                return(new ClockRow(4, dt => dt.Minute, GetRemainderFromTimeMultiples, SwitchOnLampToYellow));

            default:
                return(null);
            }
        }
示例#2
0
        public static Clock With(this Clock clock, ClockFaceElement clockFaceElement)
        {
            var clockRow = ClockRowFactory.CreateClockRow(clockFaceElement);

            if (clockRow != null)
            {
                clock.AddClockRow(clockRow);
            }
            return(clock);
        }