From ad76d09438f33e96ff2c96d307514eb0e4c70fea Mon Sep 17 00:00:00 2001 From: Jonas Arnold Date: Sun, 18 Dec 2022 15:34:37 +0100 Subject: [PATCH] implemented IndependentRobotConfigurator to adopt robots via UDP, updated UI to support IndependentRobotConfigurator commands --- ADIS_Csharp/RobotClientWpf/MainWindow.xaml | 2 +- ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs | 13 +++- .../RobotClientWpf/Views/ConfigView.xaml | 28 ++++++- .../RobotClientWpf/Views/ConfigView.xaml.cs | 58 ++++++++++++++- .../RobotClientWpf/Views/MainView.xaml | 2 +- .../RobotClientWpf/Views/MainView.xaml.cs | 16 ++-- .../RobotLib/IndependentRobotConfigurator.cs | 73 +++++++++++++++++++ 7 files changed, 176 insertions(+), 16 deletions(-) create mode 100644 ADIS_Csharp/RobotLib/IndependentRobotConfigurator.cs diff --git a/ADIS_Csharp/RobotClientWpf/MainWindow.xaml b/ADIS_Csharp/RobotClientWpf/MainWindow.xaml index 3ba0a62..8070122 100644 --- a/ADIS_Csharp/RobotClientWpf/MainWindow.xaml +++ b/ADIS_Csharp/RobotClientWpf/MainWindow.xaml @@ -7,7 +7,7 @@ xmlns:views="clr-namespace:RobotClientWpf.Views" xmlns:dj="clr-namespace:DJ;assembly=NLogViewer" mc:Ignorable="d" FontSize="15" - Title="Challenge UI" Height="700" Width="1200" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Closing="Window_Closing" Loaded="Window_Loaded"> + Title="Challenge UI" Height="700" Width="1200" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Closing="Window_Closing" Loaded="Window_Loaded" KeyDown="Window_KeyDown"> diff --git a/ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs b/ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs index 340fa81..8645934 100644 --- a/ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs +++ b/ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs @@ -20,7 +20,7 @@ namespace RobotClientWpf private static readonly string mutexName = "00489402-435c-426e-9d11-9a2b839b39b6"; // random guid private static readonly NLog.Logger log = NLog.LogManager.GetCurrentClassLogger(); - private ChallengeFactory? challenge; + private ChallengeFactory challenge; private bool manualDisconnect; public MainWindow() @@ -43,9 +43,9 @@ namespace RobotClientWpf // start window InitializeComponent(); this.challenge = new ChallengeFactory(); - // inform other views about challenge factory - this.mainView.SetChallengeFactory(this.challenge); - this.configView.SetChallengeFactory(this.challenge); + // inform other views about challenge factory and this view + this.mainView.InitializeChildView(this.challenge, this); + this.configView.InitializeChildView(this.challenge, this); // subscribe to events this.challenge.PublisherSubscriber.ConnectionStateChanged += PublisherSubscriber_ConnectionStateChanged; } @@ -173,5 +173,10 @@ namespace RobotClientWpf { this.tbIp.Text = Settings.Default.MqttBrokerIp; } + + private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + this.mainView.HandleKeyDownEvent(sender, e); + } } } diff --git a/ADIS_Csharp/RobotClientWpf/Views/ConfigView.xaml b/ADIS_Csharp/RobotClientWpf/Views/ConfigView.xaml index 6261948..fc988b3 100644 --- a/ADIS_Csharp/RobotClientWpf/Views/ConfigView.xaml +++ b/ADIS_Csharp/RobotClientWpf/Views/ConfigView.xaml @@ -5,12 +5,13 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:RobotClientWpf.Views" mc:Ignorable="d" - d:DesignHeight="450" d:DesignWidth="800"> + d:DesignHeight="430" d:DesignWidth="1200" FontSize="15"> + @@ -50,13 +51,12 @@ - + - @@ -65,9 +65,29 @@