update console UI; send a new aff if not affed when getting an aff update

pull/1/head
firealarmss 11 months ago
parent c9981b1dd5
commit 4c0e3b665e

@ -1,7 +1,30 @@
<UserControl x:Class="WhackerLinkConsoleV2.Controls.ChannelBox" <UserControl x:Class="WhackerLinkConsoleV2.Controls.ChannelBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="220" Height="96" Background="Blue"> Width="220" Height="96" Background="DodgerBlue">
<UserControl.Resources>
<Style TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<!-- Hover Effect -->
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#2980b9"/>
<!-- Hover Color -->
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Grid Margin="5"> <Grid Margin="5">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="41"/> <ColumnDefinition Width="41"/>
@ -16,30 +39,31 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Left Side PTT Button --> <!-- Left Side PTT Button -->
<Button Background="Green" Name="PttButton" Click="PTTButton_Click" Grid.RowSpan="3" HorizontalAlignment="Left" Width="52" Margin="-7,-5,0,-5" Grid.ColumnSpan="2"> <Button MouseEnter="PttButton_MouseEnter" MouseLeave="PttButton_MouseLeave" Background="#FF2870AF" Name="PttButton" Click="PTTButton_Click" Grid.RowSpan="3" HorizontalAlignment="Left" Width="52" Margin="-7,-5,0,-5" Grid.ColumnSpan="2" BorderThickness="0,0,0,0">
<Image Source="pack://application:,,,/WhackerLinkConsoleV2;component/Assets/instantptt.png" Width="24" Height="45"/> <Image Source="pack://application:,,,/WhackerLinkConsoleV2;component/Assets/instantptt.png" Width="52" Height="90"/>
</Button> </Button>
<!-- Main Info Section --> <!-- Main Info Section -->
<StackPanel Grid.Column="1" HorizontalAlignment="Left" Width="129" Margin="8,-4,0,5" Grid.RowSpan="2"> <StackPanel Grid.Column="1" HorizontalAlignment="Left" Width="129" Margin="8,-4,0,39" Grid.RowSpan="3">
<TextBlock Text="{Binding ChannelName}" FontWeight="Bold" Foreground="White" FontSize="15"/> <TextBlock Text="{Binding ChannelName}" FontWeight="Bold" Foreground="White" FontSize="15"/>
<TextBlock Text="{Binding LastSrcId}" Foreground="LightGray" FontSize="12"/> <TextBlock Text="{Binding LastSrcId}" Foreground="LightGray" FontSize="12"/>
<TextBlock Text="{Binding SystemName}" Foreground="LightGray" FontSize="12"/> <TextBlock Text="{Binding SystemName}" Foreground="LightGray" FontSize="12"/>
</StackPanel> </StackPanel>
<!-- Volume Slider --> <!-- Volume Slider -->
<Slider Grid.Column="2" Grid.RowSpan="2" Minimum="0" Maximum="4" Value="{Binding Volume, Mode=TwoWay}" <Slider Grid.Column="2" Grid.RowSpan="3" Minimum="0" Maximum="4" Value="{Binding Volume, Mode=TwoWay}"
Orientation="Vertical" Height="80" VerticalAlignment="Top" Name="VolumeSlider" Orientation="Vertical" Height="80" VerticalAlignment="Top" Name="VolumeSlider"
ValueChanged="VolumeSlider_ValueChanged" Margin="5,3,5,0" Grid.Row="1"/> ValueChanged="VolumeSlider_ValueChanged" Margin="5,1,5,0"/>
<!-- Bottom Buttons --> <!-- Bottom Buttons -->
<StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" Margin="8,0,71,0"> <StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" Margin="5,5,49,-5">
<Button Width="31" Height="33" Background="SteelBlue" x:Name="PageSelectButton" Click="PageSelectButton_Click"> <Button Width="40" Height="40" Background="#FF2870AF" x:Name="PageSelectButton" Click="PageSelectButton_Click" BorderThickness="0,0,0,0">
<Image Source="pack://application:,,,/WhackerLinkConsoleV2;component/Assets/pageselect.png" Width="24" Height="24"/> <Image Source="pack://application:,,,/WhackerLinkConsoleV2;component/Assets/pageselect.png" Width="24" Height="24"/>
</Button> </Button>
<Button Width="28" Height="33" Background="SteelBlue" x:Name="ChannelMarkerBtn" Click="ChannelMarkerBtn_Click"> <Button Width="40" Height="40" Background="#FF2870AF" x:Name="ChannelMarkerBtn" Click="ChannelMarkerBtn_Click" BorderThickness="0,0,0,0" Margin="1,0,0,0">
<Image Source="pack://application:,,,/WhackerLinkConsoleV2;component/Assets/channelmarker.png" Width="24" Height="24"/> <Image Source="pack://application:,,,/WhackerLinkConsoleV2;component/Assets/channelmarker.png" Width="24" Height="24"/>
</Button> </Button>
</StackPanel> </StackPanel>
</Grid> </Grid>
</UserControl> </UserControl>

@ -159,7 +159,7 @@ namespace WhackerLinkConsoleV2.Controls
if (IsEditMode) return; if (IsEditMode) return;
IsSelected = !IsSelected; IsSelected = !IsSelected;
Background = IsSelected ? Brushes.Blue : Brushes.Gray; Background = IsSelected ? (Brush)new BrushConverter().ConvertFrom("#FF1E90FF") : Brushes.Gray;
if (IsSelected) if (IsSelected)
{ {
@ -178,7 +178,7 @@ namespace WhackerLinkConsoleV2.Controls
if (PttState) if (PttState)
PttButton.Background = new SolidColorBrush(Colors.Red); PttButton.Background = new SolidColorBrush(Colors.Red);
else else
PttButton.Background = new SolidColorBrush(Colors.Green); PttButton.Background = (Brush)new BrushConverter().ConvertFrom("#FF2870AF");
} }
private void UpdatePageColor() private void UpdatePageColor()
@ -188,7 +188,7 @@ namespace WhackerLinkConsoleV2.Controls
if (PageState) if (PageState)
PageSelectButton.Background = new SolidColorBrush(Colors.Orange); PageSelectButton.Background = new SolidColorBrush(Colors.Orange);
else else
PageSelectButton.Background = new SolidColorBrush(Colors.Green); PageSelectButton.Background = (Brush)new BrushConverter().ConvertFrom("#FF2870AF");
} }
private void UpdateHoldColor() private void UpdateHoldColor()
@ -198,12 +198,16 @@ namespace WhackerLinkConsoleV2.Controls
if (HoldState) if (HoldState)
ChannelMarkerBtn.Background = new SolidColorBrush(Colors.Orange); ChannelMarkerBtn.Background = new SolidColorBrush(Colors.Orange);
else else
ChannelMarkerBtn.Background = new SolidColorBrush(Colors.Green); ChannelMarkerBtn.Background = (Brush)new BrushConverter().ConvertFrom("#FF2870AF");
} }
private void UpdateBackground() 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) private void PTTButton_Click(object sender, RoutedEventArgs e)
@ -239,5 +243,19 @@ namespace WhackerLinkConsoleV2.Controls
HoldState = !HoldState; HoldState = !HoldState;
HoldChannelButtonClicked.Invoke(sender, this); 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"));
}
} }
} }

@ -160,11 +160,11 @@ namespace WhackerLinkConsoleV2
ChannelsCanvas.Children.Add(systemStatusBox); ChannelsCanvas.Children.Add(systemStatusBox);
offsetX += 220; offsetX += 225;
if (offsetX + 200 > ChannelsCanvas.ActualWidth) if (offsetX + 220 > ChannelsCanvas.ActualWidth)
{ {
offsetX = 20; offsetX = 20;
offsetY += 140; offsetY += 106;
} }
_webSocketManager.AddWebSocketHandler(system.Name); _webSocketManager.AddWebSocketHandler(system.Name);
@ -174,6 +174,7 @@ namespace WhackerLinkConsoleV2
handler.OnVoiceChannelRelease += HandleVoiceRelease; handler.OnVoiceChannelRelease += HandleVoiceRelease;
handler.OnEmergencyAlarmResponse += HandleEmergencyAlarmResponse; handler.OnEmergencyAlarmResponse += HandleEmergencyAlarmResponse;
handler.OnAudioData += HandleReceivedAudio; handler.OnAudioData += HandleReceivedAudio;
handler.OnAffiliationUpdate += HandleAffiliationUpdate;
handler.OnUnitRegistrationResponse += (response) => handler.OnUnitRegistrationResponse += (response) =>
{ {
@ -655,6 +656,37 @@ namespace WhackerLinkConsoleV2
_audioManager.AddTalkgroupStream(talkgroupId, audioPacket.Data); _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) private void HandleVoiceRelease(GRP_VCH_RLS response)
{ {
foreach (ChannelBox channel in _selectedChannelsManager.GetSelectedChannels()) foreach (ChannelBox channel in _selectedChannelsManager.GetSelectedChannels())

@ -1,7 +1,7 @@
<UserControl x:Class="WhackerLinkConsoleV2.Controls.SystemStatusBox" <UserControl x:Class="WhackerLinkConsoleV2.Controls.SystemStatusBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="200" Height="120" Background="#334455" BorderBrush="Gray" BorderThickness="2"> Width="220" Height="96" Background="#334455" BorderBrush="Gray">
<Border Background="{Binding Background, RelativeSource={RelativeSource AncestorType=UserControl}}" CornerRadius="5" Padding="10"> <Border Background="{Binding Background, RelativeSource={RelativeSource AncestorType=UserControl}}" CornerRadius="5" Padding="10">
<StackPanel> <StackPanel>
<TextBlock Text="{Binding SystemName}" FontWeight="Bold" Foreground="White" FontSize="14"/> <TextBlock Text="{Binding SystemName}" FontWeight="Bold" Foreground="White" FontSize="14"/>
@ -10,4 +10,4 @@
<TextBlock Text="{Binding ConnectionState}" Foreground="White" FontSize="12"/> <TextBlock Text="{Binding ConnectionState}" Foreground="White" FontSize="12"/>
</StackPanel> </StackPanel>
</Border> </Border>
</UserControl> </UserControl>
Loading…
Cancel
Save

Powered by TurnKey Linux.