From f7720ffc677c659aaabfd1191784cb05c4778454 Mon Sep 17 00:00:00 2001 From: Jonas Arnold Date: Thu, 15 Dec 2022 16:38:06 +0100 Subject: [PATCH] added logger to WPF UI --- ADIS_Csharp/RobotClientWpf/MainWindow.xaml | 30 ++++++++++++++-- ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs | 7 +++- ADIS_Csharp/RobotClientWpf/NLog.config | 35 +++++++------------ .../RobotClientWpf/RobotClientWpf.csproj | 10 ++++++ 4 files changed, 57 insertions(+), 25 deletions(-) diff --git a/ADIS_Csharp/RobotClientWpf/MainWindow.xaml b/ADIS_Csharp/RobotClientWpf/MainWindow.xaml index e2a3025..f301bf1 100644 --- a/ADIS_Csharp/RobotClientWpf/MainWindow.xaml +++ b/ADIS_Csharp/RobotClientWpf/MainWindow.xaml @@ -5,17 +5,19 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:RobotClientWpf" 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"> + - + 192.168.156.156 @@ -46,7 +48,31 @@ - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs b/ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs index 231c149..d5d2221 100644 --- a/ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs +++ b/ADIS_Csharp/RobotClientWpf/MainWindow.xaml.cs @@ -13,6 +13,7 @@ namespace RobotClientWpf /// public partial class MainWindow : Window { + private static readonly NLog.Logger log = NLog.LogManager.GetCurrentClassLogger(); private ChallengeFactory challenge; private bool manualDisconnect; @@ -27,7 +28,11 @@ namespace RobotClientWpf { if(e == false) { - if (manualDisconnect == true) manualDisconnect = false; return; + if (manualDisconnect == true) + { + manualDisconnect = false; + return; + } this.DisplayBottomMessage(MessageSeverity.Error, "Connection to MQTT broker lost."); this.SetIpFieldsState(true, true, "Connect"); } diff --git a/ADIS_Csharp/RobotClientWpf/NLog.config b/ADIS_Csharp/RobotClientWpf/NLog.config index 7da0939..7483624 100644 --- a/ADIS_Csharp/RobotClientWpf/NLog.config +++ b/ADIS_Csharp/RobotClientWpf/NLog.config @@ -1,27 +1,18 @@  + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + internalLogFile="c:\nlog-internal.txt" internalLogLevel="Trace"> + + + - - - - - - - + + + + + + \ No newline at end of file diff --git a/ADIS_Csharp/RobotClientWpf/RobotClientWpf.csproj b/ADIS_Csharp/RobotClientWpf/RobotClientWpf.csproj index fed4496..8eb45f0 100644 --- a/ADIS_Csharp/RobotClientWpf/RobotClientWpf.csproj +++ b/ADIS_Csharp/RobotClientWpf/RobotClientWpf.csproj @@ -12,6 +12,10 @@ + + + + @@ -25,4 +29,10 @@ + + + PreserveNewest + + +