From 55883a07e91925bbab54b54c503ba0e219fdbfc1 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Sun, 23 Mar 2025 12:16:53 -0400 Subject: [PATCH] pin the max number of calls for the call history to 200; fix bad handling of dark mode for call history window; move channel background color state further down to catch late entry calls; --- dvmconsole/CallHistoryWindow.xaml | 5 +++-- dvmconsole/CallHistoryWindow.xaml.cs | 27 ++++++++++++++++++++++++++- dvmconsole/MainWindow.P25.cs | 11 ++++++----- dvmconsole/MainWindow.xaml.cs | 3 ++- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/dvmconsole/CallHistoryWindow.xaml b/dvmconsole/CallHistoryWindow.xaml index 59bfedb..2e9052f 100644 --- a/dvmconsole/CallHistoryWindow.xaml +++ b/dvmconsole/CallHistoryWindow.xaml @@ -14,13 +14,14 @@ - + - + diff --git a/dvmconsole/CallHistoryWindow.xaml.cs b/dvmconsole/CallHistoryWindow.xaml.cs index c14e1e2..7569995 100644 --- a/dvmconsole/CallHistoryWindow.xaml.cs +++ b/dvmconsole/CallHistoryWindow.xaml.cs @@ -8,6 +8,7 @@ * @license AGPLv3 License (https://opensource.org/licenses/AGPL-3.0) * * Copyright (C) 2025 Caleb, K4PHP +* Copyright (C) 2025 Bryan Biedenkapp, N2PLL * */ @@ -24,6 +25,8 @@ namespace dvmconsole { public static readonly DependencyProperty BackgroundColorProperty = DependencyProperty.Register(nameof(BackgroundColor), typeof(Brush), typeof(CallEntry), new PropertyMetadata(Brushes.Transparent)); + public static readonly DependencyProperty ForegroundColorProperty = + DependencyProperty.Register(nameof(ForegroundColor), typeof(Brush), typeof(CallEntry), new PropertyMetadata(Brushes.White)); /* ** Properties @@ -55,6 +58,15 @@ namespace dvmconsole get { return (Brush)GetValue(BackgroundColorProperty); } set { SetValue(BackgroundColorProperty, value); } } + + /// + /// Foreground color for call entry. + /// + public Brush ForegroundColor + { + get { return (Brush)GetValue(ForegroundColorProperty); } + set { SetValue(ForegroundColorProperty, value); } + } } // public class CallEntry : DependencyObject /// @@ -89,6 +101,9 @@ namespace dvmconsole /// public partial class CallHistoryWindow : Window { + private const int MAX_CALL_HISTORY = 200; + private SettingsManager settingsManager; + /* ** Properties */ @@ -105,9 +120,10 @@ namespace dvmconsole /// /// Initializes a new instance of the class. /// - public CallHistoryWindow() + public CallHistoryWindow(SettingsManager settingsManager) { InitializeComponent(); + this.settingsManager = settingsManager; ViewModel = new CallHistoryViewModel(); DataContext = ViewModel; } @@ -132,6 +148,9 @@ namespace dvmconsole { Dispatcher.Invoke(() => { + if (ViewModel.CallHistory.Count == MAX_CALL_HISTORY) + ViewModel.CallHistory.RemoveAt(MAX_CALL_HISTORY - 1); + ViewModel.CallHistory.Insert(0, new CallEntry { Channel = channel, @@ -155,6 +174,8 @@ namespace dvmconsole { foreach (var entry in ViewModel.CallHistory.Where(c => c.Channel == channel && c.SrcId == srcId)) { + entry.ForegroundColor = Brushes.Black; + if (!encrypted) entry.BackgroundColor = Brushes.LightGreen; else @@ -174,6 +195,10 @@ namespace dvmconsole { foreach (var entry in ViewModel.CallHistory.Where(c => c.Channel == channel && c.SrcId == srcId)) { + if (settingsManager.DarkMode) + entry.ForegroundColor = Brushes.White; + else + entry.ForegroundColor = Brushes.Black; entry.BackgroundColor = Brushes.Transparent; } }); diff --git a/dvmconsole/MainWindow.P25.cs b/dvmconsole/MainWindow.P25.cs index 4fa3bd2..baa01db 100644 --- a/dvmconsole/MainWindow.P25.cs +++ b/dvmconsole/MainWindow.P25.cs @@ -514,12 +514,7 @@ namespace dvmconsole channel.LastSrcId = "Last: " + alias; if (channel.algId != P25Defines.P25_ALGO_UNENCRYPT) - { - channel.Background = ChannelBox.ORANGE_GRADIENT; Log.WriteLine($"({system.Name}) P25D: Traffic *CALL ENC PARMS * PEER {e.PeerId} SRC_ID {e.SrcId} TGID {e.DstId} ALGID {channel.algId} KID {channel.kId} [STREAM ID {e.StreamId}]"); - } - else - channel.Background = ChannelBox.GREEN_GRADIENT; } // is the call over? @@ -534,6 +529,12 @@ namespace dvmconsole return; } + // do background updates here -- this catches late entry + if (channel.algId != P25Defines.P25_ALGO_UNENCRYPT) + channel.Background = ChannelBox.ORANGE_GRADIENT; + else + channel.Background = ChannelBox.GREEN_GRADIENT; + byte[] newMI = new byte[P25Defines.P25_MI_LENGTH]; int count = 0; diff --git a/dvmconsole/MainWindow.xaml.cs b/dvmconsole/MainWindow.xaml.cs index 5f91eea..dab1a22 100644 --- a/dvmconsole/MainWindow.xaml.cs +++ b/dvmconsole/MainWindow.xaml.cs @@ -108,7 +108,7 @@ namespace dvmconsole private ChannelBox playbackChannelBox; - CallHistoryWindow callHistoryWindow = new CallHistoryWindow(); + CallHistoryWindow callHistoryWindow; public static string PLAYBACKTG = "LOCPLAYBACK"; public static string PLAYBACKSYS = "Local Playback"; @@ -150,6 +150,7 @@ namespace dvmconsole DisableControls(); settingsManager.LoadSettings(); + callHistoryWindow = new CallHistoryWindow(settingsManager); selectedChannelsManager = new SelectedChannelsManager(); flashingManager = new FlashingBackgroundManager(null, channelsCanvas, null, this);