Added WLC-ALERT Buttons

pull/1/head
WhatTheReL 2 years ago committed by GitHub
parent 3f84281574
commit 24f784c7b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,9 +1,9 @@
<Application x:Class="WhackerLinkConsoleV2.App" <Application x:Class="WhackerLinkConsoleV2.App"
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"
xmlns:local="clr-namespace:WhackerLinkConsoleV2" xmlns:local="clr-namespace:WhackerLinkConsoleV2"
StartupUri="MainWindow.xaml"> StartupUri="MainWindow.xaml">
<Application.Resources> <Application.Resources>
</Application.Resources> </Application.Resources>
</Application> </Application>

@ -1,14 +1,14 @@
using System.Configuration; using System.Configuration;
using System.Data; using System.Data;
using System.Windows; using System.Windows;
namespace WhackerLinkConsoleV2 namespace WhackerLinkConsoleV2
{ {
/// <summary> /// <summary>
/// Interaction logic for App.xaml /// Interaction logic for App.xaml
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
} }
} }

@ -1,10 +1,10 @@
using System.Windows; using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]

@ -1,22 +1,22 @@
<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="200" Height="120" Background="#222222" BorderBrush="Gray" BorderThickness="2"> Width="200" Height="120" Background="#222222" BorderBrush="Gray" BorderThickness="2">
<Border CornerRadius="5" Background="{Binding Background, RelativeSource={RelativeSource AncestorType=UserControl}}"> <Border CornerRadius="5" Background="{Binding Background, RelativeSource={RelativeSource AncestorType=UserControl}}">
<Grid Margin="5"> <Grid Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="{Binding ChannelName}" FontWeight="Bold" Foreground="White" FontSize="14" Grid.Row="0"/> <TextBlock Text="{Binding ChannelName}" FontWeight="Bold" Foreground="White" FontSize="14" Grid.Row="0"/>
<TextBlock Text="{Binding SystemName}" Foreground="LightGray" FontSize="12" Grid.Row="1"/> <TextBlock Text="{Binding SystemName}" Foreground="LightGray" FontSize="12" Grid.Row="1"/>
<TextBlock Text="{Binding TGID}" Foreground="LightGray" FontSize="12" Grid.Row="2"/> <TextBlock Text="{Binding TGID}" Foreground="LightGray" FontSize="12" Grid.Row="2"/>
<Button Content="PTT" Width="80" Margin="0,5,0,0" Background="Green" Foreground="White" <Button Content="PTT" Width="80" Margin="0,5,0,0" Background="Green" Foreground="White"
HorizontalAlignment="Left" Grid.Row="3" Click="PTTButton_Click"/> HorizontalAlignment="Left" Grid.Row="3" Click="PTTButton_Click"/>
</Grid> </Grid>
</Border> </Border>
</UserControl> </UserControl>

@ -1,85 +1,85 @@
/* /*
* WhackerLink - WhackerLinkConsoleV2 * WhackerLink - WhackerLinkConsoleV2
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright (C) 2024 Caleb, K4PHP * Copyright (C) 2024 Caleb, K4PHP
* *
*/ */
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
namespace WhackerLinkConsoleV2.Controls namespace WhackerLinkConsoleV2.Controls
{ {
public partial class ChannelBox : UserControl public partial class ChannelBox : UserControl
{ {
public string ChannelName { get; set; } public string ChannelName { get; set; }
public string SystemName { get; set; } public string SystemName { get; set; }
public string TGID { get; set; } public string TGID { get; set; }
public ChannelBox() public ChannelBox()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this; DataContext = this;
MouseMove += ChannelBox_MouseMove; MouseMove += ChannelBox_MouseMove;
MouseDown += ChannelBox_MouseDown; MouseDown += ChannelBox_MouseDown;
MouseUp += ChannelBox_MouseUp; MouseUp += ChannelBox_MouseUp;
} }
public ChannelBox(string channelName, string systemName, string tgid) : this() public ChannelBox(string channelName, string systemName, string tgid) : this()
{ {
ChannelName = $"{channelName}"; ChannelName = $"{channelName}";
SystemName = $"System: {systemName}"; SystemName = $"System: {systemName}";
TGID = $"TGID: {tgid}"; TGID = $"TGID: {tgid}";
} }
private Point _dragStartPoint; private Point _dragStartPoint;
private bool _isDragging; private bool _isDragging;
private void ChannelBox_MouseDown(object sender, MouseButtonEventArgs e) private void ChannelBox_MouseDown(object sender, MouseButtonEventArgs e)
{ {
_dragStartPoint = e.GetPosition(null); _dragStartPoint = e.GetPosition(null);
_isDragging = false; _isDragging = false;
} }
private void ChannelBox_MouseMove(object sender, MouseEventArgs e) private void ChannelBox_MouseMove(object sender, MouseEventArgs e)
{ {
if (e.LeftButton == MouseButtonState.Pressed) if (e.LeftButton == MouseButtonState.Pressed)
{ {
Point currentPosition = e.GetPosition(null); Point currentPosition = e.GetPosition(null);
if (!_isDragging && (Math.Abs(currentPosition.X - _dragStartPoint.X) > SystemParameters.MinimumHorizontalDragDistance || if (!_isDragging && (Math.Abs(currentPosition.X - _dragStartPoint.X) > SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs(currentPosition.Y - _dragStartPoint.Y) > SystemParameters.MinimumVerticalDragDistance)) Math.Abs(currentPosition.Y - _dragStartPoint.Y) > SystemParameters.MinimumVerticalDragDistance))
{ {
_isDragging = true; _isDragging = true;
DataObject data = new DataObject("ChannelBox", this); DataObject data = new DataObject("ChannelBox", this);
DragDrop.DoDragDrop(this, data, DragDropEffects.Move); DragDrop.DoDragDrop(this, data, DragDropEffects.Move);
} }
} }
} }
private void ChannelBox_MouseUp(object sender, MouseButtonEventArgs e) private void ChannelBox_MouseUp(object sender, MouseButtonEventArgs e)
{ {
_isDragging = false; _isDragging = false;
} }
private void PTTButton_Click(object sender, RoutedEventArgs e) private void PTTButton_Click(object sender, RoutedEventArgs e)
{ {
MessageBox.Show($"Imagine you were talking on {ChannelName} rn"); MessageBox.Show($"Imagine you were talking on {ChannelName} rn");
} }
} }
} }

@ -1,28 +1,28 @@
/* /*
* WhackerLink - WhackerLinkConsoleV2 * WhackerLink - WhackerLinkConsoleV2
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright (C) 2024 Caleb, K4PHP * Copyright (C) 2024 Caleb, K4PHP
* *
*/ */
namespace WhackerLinkConsoleV2 namespace WhackerLinkConsoleV2
{ {
public class ChannelPosition public class ChannelPosition
{ {
public double X { get; set; } public double X { get; set; }
public double Y { get; set; } public double Y { get; set; }
} }
} }

@ -1,20 +1,53 @@
<Window x:Class="WhackerLinkConsoleV2.MainWindow" <Window x:Class="WhackerLinkConsoleV2.MainWindow"
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"
xmlns:local="clr-namespace:WhackerLinkConsoleV2.Controls" xmlns:local="clr-namespace:WhackerLinkConsoleV2.Controls"
Title="WhackerLinkConsoleV2" Height="600" Width="1000" Background="#1e1e1e"> Title="WhackerLinkConsoleV2" Height="600" Width="1000" Background="#1e1e1e">
<Grid> <Grid>
<Menu VerticalAlignment="Top" Height="25"> <Menu VerticalAlignment="Top" Height="25">
<MenuItem Header="File"> <MenuItem Header="File">
<MenuItem Header="Open Codeplug" Click="OpenCodeplug_Click"/> <MenuItem Header="Open Codeplug" Click="OpenCodeplug_Click"/>
</MenuItem> </MenuItem>
<MenuItem Header="Edit"> <MenuItem Header="Edit">
<MenuItem Header="Enable Edit Mode" Click="ToggleEditMode_Click"/> <MenuItem Header="Enable Edit Mode" Click="ToggleEditMode_Click"/>
<MenuItem Header="Select Widgets to Display" Click="SelectWidgets_Click"/> <MenuItem Header="Select Widgets to Display" Click="SelectWidgets_Click"/>
<MenuItem Header="Reset Settings" Click="ResetSettings_Click"/> <MenuItem Header="Reset Settings" Click="ResetSettings_Click"/>
</MenuItem> </MenuItem>
</Menu> </Menu>
<Canvas x:Name="ChannelsCanvas" Margin="0,25,0,0" Background="#1e1e1e" /> <Canvas x:Name="ChannelsCanvas" Margin="0,25,0,0" Background="#1e1e1e">
</Grid> </Canvas>
</Window> <Grid VerticalAlignment="Top" Height="75" Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">
<Button Content="ALERT 1" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 2" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 3" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 4" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 5" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 6" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 7" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 8" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 9" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 10" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 11" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 12" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 13" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 14" Height="47" Width="53" Click="Button_Click" />
<Button Content="ALERT 15" Height="47" Width="53" Click="Button_Click" />
</StackPanel>
</Grid>
</Grid>
</Window>

@ -1,242 +1,250 @@
/* /*
* WhackerLink - WhackerLinkConsoleV2 * WhackerLink - WhackerLinkConsoleV2
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright (C) 2024 Caleb, K4PHP * Copyright (C) 2024 Caleb, K4PHP
* *
*/ */
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using WhackerLinkLib.Models.Radio; using WhackerLinkLib.Models.Radio;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NamingConventions;
using WhackerLinkConsoleV2.Controls; using WhackerLinkConsoleV2.Controls;
using System.Collections.Generic; using System.Collections.Generic;
namespace WhackerLinkConsoleV2 namespace WhackerLinkConsoleV2
{ {
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
public Codeplug Codeplug { get; set; } public Codeplug Codeplug { get; set; }
private bool isEditMode = false; private bool isEditMode = false;
private UIElement _draggedElement; private UIElement _draggedElement;
private Point _startPoint; private Point _startPoint;
private double _offsetX; private double _offsetX;
private double _offsetY; private double _offsetY;
private bool _isDragging; private bool _isDragging;
private SettingsManager _settingsManager = new SettingsManager(); private SettingsManager _settingsManager = new SettingsManager();
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
_settingsManager.LoadSettings(); _settingsManager.LoadSettings();
Loaded += MainWindow_Loaded; Loaded += MainWindow_Loaded;
} }
private void OpenCodeplug_Click(object sender, RoutedEventArgs e) private void OpenCodeplug_Click(object sender, RoutedEventArgs e)
{ {
OpenFileDialog openFileDialog = new OpenFileDialog OpenFileDialog openFileDialog = new OpenFileDialog
{ {
Filter = "Codeplug Files (*.yml)|*.yml|All Files (*.*)|*.*", Filter = "Codeplug Files (*.yml)|*.yml|All Files (*.*)|*.*",
Title = "Open Codeplug" Title = "Open Codeplug"
}; };
if (openFileDialog.ShowDialog() == true) if (openFileDialog.ShowDialog() == true)
{ {
LoadCodeplug(openFileDialog.FileName); LoadCodeplug(openFileDialog.FileName);
_settingsManager.LastCodeplugPath = openFileDialog.FileName; _settingsManager.LastCodeplugPath = openFileDialog.FileName;
_settingsManager.SaveSettings(); _settingsManager.SaveSettings();
} }
} }
private void ResetSettings_Click(object sender, RoutedEventArgs e) private void ResetSettings_Click(object sender, RoutedEventArgs e)
{ {
if (File.Exists("UserSettings.json")) if (File.Exists("UserSettings.json"))
File.Delete("UserSettings.json"); File.Delete("UserSettings.json");
} }
private void LoadCodeplug(string filePath) private void LoadCodeplug(string filePath)
{ {
try try
{ {
var deserializer = new DeserializerBuilder() var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance) .WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build(); .Build();
var yaml = File.ReadAllText(filePath); var yaml = File.ReadAllText(filePath);
Codeplug = deserializer.Deserialize<Codeplug>(yaml); Codeplug = deserializer.Deserialize<Codeplug>(yaml);
GenerateChannelWidgets(); GenerateChannelWidgets();
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show($"Error loading codeplug: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show($"Error loading codeplug: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
} }
} }
private void GenerateChannelWidgets() private void GenerateChannelWidgets()
{ {
ChannelsCanvas.Children.Clear(); ChannelsCanvas.Children.Clear();
double offsetX = 20; double offsetX = 20;
double offsetY = 20; double offsetY = 20;
if (_settingsManager.ShowSystemStatus && Codeplug != null) if (_settingsManager.ShowSystemStatus && Codeplug != null)
{ {
foreach (var system in Codeplug.Systems) foreach (var system in Codeplug.Systems)
{ {
var systemStatusBox = new SystemStatusBox(system.Name, system.Address, system.Port); var systemStatusBox = new SystemStatusBox(system.Name, system.Address, system.Port);
Canvas.SetLeft(systemStatusBox, offsetX); Canvas.SetLeft(systemStatusBox, offsetX);
Canvas.SetTop(systemStatusBox, offsetY); Canvas.SetTop(systemStatusBox, offsetY);
systemStatusBox.MouseLeftButtonDown += SystemStatusBox_MouseLeftButtonDown; systemStatusBox.MouseLeftButtonDown += SystemStatusBox_MouseLeftButtonDown;
systemStatusBox.MouseMove += SystemStatusBox_MouseMove; systemStatusBox.MouseMove += SystemStatusBox_MouseMove;
systemStatusBox.MouseRightButtonDown += SystemStatusBox_MouseRightButtonDown; systemStatusBox.MouseRightButtonDown += SystemStatusBox_MouseRightButtonDown;
ChannelsCanvas.Children.Add(systemStatusBox); ChannelsCanvas.Children.Add(systemStatusBox);
offsetX += 220; offsetX += 220;
if (offsetX + 200 > ChannelsCanvas.ActualWidth) if (offsetX + 200 > ChannelsCanvas.ActualWidth)
{ {
offsetX = 20; offsetX = 20;
offsetY += 140; offsetY += 140;
} }
} }
} }
if (_settingsManager.ShowChannels && Codeplug != null) if (_settingsManager.ShowChannels && Codeplug != null)
{ {
foreach (var zone in Codeplug.Zones) foreach (var zone in Codeplug.Zones)
{ {
foreach (var channel in zone.Channels) foreach (var channel in zone.Channels)
{ {
var channelBox = new ChannelBox(channel.Name, channel.System, channel.Tgid); var channelBox = new ChannelBox(channel.Name, channel.System, channel.Tgid);
if (_settingsManager.ChannelPositions.TryGetValue(channel.Name, out var position)) if (_settingsManager.ChannelPositions.TryGetValue(channel.Name, out var position))
{ {
Canvas.SetLeft(channelBox, position.X); Canvas.SetLeft(channelBox, position.X);
Canvas.SetTop(channelBox, position.Y); Canvas.SetTop(channelBox, position.Y);
} }
else else
{ {
Canvas.SetLeft(channelBox, offsetX); Canvas.SetLeft(channelBox, offsetX);
Canvas.SetTop(channelBox, offsetY); Canvas.SetTop(channelBox, offsetY);
} }
channelBox.MouseLeftButtonDown += ChannelBox_MouseLeftButtonDown; channelBox.MouseLeftButtonDown += ChannelBox_MouseLeftButtonDown;
channelBox.MouseMove += ChannelBox_MouseMove; channelBox.MouseMove += ChannelBox_MouseMove;
channelBox.MouseRightButtonDown += ChannelBox_MouseRightButtonDown; channelBox.MouseRightButtonDown += ChannelBox_MouseRightButtonDown;
ChannelsCanvas.Children.Add(channelBox); ChannelsCanvas.Children.Add(channelBox);
offsetX += 220; offsetX += 220;
if (offsetX + 200 > ChannelsCanvas.ActualWidth) if (offsetX + 200 > ChannelsCanvas.ActualWidth)
{ {
offsetX = 20; offsetX = 20;
offsetY += 140; offsetY += 140;
} }
} }
} }
} }
} }
private void SelectWidgets_Click(object sender, RoutedEventArgs e) private void SelectWidgets_Click(object sender, RoutedEventArgs e)
{ {
var widgetSelectionWindow = new WidgetSelectionWindow(); var widgetSelectionWindow = new WidgetSelectionWindow();
widgetSelectionWindow.Owner = this; widgetSelectionWindow.Owner = this;
if (widgetSelectionWindow.ShowDialog() == true) if (widgetSelectionWindow.ShowDialog() == true)
{ {
_settingsManager.ShowSystemStatus = widgetSelectionWindow.ShowSystemStatus; _settingsManager.ShowSystemStatus = widgetSelectionWindow.ShowSystemStatus;
_settingsManager.ShowChannels = widgetSelectionWindow.ShowChannels; _settingsManager.ShowChannels = widgetSelectionWindow.ShowChannels;
GenerateChannelWidgets(); GenerateChannelWidgets();
_settingsManager.SaveSettings(); _settingsManager.SaveSettings();
} }
} }
private void ChannelBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) private void ChannelBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{ {
if (!isEditMode || !(sender is UIElement element)) return; if (!isEditMode || !(sender is UIElement element)) return;
_draggedElement = element; _draggedElement = element;
_startPoint = e.GetPosition(ChannelsCanvas); _startPoint = e.GetPosition(ChannelsCanvas);
_offsetX = _startPoint.X - Canvas.GetLeft(_draggedElement); _offsetX = _startPoint.X - Canvas.GetLeft(_draggedElement);
_offsetY = _startPoint.Y - Canvas.GetTop(_draggedElement); _offsetY = _startPoint.Y - Canvas.GetTop(_draggedElement);
_isDragging = true; _isDragging = true;
element.CaptureMouse(); element.CaptureMouse();
} }
private void ChannelBox_MouseMove(object sender, MouseEventArgs e) private void ChannelBox_MouseMove(object sender, MouseEventArgs e)
{ {
if (!isEditMode || !_isDragging || _draggedElement == null) return; if (!isEditMode || !_isDragging || _draggedElement == null) return;
Point currentPosition = e.GetPosition(ChannelsCanvas); Point currentPosition = e.GetPosition(ChannelsCanvas);
double newLeft = Math.Max(0, Math.Min(currentPosition.X - _offsetX, ChannelsCanvas.ActualWidth - _draggedElement.RenderSize.Width)); double newLeft = Math.Max(0, Math.Min(currentPosition.X - _offsetX, ChannelsCanvas.ActualWidth - _draggedElement.RenderSize.Width));
double newTop = Math.Max(0, Math.Min(currentPosition.Y - _offsetY, ChannelsCanvas.ActualHeight - _draggedElement.RenderSize.Height)); double newTop = Math.Max(0, Math.Min(currentPosition.Y - _offsetY, ChannelsCanvas.ActualHeight - _draggedElement.RenderSize.Height));
Canvas.SetLeft(_draggedElement, newLeft); Canvas.SetLeft(_draggedElement, newLeft);
Canvas.SetTop(_draggedElement, newTop); Canvas.SetTop(_draggedElement, newTop);
if (_draggedElement is ChannelBox channelBox) if (_draggedElement is ChannelBox channelBox)
{ {
_settingsManager.UpdateChannelPosition(channelBox.ChannelName, newLeft, newTop); _settingsManager.UpdateChannelPosition(channelBox.ChannelName, newLeft, newTop);
} }
} }
private void ChannelBox_MouseRightButtonDown(object sender, MouseButtonEventArgs e) private void ChannelBox_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{ {
if (!isEditMode || !_isDragging || _draggedElement == null) return; if (!isEditMode || !_isDragging || _draggedElement == null) return;
_isDragging = false; _isDragging = false;
_draggedElement.ReleaseMouseCapture(); _draggedElement.ReleaseMouseCapture();
_draggedElement = null; _draggedElement = null;
} }
private void SystemStatusBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) => ChannelBox_MouseLeftButtonDown(sender, e); private void SystemStatusBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) => ChannelBox_MouseLeftButtonDown(sender, e);
private void SystemStatusBox_MouseMove(object sender, MouseEventArgs e) => ChannelBox_MouseMove(sender, e); private void SystemStatusBox_MouseMove(object sender, MouseEventArgs e) => ChannelBox_MouseMove(sender, e);
private void SystemStatusBox_MouseRightButtonDown(object sender, MouseButtonEventArgs e) => ChannelBox_MouseRightButtonDown(sender, e); private void SystemStatusBox_MouseRightButtonDown(object sender, MouseButtonEventArgs e) => ChannelBox_MouseRightButtonDown(sender, e);
private void ToggleEditMode_Click(object sender, RoutedEventArgs e) private void ToggleEditMode_Click(object sender, RoutedEventArgs e)
{ {
isEditMode = !isEditMode; isEditMode = !isEditMode;
var menuItem = (MenuItem)sender; var menuItem = (MenuItem)sender;
menuItem.Header = isEditMode ? "Disable Edit Mode" : "Enable Edit Mode"; menuItem.Header = isEditMode ? "Disable Edit Mode" : "Enable Edit Mode";
} }
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{ {
_settingsManager.SaveSettings(); _settingsManager.SaveSettings();
base.OnClosing(e); base.OnClosing(e);
} }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{ {
if (!string.IsNullOrEmpty(_settingsManager.LastCodeplugPath) && File.Exists(_settingsManager.LastCodeplugPath)) if (!string.IsNullOrEmpty(_settingsManager.LastCodeplugPath) && File.Exists(_settingsManager.LastCodeplugPath))
{ {
LoadCodeplug(_settingsManager.LastCodeplugPath); LoadCodeplug(_settingsManager.LastCodeplugPath);
} }
else else
{ {
GenerateChannelWidgets(); GenerateChannelWidgets();
} }
} }
} private void Button_Click(object sender, RoutedEventArgs e)
} {
if (sender is Button button)
{
string buttonContent = button.Content.ToString();
MessageBox.Show($"Beep boop {buttonContent}");
}
}
}
}

@ -1,85 +1,85 @@
/* /*
* WhackerLink - WhackerLinkConsoleV2 * WhackerLink - WhackerLinkConsoleV2
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright (C) 2024 Caleb, K4PHP * Copyright (C) 2024 Caleb, K4PHP
* *
*/ */
using System.IO; using System.IO;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace WhackerLinkConsoleV2 namespace WhackerLinkConsoleV2
{ {
public class SettingsManager public class SettingsManager
{ {
private const string SettingsFilePath = "UserSettings.json"; private const string SettingsFilePath = "UserSettings.json";
public bool ShowSystemStatus { get; set; } = true; public bool ShowSystemStatus { get; set; } = true;
public bool ShowChannels { get; set; } = true; public bool ShowChannels { get; set; } = true;
public string LastCodeplugPath { get; set; } = null; public string LastCodeplugPath { get; set; } = null;
public Dictionary<string, ChannelPosition> ChannelPositions { get; set; } = new Dictionary<string, ChannelPosition>(); public Dictionary<string, ChannelPosition> ChannelPositions { get; set; } = new Dictionary<string, ChannelPosition>();
public void LoadSettings() public void LoadSettings()
{ {
if (!File.Exists(SettingsFilePath)) return; if (!File.Exists(SettingsFilePath)) return;
try try
{ {
var json = File.ReadAllText(SettingsFilePath); var json = File.ReadAllText(SettingsFilePath);
var loadedSettings = JsonConvert.DeserializeObject<SettingsManager>(json); var loadedSettings = JsonConvert.DeserializeObject<SettingsManager>(json);
if (loadedSettings != null) if (loadedSettings != null)
{ {
ShowSystemStatus = loadedSettings.ShowSystemStatus; ShowSystemStatus = loadedSettings.ShowSystemStatus;
ShowChannels = loadedSettings.ShowChannels; ShowChannels = loadedSettings.ShowChannels;
LastCodeplugPath = loadedSettings.LastCodeplugPath; LastCodeplugPath = loadedSettings.LastCodeplugPath;
ChannelPositions = loadedSettings.ChannelPositions ?? new Dictionary<string, ChannelPosition>(); ChannelPositions = loadedSettings.ChannelPositions ?? new Dictionary<string, ChannelPosition>();
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"Error loading settings: {ex.Message}"); Console.WriteLine($"Error loading settings: {ex.Message}");
} }
} }
public void SaveSettings() public void SaveSettings()
{ {
try try
{ {
var json = JsonConvert.SerializeObject(this, Formatting.Indented); var json = JsonConvert.SerializeObject(this, Formatting.Indented);
File.WriteAllText(SettingsFilePath, json); File.WriteAllText(SettingsFilePath, json);
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"Error saving settings: {ex.Message}"); Console.WriteLine($"Error saving settings: {ex.Message}");
} }
} }
public void UpdateChannelPosition(string channelName, double x, double y) public void UpdateChannelPosition(string channelName, double x, double y)
{ {
if (ChannelPositions.ContainsKey(channelName)) if (ChannelPositions.ContainsKey(channelName))
{ {
ChannelPositions[channelName].X = x; ChannelPositions[channelName].X = x;
ChannelPositions[channelName].Y = y; ChannelPositions[channelName].Y = y;
} }
else else
{ {
ChannelPositions[channelName] = new ChannelPosition { X = x, Y = y }; ChannelPositions[channelName] = new ChannelPosition { X = x, Y = y };
} }
} }
} }
} }

@ -1,13 +1,13 @@
<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="200" Height="120" Background="#334455" BorderBrush="Gray" BorderThickness="2">
<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"/>
<TextBlock Text="{Binding AddressPort}" Foreground="LightGray" FontSize="12"/> <TextBlock Text="{Binding AddressPort}" Foreground="LightGray" FontSize="12"/>
<TextBlock Text="Connection State:" Foreground="LightGray" FontSize="12"/> <TextBlock Text="Connection State:" Foreground="LightGray" FontSize="12"/>
<TextBlock Text="{Binding ConnectionState}" Foreground="White" FontSize="12"/> <TextBlock Text="{Binding ConnectionState}" Foreground="White" FontSize="12"/>
</StackPanel> </StackPanel>
</Border> </Border>
</UserControl> </UserControl>

@ -1,43 +1,43 @@
/* /*
* WhackerLink - WhackerLinkConsoleV2 * WhackerLink - WhackerLinkConsoleV2
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright (C) 2024 Caleb, K4PHP * Copyright (C) 2024 Caleb, K4PHP
* *
*/ */
using System.Windows.Controls; using System.Windows.Controls;
namespace WhackerLinkConsoleV2.Controls namespace WhackerLinkConsoleV2.Controls
{ {
public partial class SystemStatusBox : UserControl public partial class SystemStatusBox : UserControl
{ {
public string SystemName { get; set; } public string SystemName { get; set; }
public string AddressPort { get; set; } public string AddressPort { get; set; }
public string ConnectionState { get; set; } = "Disconnected"; public string ConnectionState { get; set; } = "Disconnected";
public SystemStatusBox() public SystemStatusBox()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this; DataContext = this;
} }
public SystemStatusBox(string systemName, string address, int port) : this() public SystemStatusBox(string systemName, string address, int port) : this()
{ {
SystemName = systemName; SystemName = systemName;
AddressPort = $"Address: {address}:{port}"; AddressPort = $"Address: {address}:{port}";
} }
} }
} }

@ -1,19 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows7.0</TargetFramework> <TargetFramework>net8.0-windows7.0</TargetFramework>
<Nullable>disable</Nullable> <Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="YamlDotNet" Version="16.2.0" /> <None Remove="whackerlink-logo %281%29.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\WhackerLinkLib\WhackerLinkLib.csproj" /> <PackageReference Include="YamlDotNet" Version="16.2.0" />
</ItemGroup> </ItemGroup>
</Project> <ItemGroup>
<ProjectReference Include="..\WhackerLinkLib\WhackerLinkLib.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="whackerlink-logo (1).png" />
</ItemGroup>
</Project>

@ -1,11 +1,11 @@
<Window x:Class="WhackerLinkConsoleV2.WidgetSelectionWindow" <Window x:Class="WhackerLinkConsoleV2.WidgetSelectionWindow"
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"
Title="Select Widgets" Height="200" Width="300" WindowStartupLocation="CenterOwner"> Title="Select Widgets" Height="200" Width="300" WindowStartupLocation="CenterOwner">
<StackPanel Margin="20"> <StackPanel Margin="20">
<TextBlock Text="Select Widgets to Display:" FontWeight="Bold" Margin="0,0,0,10" /> <TextBlock Text="Select Widgets to Display:" FontWeight="Bold" Margin="0,0,0,10" />
<CheckBox x:Name="SystemStatusCheckBox" Content="System Status" IsChecked="True" /> <CheckBox x:Name="SystemStatusCheckBox" Content="System Status" IsChecked="True" />
<CheckBox x:Name="ChannelCheckBox" Content="Channel" IsChecked="True" /> <CheckBox x:Name="ChannelCheckBox" Content="Channel" IsChecked="True" />
<Button Content="Apply" Width="80" Margin="0,20,0,0" HorizontalAlignment="Center" Click="ApplyButton_Click" /> <Button Content="Apply" Width="80" Margin="0,20,0,0" HorizontalAlignment="Center" Click="ApplyButton_Click" />
</StackPanel> </StackPanel>
</Window> </Window>

@ -1,43 +1,43 @@
/* /*
* WhackerLink - WhackerLinkConsoleV2 * WhackerLink - WhackerLinkConsoleV2
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright (C) 2024 Caleb, K4PHP * Copyright (C) 2024 Caleb, K4PHP
* *
*/ */
using System.Windows; using System.Windows;
namespace WhackerLinkConsoleV2 namespace WhackerLinkConsoleV2
{ {
public partial class WidgetSelectionWindow : Window public partial class WidgetSelectionWindow : Window
{ {
public bool ShowSystemStatus { get; private set; } = true; public bool ShowSystemStatus { get; private set; } = true;
public bool ShowChannels { get; private set; } = true; public bool ShowChannels { get; private set; } = true;
public WidgetSelectionWindow() public WidgetSelectionWindow()
{ {
InitializeComponent(); InitializeComponent();
} }
private void ApplyButton_Click(object sender, RoutedEventArgs e) private void ApplyButton_Click(object sender, RoutedEventArgs e)
{ {
ShowSystemStatus = SystemStatusCheckBox.IsChecked ?? false; ShowSystemStatus = SystemStatusCheckBox.IsChecked ?? false;
ShowChannels = ChannelCheckBox.IsChecked ?? false; ShowChannels = ChannelCheckBox.IsChecked ?? false;
DialogResult = true; DialogResult = true;
Close(); Close();
} }
} }
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.