Vereinsmeisterschaften  22aa7800eae54b428d40e835886cefe1fdefdfdf
This is a software that can be used to manage the internal competition of the swimming club Illertissen called "Vereinsmeisterschaften".
Loading...
Searching...
No Matches
Vereinsmeisterschaften.Controls.TimeSpanControl Class Reference

Interaktionslogik für TimeSpanControl.xaml This control is inspired by the HTML time input (https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_time) More...

Inheritance diagram for Vereinsmeisterschaften.Controls.TimeSpanControl:

Public Types

enum  TimeSpanControlEditModes {
  None , EditHours , EditMinutes , EditSeconds ,
  EditMilliseconds
}
 Enum with editable parts of the TimeSpan. More...
 

Public Member Functions

 TimeSpanControl ()
 Constructor of the TimeSpanControl.
 

Static Public Attributes

const ushort MAX_NUMBER_MILLISECOND_DIGITS = 3
 Maximum number of digits for the milliseconds.
 
static readonly DependencyProperty EditModeProperty = DependencyProperty.Register(nameof(EditMode), typeof(TimeSpanControlEditModes), typeof(TimeSpanControl), new UIPropertyMetadata(TimeSpanControlEditModes.EditMinutes, new PropertyChangedCallback(OnEditModeChanged)))
 Dependency property for the EditMode property.
 
static readonly DependencyProperty ValueProperty = DependencyProperty.Register(nameof(Value), typeof(TimeSpan), typeof(TimeSpanControl), new FrameworkPropertyMetadata(TimeSpan.Zero, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnValueChanged)))
 Dependency property for the Value property.
 
static readonly DependencyProperty HoursProperty = DependencyProperty.Register(nameof(Hours), typeof(int), typeof(TimeSpanControl), new UIPropertyMetadata(0, new PropertyChangedCallback(OnTimeChanged)))
 Dependency property for the Hours property.
 
static readonly DependencyProperty MinutesProperty = DependencyProperty.Register(nameof(Minutes), typeof(int), typeof(TimeSpanControl), new UIPropertyMetadata(0, new PropertyChangedCallback(OnTimeChanged)))
 Dependency property for the Minutes property.
 
static readonly DependencyProperty SecondsProperty = DependencyProperty.Register(nameof(Seconds), typeof(int), typeof(TimeSpanControl), new UIPropertyMetadata(0, new PropertyChangedCallback(OnTimeChanged)))
 Dependency property for the Seconds property.
 
static readonly DependencyProperty MillisecondsProperty = DependencyProperty.Register(nameof(Milliseconds), typeof(int), typeof(TimeSpanControl), new UIPropertyMetadata(0, new PropertyChangedCallback(OnTimeChanged)))
 Dependency property for the Milliseconds property.
 
static readonly DependencyProperty MillisecondDigitsProperty = DependencyProperty.Register(nameof(MillisecondDigits), typeof(ushort), typeof(TimeSpanControl), new PropertyMetadata(MAX_NUMBER_MILLISECOND_DIGITS, OnMillisecondDigitsChanged))
 Dependency property for the MillisecondDigits property.
 
static readonly DependencyProperty MillisecondsDisplayedProperty = MillisecondsDisplayedPropertyKey.DependencyProperty
 Read-only dependency property for the MillisecondsDisplayed property.
 
static readonly DependencyProperty HoursVisibleProperty = DependencyProperty.Register(nameof(HoursVisible), typeof(bool), typeof(TimeSpanControl), new UIPropertyMetadata(true, new PropertyChangedCallback(OnVisiblePartsChanged)))
 Dependency property for the HoursVisible property.
 
static readonly DependencyProperty MillisecondsVisibleProperty = DependencyProperty.Register(nameof(MillisecondsVisible), typeof(bool), typeof(TimeSpanControl), new UIPropertyMetadata(true, new PropertyChangedCallback(OnVisiblePartsChanged)))
 Dependency property for the MillisecondsVisible property.
 

Properties

TimeSpanControlEditModes EditMode [get, set]
 Current edit mode.
 
TimeSpan Value [get, set]
 TimeSpan value that is editable by this control
 
int Hours [get, set]
 Hours of the Value (TimeSpan.Hours)
 
int Minutes [get, set]
 Minutes of the Value (TimeSpan.Minutes)
 
int Seconds [get, set]
 Seconds of the Value (TimeSpan.Seconds)
 
int Milliseconds [get, set]
 Milliseconds of the Value (TimeSpan.Milliseconds)
 
ushort MillisecondDigits [get, set]
 Number of digits to display for the milliseconds.
 
string MillisecondsDisplayed [get, private set]
 Read-only property that contains the formatted milliseconds depending on the MillisecondDigits property.
 
bool HoursVisible [get, set]
 If true, the controls show the Hours field.
 
bool MillisecondsVisible [get, set]
 If true, the controls show the Milliseconds field.
 

Private Member Functions

void updateMillisecondsDisplayed ()
 
void handleDigitInput (byte digit)
 Integrate the entered digit into the TimeSpan value.
 
void increaseDigit ()
 Increase the digits depending on the current EditMode
 
void decreaseDigit ()
 Decrease the digits depending on the current EditMode
 
void txt_hours_PreviewMouseDown (object sender, MouseButtonEventArgs e)
 
void txt_minutes_PreviewMouseDown (object sender, MouseButtonEventArgs e)
 
void txt_seconds_PreviewMouseDown (object sender, MouseButtonEventArgs e)
 
void txt_milliseconds_PreviewMouseDown (object sender, MouseButtonEventArgs e)
 
void UserControl_PreviewKeyDown (object sender, KeyEventArgs e)
 
void btn_Increase_Click (object sender, RoutedEventArgs e)
 
void btn_Decrease_Click (object sender, RoutedEventArgs e)
 

Static Private Member Functions

static void OnEditModeChanged (DependencyObject obj, DependencyPropertyChangedEventArgs e)
 
static void OnValueChanged (DependencyObject obj, DependencyPropertyChangedEventArgs e)
 
static void OnTimeChanged (DependencyObject obj, DependencyPropertyChangedEventArgs e)
 
static void OnMillisecondDigitsChanged (DependencyObject d, DependencyPropertyChangedEventArgs e)
 
static void OnVisiblePartsChanged (DependencyObject obj, DependencyPropertyChangedEventArgs e)
 

Private Attributes

bool _digitEntry_StartWithFirstDigit = true
 
byte _digitEntry_CountEnteredZeroes = 0
 

Static Private Attributes

static readonly DependencyPropertyKey MillisecondsDisplayedPropertyKey = DependencyProperty.RegisterReadOnly(nameof(MillisecondsDisplayed), typeof(string), typeof(TimeSpanControl), new PropertyMetadata("000"))
 

Detailed Description

Interaktionslogik für TimeSpanControl.xaml This control is inspired by the HTML time input (https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_type_time)

Definition at line 11 of file TimeSpanControl.xaml.cs.

Member Enumeration Documentation

◆ TimeSpanControlEditModes

Enum with editable parts of the TimeSpan.

Definition at line 16 of file TimeSpanControl.xaml.cs.

Constructor & Destructor Documentation

◆ TimeSpanControl()

Vereinsmeisterschaften.Controls.TimeSpanControl.TimeSpanControl ( )

Constructor of the TimeSpanControl.

Definition at line 35 of file TimeSpanControl.xaml.cs.

Member Function Documentation

◆ btn_Decrease_Click()

void Vereinsmeisterschaften.Controls.TimeSpanControl.btn_Decrease_Click ( object sender,
RoutedEventArgs e )
private

Definition at line 464 of file TimeSpanControl.xaml.cs.

◆ btn_Increase_Click()

void Vereinsmeisterschaften.Controls.TimeSpanControl.btn_Increase_Click ( object sender,
RoutedEventArgs e )
private

Definition at line 459 of file TimeSpanControl.xaml.cs.

◆ decreaseDigit()

void Vereinsmeisterschaften.Controls.TimeSpanControl.decreaseDigit ( )
private

Decrease the digits depending on the current EditMode

Definition at line 348 of file TimeSpanControl.xaml.cs.

◆ handleDigitInput()

void Vereinsmeisterschaften.Controls.TimeSpanControl.handleDigitInput ( byte digit)
private

Integrate the entered digit into the TimeSpan value.

If it is the first digit after an EditMode change, it is used at the rightmost digit. For each following digit, the value is multiplied by 10 (shifted one digit to the left) and the digit is added. If the EditMode is changed automatically when the next digit will produce a number that is too large. E.g. if Hours = 3 the Edit mode will automatically change to EditMinutes because all following digits would lead to hours > 23.

Parameters
digitDigit to handle (0 .. 9)

Definition at line 270 of file TimeSpanControl.xaml.cs.

◆ increaseDigit()

void Vereinsmeisterschaften.Controls.TimeSpanControl.increaseDigit ( )
private

Increase the digits depending on the current EditMode

Definition at line 317 of file TimeSpanControl.xaml.cs.

◆ OnEditModeChanged()

static void Vereinsmeisterschaften.Controls.TimeSpanControl.OnEditModeChanged ( DependencyObject obj,
DependencyPropertyChangedEventArgs e )
staticprivate

Definition at line 63 of file TimeSpanControl.xaml.cs.

◆ OnMillisecondDigitsChanged()

static void Vereinsmeisterschaften.Controls.TimeSpanControl.OnMillisecondDigitsChanged ( DependencyObject d,
DependencyPropertyChangedEventArgs e )
staticprivate

Definition at line 178 of file TimeSpanControl.xaml.cs.

◆ OnTimeChanged()

static void Vereinsmeisterschaften.Controls.TimeSpanControl.OnTimeChanged ( DependencyObject obj,
DependencyPropertyChangedEventArgs e )
staticprivate

Definition at line 153 of file TimeSpanControl.xaml.cs.

◆ OnValueChanged()

static void Vereinsmeisterschaften.Controls.TimeSpanControl.OnValueChanged ( DependencyObject obj,
DependencyPropertyChangedEventArgs e )
staticprivate

Definition at line 86 of file TimeSpanControl.xaml.cs.

◆ OnVisiblePartsChanged()

static void Vereinsmeisterschaften.Controls.TimeSpanControl.OnVisiblePartsChanged ( DependencyObject obj,
DependencyPropertyChangedEventArgs e )
staticprivate

Definition at line 243 of file TimeSpanControl.xaml.cs.

◆ txt_hours_PreviewMouseDown()

void Vereinsmeisterschaften.Controls.TimeSpanControl.txt_hours_PreviewMouseDown ( object sender,
MouseButtonEventArgs e )
private

Definition at line 381 of file TimeSpanControl.xaml.cs.

◆ txt_milliseconds_PreviewMouseDown()

void Vereinsmeisterschaften.Controls.TimeSpanControl.txt_milliseconds_PreviewMouseDown ( object sender,
MouseButtonEventArgs e )
private

Definition at line 402 of file TimeSpanControl.xaml.cs.

◆ txt_minutes_PreviewMouseDown()

void Vereinsmeisterschaften.Controls.TimeSpanControl.txt_minutes_PreviewMouseDown ( object sender,
MouseButtonEventArgs e )
private

Definition at line 388 of file TimeSpanControl.xaml.cs.

◆ txt_seconds_PreviewMouseDown()

void Vereinsmeisterschaften.Controls.TimeSpanControl.txt_seconds_PreviewMouseDown ( object sender,
MouseButtonEventArgs e )
private

Definition at line 395 of file TimeSpanControl.xaml.cs.

◆ updateMillisecondsDisplayed()

void Vereinsmeisterschaften.Controls.TimeSpanControl.updateMillisecondsDisplayed ( )
private

Definition at line 204 of file TimeSpanControl.xaml.cs.

◆ UserControl_PreviewKeyDown()

void Vereinsmeisterschaften.Controls.TimeSpanControl.UserControl_PreviewKeyDown ( object sender,
KeyEventArgs e )
private

Definition at line 409 of file TimeSpanControl.xaml.cs.

Member Data Documentation

◆ _digitEntry_CountEnteredZeroes

byte Vereinsmeisterschaften.Controls.TimeSpanControl._digitEntry_CountEnteredZeroes = 0
private

Definition at line 43 of file TimeSpanControl.xaml.cs.

◆ _digitEntry_StartWithFirstDigit

bool Vereinsmeisterschaften.Controls.TimeSpanControl._digitEntry_StartWithFirstDigit = true
private

Definition at line 42 of file TimeSpanControl.xaml.cs.

◆ EditModeProperty

readonly DependencyProperty Vereinsmeisterschaften.Controls.TimeSpanControl.EditModeProperty = DependencyProperty.Register(nameof(EditMode), typeof(TimeSpanControlEditModes), typeof(TimeSpanControl), new UIPropertyMetadata(TimeSpanControlEditModes.EditMinutes, new PropertyChangedCallback(OnEditModeChanged)))
static

Dependency property for the EditMode property.

Definition at line 61 of file TimeSpanControl.xaml.cs.

◆ HoursProperty

readonly DependencyProperty Vereinsmeisterschaften.Controls.TimeSpanControl.HoursProperty = DependencyProperty.Register(nameof(Hours), typeof(int), typeof(TimeSpanControl), new UIPropertyMetadata(0, new PropertyChangedCallback(OnTimeChanged)))
static

Dependency property for the Hours property.

Definition at line 109 of file TimeSpanControl.xaml.cs.

◆ HoursVisibleProperty

readonly DependencyProperty Vereinsmeisterschaften.Controls.TimeSpanControl.HoursVisibleProperty = DependencyProperty.Register(nameof(HoursVisible), typeof(bool), typeof(TimeSpanControl), new UIPropertyMetadata(true, new PropertyChangedCallback(OnVisiblePartsChanged)))
static

Dependency property for the HoursVisible property.

Definition at line 227 of file TimeSpanControl.xaml.cs.

◆ MAX_NUMBER_MILLISECOND_DIGITS

const ushort Vereinsmeisterschaften.Controls.TimeSpanControl.MAX_NUMBER_MILLISECOND_DIGITS = 3
static

Maximum number of digits for the milliseconds.

Definition at line 28 of file TimeSpanControl.xaml.cs.

◆ MillisecondDigitsProperty

readonly DependencyProperty Vereinsmeisterschaften.Controls.TimeSpanControl.MillisecondDigitsProperty = DependencyProperty.Register(nameof(MillisecondDigits), typeof(ushort), typeof(TimeSpanControl), new PropertyMetadata(MAX_NUMBER_MILLISECOND_DIGITS, OnMillisecondDigitsChanged))
static

Dependency property for the MillisecondDigits property.

Definition at line 176 of file TimeSpanControl.xaml.cs.

◆ MillisecondsDisplayedProperty

readonly DependencyProperty Vereinsmeisterschaften.Controls.TimeSpanControl.MillisecondsDisplayedProperty = MillisecondsDisplayedPropertyKey.DependencyProperty
static

Read-only dependency property for the MillisecondsDisplayed property.

Definition at line 202 of file TimeSpanControl.xaml.cs.

◆ MillisecondsDisplayedPropertyKey

readonly DependencyPropertyKey Vereinsmeisterschaften.Controls.TimeSpanControl.MillisecondsDisplayedPropertyKey = DependencyProperty.RegisterReadOnly(nameof(MillisecondsDisplayed), typeof(string), typeof(TimeSpanControl), new PropertyMetadata("000"))
staticprivate

Definition at line 197 of file TimeSpanControl.xaml.cs.

◆ MillisecondsProperty

readonly DependencyProperty Vereinsmeisterschaften.Controls.TimeSpanControl.MillisecondsProperty = DependencyProperty.Register(nameof(Milliseconds), typeof(int), typeof(TimeSpanControl), new UIPropertyMetadata(0, new PropertyChangedCallback(OnTimeChanged)))
static

Dependency property for the Milliseconds property.

Definition at line 151 of file TimeSpanControl.xaml.cs.

◆ MillisecondsVisibleProperty

readonly DependencyProperty Vereinsmeisterschaften.Controls.TimeSpanControl.MillisecondsVisibleProperty = DependencyProperty.Register(nameof(MillisecondsVisible), typeof(bool), typeof(TimeSpanControl), new UIPropertyMetadata(true, new PropertyChangedCallback(OnVisiblePartsChanged)))
static

Dependency property for the MillisecondsVisible property.

Definition at line 241 of file TimeSpanControl.xaml.cs.

◆ MinutesProperty

readonly DependencyProperty Vereinsmeisterschaften.Controls.TimeSpanControl.MinutesProperty = DependencyProperty.Register(nameof(Minutes), typeof(int), typeof(TimeSpanControl), new UIPropertyMetadata(0, new PropertyChangedCallback(OnTimeChanged)))
static

Dependency property for the Minutes property.

Definition at line 123 of file TimeSpanControl.xaml.cs.

◆ SecondsProperty

readonly DependencyProperty Vereinsmeisterschaften.Controls.TimeSpanControl.SecondsProperty = DependencyProperty.Register(nameof(Seconds), typeof(int), typeof(TimeSpanControl), new UIPropertyMetadata(0, new PropertyChangedCallback(OnTimeChanged)))
static

Dependency property for the Seconds property.

Definition at line 137 of file TimeSpanControl.xaml.cs.

◆ ValueProperty

readonly DependencyProperty Vereinsmeisterschaften.Controls.TimeSpanControl.ValueProperty = DependencyProperty.Register(nameof(Value), typeof(TimeSpan), typeof(TimeSpanControl), new FrameworkPropertyMetadata(TimeSpan.Zero, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnValueChanged)))
static

Dependency property for the Value property.

Definition at line 84 of file TimeSpanControl.xaml.cs.

Property Documentation

◆ EditMode

TimeSpanControlEditModes Vereinsmeisterschaften.Controls.TimeSpanControl.EditMode
getset

Current edit mode.

This determines the part of the TimeSpan that is currently edited.

Definition at line 52 of file TimeSpanControl.xaml.cs.

◆ Hours

int Vereinsmeisterschaften.Controls.TimeSpanControl.Hours
getset

Hours of the Value (TimeSpan.Hours)

Definition at line 100 of file TimeSpanControl.xaml.cs.

◆ HoursVisible

bool Vereinsmeisterschaften.Controls.TimeSpanControl.HoursVisible
getset

If true, the controls show the Hours field.

Definition at line 218 of file TimeSpanControl.xaml.cs.

◆ MillisecondDigits

ushort Vereinsmeisterschaften.Controls.TimeSpanControl.MillisecondDigits
getset

Number of digits to display for the milliseconds.

Definition at line 167 of file TimeSpanControl.xaml.cs.

◆ Milliseconds

int Vereinsmeisterschaften.Controls.TimeSpanControl.Milliseconds
getset

Milliseconds of the Value (TimeSpan.Milliseconds)

Definition at line 142 of file TimeSpanControl.xaml.cs.

◆ MillisecondsDisplayed

string Vereinsmeisterschaften.Controls.TimeSpanControl.MillisecondsDisplayed
getprivate set

Read-only property that contains the formatted milliseconds depending on the MillisecondDigits property.

Definition at line 191 of file TimeSpanControl.xaml.cs.

◆ MillisecondsVisible

bool Vereinsmeisterschaften.Controls.TimeSpanControl.MillisecondsVisible
getset

If true, the controls show the Milliseconds field.

Definition at line 232 of file TimeSpanControl.xaml.cs.

◆ Minutes

int Vereinsmeisterschaften.Controls.TimeSpanControl.Minutes
getset

Minutes of the Value (TimeSpan.Minutes)

Definition at line 114 of file TimeSpanControl.xaml.cs.

◆ Seconds

int Vereinsmeisterschaften.Controls.TimeSpanControl.Seconds
getset

Seconds of the Value (TimeSpan.Seconds)

Definition at line 128 of file TimeSpanControl.xaml.cs.

◆ Value

TimeSpan Vereinsmeisterschaften.Controls.TimeSpanControl.Value
getset

TimeSpan value that is editable by this control

Definition at line 75 of file TimeSpanControl.xaml.cs.


The documentation for this class was generated from the following file: