Initial refactor

pull/1/head
firealarmss 1 year ago
commit 1b04784ad5

399
.gitignore vendored

@ -0,0 +1,399 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml

3
.gitmodules vendored

@ -0,0 +1,3 @@
[submodule "WhackerLinkLib"]
path = WhackerLinkLib
url = https://github.com/whackerlink/WhackerLinkLib

@ -0,0 +1,51 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WhackerLinkLib", "WhackerLinkLib\WhackerLinkLib.csproj", "{5918329A-6374-40E2-874D-445360C89676}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WhackerLinkConsoleV2", "WhackerLinkConsoleV2\WhackerLinkConsoleV2.csproj", "{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
NoVocode|Any CPU = NoVocode|Any CPU
NoVocode|x86 = NoVocode|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5918329A-6374-40E2-874D-445360C89676}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5918329A-6374-40E2-874D-445360C89676}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5918329A-6374-40E2-874D-445360C89676}.Debug|x86.ActiveCfg = Debug|x86
{5918329A-6374-40E2-874D-445360C89676}.Debug|x86.Build.0 = Debug|x86
{5918329A-6374-40E2-874D-445360C89676}.NoVocode|Any CPU.ActiveCfg = NoVocode|Any CPU
{5918329A-6374-40E2-874D-445360C89676}.NoVocode|Any CPU.Build.0 = NoVocode|Any CPU
{5918329A-6374-40E2-874D-445360C89676}.NoVocode|x86.ActiveCfg = NoVocode|x86
{5918329A-6374-40E2-874D-445360C89676}.NoVocode|x86.Build.0 = NoVocode|x86
{5918329A-6374-40E2-874D-445360C89676}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5918329A-6374-40E2-874D-445360C89676}.Release|Any CPU.Build.0 = Release|Any CPU
{5918329A-6374-40E2-874D-445360C89676}.Release|x86.ActiveCfg = Release|x86
{5918329A-6374-40E2-874D-445360C89676}.Release|x86.Build.0 = Release|x86
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.Debug|x86.ActiveCfg = Debug|Any CPU
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.Debug|x86.Build.0 = Debug|Any CPU
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.NoVocode|Any CPU.ActiveCfg = Debug|Any CPU
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.NoVocode|Any CPU.Build.0 = Debug|Any CPU
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.NoVocode|x86.ActiveCfg = Debug|Any CPU
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.NoVocode|x86.Build.0 = Debug|Any CPU
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.Release|Any CPU.Build.0 = Release|Any CPU
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.Release|x86.ActiveCfg = Release|Any CPU
{710D1FA8-2E0D-42CB-9174-FCD9EB7A718F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2891343C-A29A-4952-B9E1-2468A3DA70DC}
EndGlobalSection
EndGlobal

@ -0,0 +1,9 @@
<Application x:Class="WhackerLinkConsoleV2.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WhackerLinkConsoleV2"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

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

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

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

@ -0,0 +1,66 @@
using System.Threading.Channels;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace WhackerLinkConsoleV2.Controls
{
public partial class ChannelBox : UserControl
{
public string ChannelName { get; set; }
public string SystemName { get; set; }
public string TGID { get; set; }
public ChannelBox()
{
InitializeComponent();
DataContext = this;
MouseMove += ChannelBox_MouseMove;
MouseDown += ChannelBox_MouseDown;
MouseUp += ChannelBox_MouseUp;
}
public ChannelBox(string channelName, string systemName, string tgid) : this()
{
ChannelName = $"{channelName}";
SystemName = $"System: {systemName}";
TGID = $"TGID: {tgid}";
}
private Point _dragStartPoint;
private bool _isDragging;
private void ChannelBox_MouseDown(object sender, MouseButtonEventArgs e)
{
_dragStartPoint = e.GetPosition(null);
_isDragging = false;
}
private void ChannelBox_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
Point currentPosition = e.GetPosition(null);
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);
}
}
}
private void ChannelBox_MouseUp(object sender, MouseButtonEventArgs e)
{
_isDragging = false;
}
private void PTTButton_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show($"Imagine you were talking on {ChannelName} rn");
}
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WhackerLinkConsoleV2
{
public class ChannelPosition
{
public double X { get; set; }
public double Y { get; set; }
}
}

@ -0,0 +1,23 @@
<Window x:Class="WhackerLinkConsoleV2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WhackerLinkConsoleV2.Controls"
Title="WhackerLinkConsoleV2" Height="600" Width="1000" Background="#1e1e1e">
<Grid>
<!-- Menu Bar -->
<Menu VerticalAlignment="Top" Height="25">
<MenuItem Header="File">
<MenuItem Header="Open Codeplug" Click="OpenCodeplug_Click"/>
</MenuItem>
<MenuItem Header="Edit">
<!-- Toggle button for enabling/disabling edit mode -->
<MenuItem Header="Enable Edit Mode" Click="ToggleEditMode_Click"/>
<MenuItem Header="Select Widgets to Display" Click="SelectWidgets_Click"/>
<MenuItem Header="Reset Settings" Click="ResetSettings_Click"/>
</MenuItem>
</Menu>
<!-- Main Layout with Canvas to hold ChannelBoxes -->
<Canvas x:Name="ChannelsCanvas" Margin="0,25,0,0" Background="#1e1e1e" />
</Grid>
</Window>

@ -0,0 +1,222 @@
using Microsoft.Win32;
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using WhackerLinkLib.Models.Radio;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
using WhackerLinkConsoleV2.Controls;
using System.Collections.Generic;
namespace WhackerLinkConsoleV2
{
public partial class MainWindow : Window
{
public Codeplug Codeplug { get; set; }
private bool isEditMode = false;
private UIElement _draggedElement;
private Point _startPoint;
private double _offsetX;
private double _offsetY;
private bool _isDragging;
private SettingsManager _settingsManager = new SettingsManager();
public MainWindow()
{
InitializeComponent();
_settingsManager.LoadSettings();
Loaded += MainWindow_Loaded;
}
private void OpenCodeplug_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "Codeplug Files (*.yml)|*.yml|All Files (*.*)|*.*",
Title = "Open Codeplug"
};
if (openFileDialog.ShowDialog() == true)
{
LoadCodeplug(openFileDialog.FileName);
_settingsManager.LastCodeplugPath = openFileDialog.FileName;
_settingsManager.SaveSettings();
}
}
private void ResetSettings_Click(object sender, RoutedEventArgs e)
{
if (File.Exists("UserSettings.json"))
File.Delete("UserSettings.json");
}
private void LoadCodeplug(string filePath)
{
try
{
var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build();
var yaml = File.ReadAllText(filePath);
Codeplug = deserializer.Deserialize<Codeplug>(yaml);
GenerateChannelWidgets();
}
catch (Exception ex)
{
MessageBox.Show($"Error loading codeplug: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void GenerateChannelWidgets()
{
ChannelsCanvas.Children.Clear();
double offsetX = 20;
double offsetY = 20;
if (_settingsManager.ShowSystemStatus && Codeplug != null)
{
foreach (var system in Codeplug.Systems)
{
var systemStatusBox = new SystemStatusBox(system.Name, system.Address, system.Port);
Canvas.SetLeft(systemStatusBox, offsetX);
Canvas.SetTop(systemStatusBox, offsetY);
systemStatusBox.MouseLeftButtonDown += SystemStatusBox_MouseLeftButtonDown;
systemStatusBox.MouseMove += SystemStatusBox_MouseMove;
systemStatusBox.MouseRightButtonDown += SystemStatusBox_MouseRightButtonDown;
ChannelsCanvas.Children.Add(systemStatusBox);
offsetX += 220;
if (offsetX + 200 > ChannelsCanvas.ActualWidth)
{
offsetX = 20;
offsetY += 140;
}
}
}
if (_settingsManager.ShowChannels && Codeplug != null)
{
foreach (var zone in Codeplug.Zones)
{
foreach (var channel in zone.Channels)
{
var channelBox = new ChannelBox(channel.Name, channel.System, channel.Tgid);
if (_settingsManager.ChannelPositions.TryGetValue(channel.Name, out var position))
{
Canvas.SetLeft(channelBox, position.X);
Canvas.SetTop(channelBox, position.Y);
}
else
{
Canvas.SetLeft(channelBox, offsetX);
Canvas.SetTop(channelBox, offsetY);
}
channelBox.MouseLeftButtonDown += ChannelBox_MouseLeftButtonDown;
channelBox.MouseMove += ChannelBox_MouseMove;
channelBox.MouseRightButtonDown += ChannelBox_MouseRightButtonDown;
ChannelsCanvas.Children.Add(channelBox);
offsetX += 220;
if (offsetX + 200 > ChannelsCanvas.ActualWidth)
{
offsetX = 20;
offsetY += 140;
}
}
}
}
}
private void SelectWidgets_Click(object sender, RoutedEventArgs e)
{
var widgetSelectionWindow = new WidgetSelectionWindow();
widgetSelectionWindow.Owner = this;
if (widgetSelectionWindow.ShowDialog() == true)
{
_settingsManager.ShowSystemStatus = widgetSelectionWindow.ShowSystemStatus;
_settingsManager.ShowChannels = widgetSelectionWindow.ShowChannels;
GenerateChannelWidgets();
_settingsManager.SaveSettings();
}
}
private void ChannelBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (!isEditMode || !(sender is UIElement element)) return;
_draggedElement = element;
_startPoint = e.GetPosition(ChannelsCanvas);
_offsetX = _startPoint.X - Canvas.GetLeft(_draggedElement);
_offsetY = _startPoint.Y - Canvas.GetTop(_draggedElement);
_isDragging = true;
element.CaptureMouse();
}
private void ChannelBox_MouseMove(object sender, MouseEventArgs e)
{
if (!isEditMode || !_isDragging || _draggedElement == null) return;
Point currentPosition = e.GetPosition(ChannelsCanvas);
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));
Canvas.SetLeft(_draggedElement, newLeft);
Canvas.SetTop(_draggedElement, newTop);
if (_draggedElement is ChannelBox channelBox)
{
_settingsManager.UpdateChannelPosition(channelBox.ChannelName, newLeft, newTop);
}
}
private void ChannelBox_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
if (!isEditMode || !_isDragging || _draggedElement == null) return;
_isDragging = false;
_draggedElement.ReleaseMouseCapture();
_draggedElement = null;
}
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_MouseRightButtonDown(object sender, MouseButtonEventArgs e) => ChannelBox_MouseRightButtonDown(sender, e);
private void ToggleEditMode_Click(object sender, RoutedEventArgs e)
{
isEditMode = !isEditMode;
var menuItem = (MenuItem)sender;
menuItem.Header = isEditMode ? "Disable Edit Mode" : "Enable Edit Mode";
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
_settingsManager.SaveSettings();
base.OnClosing(e);
}
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(_settingsManager.LastCodeplugPath) && File.Exists(_settingsManager.LastCodeplugPath))
{
LoadCodeplug(_settingsManager.LastCodeplugPath);
}
else
{
GenerateChannelWidgets();
}
}
}
}

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
namespace WhackerLinkConsoleV2
{
public class SettingsManager
{
private const string SettingsFilePath = "UserSettings.json";
public bool ShowSystemStatus { get; set; } = true;
public bool ShowChannels { get; set; } = true;
public string LastCodeplugPath { get; set; } = null;
public Dictionary<string, ChannelPosition> ChannelPositions { get; set; } = new Dictionary<string, ChannelPosition>();
public void LoadSettings()
{
if (!File.Exists(SettingsFilePath)) return;
try
{
var json = File.ReadAllText(SettingsFilePath);
var loadedSettings = JsonConvert.DeserializeObject<SettingsManager>(json);
if (loadedSettings != null)
{
ShowSystemStatus = loadedSettings.ShowSystemStatus;
ShowChannels = loadedSettings.ShowChannels;
LastCodeplugPath = loadedSettings.LastCodeplugPath;
ChannelPositions = loadedSettings.ChannelPositions ?? new Dictionary<string, ChannelPosition>();
}
}
catch (Exception ex)
{
Console.WriteLine($"Error loading settings: {ex.Message}");
}
}
public void SaveSettings()
{
try
{
var json = JsonConvert.SerializeObject(this, Formatting.Indented);
File.WriteAllText(SettingsFilePath, json);
}
catch (Exception ex)
{
Console.WriteLine($"Error saving settings: {ex.Message}");
}
}
public void UpdateChannelPosition(string channelName, double x, double y)
{
if (ChannelPositions.ContainsKey(channelName))
{
ChannelPositions[channelName].X = x;
ChannelPositions[channelName].Y = y;
}
else
{
ChannelPositions[channelName] = new ChannelPosition { X = x, Y = y };
}
}
}
}

@ -0,0 +1,13 @@
<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">
<Border Background="{Binding Background, RelativeSource={RelativeSource AncestorType=UserControl}}" CornerRadius="5" Padding="10">
<StackPanel>
<TextBlock Text="{Binding SystemName}" FontWeight="Bold" Foreground="White" FontSize="14"/>
<TextBlock Text="{Binding AddressPort}" Foreground="LightGray" FontSize="12"/>
<TextBlock Text="Connection State:" Foreground="LightGray" FontSize="12"/>
<TextBlock Text="{Binding ConnectionState}" Foreground="White" FontSize="12"/>
</StackPanel>
</Border>
</UserControl>

@ -0,0 +1,23 @@
using System.Windows.Controls;
namespace WhackerLinkConsoleV2.Controls
{
public partial class SystemStatusBox : UserControl
{
public string SystemName { get; set; }
public string AddressPort { get; set; }
public string ConnectionState { get; set; } = "Disconnected";
public SystemStatusBox()
{
InitializeComponent();
DataContext = this;
}
public SystemStatusBox(string systemName, string address, int port) : this()
{
SystemName = systemName;
AddressPort = $"Address: {address}:{port}";
}
}
}

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="YamlDotNet" Version="16.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WhackerLinkLib\WhackerLinkLib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,11 @@
<Window x:Class="WhackerLinkConsoleV2.WidgetSelectionWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Select Widgets" Height="200" Width="300" WindowStartupLocation="CenterOwner">
<StackPanel Margin="20">
<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="ChannelCheckBox" Content="Channel" IsChecked="True" />
<Button Content="Apply" Width="80" Margin="0,20,0,0" HorizontalAlignment="Center" Click="ApplyButton_Click" />
</StackPanel>
</Window>

@ -0,0 +1,23 @@
using System.Windows;
namespace WhackerLinkConsoleV2
{
public partial class WidgetSelectionWindow : Window
{
public bool ShowSystemStatus { get; private set; } = true;
public bool ShowChannels { get; private set; } = true;
public WidgetSelectionWindow()
{
InitializeComponent();
}
private void ApplyButton_Click(object sender, RoutedEventArgs e)
{
ShowSystemStatus = SystemStatusCheckBox.IsChecked ?? false;
ShowChannels = ChannelCheckBox.IsChecked ?? false;
DialogResult = true;
Close();
}
}
}

@ -0,0 +1 @@
Subproject commit d452c974cdfb7bb72425042e300c9a3442b89b57
Loading…
Cancel
Save

Powered by TurnKey Linux.