private void UpdateTexts() { YearText.Text = SelectedTime.Year.ToString("0000"); MonthText.Text = SelectedTime.Month.ToString("00"); DayText.Text = SelectedTime.Day.ToString("00"); HourText.Text = SelectedTime.Hour.ToString("00"); MinuteText.Text = SelectedTime.Minute.ToString("00"); SecondText.Text = SelectedTime.Second.ToString("00"); YearText.SelectAll(); MonthText.SelectAll(); DayText.SelectAll(); HourText.SelectAll(); MinuteText.SelectAll(); SecondText.SelectAll(); }
void ReleaseDesignerOutlets() { if (FirstText != null) { FirstText.Dispose(); FirstText = null; } if (SecondText != null) { SecondText.Dispose(); SecondText = null; } if (ValidateButton != null) { ValidateButton.Dispose(); ValidateButton = null; } }
private void Text_PreviewKeyDown(object sender, KeyEventArgs args) { TextBox source = (TextBox)args.Source; int value, min, max; GetFieldInfo(source, out value, out min, out max); if (args.Key == Key.Down && Keyboard.Modifiers == ModifierKeys.None) { value--; if (value < min) { value = max; } args.Handled = true; SetTimeComponent(value, source); UpdateTexts(); } if (args.Key == Key.Up && Keyboard.Modifiers == ModifierKeys.None) { value++; if (value > max) { value = min; } args.Handled = true; SetTimeComponent(value, source); UpdateTexts(); } if (args.Key == Key.Left && Keyboard.Modifiers == ModifierKeys.None) { if (source.SelectionLength == source.Text.Length || source.SelectionLength == 0 && source.SelectionStart == 0) { if (source == YearText) { SecondText.Focus(); } else { source.MoveFocus(new TraversalRequest(FocusNavigationDirection.Previous)); } args.Handled = true; } } if (args.Key == Key.Right && Keyboard.Modifiers == ModifierKeys.None) { if (source.SelectionLength == source.Text.Length || source.SelectionLength == 0 && source.SelectionStart == source.Text.Length) { if (source == SecondText) { YearText.Focus(); } else { source.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); } args.Handled = true; } } }