From 11ba37c1c284580a7a35bc80331aa45545aeea97 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Fri, 21 Mar 2025 13:05:38 -0400 Subject: [PATCH] when GenerateChannelWidgets() is called ensure the systemStatuses are cleared and all FNE systems are cleared and shutdown; when loading a codeplug ensure controls are disabled, and are only enabled after widget generation finishes; --- dvmconsole/MainWindow.xaml.cs | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/dvmconsole/MainWindow.xaml.cs b/dvmconsole/MainWindow.xaml.cs index f6c8881..3248a20 100644 --- a/dvmconsole/MainWindow.xaml.cs +++ b/dvmconsole/MainWindow.xaml.cs @@ -216,6 +216,8 @@ namespace dvmconsole /// private void LoadCodeplug(string filePath) { + DisableControls(); + try { var deserializer = new DeserializerBuilder() @@ -223,11 +225,11 @@ namespace dvmconsole .IgnoreUnmatchedProperties() .Build(); - var yaml = File.ReadAllText(filePath); + string yaml = File.ReadAllText(filePath); Codeplug = deserializer.Deserialize(yaml); - EnableControls(); GenerateChannelWidgets(); + EnableControls(); } catch (Exception ex) { @@ -242,6 +244,10 @@ namespace dvmconsole private void GenerateChannelWidgets() { channelsCanvas.Children.Clear(); + systemStatuses.Clear(); + + fneSystemManager.ClearAll(); + double offsetX = 20; double offsetY = 20; @@ -249,10 +255,10 @@ namespace dvmconsole if (Codeplug != null) { + // load and initialize systems foreach (var system in Codeplug.Systems) { - var systemStatusBox = new SystemStatusBox(system.Name, system.Address, system.Port); - + SystemStatusBox systemStatusBox = new SystemStatusBox(system.Name, system.Address, system.Port); if (settingsManager.SystemStatusPositions.TryGetValue(system.Name, out var position)) { Canvas.SetLeft(systemStatusBox, position.X); @@ -277,13 +283,14 @@ namespace dvmconsole offsetY += 106; } + // do we have aliases for this system? if (File.Exists(system.AliasPath)) system.RidAlias = AliasTools.LoadAliases(system.AliasPath); fneSystemManager.AddFneSystem(system.Name, system, this); - PeerSystem peer = fneSystemManager.GetFneSystem(system.Name); + // hook FNE events peer.peer.PeerConnected += (sender, response) => { Trace.WriteLine("FNE Peer connected"); @@ -304,6 +311,7 @@ namespace dvmconsole }); }; + // start peer Task.Run(() => { try @@ -318,18 +326,19 @@ namespace dvmconsole if (!settingsManager.ShowSystemStatus) systemStatusBox.Visibility = Visibility.Collapsed; - } } + // are we showing channels? if (settingsManager.ShowChannels && Codeplug != null) { + // iterate through the coeplug zones and begin building channel widgets foreach (var zone in Codeplug.Zones) { + // iterate through zone channels. foreach (var channel in zone.Channels) { - var channelBox = new ChannelBox(selectedChannelsManager, audioManager, channel.Name, channel.System, channel.Tgid); - + ChannelBox channelBox = new ChannelBox(selectedChannelsManager, audioManager, channel.Name, channel.System, channel.Tgid); systemStatuses.Add(channel.Name, new SlotStatus()); if (settingsManager.ChannelPositions.TryGetValue(channel.Name, out var position)) @@ -363,11 +372,13 @@ namespace dvmconsole } } + // are we showing user configured alert tones? if (settingsManager.ShowAlertTones && Codeplug != null) { + // iterate through the alert tones and begin building alert tone widges foreach (var alertPath in settingsManager.AlertToneFilePaths) { - var alertTone = new AlertTone(alertPath) { IsEditMode = isEditMode }; + AlertTone alertTone = new AlertTone(alertPath) { IsEditMode = isEditMode }; alertTone.OnAlertTone += SendAlertTone; if (settingsManager.AlertTonePositions.TryGetValue(alertPath, out var position)) @@ -387,6 +398,7 @@ namespace dvmconsole } } + // initialize the playback channel playbackChannelBox = new ChannelBox(selectedChannelsManager, audioManager, PLAYBACKCHNAME, PLAYBACKSYS, PLAYBACKTG); if (settingsManager.ChannelPositions.TryGetValue(PLAYBACKCHNAME, out var pos)) @@ -427,10 +439,11 @@ namespace dvmconsole PeerSystem fne = fneSystemManager.GetFneSystem(system.Name); + // is the channel selected? if (channel.IsSelected) { - uint newTgid = UInt32.Parse(cpgChannel.Tgid); - + // if the channel is configured for encryption request the key from the FNE + uint newTgid = uint.Parse(cpgChannel.Tgid); if (cpgChannel.GetAlgoId() != 0 && cpgChannel.GetKeyId() != 0) fne.peer.SendMasterKeyRequest(cpgChannel.GetAlgoId(), cpgChannel.GetKeyId()); }