Skip to content

Commit ba45ba0

Browse files
author
RandomEngy
committed
Fix text in number box incorrectly being shown in gray in some circumstances.
--HG-- branch : beta
1 parent ea82278 commit ba45ba0

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

VidCoder/Controls/NumberBox.xaml.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ public partial class NumberBox : UserControl
2424
public NumberBox()
2525
{
2626
this.noneCaption = "(none)";
27-
//this.Minimum = double.MinValue;
28-
//this.Maximum = double.MaxValue;
2927
this.UpdateBindingOnTextChange = true;
3028
this.ShowIncrementButtons = true;
3129
this.SelectAllOnClick = true;
@@ -97,8 +95,6 @@ public double Maximum
9795
SetValue(MaximumProperty, value);
9896
}
9997
}
100-
//public double Minimum { get; set; }
101-
//public double Maximum { get; set; }
10298

10399
public const string ModulusPropertyName = "Modulus";
104100
public static readonly DependencyProperty ModulusProperty = DependencyProperty.Register(
@@ -118,8 +114,6 @@ public double Modulus
118114
}
119115
}
120116

121-
//public double Modulus { get; set; }
122-
123117
public bool UpdateBindingOnTextChange { get; set; }
124118

125119
public bool ShowIncrementButtons { get; set; }
@@ -190,11 +184,25 @@ private void RefreshNumberBox()
190184
if (this.AllowEmpty && this.Number == 0)
191185
{
192186
this.numberBox.Text = this.hasFocus ? string.Empty : this.NoneCaption;
193-
this.numberBox.Foreground = new SolidColorBrush(Colors.Gray);
187+
//this.numberBox.Foreground = new SolidColorBrush(Colors.Gray);
194188
}
195189
else
196190
{
197191
this.numberBox.Text = this.Number.ToString();
192+
//this.numberBox.Foreground = new SolidColorBrush(Colors.Black);
193+
}
194+
195+
this.RefreshNumberBoxColor();
196+
}
197+
198+
private void RefreshNumberBoxColor()
199+
{
200+
if (this.numberBox.Text == this.NoneCaption)
201+
{
202+
this.numberBox.Foreground = new SolidColorBrush(Colors.Gray);
203+
}
204+
else
205+
{
198206
this.numberBox.Foreground = new SolidColorBrush(Colors.Black);
199207
}
200208
}
@@ -346,6 +354,8 @@ private void NumberBoxTextChanged(object sender, TextChangedEventArgs e)
346354

347355
this.UpdateNumberBindingFromBox();
348356
}
357+
358+
this.RefreshNumberBoxColor();
349359
}
350360

351361
private void UpdateNumberBindingFromBox()

0 commit comments

Comments
 (0)