Skip to content

Commit

Permalink
minor ux improvement.
Browse files Browse the repository at this point in the history
  • Loading branch information
magicnat committed Jan 31, 2020
1 parent 9d41fc6 commit 9fcedab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ChuniVController/ChuniVController/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@

<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="1" MouseEnter="SetAllowFocus" MouseLeave="SetDenyFocus" >
<Label Content="Key width:" />
<TextBox x:Name="KeyWidth" Text="120" Width="60" MouseEnter="SetAllowFocus" MouseLeave="SetDenyFocus" Height="17" />
<TextBox x:Name="KeyWidth" PreviewTextInput="NumericValidation" Text="120" Width="60" MouseEnter="SetAllowFocus" MouseLeave="SetDenyFocus" Height="17" />
<Label Margin="3,0,0,0" Content="Key height:" HorizontalAlignment="Left" />
<TextBox x:Name="KeyHeight" HorizontalAlignment="Left" Text="250" Width="60" Height="17" />
<TextBox x:Name="KeyHeight" PreviewTextInput="NumericValidation" HorizontalAlignment="Left" Text="250" Width="60" Height="17" />
<Label Margin="3,0,0,0" Content="Sensor height:" />
<TextBox x:Name="AirHeight" Text="300" Margin="3,0,0,0" Width="60" Height="17" />
<TextBox x:Name="AirHeight" PreviewTextInput="NumericValidation" Text="300" Margin="3,0,0,0" Width="60" Height="17" />
<Button Margin="3" Content="Apply" HorizontalAlignment="Left" Width="75" Click="DoApply" IsDefault="True" />
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
<Label Content="Opacity" />
Expand Down
16 changes: 16 additions & 0 deletions ChuniVController/ChuniVController/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ private void Render()
}
}

protected override void OnPreviewKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Space) e.Handled = true; // so that checkboxes won't be trigger by the IR sensor simulation
base.OnPreviewKeyDown(e);
}

private void NumericValidation(object sender, TextCompositionEventArgs e)
{
int _;
e.Handled = !int.TryParse(e.Text, out _);
if (e.Handled && e.Text.Equals(".") && ((TextBox) sender).Text.IndexOf('.') == -1)
{
e.Handled = false;
}
}

private void SetAllowFocus(object sender, RoutedEventArgs e)
{
AllowFocus();
Expand Down

0 comments on commit 9fcedab

Please sign in to comment.