예제 #1
0
        private void OnTimeChanged(DateTime?oldValue, DateTime?newValue)
        {
            TimeInstant oldTime = oldValue != null ? new TimeInstant(((DateTime)oldValue).Hour, ((DateTime)oldValue).Minute) : new TimeInstant();

            _value = newValue != null ? new TimeInstant(((DateTime)newValue).Hour, ((DateTime)newValue).Minute) : new TimeInstant();

            NotifyMinutesPropertyChanged(oldTime, _value);
            NotifyHoursPropertyChanged(oldTime, _value);
        }
예제 #2
0
        private void NotifyMinutesPropertyChanged(TimeInstant oldValue, TimeInstant newValue)
        {
            // Notify when changed, but also when minutes is zero, as that is the starting value
            if (TimeInstant.MinutesAreDifferent(oldValue, newValue) || newValue.Minutes == 0)
            {
                NotifyPropertyChanged("Minutes");

                this.SetValue(TimeProperty, _value.ToDateTime());
            }
        }
예제 #3
0
        public static bool HoursAreDifferent(TimeInstant lhs, TimeInstant rhs)
        {
            if (lhs.IsEmpty ^ rhs.IsEmpty)
            {
                return(true);
            }

            if (lhs.IsEmpty && rhs.IsEmpty)
            {
                return(false);
            }

            return(lhs.Hours != rhs.Hours);
        }
예제 #4
0
        private void DecrementMinutes()
        {
            if (!IsContentValid)
            {
                return;
            }

            TimeInstant prevValue = _value;

            if (_value.IsEmpty)
            {
                _value = TimeInstant.EndOfDay;

                NotifyHoursPropertyChanged(prevValue, _value);
            }

            _value.DecrementMinutes();

            NotifyMinutesPropertyChanged(prevValue, _value);
        }