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"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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.ColumnDefinitions>
<ColumnDefinition Width="41"/>
@ -16,30 +39,31 @@
</Grid.RowDefinitions>
<!-- 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">
<Image Source="pack://application:,,,/WhackerLinkConsoleV2;component/Assets/instantptt.png" Width="24" Height="45"/>
<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="52" Height="90"/>
</Button>
<!-- 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 LastSrcId}" Foreground="LightGray" FontSize="12"/>
<TextBlock Text="{Binding SystemName}" Foreground="LightGray" FontSize="12"/>
</StackPanel>
<!-- 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"
ValueChanged="VolumeSlider_ValueChanged" Margin="5,3,5,0" Grid.Row="1"/>
ValueChanged="VolumeSlider_ValueChanged" Margin="5,1,5,0"/>
<!-- Bottom Buttons -->
<StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" Margin="8,0,71,0">
<Button Width="31" Height="33" Background="SteelBlue" x:Name="PageSelectButton" Click="PageSelectButton_Click">
<StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" Margin="5,5,49,-5">
<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"/>
</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"/>
</Button>
</StackPanel>
</Grid>
</UserControl>

@ -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"));
}
}
}

@ -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())

@ -1,7 +1,7 @@
<UserControl x:Class="WhackerLinkConsoleV2.Controls.SystemStatusBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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">
<StackPanel>
<TextBlock Text="{Binding SystemName}" FontWeight="Bold" Foreground="White" FontSize="14"/>

Loading…
Cancel
Save

Powered by TurnKey Linux.