Skip to content

Commit

Permalink
Fix: Disable RDP reconnect menu item while already connecting... (#2988)
Browse files Browse the repository at this point in the history
* Fix: Don't allow reconnect while connecting

* Chore: Remove debug

* Docs: #2988
  • Loading branch information
BornToBeRoot authored Jan 17, 2025
1 parent f4d2b81 commit 80cbdcb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
31 changes: 15 additions & 16 deletions Source/NETworkManager/Controls/DragablzTabHostWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -71,7 +70,7 @@ private async void FocusEmbeddedWindow()

// Focus embedded window in the selected tab
(((DragablzTabItem)tabablzControl.SelectedItem)?.View as IEmbeddedWindow)?.FocusEmbeddedWindow();

break;
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<TabablzControl>(this))
foreach (var tabItem in tabablzControl.Items.OfType<DragablzTabItem>())
((IDragablzTabItem)tabItem.View).CloseTab();
foreach (var tabItem in tabablzControl.Items.OfType<DragablzTabItem>())
((IDragablzTabItem)tabItem.View).CloseTab();

// Reset the dragging state
switch (ApplicationName)
Expand Down Expand Up @@ -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<TabablzControl>(this))
{
// Skip if no items
if (tabablzControl.Items.Count == 0)
continue;

foreach (var item in tabablzControl.Items.OfType<DragablzTabItem>())
{
if (item.View is RemoteDesktopControl control)
Expand Down
3 changes: 3 additions & 0 deletions Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ private void Connect()

private void Reconnect()
{
if (IsConnecting)
return;

if (IsConnected)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions Website/docs/changelog/next-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 80cbdcb

Please sign in to comment.