Skip to content

Commit

Permalink
Merge branch 'master' into DYN-6270/Library/update-build-after-code-c…
Browse files Browse the repository at this point in the history
…leanup
  • Loading branch information
Enzo707 authored Nov 2, 2023
2 parents d3ebb45 + 6c42a3c commit 76fcc47
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,25 @@ public string Watermark
new FrameworkPropertyMetadata("0"));

// The Value of the numerical up/down control. Bind to this property
public int Value
public string Value
{
get { return (int)GetValue(ValueProperty); }
get { return (string)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}

// Using a DependencyProperty as the backing store for Value.
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value",
typeof(int),
typeof(string),
typeof(NumericUpDownControl),
new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnValuePropertyChanged)));
new FrameworkPropertyMetadata("0", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnValuePropertyChanged)));

// Setting the input TextBox
private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var numericUpDownControl = d as NumericUpDownControl;
numericUpDownControl.inputField.Text = e.NewValue.ToString();
if (String.IsNullOrEmpty(e.NewValue.ToString())) return;
if (numericUpDownControl.watermarkLabel.Visibility == Visibility.Visible)
{
numericUpDownControl.watermarkLabel.Visibility = Visibility.Collapsed;
Expand All @@ -79,11 +80,11 @@ public NumericUpDownControl()
#region UI utility functions
private void spinnerUp_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty( inputField.Text))
if (string.IsNullOrEmpty(inputField.Text))
{
if (Int32.TryParse(watermarkLabel.Content as string, out int watermarkValue))
{
Value = ++watermarkValue;
Value = (++watermarkValue).ToString();
return;
}
else
Expand All @@ -93,17 +94,17 @@ private void spinnerUp_Click(object sender, RoutedEventArgs e)
}
if (Int32.TryParse(inputField.Text, out int value))
{
Value = ++value;
Value = (++value).ToString();
};
}

private void spinnerDown_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(inputField.Text))
{
if (Int32.TryParse(watermarkLabel.Content as string, out int watermarkValue))
if (Int32.TryParse(watermarkLabel.Content as string, out int watermarkValue) && watermarkValue > 0)
{
Value = --watermarkValue;
Value = (--watermarkValue).ToString();
return;
}
else
Expand All @@ -113,9 +114,8 @@ private void spinnerDown_Click(object sender, RoutedEventArgs e)
}
if (Int32.TryParse(inputField.Text, out int value))
{
// Allows positive whole numbers
if (value <= 0) return;
Value = --value;
if (value == 0) return;
Value = (--value).ToString();
};
}

Expand All @@ -133,7 +133,7 @@ private void inputField_TextChanged(object sender, TextChangedEventArgs e)
{
if (Int32.TryParse(inputField.Text, out int value))
{
Value = value;
Value = value.ToString();
};
}

Expand Down

0 comments on commit 76fcc47

Please sign in to comment.