Update TestWindow
This commit is contained in:
@ -13,5 +13,8 @@
|
||||
ItemSelectionChanged="OnItemSelectionChanged"/>
|
||||
<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"/>
|
||||
<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>
|
||||
</Window>
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Xceed.Wpf.Toolkit.Primitives;
|
||||
@ -13,5 +14,25 @@ namespace Elwig.Windows {
|
||||
private void OnItemSelectionChanged(object sender, ItemSelectionChangedEventArgs e) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user