code tidy up

This commit is contained in:
Dimitrij
2025-10-21 22:19:22 +01:00
parent facc523aae
commit 1288a274f3
24 changed files with 105 additions and 77 deletions

View File

@@ -431,7 +431,7 @@ namespace BrightIdeasSoftware
/// Override the basic message pump
/// </summary>
/// <param name="m"></param>
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
//[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
protected override void WndProc(ref Message m)
{
const int WM_DESTROY = 2;
@@ -492,7 +492,7 @@ namespace BrightIdeasSoftware
base.WndProc(ref m);
}
private bool HandleReflectNotify(ref Message m)
private static bool HandleReflectNotify(ref Message m)
{
NativeMethods.NMHDR nmhdr = (NativeMethods.NMHDR)m.GetLParam(typeof(NativeMethods.NMHDR));
System.Diagnostics.Debug.WriteLine(String.Format("rn: {0}", nmhdr.code));

View File

@@ -77,14 +77,16 @@ using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Windows.Forms;
using MethodInvoker = System.Windows.Forms.MethodInvoker;
namespace BrightIdeasSoftware
{
[SupportedOSPlatform("windows")]
/// <summary>
/// A virtual object list view operates in virtual mode, that is, it only gets model objects for
/// a row when it is needed. This gives it the ability to handle very large numbers of rows with

View File

@@ -10,7 +10,7 @@ using mRemoteNG.UI.Window;
namespace mRemoteNG.App
{
[SupportedOSPlatform("windows")]
public static class Windows
public static class AppWindows
{
private static ActiveDirectoryImportWindow _adimportForm;
private static ExternalToolsWindow _externalappsForm;

View File

@@ -57,9 +57,9 @@ namespace mRemoteNG.App.Initialization
return new OnlyLogMessageFilter(
new MessageTypeFilterDecorator(
new NotificationPanelMessageFilteringOptions(),
new MessageFocusDecorator(Windows.ErrorsForm,
new MessageFocusDecorator(AppWindows.ErrorsForm,
new NotificationPanelSwitchOnMessageFilteringOptions(),
new NotificationPanelMessageWriter(Windows.ErrorsForm))
new NotificationPanelMessageWriter(AppWindows.ErrorsForm))
)
);
}

View File

@@ -63,7 +63,7 @@ namespace mRemoteNG.Config.Settings
}
}
private IDockContent GetContentFromPersistString(string persistString)
private IDockContent? GetContentFromPersistString(string persistString)
{
// pnlLayout.xml persistence XML fix for refactoring to mRemoteNG
if (persistString.StartsWith("mRemote."))
@@ -72,13 +72,13 @@ namespace mRemoteNG.Config.Settings
try
{
if (persistString == typeof(ConfigWindow).ToString())
return App.Windows.ConfigForm;
return AppWindows.ConfigForm;
if (persistString == typeof(ConnectionTreeWindow).ToString())
return App.Windows.TreeForm;
return AppWindows.TreeForm;
if (persistString == typeof(ErrorAndInfoWindow).ToString())
return App.Windows.ErrorsForm;
return AppWindows.ErrorsForm;
}
catch (Exception ex)
{

View File

@@ -9,6 +9,7 @@ using mRemoteNG.Connection.Protocol.ARD;
using mRemoteNG.Connection.Protocol.Http;
using mRemoteNG.Connection.Protocol.PowerShell;
using mRemoteNG.Connection.Protocol.Terminal;
using mRemoteNG.Connection.Protocol.WSL;
using mRemoteNG.Connection.Protocol.RAW;
using mRemoteNG.Connection.Protocol.RDP;
using mRemoteNG.Connection.Protocol.Rlogin;

View File

@@ -38,13 +38,14 @@ namespace mRemoteNG.Connection.Protocol
[LocalizedAttributes.LocalizedDescription(nameof(Language.Ard))]
ARD = 11,
[LocalizedAttributes.LocalizedDescription(nameof(Language.Wsl))]
WSL = 12,
[LocalizedAttributes.LocalizedDescription(nameof(Language.Terminal))]
Terminal = 12,
[LocalizedAttributes.LocalizedDescription(nameof(Language.Wsl))]
WSL = 13,
[LocalizedAttributes.LocalizedDescription(nameof(Language.AnyDesk))]
AnyDesk = 13,
AnyDesk = 14,
[LocalizedAttributes.LocalizedDescription(nameof(Language.ExternalTool))]
IntApp = 20
@@ -54,8 +55,7 @@ namespace mRemoteNG.Connection.Protocol
{
public static bool SupportBlankHostname(ProtocolType protocolType)
{
return (protocolType == ProtocolType.IntApp || protocolType == ProtocolType.PowerShell || protocolType == ProtocolType.WSL);
return (protocolType == ProtocolType.IntApp || protocolType == ProtocolType.PowerShell || protocolType == ProtocolType.Terminal);
return (protocolType == ProtocolType.IntApp || protocolType == ProtocolType.PowerShell || protocolType == ProtocolType.WSL || protocolType == ProtocolType.Terminal);
}
}
}

View File

@@ -375,6 +375,15 @@ namespace mRemoteNG.Resources.Language {
}
}
/// <summary>
/// Looks up a localized string similar to AnyDesk.
/// </summary>
internal static string AnyDesk {
get {
return ResourceManager.GetString("AnyDesk", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Appearance.
/// </summary>
@@ -6504,6 +6513,15 @@ namespace mRemoteNG.Resources.Language {
}
}
/// <summary>
/// Looks up a localized string similar to Terminal.
/// </summary>
internal static string Terminal {
get {
return ResourceManager.GetString("Terminal", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Test connection.
/// </summary>
@@ -7279,6 +7297,15 @@ namespace mRemoteNG.Resources.Language {
}
}
/// <summary>
/// Looks up a localized string similar to WSL.
/// </summary>
internal static string Wsl {
get {
return ResourceManager.GetString("Wsl", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Yes.
/// </summary>

View File

@@ -11,7 +11,7 @@ using System.Resources;
// Compute version values
//Build nr: 3177
//Build nr: 3225
// General Information
[assembly: AssemblyTitle("mRemoteNG")]
@@ -24,7 +24,7 @@ using System.Resources;
[assembly: AssemblyCulture("")]
// Version information
[assembly: AssemblyVersion("1.78.2.3177")]
[assembly: AssemblyFileVersion("1.78.2.3177")]
[assembly: AssemblyVersion("1.78.2.3225")]
[assembly: AssemblyFileVersion("1.78.2.3225")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
[assembly: AssemblyInformationalVersion("1.78.2 (Nightly Build 3177) x64")]
[assembly: AssemblyInformationalVersion("1.78.2 (Nightly Build 3225) x64")]

View File

@@ -856,12 +856,12 @@ namespace mRemoteNG.UI.Controls
{
try
{
App.Windows.Show(WindowType.SSHTransfer);
App.Windows.SshtransferForm.Hostname = _connectionTree.SelectedNode.Hostname;
App.Windows.SshtransferForm.Username = _connectionTree.SelectedNode.Username;
AppWindows.Show(WindowType.SSHTransfer);
AppWindows.SshtransferForm.Hostname = _connectionTree.SelectedNode.Hostname;
AppWindows.SshtransferForm.Username = _connectionTree.SelectedNode.Username;
//App.Windows.SshtransferForm.Password = _connectionTree.SelectedNode.Password.ConvertToUnsecureString();
App.Windows.SshtransferForm.Password = _connectionTree.SelectedNode.Password;
App.Windows.SshtransferForm.Port = Convert.ToString(_connectionTree.SelectedNode.Port);
AppWindows.SshtransferForm.Password = _connectionTree.SelectedNode.Password;
AppWindows.SshtransferForm.Port = Convert.ToString(_connectionTree.SelectedNode.Port);
}
catch (Exception ex)
{
@@ -926,12 +926,12 @@ namespace mRemoteNG.UI.Controls
private void OnImportActiveDirectoryClicked(object sender, EventArgs e)
{
App.Windows.Show(WindowType.ActiveDirectoryImport);
AppWindows.Show(WindowType.ActiveDirectoryImport);
}
private void OnImportPortScanClicked(object sender, EventArgs e)
{
App.Windows.Show(WindowType.PortScan);
AppWindows.Show(WindowType.PortScan);
}
private void OnExportFileClicked(object sender, EventArgs e)

View File

@@ -450,7 +450,7 @@ namespace mRemoteNG.UI.Controls.ConnectionTree
{
try
{
App.Windows.ConfigForm.SelectedTreeNode = SelectedNode;
AppWindows.ConfigForm.SelectedTreeNode = SelectedNode;
}
catch (Exception ex)
{
@@ -548,7 +548,7 @@ namespace mRemoteNG.UI.Controls.ConnectionTree
// ensures that if we are filtering and a new item is added that doesn't match the filter, it will be filtered out
_connectionTreeSearchTextFilter.SpecialInclusionList.Clear();
UpdateFiltering();
App.Windows.ConfigForm.SelectedTreeNode = SelectedNode;
AppWindows.ConfigForm.SelectedTreeNode = SelectedNode;
}
catch (Exception ex)
{

View File

@@ -100,7 +100,7 @@ namespace mRemoteNG.UI.Controls
{
ExternalTool extA = (ExternalTool)((ToolStripButton)sender).Tag;
Connection.ConnectionInfo selectedTreeNode = App.Windows.TreeForm.SelectedNode;
Connection.ConnectionInfo selectedTreeNode = AppWindows.TreeForm.SelectedNode;
if (selectedTreeNode != null && selectedTreeNode.GetTreeNodeType() == TreeNodeType.Connection ||
selectedTreeNode.GetTreeNodeType() == TreeNodeType.PuttySession)
extA.Start(selectedTreeNode);

View File

@@ -217,8 +217,8 @@ namespace mRemoteNG.UI.Forms.OptionsPages
private async void btnUpdateCheckNow_Click(object sender, EventArgs e)
{
App.Windows.Show(WindowType.Update);
var updateWindow = App.Windows.UpdateForm;
AppWindows.Show(WindowType.Update);
var updateWindow = AppWindows.UpdateForm;
if (updateWindow != null && !updateWindow.IsDisposed)
{
await updateWindow.PerformUpdateCheckAsync();

View File

@@ -230,7 +230,7 @@ namespace mRemoteNG.UI.Forms
// Initialize panel binding for Connections and Config panels
UI.Panels.PanelBinder.Instance.Initialize();
App.Windows.TreeForm.Focus();
AppWindows.TreeForm.Focus();
PuttySessionsManager.Instance.StartWatcher();
@@ -322,7 +322,7 @@ namespace mRemoteNG.UI.Forms
private void SetMenuDependencies()
{
fileMenu.TreeWindow = App.Windows.TreeForm;
fileMenu.TreeWindow = AppWindows.TreeForm;
viewMenu.TsExternalTools = _externalToolsToolStrip;
viewMenu.TsQuickConnect = _quickConnectToolStrip;
@@ -401,9 +401,9 @@ namespace mRemoteNG.UI.Forms
if (CTaskDialog.CommandButtonResult != 1) return;
App.Windows.Show(WindowType.Options);
if (App.Windows.OptionsFormWindow != null)
App.Windows.OptionsFormWindow.SetActivatedPage(Language.Updates);
AppWindows.Show(WindowType.Options);
if (AppWindows.OptionsFormWindow != null)
AppWindows.OptionsFormWindow.SetActivatedPage(Language.Updates);
}
private async Task CheckForUpdates()
@@ -705,7 +705,7 @@ namespace mRemoteNG.UI.Forms
titleBuilder.Append(SelectedConnection.Name);
if (Properties.Settings.Default.TrackActiveConnectionInConnectionTree)
App.Windows.TreeForm.JumpToNode(SelectedConnection);
AppWindows.TreeForm.JumpToNode(SelectedConnection);
}
Text = titleBuilder.ToString();
@@ -765,9 +765,9 @@ namespace mRemoteNG.UI.Forms
{
pnlDock.Visible = false;
App.Windows.TreeForm.Show(pnlDock, DockState.DockLeft);
App.Windows.ConfigForm.Show(pnlDock, DockState.DockLeft);
App.Windows.ErrorsForm.Show(pnlDock, DockState.DockBottomAutoHide);
AppWindows.TreeForm.Show(pnlDock, DockState.DockLeft);
AppWindows.ConfigForm.Show(pnlDock, DockState.DockLeft);
AppWindows.ErrorsForm.Show(pnlDock, DockState.DockBottomAutoHide);
viewMenu._mMenViewErrorsAndInfos.Checked = true;
ShowFileMenu();
@@ -794,7 +794,7 @@ namespace mRemoteNG.UI.Forms
if (Properties.Settings.Default.ViewMenuMessages == true)
{
App.Windows.ErrorsForm.Show(pnlDock, DockState.DockBottomAutoHide);
AppWindows.ErrorsForm.Show(pnlDock, DockState.DockBottomAutoHide);
viewMenu._mMenViewErrorsAndInfos.Checked = true;
}
else

View File

@@ -203,7 +203,7 @@ namespace mRemoteNG.UI.Menu
private void mMenToolsOptions_Click(object sender, EventArgs e)
{
App.Windows.Show(WindowType.Options);
AppWindows.Show(WindowType.Options);
}
#endregion

View File

@@ -180,8 +180,8 @@ namespace mRemoteNG.UI.Menu
private async void mMenToolsUpdate_Click(object sender, EventArgs e)
{
App.Windows.Show(WindowType.Update);
var updateWindow = App.Windows.UpdateForm;
AppWindows.Show(WindowType.Update);
var updateWindow = AppWindows.UpdateForm;
if (updateWindow != null && !updateWindow.IsDisposed)
{
await updateWindow.PerformUpdateCheckAsync();

View File

@@ -88,27 +88,27 @@ namespace mRemoteNG.UI.Menu
private void mMenToolsSSHTransfer_Click(object sender, EventArgs e)
{
App.Windows.Show(WindowType.SSHTransfer);
AppWindows.Show(WindowType.SSHTransfer);
}
private void mMenToolsUVNCSC_Click(object sender, EventArgs e)
{
App.Windows.Show(WindowType.UltraVNCSC);
AppWindows.Show(WindowType.UltraVNCSC);
}
private void mMenToolsExternalApps_Click(object sender, EventArgs e)
{
App.Windows.Show(WindowType.ExternalApps);
AppWindows.Show(WindowType.ExternalApps);
}
private void mMenToolsPortScan_Click(object sender, EventArgs e)
{
App.Windows.Show(WindowType.PortScan);
AppWindows.Show(WindowType.PortScan);
}
private void mMenToolsOptions_Click(object sender, EventArgs e)
{
App.Windows.Show(WindowType.Options);
AppWindows.Show(WindowType.Options);
}
#endregion

View File

@@ -198,7 +198,7 @@ namespace mRemoteNG.UI.Menu
internal void mMenView_DropDownOpening(object sender, EventArgs e)
{
_mMenViewErrorsAndInfos.Checked = !App.Windows.ErrorsForm.IsHidden;
_mMenViewErrorsAndInfos.Checked = !AppWindows.ErrorsForm.IsHidden;
_mMenViewLockToolbars.Checked = Settings.Default.LockToolbars;
_mMenViewExtAppsToolbar.Checked = TsExternalTools.Visible;
@@ -227,12 +227,12 @@ namespace mRemoteNG.UI.Menu
{
if (_mMenViewErrorsAndInfos.Checked == false)
{
App.Windows.ErrorsForm.Show(MainForm.pnlDock);
AppWindows.ErrorsForm.Show(MainForm.pnlDock);
_mMenViewErrorsAndInfos.Checked = true;
}
else
{
App.Windows.ErrorsForm.Hide();
AppWindows.ErrorsForm.Hide();
_mMenViewErrorsAndInfos.Checked = false;
}
}

View File

@@ -1,9 +1,9 @@
using System;
using System;
using System.Runtime.Versioning;
using mRemoteNG.App;
using mRemoteNG.Properties;
using WeifenLuo.WinFormsUI.Docking;
using mRemoteNG.UI;
namespace mRemoteNG.UI.Panels
{
/// <summary>
@@ -26,14 +26,14 @@ namespace mRemoteNG.UI.Panels
/// </summary>
public void Initialize()
{
if (Windows.TreeForm != null)
if (AppWindows.TreeForm != null)
{
Windows.TreeForm.VisibleChanged += OnTreeFormVisibleChanged;
AppWindows.TreeForm.VisibleChanged += OnTreeFormVisibleChanged;
}
if (Windows.ConfigForm != null)
if (AppWindows.ConfigForm != null)
{
Windows.ConfigForm.VisibleChanged += OnConfigFormVisibleChanged;
AppWindows.ConfigForm.VisibleChanged += OnConfigFormVisibleChanged;
}
}
@@ -44,18 +44,18 @@ namespace mRemoteNG.UI.Panels
return;
// Only act when the panel becomes visible (expanded from auto-hide)
if (!Windows.TreeForm.Visible)
if (!AppWindows.TreeForm.Visible)
return;
// Only bind when both panels are in auto-hide state
if (!IsPanelAutoHidden(Windows.TreeForm) || !IsPanelAutoHidden(Windows.ConfigForm))
if (!IsPanelAutoHidden(AppWindows.TreeForm) || !IsPanelAutoHidden(AppWindows.ConfigForm))
return;
_isProcessing = true;
try
{
// Show the Config panel by activating it
ShowPanel(Windows.ConfigForm);
ShowPanel(AppWindows.ConfigForm);
}
finally
{
@@ -70,18 +70,18 @@ namespace mRemoteNG.UI.Panels
return;
// Only act when the panel becomes visible (expanded from auto-hide)
if (!Windows.ConfigForm.Visible)
if (!AppWindows.ConfigForm.Visible)
return;
// Only bind when both panels are in auto-hide state
if (!IsPanelAutoHidden(Windows.TreeForm) || !IsPanelAutoHidden(Windows.ConfigForm))
if (!IsPanelAutoHidden(AppWindows.TreeForm) || !IsPanelAutoHidden(AppWindows.ConfigForm))
return;
_isProcessing = true;
try
{
// Show the Connections panel by activating it
ShowPanel(Windows.TreeForm);
ShowPanel(AppWindows.TreeForm);
}
finally
{

View File

@@ -44,7 +44,7 @@ namespace mRemoteNG.UI.Window
private void BtnImport_Click(object sender, EventArgs e)
{
Connection.ConnectionInfo selectedNode = App.Windows.TreeForm.SelectedNode;
Connection.ConnectionInfo selectedNode = AppWindows.TreeForm.SelectedNode;
ContainerInfo importDestination;
if (selectedNode != null)
importDestination = selectedNode as ContainerInfo ?? selectedNode.Parent;

View File

@@ -515,14 +515,14 @@ namespace mRemoteNG.UI.Window
InterfaceControl interfaceControl = GetInterfaceControl();
if (interfaceControl == null) return;
App.Windows.Show(WindowType.SSHTransfer);
AppWindows.Show(WindowType.SSHTransfer);
ConnectionInfo connectionInfo = interfaceControl.Info;
App.Windows.SshtransferForm.Hostname = connectionInfo.Hostname;
App.Windows.SshtransferForm.Username = connectionInfo.Username;
AppWindows.SshtransferForm.Hostname = connectionInfo.Hostname;
AppWindows.SshtransferForm.Username = connectionInfo.Username;
//App.Windows.SshtransferForm.Password = connectionInfo.Password.ConvertToUnsecureString();
App.Windows.SshtransferForm.Password = connectionInfo.Password;
App.Windows.SshtransferForm.Port = Convert.ToString(connectionInfo.Port);
AppWindows.SshtransferForm.Password = connectionInfo.Password;
AppWindows.SshtransferForm.Port = Convert.ToString(connectionInfo.Port);
}
catch (Exception ex)
{

View File

@@ -192,7 +192,7 @@ namespace mRemoteNG.UI.Window
if (PreviousActiveForm != null)
PreviousActiveForm.Show(FrmMain.Default.pnlDock);
else
App.Windows.TreeForm.Show(FrmMain.Default.pnlDock);
AppWindows.TreeForm.Show(FrmMain.Default.pnlDock);
}
catch (Exception)
{

View File

@@ -302,13 +302,11 @@ namespace mRemoteNG.UI.Window
/// </summary>
private ContainerInfo GetDestinationContainerForImportedHosts()
{
ConnectionInfo selectedNode = App.Windows.TreeForm.SelectedNode
?? App.Windows.TreeForm.ConnectionTree.ConnectionTreeModel.RootNodes.OfType<RootNodeInfo>()
.First();
ConnectionInfo selectedNode = AppWindows.TreeForm.SelectedNode ?? AppWindows.TreeForm.ConnectionTree.ConnectionTreeModel.RootNodes.OfType<RootNodeInfo>().First();
// if a putty node is selected, place imported connections in the root connection node
if (selectedNode is RootPuttySessionsNodeInfo || selectedNode is PuttySessionInfo)
selectedNode = App.Windows.TreeForm.ConnectionTree.ConnectionTreeModel.RootNodes.OfType<RootNodeInfo>()
selectedNode = AppWindows.TreeForm.ConnectionTree.ConnectionTreeModel.RootNodes.OfType<RootNodeInfo>()
.First();
// if the selected node is a connection, use its parent container

View File

@@ -171,7 +171,7 @@ namespace mRemoteNG.UI.Window
{
//vnc.Dispose()
Dispose();
App.Windows.Show(WindowType.UltraVNCSC);
AppWindows.Show(WindowType.UltraVNCSC);
}
#endregion