From de47da1c01b9667216c16554e6df4f08f26f6355 Mon Sep 17 00:00:00 2001 From: Jerker Dahlblom Date: Sun, 15 Oct 2023 15:04:16 +0300 Subject: [PATCH] Various small fixes --- .../DCSInsight/Communication/TCPClientHandler.cs | 2 +- src/client/DCSInsight/Misc/ResultComparator.cs | 5 +---- .../DCSInsight/Windows/WindowRangeTest.xaml.cs | 13 +++++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/client/DCSInsight/Communication/TCPClientHandler.cs b/src/client/DCSInsight/Communication/TCPClientHandler.cs index f48739e..dff1a1c 100644 --- a/src/client/DCSInsight/Communication/TCPClientHandler.cs +++ b/src/client/DCSInsight/Communication/TCPClientHandler.cs @@ -25,7 +25,7 @@ internal class TCPClientHandler : IDisposable, ICommandListener private Thread _clientThread; private bool _isRunning; private readonly string _host; - private string _port; + private readonly string _port; private bool _apiListReceived = false; private int _metaDataPollCounter; public bool LogJSON { get; set; } diff --git a/src/client/DCSInsight/Misc/ResultComparator.cs b/src/client/DCSInsight/Misc/ResultComparator.cs index b1da4fa..b294906 100644 --- a/src/client/DCSInsight/Misc/ResultComparator.cs +++ b/src/client/DCSInsight/Misc/ResultComparator.cs @@ -8,8 +8,7 @@ namespace DCSInsight.Misc internal class ResultComparator { private readonly DCSAPI _dcsApi; - private bool _resultHasChanged; - private object _lockObject = new(); + private readonly object _lockObject = new(); public ResultComparator(DCSAPI dcsApi) { @@ -61,7 +60,6 @@ public bool SetResult(DCSAPI dcsApi) if (dcsApi.Result != _dcsApi.Result) { _dcsApi.Result = dcsApi.Result; - _resultHasChanged = true; return true; } } @@ -71,7 +69,6 @@ public bool SetResult(DCSAPI dcsApi) Common.ShowErrorMessageBox(ex); } - _resultHasChanged = false; return false; } diff --git a/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs b/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs index ac93242..0a89b98 100644 --- a/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs +++ b/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs @@ -32,11 +32,11 @@ public partial class WindowRangeTest : Window, IErrorListener, IConnectionListen private bool _stopRunning; private bool _doLoop; private bool _showChangesOnly; - private static readonly AutoResetEvent AutoResetEvent1 = new AutoResetEvent(false); + private static readonly AutoResetEvent AutoResetEvent1 = new(false); private Thread _thread; - private int _threadLoopSleep = 50; + private readonly int _threadLoopSleep = 50; private readonly List _resultComparatorList = new(); - private object _lockObject = new(); + private readonly object _lockObject = new(); public WindowRangeTest(List dcsAPIList) { @@ -137,7 +137,6 @@ public void DataReceived(DataEventArgs args) var hasChanged = _resultComparatorList.First(o => o.IsMatch(args.DCSApi)).SetResult(args.DCSApi); - Debug.WriteLine($"Has Changed = {hasChanged}"); if (_showChangesOnly && !hasChanged) { AutoResetEvent1.Set(); @@ -351,8 +350,10 @@ private void BuildUI() foreach (var dcsAPIParameterType in _dcsAPI.Parameters) { - var stackPanel = new StackPanel(); - stackPanel.Orientation = Orientation.Horizontal; + var stackPanel = new StackPanel + { + Orientation = Orientation.Horizontal + }; var label = new Label {