From 4c0e3b665e93f1ea27d6f7a66f1534d5a13ca373 Mon Sep 17 00:00:00 2001 From: firealarmss Date: Sat, 1 Mar 2025 13:04:16 -0600 Subject: [PATCH] update console UI; send a new aff if not affed when getting an aff update --- WhackerLinkConsoleV2/ChannelBox.xaml | 48 +++++++++++++++++------ WhackerLinkConsoleV2/ChannelBox.xaml.cs | 28 ++++++++++--- WhackerLinkConsoleV2/MainWindow.xaml.cs | 38 ++++++++++++++++-- WhackerLinkConsoleV2/SystemStatusBox.xaml | 4 +- 4 files changed, 96 insertions(+), 22 deletions(-) diff --git a/WhackerLinkConsoleV2/ChannelBox.xaml b/WhackerLinkConsoleV2/ChannelBox.xaml index 07bcf7f..56e9b3f 100644 --- a/WhackerLinkConsoleV2/ChannelBox.xaml +++ b/WhackerLinkConsoleV2/ChannelBox.xaml @@ -1,7 +1,30 @@  + Width="220" Height="96" Background="DodgerBlue"> + + + + @@ -16,30 +39,31 @@ - - + - + ValueChanged="VolumeSlider_ValueChanged" Margin="5,1,5,0"/> - - - + - + \ No newline at end of file diff --git a/WhackerLinkConsoleV2/ChannelBox.xaml.cs b/WhackerLinkConsoleV2/ChannelBox.xaml.cs index 2b245bd..b337bf0 100644 --- a/WhackerLinkConsoleV2/ChannelBox.xaml.cs +++ b/WhackerLinkConsoleV2/ChannelBox.xaml.cs @@ -159,7 +159,7 @@ namespace WhackerLinkConsoleV2.Controls if (IsEditMode) return; IsSelected = !IsSelected; - Background = IsSelected ? Brushes.Blue : Brushes.Gray; + Background = IsSelected ? (Brush)new BrushConverter().ConvertFrom("#FF1E90FF") : Brushes.Gray; if (IsSelected) { @@ -178,7 +178,7 @@ namespace WhackerLinkConsoleV2.Controls if (PttState) PttButton.Background = new SolidColorBrush(Colors.Red); else - PttButton.Background = new SolidColorBrush(Colors.Green); + PttButton.Background = (Brush)new BrushConverter().ConvertFrom("#FF2870AF"); } private void UpdatePageColor() @@ -188,7 +188,7 @@ namespace WhackerLinkConsoleV2.Controls if (PageState) PageSelectButton.Background = new SolidColorBrush(Colors.Orange); else - PageSelectButton.Background = new SolidColorBrush(Colors.Green); + PageSelectButton.Background = (Brush)new BrushConverter().ConvertFrom("#FF2870AF"); } private void UpdateHoldColor() @@ -198,12 +198,16 @@ namespace WhackerLinkConsoleV2.Controls if (HoldState) ChannelMarkerBtn.Background = new SolidColorBrush(Colors.Orange); else - ChannelMarkerBtn.Background = new SolidColorBrush(Colors.Green); + ChannelMarkerBtn.Background = (Brush)new BrushConverter().ConvertFrom("#FF2870AF"); } private void UpdateBackground() { - Background = IsSelected ? Brushes.DodgerBlue : Brushes.DarkGray; + Background = IsSelected ? (Brush)new BrushConverter().ConvertFrom("#FF1E90FF") : Brushes.DarkGray; + + ChannelMarkerBtn.Background = IsSelected ? (Brush)new BrushConverter().ConvertFrom("#FF2870AF") : new SolidColorBrush(Colors.Gray); + PageSelectButton.Background = IsSelected ? (Brush)new BrushConverter().ConvertFrom("#FF2870AF") : new SolidColorBrush(Colors.Gray); + PttButton.Background = IsSelected ? (Brush)new BrushConverter().ConvertFrom("#FF2870AF") : new SolidColorBrush(Colors.Gray); } private void PTTButton_Click(object sender, RoutedEventArgs e) @@ -239,5 +243,19 @@ namespace WhackerLinkConsoleV2.Controls HoldState = !HoldState; HoldChannelButtonClicked.Invoke(sender, this); } + + private void PttButton_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) + { + if (!IsSelected || PttState) return; + + ((Button)sender).Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF3FA0FF")); + } + + private void PttButton_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) + { + if (!IsSelected || PttState) return; + + ((Button)sender).Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF2870AF")); + } } } diff --git a/WhackerLinkConsoleV2/MainWindow.xaml.cs b/WhackerLinkConsoleV2/MainWindow.xaml.cs index 1afc129..4a96d3a 100644 --- a/WhackerLinkConsoleV2/MainWindow.xaml.cs +++ b/WhackerLinkConsoleV2/MainWindow.xaml.cs @@ -160,11 +160,11 @@ namespace WhackerLinkConsoleV2 ChannelsCanvas.Children.Add(systemStatusBox); - offsetX += 220; - if (offsetX + 200 > ChannelsCanvas.ActualWidth) + offsetX += 225; + if (offsetX + 220 > ChannelsCanvas.ActualWidth) { offsetX = 20; - offsetY += 140; + offsetY += 106; } _webSocketManager.AddWebSocketHandler(system.Name); @@ -174,6 +174,7 @@ namespace WhackerLinkConsoleV2 handler.OnVoiceChannelRelease += HandleVoiceRelease; handler.OnEmergencyAlarmResponse += HandleEmergencyAlarmResponse; handler.OnAudioData += HandleReceivedAudio; + handler.OnAffiliationUpdate += HandleAffiliationUpdate; handler.OnUnitRegistrationResponse += (response) => { @@ -655,6 +656,37 @@ namespace WhackerLinkConsoleV2 _audioManager.AddTalkgroupStream(talkgroupId, audioPacket.Data); } + private void HandleAffiliationUpdate(AFF_UPDATE affUpdate) + { + foreach (ChannelBox channel in _selectedChannelsManager.GetSelectedChannels()) + { + Codeplug.System system = Codeplug.GetSystemForChannel(channel.ChannelName); + Codeplug.Channel cpgChannel = Codeplug.GetChannelByName(channel.ChannelName); + IPeer handler = _webSocketManager.GetWebSocketHandler(system.Name); + + bool ridExists = affUpdate.Affiliations.Any(aff => aff.SrcId == system.Rid); + bool tgidExists = affUpdate.Affiliations.Any(aff => aff.DstId == cpgChannel.Tgid); + + if (ridExists && tgidExists) + { + Console.WriteLine("rid aff'ed"); + } + else + { + Console.WriteLine("rid not aff'ed"); + + GRP_AFF_REQ affReq = new GRP_AFF_REQ + { + SrcId = system.Rid, + DstId = cpgChannel.Tgid, + Site = system.Site + }; + + handler.SendMessage(affReq.GetData()); + } + } + } + private void HandleVoiceRelease(GRP_VCH_RLS response) { foreach (ChannelBox channel in _selectedChannelsManager.GetSelectedChannels()) diff --git a/WhackerLinkConsoleV2/SystemStatusBox.xaml b/WhackerLinkConsoleV2/SystemStatusBox.xaml index b9d5a70..f707da3 100644 --- a/WhackerLinkConsoleV2/SystemStatusBox.xaml +++ b/WhackerLinkConsoleV2/SystemStatusBox.xaml @@ -1,7 +1,7 @@  + Width="220" Height="96" Background="#334455" BorderBrush="Gray"> @@ -10,4 +10,4 @@ - + \ No newline at end of file