private void Timer_Tick(object sender, EventArgs e)
 {
     if (timer.Tag == null)
     {
         timer.Tag = TimeSpan.FromSeconds(1);
     }
     else
     {
         timer.Tag = ((TimeSpan)timer.Tag).Add(TimeSpan.FromSeconds(1));
     }
     if (((TimeSpan)timer.Tag) >= Expiry)
     {
         DisposeTimer();
         InternalText = null;
         if (OKCommand != null)
         {
             if (OKCommand.CanExecute(null))
             {
                 OKCommand.Execute(null);
             }
         }
         else
         {
             Visibility = Visibility.Collapsed;
         }
     }
     if (!Text.IsNullOrEmpty() && Expiry.HasValue && timer?.Tag != null)
     {
         InternalText = Text.Replace("{TimeRemaining}", (Expiry.Value - (((TimeSpan?)timer.Tag) ?? TimeSpan.Zero)).ToReadableString());
     }
 }
 private void EntrySelector_ComboBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter && OKCommand.CanExecute(null))
     {
         OKCommand.Execute(null);
     }
 }
Esempio n. 3
0
 private void CanExecuteChanged(object sender, EventArgs e)
 {
     if (OKCommand != null)
     {
         _canExecute = OKCommand.CanExecute(null);
     }
     CoerceValue(UIElement.IsEnabledProperty);
 }