From 630f504785276ff4bf9a1f759656e04b03a186ae Mon Sep 17 00:00:00 2001 From: Jonas Arnold Date: Thu, 22 Dec 2022 18:31:21 +0100 Subject: [PATCH] added status of mobile robot in UI implemented battery state for both robots in RobotLib --- .../Utilities/UIAccessHelpers.cs | 16 ++++++++ .../RobotClientWpf/Views/ConfigView.xaml | 2 +- .../RobotClientWpf/Views/ConfigView.xaml.cs | 8 ++-- .../RobotClientWpf/Views/MainView.xaml | 19 ++++++--- .../RobotClientWpf/Views/MainView.xaml.cs | 17 +++++++- ADIS_Csharp/RobotLib/Battery/DevBattery.cs | 40 +++++++++++++++++-- .../Communication/MqttPublisherSubscriber.cs | 2 +- ADIS_Csharp/RobotLib/Robot.cs | 20 +++++----- 8 files changed, 100 insertions(+), 24 deletions(-) diff --git a/ADIS_Csharp/RobotClientWpf/Utilities/UIAccessHelpers.cs b/ADIS_Csharp/RobotClientWpf/Utilities/UIAccessHelpers.cs index b43aa37..3ab21d9 100644 --- a/ADIS_Csharp/RobotClientWpf/Utilities/UIAccessHelpers.cs +++ b/ADIS_Csharp/RobotClientWpf/Utilities/UIAccessHelpers.cs @@ -3,6 +3,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Media; +using System.Windows.Shapes; namespace RobotClientWpf.Utilities { @@ -99,5 +100,20 @@ namespace RobotClientWpf.Utilities textBlock.Foreground = foregroundColor; } } + + public static void SetShapeVisibility(Shape shape, bool visible) + { + if (!Application.Current.Dispatcher.CheckAccess()) + { + Application.Current.Dispatcher.BeginInvoke(new Action(() => + { + SetShapeVisibility(shape, visible); + })); + } + else + { + shape.Opacity = visible?100:0; + } + } } } diff --git a/ADIS_Csharp/RobotClientWpf/Views/ConfigView.xaml b/ADIS_Csharp/RobotClientWpf/Views/ConfigView.xaml index fc988b3..f5c20be 100644 --- a/ADIS_Csharp/RobotClientWpf/Views/ConfigView.xaml +++ b/ADIS_Csharp/RobotClientWpf/Views/ConfigView.xaml @@ -76,7 +76,7 @@