diff --git a/WhackerLinkConsoleV2/AlertTone.xaml b/WhackerLinkConsoleV2/AlertTone.xaml
index 53e560a..6599fb9 100644
--- a/WhackerLinkConsoleV2/AlertTone.xaml
+++ b/WhackerLinkConsoleV2/AlertTone.xaml
@@ -8,8 +8,8 @@
DataContext="{Binding RelativeSource={RelativeSource Self}}">
-
-
+
+
diff --git a/WhackerLinkConsoleV2/ChannelBox.xaml b/WhackerLinkConsoleV2/ChannelBox.xaml
index 908d130..4cb57a7 100644
--- a/WhackerLinkConsoleV2/ChannelBox.xaml
+++ b/WhackerLinkConsoleV2/ChannelBox.xaml
@@ -1,7 +1,8 @@
+ Width="200" Height="120" Background="{Binding Background, RelativeSource={RelativeSource AncestorType=UserControl}}"
+ BorderBrush="Gray" BorderThickness="2">
diff --git a/WhackerLinkConsoleV2/ChannelBox.xaml.cs b/WhackerLinkConsoleV2/ChannelBox.xaml.cs
index 73d4fc7..3696ee4 100644
--- a/WhackerLinkConsoleV2/ChannelBox.xaml.cs
+++ b/WhackerLinkConsoleV2/ChannelBox.xaml.cs
@@ -21,6 +21,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
+using System.Windows.Media;
namespace WhackerLinkConsoleV2.Controls
{
@@ -30,56 +31,60 @@ namespace WhackerLinkConsoleV2.Controls
public string SystemName { get; set; }
public string TGID { get; set; }
- public ChannelBox()
- {
- InitializeComponent();
- DataContext = this;
+ public event EventHandler PTTButtonClicked;
+
+ private readonly SelectedChannelsManager _selectedChannelsManager;
+
+ public bool IsEditMode { get; set; }
- MouseMove += ChannelBox_MouseMove;
- MouseDown += ChannelBox_MouseDown;
- MouseUp += ChannelBox_MouseUp;
+ private bool _isSelected;
+ public bool IsSelected
+ {
+ get => _isSelected;
+ set
+ {
+ _isSelected = value;
+ UpdateBackground();
+ }
}
- public ChannelBox(string channelName, string systemName, string tgid) : this()
+ public ChannelBox(SelectedChannelsManager selectedChannelsManager, string channelName, string systemName, string tgid)
{
- ChannelName = $"{channelName}";
+ InitializeComponent();
+ DataContext = this;
+ _selectedChannelsManager = selectedChannelsManager;
+ ChannelName = channelName;
SystemName = $"System: {systemName}";
TGID = $"TGID: {tgid}";
+ UpdateBackground();
+ MouseLeftButtonDown += ChannelBox_MouseLeftButtonDown;
}
- private Point _dragStartPoint;
- private bool _isDragging;
-
- private void ChannelBox_MouseDown(object sender, MouseButtonEventArgs e)
+ private void ChannelBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
- _dragStartPoint = e.GetPosition(null);
- _isDragging = false;
- }
+ if (IsEditMode) return;
- private void ChannelBox_MouseMove(object sender, MouseEventArgs e)
- {
- if (e.LeftButton == MouseButtonState.Pressed)
- {
- Point currentPosition = e.GetPosition(null);
+ IsSelected = !IsSelected;
+ Background = IsSelected ? Brushes.Blue : Brushes.Gray;
- if (!_isDragging && (Math.Abs(currentPosition.X - _dragStartPoint.X) > SystemParameters.MinimumHorizontalDragDistance ||
- Math.Abs(currentPosition.Y - _dragStartPoint.Y) > SystemParameters.MinimumVerticalDragDistance))
- {
- _isDragging = true;
- DataObject data = new DataObject("ChannelBox", this);
- DragDrop.DoDragDrop(this, data, DragDropEffects.Move);
- }
+ if (IsSelected)
+ {
+ _selectedChannelsManager.AddSelectedChannel(this);
+ }
+ else
+ {
+ _selectedChannelsManager.RemoveSelectedChannel(this);
}
}
- private void ChannelBox_MouseUp(object sender, MouseButtonEventArgs e)
+ private void UpdateBackground()
{
- _isDragging = false;
+ Background = IsSelected ? Brushes.DodgerBlue : Brushes.DarkGray;
}
private void PTTButton_Click(object sender, RoutedEventArgs e)
{
- MessageBox.Show($"Imagine you were talking on {ChannelName} rn");
+ PTTButtonClicked.Invoke(sender, this);
}
}
}
diff --git a/WhackerLinkConsoleV2/MainWindow.xaml.cs b/WhackerLinkConsoleV2/MainWindow.xaml.cs
index 7c1b062..2d6f940 100644
--- a/WhackerLinkConsoleV2/MainWindow.xaml.cs
+++ b/WhackerLinkConsoleV2/MainWindow.xaml.cs
@@ -44,11 +44,14 @@ namespace WhackerLinkConsoleV2
private bool _isDragging;
private SettingsManager _settingsManager = new SettingsManager();
+ private SelectedChannelsManager _selectedChannelsManager;
public MainWindow()
{
InitializeComponent();
_settingsManager.LoadSettings();
+ _selectedChannelsManager = new SelectedChannelsManager();
+
Loaded += MainWindow_Loaded;
}
@@ -137,7 +140,7 @@ namespace WhackerLinkConsoleV2
{
foreach (var channel in zone.Channels)
{
- var channelBox = new ChannelBox(channel.Name, channel.System, channel.Tgid);
+ var channelBox = new ChannelBox(_selectedChannelsManager, channel.Name, channel.System, channel.Tgid);
if (_settingsManager.ChannelPositions.TryGetValue(channel.Name, out var position))
{
@@ -150,6 +153,8 @@ namespace WhackerLinkConsoleV2
Canvas.SetTop(channelBox, offsetY);
}
+ channelBox.PTTButtonClicked += ChannelBox_PTTButtonClicked;
+
channelBox.MouseLeftButtonDown += ChannelBox_MouseLeftButtonDown;
channelBox.MouseMove += ChannelBox_MouseMove;
channelBox.MouseRightButtonDown += ChannelBox_MouseRightButtonDown;
@@ -241,6 +246,11 @@ namespace WhackerLinkConsoleV2
_draggedElement = null;
}
+ private void ChannelBox_PTTButtonClicked(object sender, ChannelBox channelBox)
+ {
+ MessageBox.Show($"Imagine you were talking on {channelBox.ChannelName} rn", "PTT Action", MessageBoxButton.OK);
+ }
+
private void SystemStatusBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) => ChannelBox_MouseLeftButtonDown(sender, e);
private void SystemStatusBox_MouseMove(object sender, MouseEventArgs e) => ChannelBox_MouseMove(sender, e);
@@ -274,6 +284,11 @@ namespace WhackerLinkConsoleV2
{
alertTone.IsEditMode = isEditMode;
}
+
+ if (child is ChannelBox channelBox)
+ {
+ channelBox.IsEditMode = isEditMode;
+ }
}
}
diff --git a/WhackerLinkConsoleV2/SelectedChannelsManager.cs b/WhackerLinkConsoleV2/SelectedChannelsManager.cs
new file mode 100644
index 0000000..df7d119
--- /dev/null
+++ b/WhackerLinkConsoleV2/SelectedChannelsManager.cs
@@ -0,0 +1,61 @@
+/*
+* WhackerLink - WhackerLinkConsoleV2
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*
+* Copyright (C) 2024 Caleb, K4PHP
+*
+*/
+
+using WhackerLinkConsoleV2.Controls;
+
+namespace WhackerLinkConsoleV2
+{
+ public class SelectedChannelsManager
+ {
+ private readonly HashSet _selectedChannels;
+
+ public SelectedChannelsManager()
+ {
+ _selectedChannels = new HashSet();
+ }
+
+ public void AddSelectedChannel(ChannelBox channel)
+ {
+ if (_selectedChannels.Add(channel))
+ {
+ channel.IsSelected = true;
+ }
+ }
+
+ public void RemoveSelectedChannel(ChannelBox channel)
+ {
+ if (_selectedChannels.Remove(channel))
+ {
+ channel.IsSelected = false;
+ }
+ }
+
+ public void ClearSelections()
+ {
+ foreach (var channel in _selectedChannels)
+ {
+ channel.IsSelected = false;
+ }
+ _selectedChannels.Clear();
+ }
+
+ public IReadOnlyCollection GetSelectedChannels() => _selectedChannels;
+ }
+}
diff --git a/WhackerLinkLib b/WhackerLinkLib
index d452c97..d36c2cc 160000
--- a/WhackerLinkLib
+++ b/WhackerLinkLib
@@ -1 +1 @@
-Subproject commit d452c974cdfb7bb72425042e300c9a3442b89b57
+Subproject commit d36c2ccfc141336d1a541b68f2827dc626c4ff60