diff --git a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs index 8558a9b368..1853dbecc4 100644 --- a/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs +++ b/Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs @@ -1,4 +1,12 @@ -using System; +using Dragablz; +using MahApps.Metro.Controls.Dialogs; +using NETworkManager.Localization; +using NETworkManager.Localization.Resources; +using NETworkManager.Models; +using NETworkManager.Models.RemoteDesktop; +using NETworkManager.Settings; +using NETworkManager.Utilities; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; @@ -9,15 +17,6 @@ using System.Windows.Forms; using System.Windows.Input; using System.Windows.Interop; -using Dragablz; -using MahApps.Metro.Controls.Dialogs; -using NETworkManager.Localization; -using NETworkManager.Localization.Resources; -using NETworkManager.Models; -using NETworkManager.Models.RemoteDesktop; -using NETworkManager.Settings; -using NETworkManager.Utilities; -using Application = System.Windows.Application; namespace NETworkManager.Controls; @@ -71,7 +70,7 @@ private async void FocusEmbeddedWindow() // Focus embedded window in the selected tab (((DragablzTabItem)tabablzControl.SelectedItem)?.View as IEmbeddedWindow)?.FocusEmbeddedWindow(); - + break; } } @@ -169,7 +168,7 @@ private bool RemoteDesktop_IsConnected_CanExecute(object view) private bool RemoteDesktop_IsDisconnected_CanExecute(object view) { if (view is RemoteDesktopControl control) - return !control.IsConnected; + return !control.IsConnected && !control.IsConnecting; return false; } @@ -376,8 +375,8 @@ private void DragablzTabHostWindow_OnClosing(object sender, CancelEventArgs e) { // Find all TabablzControl in the active window foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(this)) - foreach (var tabItem in tabablzControl.Items.OfType()) - ((IDragablzTabItem)tabItem.View).CloseTab(); + foreach (var tabItem in tabablzControl.Items.OfType()) + ((IDragablzTabItem)tabItem.View).CloseTab(); // Reset the dragging state switch (ApplicationName) @@ -481,14 +480,14 @@ private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref } private void UpdateOnWindowResize() - { + { // Find all TabablzControl foreach (var tabablzControl in VisualTreeHelper.FindVisualChildren(this)) { // Skip if no items if (tabablzControl.Items.Count == 0) continue; - + foreach (var item in tabablzControl.Items.OfType()) { if (item.View is RemoteDesktopControl control) diff --git a/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs b/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs index 98d9e24d8d..3ad004fdac 100644 --- a/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs +++ b/Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs @@ -327,6 +327,9 @@ private void Connect() private void Reconnect() { + if (IsConnecting) + return; + if (IsConnected) return; diff --git a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs index 66d4ec1058..06b8e44942 100644 --- a/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/RemoteDesktopHostViewModel.cs @@ -245,7 +245,7 @@ private bool IsConnected_CanExecute(object view) private bool IsDisconnected_CanExecute(object view) { if (view is RemoteDesktopControl control) - return !control.IsConnected; + return !control.IsConnected && !control.IsConnecting; return false; } @@ -281,7 +281,7 @@ private void FullscreenAction(object view) private void AdjustScreenAction(object view) { if (view is RemoteDesktopControl control) - control.AdjustScreen(force:true); + control.AdjustScreen(force: true); } public ICommand SendCtrlAltDelCommand => new RelayCommand(SendCtrlAltDelAction, IsConnected_CanExecute); diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index f21450391a..dbc1144ea0 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -60,6 +60,10 @@ Release date: **xx.xx.2024** - Fixed two `NullReferenceException` in ICMP & NETBIOS for some IP addresses. [#2964](https://github.com/BornToBeRoot/NETworkManager/pull/2964) +- **Remote Desktop** + + - Fixed an app crash when a reconnect was triggered while it was already trying to connect. [#2988](https://github.com/BornToBeRoot/NETworkManager/pull/2988) + ## Dependencies, Refactoring & Documentation - 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)