Skip to content

Commit 9fcedab

Browse files
committed
minor ux improvement.
1 parent 9d41fc6 commit 9fcedab

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

ChuniVController/ChuniVController/MainWindow.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030

3131
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="1" MouseEnter="SetAllowFocus" MouseLeave="SetDenyFocus" >
3232
<Label Content="Key width:" />
33-
<TextBox x:Name="KeyWidth" Text="120" Width="60" MouseEnter="SetAllowFocus" MouseLeave="SetDenyFocus" Height="17" />
33+
<TextBox x:Name="KeyWidth" PreviewTextInput="NumericValidation" Text="120" Width="60" MouseEnter="SetAllowFocus" MouseLeave="SetDenyFocus" Height="17" />
3434
<Label Margin="3,0,0,0" Content="Key height:" HorizontalAlignment="Left" />
35-
<TextBox x:Name="KeyHeight" HorizontalAlignment="Left" Text="250" Width="60" Height="17" />
35+
<TextBox x:Name="KeyHeight" PreviewTextInput="NumericValidation" HorizontalAlignment="Left" Text="250" Width="60" Height="17" />
3636
<Label Margin="3,0,0,0" Content="Sensor height:" />
37-
<TextBox x:Name="AirHeight" Text="300" Margin="3,0,0,0" Width="60" Height="17" />
37+
<TextBox x:Name="AirHeight" PreviewTextInput="NumericValidation" Text="300" Margin="3,0,0,0" Width="60" Height="17" />
3838
<Button Margin="3" Content="Apply" HorizontalAlignment="Left" Width="75" Click="DoApply" IsDefault="True" />
3939
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
4040
<Label Content="Opacity" />

ChuniVController/ChuniVController/MainWindow.xaml.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ private void Render()
8686
}
8787
}
8888

89+
protected override void OnPreviewKeyDown(KeyEventArgs e)
90+
{
91+
if (e.Key == Key.Space) e.Handled = true; // so that checkboxes won't be trigger by the IR sensor simulation
92+
base.OnPreviewKeyDown(e);
93+
}
94+
95+
private void NumericValidation(object sender, TextCompositionEventArgs e)
96+
{
97+
int _;
98+
e.Handled = !int.TryParse(e.Text, out _);
99+
if (e.Handled && e.Text.Equals(".") && ((TextBox) sender).Text.IndexOf('.') == -1)
100+
{
101+
e.Handled = false;
102+
}
103+
}
104+
89105
private void SetAllowFocus(object sender, RoutedEventArgs e)
90106
{
91107
AllowFocus();

0 commit comments

Comments
 (0)