Update TestWindow

This commit is contained in:
2023-08-14 20:13:08 +02:00
parent 99a6f53307
commit c871dea873
2 changed files with 24 additions and 0 deletions

View File

@ -13,5 +13,8 @@
ItemSelectionChanged="OnItemSelectionChanged"/> ItemSelectionChanged="OnItemSelectionChanged"/>
<TextBlock x:Name="MyText" HorizontalAlignment="Left" Margin="318,246,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/> <TextBlock x:Name="MyText" HorizontalAlignment="Left" Margin="318,246,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
<ListBox x:Name="MyListBox" HorizontalAlignment="Left" Margin="492,125,0,0" VerticalAlignment="Top"/> <ListBox x:Name="MyListBox" HorizontalAlignment="Left" Margin="492,125,0,0" VerticalAlignment="Top"/>
<Button x:Name="WeighingButton1" Click="WeighingButton1_Click" Height="30" Content="Aktuelles Gewicht" Width="110" Margin="515,246,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Button x:Name="WeighingButton2" Click="WeighingButton2_Click" Height="30" Content="Wiegen" Width="110" Margin="515,285,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<TextBlock x:Name="Output" Height="20" Width="200" Margin="470,329,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</Grid> </Grid>
</Window> </Window>

View File

@ -1,3 +1,4 @@
using System;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using Xceed.Wpf.Toolkit.Primitives; using Xceed.Wpf.Toolkit.Primitives;
@ -13,5 +14,25 @@ namespace Elwig.Windows {
private void OnItemSelectionChanged(object sender, ItemSelectionChangedEventArgs e) { private void OnItemSelectionChanged(object sender, ItemSelectionChangedEventArgs e) {
MyText.Text = string.Join(", ", MyComboBox.SelectedItems.Cast<string>()); MyText.Text = string.Join(", ", MyComboBox.SelectedItems.Cast<string>());
} }
private async void WeighingButton1_Click(object sender, RoutedEventArgs evt) {
try {
var res = await App.Scales[0].GetCurrentWeight();
Output.Text = res.ToString();
} catch (Exception e) {
MessageBox.Show($"Beim Wiegen ist ein Fehler aufgetreten:\n\n{e.Message}", "Waagenfehler",
MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private async void WeighingButton2_Click(object sender, RoutedEventArgs evt) {
try {
var res = await App.Scales[0].Weigh();
Output.Text = res.ToString();
} catch (Exception e) {
MessageBox.Show($"Beim Wiegen ist ein Fehler aufgetreten:\n\n{e.Message}", "Waagenfehler",
MessageBoxButton.OK, MessageBoxImage.Error);
}
}
} }
} }