Skip to content

Commit 80cbdcb

Browse files
authored
Fix: Disable RDP reconnect menu item while already connecting... (#2988)
* Fix: Don't allow reconnect while connecting * Chore: Remove debug * Docs: #2988
1 parent f4d2b81 commit 80cbdcb

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
using System;
1+
using Dragablz;
2+
using MahApps.Metro.Controls.Dialogs;
3+
using NETworkManager.Localization;
4+
using NETworkManager.Localization.Resources;
5+
using NETworkManager.Models;
6+
using NETworkManager.Models.RemoteDesktop;
7+
using NETworkManager.Settings;
8+
using NETworkManager.Utilities;
9+
using System;
210
using System.Collections.Generic;
311
using System.ComponentModel;
412
using System.Diagnostics;
@@ -9,15 +17,6 @@
917
using System.Windows.Forms;
1018
using System.Windows.Input;
1119
using System.Windows.Interop;
12-
using Dragablz;
13-
using MahApps.Metro.Controls.Dialogs;
14-
using NETworkManager.Localization;
15-
using NETworkManager.Localization.Resources;
16-
using NETworkManager.Models;
17-
using NETworkManager.Models.RemoteDesktop;
18-
using NETworkManager.Settings;
19-
using NETworkManager.Utilities;
20-
using Application = System.Windows.Application;
2120

2221
namespace NETworkManager.Controls;
2322

@@ -71,7 +70,7 @@ private async void FocusEmbeddedWindow()
7170

7271
// Focus embedded window in the selected tab
7372
(((DragablzTabItem)tabablzControl.SelectedItem)?.View as IEmbeddedWindow)?.FocusEmbeddedWindow();
74-
73+
7574
break;
7675
}
7776
}
@@ -169,7 +168,7 @@ private bool RemoteDesktop_IsConnected_CanExecute(object view)
169168
private bool RemoteDesktop_IsDisconnected_CanExecute(object view)
170169
{
171170
if (view is RemoteDesktopControl control)
172-
return !control.IsConnected;
171+
return !control.IsConnected && !control.IsConnecting;
173172

174173
return false;
175174
}
@@ -376,8 +375,8 @@ private void DragablzTabHostWindow_OnClosing(object sender, CancelEventArgs e)
376375
{
377376
// Find all TabablzControl in the active window
378377
foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren<TabablzControl>(this))
379-
foreach (var tabItem in tabablzControl.Items.OfType<DragablzTabItem>())
380-
((IDragablzTabItem)tabItem.View).CloseTab();
378+
foreach (var tabItem in tabablzControl.Items.OfType<DragablzTabItem>())
379+
((IDragablzTabItem)tabItem.View).CloseTab();
381380

382381
// Reset the dragging state
383382
switch (ApplicationName)
@@ -481,14 +480,14 @@ private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref
481480
}
482481

483482
private void UpdateOnWindowResize()
484-
{
483+
{
485484
// Find all TabablzControl
486485
foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren<TabablzControl>(this))
487486
{
488487
// Skip if no items
489488
if (tabablzControl.Items.Count == 0)
490489
continue;
491-
490+
492491
foreach (var item in tabablzControl.Items.OfType<DragablzTabItem>())
493492
{
494493
if (item.View is RemoteDesktopControl control)

Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs

+3
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ private void Connect()
327327

328328
private void Reconnect()
329329
{
330+
if (IsConnecting)
331+
return;
332+
330333
if (IsConnected)
331334
return;
332335

Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private bool IsConnected_CanExecute(object view)
245245
private bool IsDisconnected_CanExecute(object view)
246246
{
247247
if (view is RemoteDesktopControl control)
248-
return !control.IsConnected;
248+
return !control.IsConnected && !control.IsConnecting;
249249

250250
return false;
251251
}
@@ -281,7 +281,7 @@ private void FullscreenAction(object view)
281281
private void AdjustScreenAction(object view)
282282
{
283283
if (view is RemoteDesktopControl control)
284-
control.AdjustScreen(force:true);
284+
control.AdjustScreen(force: true);
285285
}
286286

287287
public ICommand SendCtrlAltDelCommand => new RelayCommand(SendCtrlAltDelAction, IsConnected_CanExecute);

Website/docs/changelog/next-release.md

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ Release date: **xx.xx.2024**
6060

6161
- Fixed two `NullReferenceException` in ICMP & NETBIOS for some IP addresses. [#2964](https://github.com/BornToBeRoot/NETworkManager/pull/2964)
6262

63+
- **Remote Desktop**
64+
65+
- Fixed an app crash when a reconnect was triggered while it was already trying to connect. [#2988](https://github.com/BornToBeRoot/NETworkManager/pull/2988)
66+
6367
## Dependencies, Refactoring & Documentation
6468

6569
- Migrated code for some loading indicators from the library [LoadingIndicators.WPF] (https://github.com/zeluisping/LoadingIndicators.WPF) to the NETworkManager repo, as the original repo looks unmaintained and has problems with MahApps.Metro version 2 and later. [#2963](https://github.com/BornToBeRoot/NETworkManager/pull/2963)

0 commit comments

Comments
 (0)