mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 14:07:46 +08:00
Add confirmation dialog for disconnect operation from context menu
Co-authored-by: Kvarkas <3611964+Kvarkas@users.noreply.github.com>
This commit is contained in:
9
mRemoteNG/Language/Language.Designer.cs
generated
9
mRemoteNG/Language/Language.Designer.cs
generated
@@ -1041,6 +1041,15 @@ namespace mRemoteNG.Resources.Language {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Are you sure you want to disconnect "{0}"?.
|
||||
/// </summary>
|
||||
internal static string ConfirmDisconnectConnection {
|
||||
get {
|
||||
return ResourceManager.GetString("ConfirmDisconnectConnection", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Are you sure you want to delete the credential record, {0}?.
|
||||
/// </summary>
|
||||
|
||||
@@ -348,6 +348,9 @@
|
||||
<data name="ConfirmCloseConnectionPanelMainInstruction" xml:space="preserve">
|
||||
<value>Are you sure you want to close the panel, "{0}"? Any connections that it contains will also be closed.</value>
|
||||
</data>
|
||||
<data name="ConfirmDisconnectConnection" xml:space="preserve">
|
||||
<value>Are you sure you want to disconnect "{0}"?</value>
|
||||
</data>
|
||||
<data name="ConfirmDeleteExternalTool" xml:space="preserve">
|
||||
<value>Are you sure you want to delete the external tool, "{0}"?</value>
|
||||
</data>
|
||||
|
||||
@@ -3,9 +3,12 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Config;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Properties;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tools.Clipboard;
|
||||
using mRemoteNG.Tree;
|
||||
@@ -13,6 +16,7 @@ using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.Resources.Language;
|
||||
using System.Runtime.Versioning;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.UI.TaskDialog;
|
||||
|
||||
// ReSharper disable UnusedParameter.Local
|
||||
|
||||
@@ -794,6 +798,27 @@ namespace mRemoteNG.UI.Controls
|
||||
try
|
||||
{
|
||||
if (connectionInfo == null) return;
|
||||
|
||||
// Check if confirmation is needed based on settings
|
||||
if (Settings.Default.ConfirmCloseConnection == (int)ConfirmCloseEnum.All)
|
||||
{
|
||||
string confirmMessage = string.Format(Language.ConfirmDisconnectConnection, connectionInfo.Name);
|
||||
DialogResult result = CTaskDialog.MessageBox(this, GeneralAppInfo.ProductName,
|
||||
confirmMessage, "", "", "",
|
||||
Language.CheckboxDoNotShowThisMessageAgain,
|
||||
ETaskDialogButtons.YesNo, ESysIcons.Question,
|
||||
ESysIcons.Question);
|
||||
if (CTaskDialog.VerificationChecked)
|
||||
{
|
||||
Settings.Default.ConfirmCloseConnection--;
|
||||
}
|
||||
|
||||
if (result == DialogResult.No)
|
||||
{
|
||||
return; // User cancelled the disconnect
|
||||
}
|
||||
}
|
||||
|
||||
ContainerInfo nodeAsContainer = connectionInfo as ContainerInfo;
|
||||
if (nodeAsContainer != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user