react to pressing Enter in text fields

This commit is contained in:
Florian Stinglmayr 2021-07-09 11:24:46 +02:00
parent 1926ba883b
commit 2125844acb
2 changed files with 14 additions and 4 deletions

View File

@ -29,11 +29,11 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ToolBar VerticalAlignment="Top" Grid.Row="0" Width="Auto" Grid.ColumnSpan="3" Height="Auto" Margin="0,0,0,0" HorizontalAlignment="Left"> <ToolBar VerticalAlignment="Top" Grid.Row="0" Width="Auto" Grid.ColumnSpan="3" Height="Auto" Margin="0,0,0,0" HorizontalAlignment="Left">
<Label Content="System:" HorizontalAlignment="Left" VerticalAlignment="Top"/> <Label Content="System:" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<TextBox x:Name="system" HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Margin="0,0,0,3.286" MinWidth="120" VerticalContentAlignment="Center"/> <TextBox x:Name="system" HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Margin="0,0,0,3.286" MinWidth="120" VerticalContentAlignment="Center" KeyDown="Filter_KeyDown"/>
<Label Content="Station:" Height="26.2857142857143" VerticalAlignment="Top"/> <Label Content="Station:" Height="26.2857142857143" VerticalAlignment="Top"/>
<TextBox x:Name="station" Margin="0" TextWrapping="Wrap" VerticalAlignment="Center" MinWidth="120"/> <TextBox x:Name="station" Margin="0" TextWrapping="Wrap" VerticalAlignment="Center" MinWidth="120" KeyDown="Filter_KeyDown"/>
<Label Content="Faction:" Height="26.2857142857143" VerticalAlignment="Top"/> <Label Content="Faction:" Height="26.2857142857143" VerticalAlignment="Top"/>
<TextBox x:Name="faction" Margin="0" TextWrapping="Wrap" VerticalAlignment="Center" MinWidth="120"/> <TextBox x:Name="faction" Margin="0" TextWrapping="Wrap" VerticalAlignment="Center" MinWidth="120" KeyDown="Filter_KeyDown"/>
<Separator Height="26.2857142857143" Margin="0" VerticalAlignment="Top"/> <Separator Height="26.2857142857143" Margin="0" VerticalAlignment="Top"/>
<Button x:Name="AddFilter" Content="Add Objective" VerticalAlignment="Stretch" Click="AddFilter_Click" Margin="0,0,0,0.286" RenderTransformOrigin="0.5,0.505"/> <Button x:Name="AddFilter" Content="Add Objective" VerticalAlignment="Stretch" Click="AddFilter_Click" Margin="0,0,0,0.286" RenderTransformOrigin="0.5,0.505"/>
</ToolBar> </ToolBar>

View File

@ -119,7 +119,7 @@ namespace NonaBGS {
RefreshObjectives(); RefreshObjectives();
} }
private void AddFilter_Click(object sender, RoutedEventArgs e) { private void AddObjective() {
Objective objective = new Objective { Objective objective = new Objective {
System = system.Text, System = system.Text,
Faction = faction.Text, Faction = faction.Text,
@ -136,6 +136,10 @@ namespace NonaBGS {
} }
} }
private void AddFilter_Click(object sender, RoutedEventArgs e) {
AddObjective();
}
private void GenerateDiscord_Click(object sender, RoutedEventArgs e) { private void GenerateDiscord_Click(object sender, RoutedEventArgs e) {
NonaDiscordLog discord = new NonaDiscordLog(); NonaDiscordLog discord = new NonaDiscordLog();
string report = discord.GenerateDiscordLog(Report); string report = discord.GenerateDiscordLog(Report);
@ -188,5 +192,11 @@ namespace NonaBGS {
Config.Global.UseEDDB = (bool)useeddb.IsChecked; Config.Global.UseEDDB = (bool)useeddb.IsChecked;
SyncDatabases(); SyncDatabases();
} }
private void Filter_KeyDown(object sender, KeyEventArgs e) {
if (e.Key == Key.Enter) {
AddObjective();
}
}
} }
} }