コード例 #1
0
        private static void OnUseCurrentTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CurrentTimePicker _this = d as CurrentTimePicker;
            if (_this == null)
            {
                return;
            }

            if(!(e.NewValue is bool))
            {
                return;
            }
            bool newUseCurrentTime = (bool)e.NewValue;

            if(newUseCurrentTime)
            {
                _this.UnderPicker.IsEnabled = false;
                _this.WidenAnimation.KeyFrames[0].Value = _this.ControlRoot.ActualWidth;
                if (_this.ControlRoot.ActualWidth > 0)
                {
                    _this.ScaleUpBoxFrame.Value = _this.NarrowColumn.Width.Value / _this.ControlRoot.ActualWidth;
                }
                if (_this.Common.CurrentState.Name == _this.UseCurrentTimeStateKey)
                {
                    VisualStateManager.GoToState(_this, _this.UseCurrentTimeStateKey, false);
                }
                else
                {
                    VisualStateManager.GoToState(_this, _this.UseCurrentTimeStateKey, true);
                }
            }
            else
            {
                _this.Time = DateTime.Now.TimeOfDay;
                _this.UnderPicker.IsEnabled = true;
                if (_this.ControlRoot.ActualWidth > 0)
                {
                    _this.ScaleDownBoxFrame.Value = _this.NarrowColumn.Width.Value / _this.ControlRoot.ActualWidth;
                }
                if (_this.Common.CurrentState.Name == _this.UseCustomTimeStateKey)
                {
                    VisualStateManager.GoToState(_this, _this.UseCustomTimeStateKey, false);
                }
                else
                {
                    VisualStateManager.GoToState(_this, _this.UseCustomTimeStateKey, true);
                }
            }
        }
コード例 #2
0
        private static void OnTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CurrentTimePicker _this = d as CurrentTimePicker;
            if(_this == null)
            {
                return;
            }

            if(!(e.NewValue is TimeSpan))
            {
                return;
            }
            TimeSpan newTime = (TimeSpan)e.NewValue;
            
            _this.UnderPicker.Time = newTime;           
        }