mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
merged branch 'develop' into 'improve_credential_manager'
# Conflicts: # CredentialManagerForm.cs # PasswordForm.cs
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Config.Serializers;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNGTests.TestHelpers;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers
|
||||
{
|
||||
public class DataTableDeserializerTests
|
||||
{
|
||||
private DataTableDeserializer _deserializer;
|
||||
|
||||
[Test]
|
||||
public void WeCanDeserializeATree()
|
||||
{
|
||||
var model = CreateConnectionTreeModel();
|
||||
var dataTable = CreateDataTable(model.RootNodes[0]);
|
||||
_deserializer = new DataTableDeserializer();
|
||||
var output = _deserializer.Deserialize(dataTable);
|
||||
Assert.That(output.GetRecursiveChildList().Count(), Is.EqualTo(model.GetRecursiveChildList().Count()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WeCanDeserializeASingleEntry()
|
||||
{
|
||||
var dataTable = CreateDataTable(new ConnectionInfo());
|
||||
_deserializer = new DataTableDeserializer();
|
||||
var output = _deserializer.Deserialize(dataTable);
|
||||
Assert.That(output.GetRecursiveChildList().Count(), Is.EqualTo(1));
|
||||
}
|
||||
|
||||
|
||||
private DataTable CreateDataTable(ConnectionInfo tableContent)
|
||||
{
|
||||
var serializer = new DataTableSerializer(new SaveFilter());
|
||||
return serializer.Serialize(tableContent);
|
||||
}
|
||||
|
||||
private ConnectionTreeModel CreateConnectionTreeModel()
|
||||
{
|
||||
var builder = new ConnectionTreeModelBuilder();
|
||||
return builder.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNGTests.TestHelpers;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Config.Serializers
|
||||
@@ -20,13 +21,6 @@ namespace mRemoteNGTests.Config.Serializers
|
||||
_dataTableSerializer = new DataTableSerializer(_saveFilter);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
_saveFilter = null;
|
||||
_dataTableSerializer = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllItemsSerialized()
|
||||
{
|
||||
@@ -35,6 +29,14 @@ namespace mRemoteNGTests.Config.Serializers
|
||||
Assert.That(dataTable.Rows.Count, Is.EqualTo(3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReturnsEmptyDataTableWhenGivenEmptyConnectionTreeModel()
|
||||
{
|
||||
var model = new ConnectionTreeModel();
|
||||
var dataTable = _dataTableSerializer.Serialize(model);
|
||||
Assert.That(dataTable.Rows.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UsernameSerializedWhenSaveSecurityAllowsIt()
|
||||
{
|
||||
@@ -109,20 +111,18 @@ namespace mRemoteNGTests.Config.Serializers
|
||||
Assert.That(dataTable.Rows[0]["InheritUsername"], Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanSerializeEmptyConnectionInfo()
|
||||
{
|
||||
var dataTable = _dataTableSerializer.Serialize(new ConnectionInfo());
|
||||
Assert.That(dataTable.Rows.Count, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
|
||||
private ConnectionTreeModel CreateConnectionTreeModel()
|
||||
{
|
||||
var model = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var folder1 = new ContainerInfo {Name = "folder1", Username = "user1", Domain = "domain1", Password = "password1"};
|
||||
var con1 = new ConnectionInfo {Name = "Con1", Username = "user1", Domain = "domain1", Password = "password1" };
|
||||
var con2 = new ConnectionInfo {Name = "Con2", Username = "user2", Domain = "domain2", Password = "password2" };
|
||||
|
||||
root.AddChild(folder1);
|
||||
root.AddChild(con2);
|
||||
folder1.AddChild(con1);
|
||||
model.AddRootNode(root);
|
||||
return model;
|
||||
var builder = new ConnectionTreeModelBuilder();
|
||||
return builder.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
25
mRemoteNGTests/TestHelpers/ConnectionTreeModelBuilder.cs
Normal file
25
mRemoteNGTests/TestHelpers/ConnectionTreeModelBuilder.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNGTests.TestHelpers
|
||||
{
|
||||
public class ConnectionTreeModelBuilder
|
||||
{
|
||||
public ConnectionTreeModel Build()
|
||||
{
|
||||
var model = new ConnectionTreeModel();
|
||||
var root = new RootNodeInfo(RootNodeType.Connection);
|
||||
var folder1 = new ContainerInfo { Name = "folder1", Username = "user1", Domain = "domain1", Password = "password1" };
|
||||
var con1 = new ConnectionInfo { Name = "Con1", Username = "user1", Domain = "domain1", Password = "password1" };
|
||||
var con2 = new ConnectionInfo { Name = "Con2", Username = "user2", Domain = "domain2", Password = "password2" };
|
||||
|
||||
root.AddChild(folder1);
|
||||
root.AddChild(con2);
|
||||
folder1.AddChild(con1);
|
||||
model.AddRootNode(root);
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,6 +110,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="App\UpdaterTests.cs" />
|
||||
<Compile Include="BinaryFileTests.cs" />
|
||||
<Compile Include="Config\Serializers\DataTableDeserializerTests.cs" />
|
||||
<Compile Include="Config\CredentialHarvesterTests.cs" />
|
||||
<Compile Include="Config\CredentialRecordLoaderTests.cs" />
|
||||
<Compile Include="Config\Serializers\ConfConsEnsureConnectionsHaveIdsTests.cs" />
|
||||
@@ -154,6 +155,7 @@
|
||||
<Compile Include="Security\PasswordCreation\PasswordLengthConstraintTests.cs" />
|
||||
<Compile Include="Security\RandomGeneratorTests.cs" />
|
||||
<Compile Include="Security\SecureStringExtensionsTests.cs" />
|
||||
<Compile Include="TestHelpers\ConnectionTreeModelBuilder.cs" />
|
||||
<Compile Include="Security\XmlCryptoProviderBuilderTests.cs" />
|
||||
<Compile Include="Tools\ExternalToolsArgumentParserTests.cs" />
|
||||
<Compile Include="Tools\FullyObservableCollectionTests.cs" />
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
#endif
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
@@ -15,7 +16,10 @@ namespace mRemoteNG.App
|
||||
|
||||
public ILog Log { get; private set; }
|
||||
|
||||
public static string DefaultLogPath => BuildLogFilePath();
|
||||
public static string DefaultLogPath
|
||||
{
|
||||
get { return BuildLogFilePath(); }
|
||||
}
|
||||
|
||||
private Logger()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
@@ -84,6 +85,10 @@ namespace mRemoteNG.App
|
||||
|
||||
[DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
internal static extern bool SetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true)]
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
internal static extern bool CloseHandle(IntPtr handle);
|
||||
#endregion
|
||||
|
||||
#region Structures
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Forms;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
@@ -12,7 +13,10 @@ namespace mRemoteNG.App
|
||||
{
|
||||
private static string _updateFilePath;
|
||||
|
||||
private static bool UpdatePending => !string.IsNullOrEmpty(_updateFilePath);
|
||||
private static bool UpdatePending
|
||||
{
|
||||
get { return !string.IsNullOrEmpty(_updateFilePath); }
|
||||
}
|
||||
|
||||
public static void Quit(string updateFilePath = null)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
@@ -11,7 +11,10 @@ namespace mRemoteNG.App
|
||||
{
|
||||
private static SupportedCultures _Instance;
|
||||
|
||||
private static SupportedCultures SingletonInstance => _Instance ?? (_Instance = new SupportedCultures());
|
||||
private static SupportedCultures SingletonInstance
|
||||
{
|
||||
get { return _Instance ?? (_Instance = new SupportedCultures()); }
|
||||
}
|
||||
|
||||
|
||||
private SupportedCultures()
|
||||
|
||||
@@ -13,6 +13,7 @@ using mRemoteNG.Tools;
|
||||
#else
|
||||
using System.Windows.Forms;
|
||||
#endif
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App.Update
|
||||
{
|
||||
@@ -28,11 +29,20 @@ namespace mRemoteNG.App.Update
|
||||
|
||||
public string ChangeLog { get; private set; }
|
||||
|
||||
public bool IsGetUpdateInfoRunning => _getUpdateInfoThread != null && _getUpdateInfoThread.IsAlive;
|
||||
public bool IsGetUpdateInfoRunning
|
||||
{
|
||||
get { return _getUpdateInfoThread != null && _getUpdateInfoThread.IsAlive; }
|
||||
}
|
||||
|
||||
private bool IsGetChangeLogRunning => _getChangeLogThread != null && _getChangeLogThread.IsAlive;
|
||||
private bool IsGetChangeLogRunning
|
||||
{
|
||||
get { return _getChangeLogThread != null && _getChangeLogThread.IsAlive; }
|
||||
}
|
||||
|
||||
public bool IsDownloadUpdateRunning => _downloadUpdateWebClient != null;
|
||||
public bool IsDownloadUpdateRunning
|
||||
{
|
||||
get { return _downloadUpdateWebClient != null; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Timers;
|
||||
using mRemoteNG.App;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.Connections.Multiuser
|
||||
{
|
||||
@@ -11,7 +12,10 @@ namespace mRemoteNG.Config.Connections.Multiuser
|
||||
private readonly ConnectionsLoader _connectionsLoader;
|
||||
private readonly ConnectionsSaver _connectionsSaver;
|
||||
|
||||
public double TimerIntervalInMilliseconds => _updateTimer.Interval;
|
||||
public double TimerIntervalInMilliseconds
|
||||
{
|
||||
get { return _updateTimer.Interval; }
|
||||
}
|
||||
|
||||
public RemoteConnectionsSyncronizer(IConnectionsUpdateChecker updateChecker)
|
||||
{
|
||||
@@ -47,10 +51,25 @@ namespace mRemoteNG.Config.Connections.Multiuser
|
||||
_connectionsSaver.SaveConnections();
|
||||
}
|
||||
|
||||
public void Enable() => _updateTimer.Start();
|
||||
public void Disable() => _updateTimer.Stop();
|
||||
public bool IsUpdateAvailable() => _updateChecker.IsUpdateAvailable();
|
||||
public void IsUpdateAvailableAsync() => _updateChecker.IsUpdateAvailableAsync();
|
||||
public void Enable()
|
||||
{
|
||||
_updateTimer.Start();
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
_updateTimer.Stop();
|
||||
}
|
||||
|
||||
public bool IsUpdateAvailable()
|
||||
{
|
||||
return _updateChecker.IsUpdateAvailable();
|
||||
}
|
||||
|
||||
public void IsUpdateAvailableAsync()
|
||||
{
|
||||
_updateChecker.IsUpdateAvailableAsync();
|
||||
}
|
||||
|
||||
|
||||
private void OnUpdateCheckStarted(object sender, EventArgs eventArgs)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Data.SqlClient;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.DatabaseConnectors
|
||||
{
|
||||
@@ -14,7 +15,10 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
private string _sqlUsername;
|
||||
private string _sqlPassword;
|
||||
|
||||
public bool IsConnected => (SqlConnection.State == ConnectionState.Open);
|
||||
public bool IsConnected
|
||||
{
|
||||
get { return (SqlConnection.State == ConnectionState.Open); }
|
||||
}
|
||||
|
||||
public SqlDatabaseConnector()
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace mRemoteNG.Config.Import
|
||||
Import(fileNameAsString, destinationContainer);
|
||||
}
|
||||
|
||||
public void Import(string filePath, ContainerInfo destinationContainer)
|
||||
private static void Import(string filePath, ContainerInfo destinationContainer)
|
||||
{
|
||||
var dataProvider = new FileDataProvider(filePath);
|
||||
var fileContent = dataProvider.Load();
|
||||
|
||||
@@ -3,16 +3,19 @@ using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public abstract class AbstractPuttySessionsProvider
|
||||
{
|
||||
public virtual RootPuttySessionsNodeInfo RootInfo { get; } = new RootPuttySessionsNodeInfo();
|
||||
protected virtual List<PuttySessionInfo> Sessions => RootInfo.Children.OfType<PuttySessionInfo>().ToList();
|
||||
protected virtual List<PuttySessionInfo> Sessions
|
||||
{
|
||||
get { return RootInfo.Children.OfType<PuttySessionInfo>().ToList(); }
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
public abstract string[] GetSessionNames(bool raw = false);
|
||||
public abstract PuttySessionInfo GetSession(string sessionName);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
@@ -12,7 +12,11 @@ namespace mRemoteNG.Config.Putty
|
||||
public static PuttySessionsManager Instance { get; } = new PuttySessionsManager();
|
||||
|
||||
private readonly List<AbstractPuttySessionsProvider> _providers = new List<AbstractPuttySessionsProvider>();
|
||||
public IEnumerable<AbstractPuttySessionsProvider> Providers => _providers;
|
||||
public IEnumerable<AbstractPuttySessionsProvider> Providers
|
||||
{
|
||||
get { return _providers; }
|
||||
}
|
||||
|
||||
public List<RootPuttySessionsNodeInfo> RootPuttySessionsNodes { get; } = new List<RootPuttySessionsNodeInfo>();
|
||||
|
||||
private PuttySessionsManager()
|
||||
@@ -122,7 +126,10 @@ namespace mRemoteNG.Config.Putty
|
||||
#region Public Classes
|
||||
public class SessionList : StringConverter
|
||||
{
|
||||
public static string[] Names => Instance.GetSessionNames();
|
||||
public static string[] Names
|
||||
{
|
||||
get { return Instance.GetSessionNames(); }
|
||||
}
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
{
|
||||
|
||||
@@ -178,22 +178,24 @@ namespace mRemoteNG.Config.Serializers
|
||||
var treeNodeTypeString = xmlNode.Attributes?["Type"].Value ?? "connection";
|
||||
var nodeType = (TreeNodeType)Enum.Parse(typeof(TreeNodeType), treeNodeTypeString, true);
|
||||
|
||||
if (nodeType == TreeNodeType.Connection)
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (nodeType)
|
||||
{
|
||||
var connectionInfo = GetConnectionInfoFromXml(xmlNode);
|
||||
parentContainer.AddChild(connectionInfo);
|
||||
}
|
||||
else if (nodeType == TreeNodeType.Container)
|
||||
{
|
||||
var containerInfo = new ContainerInfo();
|
||||
case TreeNodeType.Connection:
|
||||
var connectionInfo = GetConnectionInfoFromXml(xmlNode);
|
||||
parentContainer.AddChild(connectionInfo);
|
||||
break;
|
||||
case TreeNodeType.Container:
|
||||
var containerInfo = new ContainerInfo();
|
||||
|
||||
if (_confVersion >= 0.9)
|
||||
containerInfo.CopyFrom(GetConnectionInfoFromXml(xmlNode));
|
||||
if (_confVersion >= 0.8)
|
||||
containerInfo.IsExpanded = xmlNode.Attributes?["Expanded"].Value == "True";
|
||||
if (_confVersion >= 0.9)
|
||||
containerInfo.CopyFrom(GetConnectionInfoFromXml(xmlNode));
|
||||
if (_confVersion >= 0.8)
|
||||
containerInfo.IsExpanded = xmlNode.Attributes?["Expanded"].Value == "True";
|
||||
|
||||
parentContainer.AddChild(containerInfo);
|
||||
AddNodesFromXmlRecursive(xmlNode, containerInfo);
|
||||
parentContainer.AddChild(containerInfo);
|
||||
AddNodesFromXmlRecursive(xmlNode, containerInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,7 +332,9 @@ namespace mRemoteNG.Config.Serializers
|
||||
case 3:
|
||||
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors32Bit;
|
||||
break;
|
||||
// ReSharper disable once RedundantCaseLabel
|
||||
case 4:
|
||||
default:
|
||||
connectionInfo.Colors = ProtocolRDP.RDPColors.Colors15Bit;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
var id = (string) row["ConstantID"];
|
||||
var connectionInfo = connectionList.First(node => node.ConstantID == id);
|
||||
var parentId = (string) row["ParentID"];
|
||||
if (parentId == "0")
|
||||
if (parentId == "0" || connectionList.All(node => node.ConstantID != parentId))
|
||||
rootNode.AddChild(connectionInfo);
|
||||
else
|
||||
(connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild(connectionInfo);
|
||||
|
||||
@@ -25,147 +25,162 @@ namespace mRemoteNG.Config.Serializers
|
||||
|
||||
public DataTable Serialize(ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
var rootNode = (RootNodeInfo)connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
|
||||
return Serialize(rootNode);
|
||||
try
|
||||
{
|
||||
_dataTable = BuildTable();
|
||||
_currentNodeIndex = 0;
|
||||
var rootNode = connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
|
||||
return Serialize(rootNode);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return _dataTable;
|
||||
}
|
||||
}
|
||||
|
||||
public DataTable Serialize(ConnectionInfo serializationTarget)
|
||||
{
|
||||
_dataTable = new DataTable(TableName);
|
||||
CreateSchema();
|
||||
SetPrimaryKey();
|
||||
_dataTable = BuildTable();
|
||||
_currentNodeIndex = 0;
|
||||
SerializeNodesRecursive(serializationTarget);
|
||||
return _dataTable;
|
||||
}
|
||||
|
||||
private void CreateSchema()
|
||||
private DataTable BuildTable()
|
||||
{
|
||||
// Note: these columns must be defined in the same order that they exist in the DB
|
||||
_dataTable.Columns.Add("ID", typeof(int));
|
||||
_dataTable.Columns[0].AutoIncrement = true;
|
||||
_dataTable.Columns.Add("ConstantID", typeof(string));
|
||||
_dataTable.Columns.Add("PositionID", typeof(int));
|
||||
_dataTable.Columns.Add("ParentID", typeof(string));
|
||||
_dataTable.Columns.Add("LastChange", typeof(SqlDateTime));
|
||||
_dataTable.Columns.Add("Name", typeof(string));
|
||||
_dataTable.Columns.Add("Type", typeof(string));
|
||||
_dataTable.Columns.Add("Expanded", typeof(bool));
|
||||
_dataTable.Columns.Add("Description", typeof(string));
|
||||
_dataTable.Columns.Add("Icon", typeof(string));
|
||||
_dataTable.Columns.Add("Panel", typeof(string));
|
||||
_dataTable.Columns.Add("Username", typeof(string));
|
||||
_dataTable.Columns.Add("DomainName", typeof(string));
|
||||
_dataTable.Columns.Add("Password", typeof(string));
|
||||
_dataTable.Columns.Add("Hostname", typeof(string));
|
||||
_dataTable.Columns.Add("Protocol", typeof(string));
|
||||
_dataTable.Columns.Add("PuttySession", typeof(string));
|
||||
_dataTable.Columns.Add("Port", typeof(int));
|
||||
_dataTable.Columns.Add("ConnectToConsole", typeof(bool));
|
||||
_dataTable.Columns.Add("UseCredSsp", typeof(bool));
|
||||
_dataTable.Columns.Add("RenderingEngine", typeof(string));
|
||||
_dataTable.Columns.Add("ICAEncryptionStrength", typeof(string));
|
||||
_dataTable.Columns.Add("RDPAuthenticationLevel", typeof(string));
|
||||
_dataTable.Columns.Add("Colors", typeof(string));
|
||||
_dataTable.Columns.Add("Resolution", typeof(string));
|
||||
_dataTable.Columns.Add("DisplayWallpaper", typeof(bool));
|
||||
_dataTable.Columns.Add("DisplayThemes", typeof(bool));
|
||||
_dataTable.Columns.Add("EnableFontSmoothing", typeof(bool));
|
||||
_dataTable.Columns.Add("EnableDesktopComposition", typeof(bool));
|
||||
_dataTable.Columns.Add("CacheBitmaps", typeof(bool));
|
||||
_dataTable.Columns.Add("RedirectDiskDrives", typeof(bool));
|
||||
_dataTable.Columns.Add("RedirectPorts", typeof(bool));
|
||||
_dataTable.Columns.Add("RedirectPrinters", typeof(bool));
|
||||
_dataTable.Columns.Add("RedirectSmartCards", typeof(bool));
|
||||
_dataTable.Columns.Add("RedirectSound", typeof(string));
|
||||
_dataTable.Columns.Add("RedirectKeys", typeof(bool));
|
||||
_dataTable.Columns.Add("Connected", typeof(bool));
|
||||
_dataTable.Columns.Add("PreExtApp", typeof(string));
|
||||
_dataTable.Columns.Add("PostExtApp", typeof(string));
|
||||
_dataTable.Columns.Add("MacAddress", typeof(string));
|
||||
_dataTable.Columns.Add("UserField", typeof(string));
|
||||
_dataTable.Columns.Add("ExtApp", typeof(string));
|
||||
_dataTable.Columns.Add("VNCCompression", typeof(string));
|
||||
_dataTable.Columns.Add("VNCEncoding", typeof(string));
|
||||
_dataTable.Columns.Add("VNCAuthMode", typeof(string));
|
||||
_dataTable.Columns.Add("VNCProxyType", typeof(string));
|
||||
_dataTable.Columns.Add("VNCProxyIP", typeof(string));
|
||||
_dataTable.Columns.Add("VNCProxyPort", typeof(int));
|
||||
_dataTable.Columns.Add("VNCProxyUsername", typeof(string));
|
||||
_dataTable.Columns.Add("VNCProxyPassword", typeof(string));
|
||||
_dataTable.Columns.Add("VNCColors", typeof(string));
|
||||
_dataTable.Columns.Add("VNCSmartSizeMode", typeof(string));
|
||||
_dataTable.Columns.Add("VNCViewOnly", typeof(bool));
|
||||
_dataTable.Columns.Add("RDGatewayUsageMethod", typeof(string));
|
||||
_dataTable.Columns.Add("RDGatewayHostname", typeof(string));
|
||||
_dataTable.Columns.Add("RDGatewayUseConnectionCredentials", typeof(string));
|
||||
_dataTable.Columns.Add("RDGatewayUsername", typeof(string));
|
||||
_dataTable.Columns.Add("RDGatewayPassword", typeof(string));
|
||||
_dataTable.Columns.Add("RDGatewayDomain", typeof(string));
|
||||
_dataTable.Columns.Add("InheritCacheBitmaps", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritColors", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritDescription", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritDisplayThemes", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritDisplayWallpaper", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritEnableFontSmoothing", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritEnableDesktopComposition", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritDomain", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritIcon", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritPanel", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritPassword", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritPort", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritProtocol", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritPuttySession", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRedirectDiskDrives", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRedirectKeys", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRedirectPorts", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRedirectPrinters", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRedirectSmartCards", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRedirectSound", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritResolution", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritUseConsoleSession", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritUseCredSsp", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRenderingEngine", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritICAEncryptionStrength", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRDPAuthenticationLevel", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritUsername", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritPreExtApp", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritPostExtApp", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritMacAddress", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritUserField", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritExtApp", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritVNCCompression", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritVNCEncoding", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritVNCAuthMode", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritVNCProxyType", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritVNCProxyIP", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritVNCProxyPort", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritVNCProxyUsername", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritVNCProxyPassword", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritVNCColors", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritVNCSmartSizeMode", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritVNCViewOnly", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRDGatewayUsageMethod", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRDGatewayHostname", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRDGatewayUseConnectionCredentials", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRDGatewayUsername", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRDGatewayPassword", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRDGatewayDomain", typeof(bool));
|
||||
_dataTable.Columns.Add("LoadBalanceInfo", typeof(string));
|
||||
_dataTable.Columns.Add("AutomaticResize", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritLoadBalanceInfo", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritAutomaticResize", typeof(bool));
|
||||
_dataTable.Columns.Add("RDPMinutesToIdleTimeout", typeof(int));
|
||||
_dataTable.Columns.Add("RDPAlertIdleTimeout", typeof(bool));
|
||||
_dataTable.Columns.Add("SoundQuality", typeof(string));
|
||||
_dataTable.Columns.Add("InheritRDPMinutesToIdleTimeout", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritRDPAlertIdleTimeout", typeof(bool));
|
||||
_dataTable.Columns.Add("InheritSoundQuality", typeof(bool));
|
||||
var dataTable = new DataTable(TableName);
|
||||
CreateSchema(dataTable);
|
||||
SetPrimaryKey(dataTable);
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
private void SetPrimaryKey()
|
||||
private void CreateSchema(DataTable dataTable)
|
||||
{
|
||||
_dataTable.PrimaryKey = new[] { _dataTable.Columns["ConstantID"] };
|
||||
// Note: these columns must be defined in the same order that they exist in the DB
|
||||
dataTable.Columns.Add("ID", typeof(int));
|
||||
dataTable.Columns[0].AutoIncrement = true;
|
||||
dataTable.Columns.Add("ConstantID", typeof(string));
|
||||
dataTable.Columns.Add("PositionID", typeof(int));
|
||||
dataTable.Columns.Add("ParentID", typeof(string));
|
||||
dataTable.Columns.Add("LastChange", typeof(SqlDateTime));
|
||||
dataTable.Columns.Add("Name", typeof(string));
|
||||
dataTable.Columns.Add("Type", typeof(string));
|
||||
dataTable.Columns.Add("Expanded", typeof(bool));
|
||||
dataTable.Columns.Add("Description", typeof(string));
|
||||
dataTable.Columns.Add("Icon", typeof(string));
|
||||
dataTable.Columns.Add("Panel", typeof(string));
|
||||
dataTable.Columns.Add("Username", typeof(string));
|
||||
dataTable.Columns.Add("DomainName", typeof(string));
|
||||
dataTable.Columns.Add("Password", typeof(string));
|
||||
dataTable.Columns.Add("Hostname", typeof(string));
|
||||
dataTable.Columns.Add("Protocol", typeof(string));
|
||||
dataTable.Columns.Add("PuttySession", typeof(string));
|
||||
dataTable.Columns.Add("Port", typeof(int));
|
||||
dataTable.Columns.Add("ConnectToConsole", typeof(bool));
|
||||
dataTable.Columns.Add("UseCredSsp", typeof(bool));
|
||||
dataTable.Columns.Add("RenderingEngine", typeof(string));
|
||||
dataTable.Columns.Add("ICAEncryptionStrength", typeof(string));
|
||||
dataTable.Columns.Add("RDPAuthenticationLevel", typeof(string));
|
||||
dataTable.Columns.Add("Colors", typeof(string));
|
||||
dataTable.Columns.Add("Resolution", typeof(string));
|
||||
dataTable.Columns.Add("DisplayWallpaper", typeof(bool));
|
||||
dataTable.Columns.Add("DisplayThemes", typeof(bool));
|
||||
dataTable.Columns.Add("EnableFontSmoothing", typeof(bool));
|
||||
dataTable.Columns.Add("EnableDesktopComposition", typeof(bool));
|
||||
dataTable.Columns.Add("CacheBitmaps", typeof(bool));
|
||||
dataTable.Columns.Add("RedirectDiskDrives", typeof(bool));
|
||||
dataTable.Columns.Add("RedirectPorts", typeof(bool));
|
||||
dataTable.Columns.Add("RedirectPrinters", typeof(bool));
|
||||
dataTable.Columns.Add("RedirectSmartCards", typeof(bool));
|
||||
dataTable.Columns.Add("RedirectSound", typeof(string));
|
||||
dataTable.Columns.Add("RedirectKeys", typeof(bool));
|
||||
dataTable.Columns.Add("Connected", typeof(bool));
|
||||
dataTable.Columns.Add("PreExtApp", typeof(string));
|
||||
dataTable.Columns.Add("PostExtApp", typeof(string));
|
||||
dataTable.Columns.Add("MacAddress", typeof(string));
|
||||
dataTable.Columns.Add("UserField", typeof(string));
|
||||
dataTable.Columns.Add("ExtApp", typeof(string));
|
||||
dataTable.Columns.Add("VNCCompression", typeof(string));
|
||||
dataTable.Columns.Add("VNCEncoding", typeof(string));
|
||||
dataTable.Columns.Add("VNCAuthMode", typeof(string));
|
||||
dataTable.Columns.Add("VNCProxyType", typeof(string));
|
||||
dataTable.Columns.Add("VNCProxyIP", typeof(string));
|
||||
dataTable.Columns.Add("VNCProxyPort", typeof(int));
|
||||
dataTable.Columns.Add("VNCProxyUsername", typeof(string));
|
||||
dataTable.Columns.Add("VNCProxyPassword", typeof(string));
|
||||
dataTable.Columns.Add("VNCColors", typeof(string));
|
||||
dataTable.Columns.Add("VNCSmartSizeMode", typeof(string));
|
||||
dataTable.Columns.Add("VNCViewOnly", typeof(bool));
|
||||
dataTable.Columns.Add("RDGatewayUsageMethod", typeof(string));
|
||||
dataTable.Columns.Add("RDGatewayHostname", typeof(string));
|
||||
dataTable.Columns.Add("RDGatewayUseConnectionCredentials", typeof(string));
|
||||
dataTable.Columns.Add("RDGatewayUsername", typeof(string));
|
||||
dataTable.Columns.Add("RDGatewayPassword", typeof(string));
|
||||
dataTable.Columns.Add("RDGatewayDomain", typeof(string));
|
||||
dataTable.Columns.Add("InheritCacheBitmaps", typeof(bool));
|
||||
dataTable.Columns.Add("InheritColors", typeof(bool));
|
||||
dataTable.Columns.Add("InheritDescription", typeof(bool));
|
||||
dataTable.Columns.Add("InheritDisplayThemes", typeof(bool));
|
||||
dataTable.Columns.Add("InheritDisplayWallpaper", typeof(bool));
|
||||
dataTable.Columns.Add("InheritEnableFontSmoothing", typeof(bool));
|
||||
dataTable.Columns.Add("InheritEnableDesktopComposition", typeof(bool));
|
||||
dataTable.Columns.Add("InheritDomain", typeof(bool));
|
||||
dataTable.Columns.Add("InheritIcon", typeof(bool));
|
||||
dataTable.Columns.Add("InheritPanel", typeof(bool));
|
||||
dataTable.Columns.Add("InheritPassword", typeof(bool));
|
||||
dataTable.Columns.Add("InheritPort", typeof(bool));
|
||||
dataTable.Columns.Add("InheritProtocol", typeof(bool));
|
||||
dataTable.Columns.Add("InheritPuttySession", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRedirectDiskDrives", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRedirectKeys", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRedirectPorts", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRedirectPrinters", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRedirectSmartCards", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRedirectSound", typeof(bool));
|
||||
dataTable.Columns.Add("InheritResolution", typeof(bool));
|
||||
dataTable.Columns.Add("InheritUseConsoleSession", typeof(bool));
|
||||
dataTable.Columns.Add("InheritUseCredSsp", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRenderingEngine", typeof(bool));
|
||||
dataTable.Columns.Add("InheritICAEncryptionStrength", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRDPAuthenticationLevel", typeof(bool));
|
||||
dataTable.Columns.Add("InheritUsername", typeof(bool));
|
||||
dataTable.Columns.Add("InheritPreExtApp", typeof(bool));
|
||||
dataTable.Columns.Add("InheritPostExtApp", typeof(bool));
|
||||
dataTable.Columns.Add("InheritMacAddress", typeof(bool));
|
||||
dataTable.Columns.Add("InheritUserField", typeof(bool));
|
||||
dataTable.Columns.Add("InheritExtApp", typeof(bool));
|
||||
dataTable.Columns.Add("InheritVNCCompression", typeof(bool));
|
||||
dataTable.Columns.Add("InheritVNCEncoding", typeof(bool));
|
||||
dataTable.Columns.Add("InheritVNCAuthMode", typeof(bool));
|
||||
dataTable.Columns.Add("InheritVNCProxyType", typeof(bool));
|
||||
dataTable.Columns.Add("InheritVNCProxyIP", typeof(bool));
|
||||
dataTable.Columns.Add("InheritVNCProxyPort", typeof(bool));
|
||||
dataTable.Columns.Add("InheritVNCProxyUsername", typeof(bool));
|
||||
dataTable.Columns.Add("InheritVNCProxyPassword", typeof(bool));
|
||||
dataTable.Columns.Add("InheritVNCColors", typeof(bool));
|
||||
dataTable.Columns.Add("InheritVNCSmartSizeMode", typeof(bool));
|
||||
dataTable.Columns.Add("InheritVNCViewOnly", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRDGatewayUsageMethod", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRDGatewayHostname", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRDGatewayUseConnectionCredentials", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRDGatewayUsername", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRDGatewayPassword", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRDGatewayDomain", typeof(bool));
|
||||
dataTable.Columns.Add("LoadBalanceInfo", typeof(string));
|
||||
dataTable.Columns.Add("AutomaticResize", typeof(bool));
|
||||
dataTable.Columns.Add("InheritLoadBalanceInfo", typeof(bool));
|
||||
dataTable.Columns.Add("InheritAutomaticResize", typeof(bool));
|
||||
dataTable.Columns.Add("RDPMinutesToIdleTimeout", typeof(int));
|
||||
dataTable.Columns.Add("RDPAlertIdleTimeout", typeof(bool));
|
||||
dataTable.Columns.Add("SoundQuality", typeof(string));
|
||||
dataTable.Columns.Add("InheritRDPMinutesToIdleTimeout", typeof(bool));
|
||||
dataTable.Columns.Add("InheritRDPAlertIdleTimeout", typeof(bool));
|
||||
dataTable.Columns.Add("InheritSoundQuality", typeof(bool));
|
||||
}
|
||||
|
||||
private void SetPrimaryKey(DataTable dataTable)
|
||||
{
|
||||
dataTable.PrimaryKey = new[] { dataTable.Columns["ConstantID"] };
|
||||
}
|
||||
|
||||
private void SerializeNodesRecursive(ConnectionInfo connectionInfo)
|
||||
@@ -186,7 +201,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
dataRow["Name"] = connectionInfo.Name;
|
||||
dataRow["Type"] = connectionInfo.GetTreeNodeType().ToString();
|
||||
dataRow["ConstantID"] = connectionInfo.ConstantID;
|
||||
dataRow["ParentID"] = connectionInfo.Parent.ConstantID;
|
||||
dataRow["ParentID"] = connectionInfo.Parent?.ConstantID ?? "";
|
||||
dataRow["PositionID"] = _currentNodeIndex;
|
||||
dataRow["LastChange"] = (SqlDateTime)DateTime.Now;
|
||||
var info = connectionInfo as ContainerInfo;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
return connectionTreeModel;
|
||||
}
|
||||
|
||||
private void VerifySchemaVersion(XmlNode rdcManNode)
|
||||
private static void VerifySchemaVersion(XmlNode rdcManNode)
|
||||
{
|
||||
var schemaVersion = Convert.ToInt32(rdcManNode?.Attributes?["schemaVersion"].Value);
|
||||
if (schemaVersion != 1)
|
||||
@@ -44,7 +44,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
}
|
||||
|
||||
private void VerifyFileVersion(XmlNode rdcManNode)
|
||||
private static void VerifyFileVersion(XmlNode rdcManNode)
|
||||
{
|
||||
var versionNode = rdcManNode.SelectSingleNode("./version")?.InnerText;
|
||||
if (versionNode != null)
|
||||
@@ -61,7 +61,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
}
|
||||
|
||||
private void ImportFileOrGroup(XmlNode xmlNode, ContainerInfo parentContainer)
|
||||
private static void ImportFileOrGroup(XmlNode xmlNode, ContainerInfo parentContainer)
|
||||
{
|
||||
var propertiesNode = xmlNode.SelectSingleNode("./properties");
|
||||
var newContainer = ImportContainer(propertiesNode, parentContainer);
|
||||
@@ -70,6 +70,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
if (childNodes == null) return;
|
||||
foreach (XmlNode childNode in childNodes)
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (childNode.Name)
|
||||
{
|
||||
case "group":
|
||||
@@ -82,7 +83,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
}
|
||||
}
|
||||
|
||||
private ContainerInfo ImportContainer(XmlNode containerPropertiesNode, ContainerInfo parentContainer)
|
||||
private static ContainerInfo ImportContainer(XmlNode containerPropertiesNode, ContainerInfo parentContainer)
|
||||
{
|
||||
var newContainer = new ContainerInfo();
|
||||
var connectionInfo = ConnectionInfoFromXml(containerPropertiesNode);
|
||||
@@ -93,13 +94,13 @@ namespace mRemoteNG.Config.Serializers
|
||||
return newContainer;
|
||||
}
|
||||
|
||||
private void ImportServer(XmlNode serverNode, ContainerInfo parentContainer)
|
||||
private static void ImportServer(XmlNode serverNode, ContainerInfo parentContainer)
|
||||
{
|
||||
var newConnectionInfo = ConnectionInfoFromXml(serverNode);
|
||||
parentContainer.AddChild(newConnectionInfo);
|
||||
}
|
||||
|
||||
private ConnectionInfo ConnectionInfoFromXml(XmlNode xmlNode)
|
||||
private static ConnectionInfo ConnectionInfoFromXml(XmlNode xmlNode)
|
||||
{
|
||||
var connectionInfo = new ConnectionInfo {Protocol = ProtocolType.RDP};
|
||||
|
||||
@@ -202,6 +203,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
var localResourcesNode = xmlNode.SelectSingleNode("./localResources");
|
||||
if (localResourcesNode?.Attributes?["inherit"].Value == "None")
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (localResourcesNode.SelectSingleNode("./audioRedirection")?.InnerText)
|
||||
{
|
||||
case "0": // Bring to this computer
|
||||
@@ -218,6 +220,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
// ./audioRedirectionQuality
|
||||
// ./audioCaptureRedirection
|
||||
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (localResourcesNode.SelectSingleNode("./keyboardHook")?.InnerText)
|
||||
{
|
||||
case "0": // On the local computer
|
||||
@@ -250,6 +253,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
var securitySettingsNode = xmlNode.SelectSingleNode("./securitySettings");
|
||||
if (securitySettingsNode?.Attributes?["inherit"].Value == "None")
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (securitySettingsNode.SelectSingleNode("./authentication")?.InnerText)
|
||||
{
|
||||
case "0": // No authentication
|
||||
@@ -275,7 +279,7 @@ namespace mRemoteNG.Config.Serializers
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
private string DecryptRdcManPassword(string ciphertext)
|
||||
private static string DecryptRdcManPassword(string ciphertext)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ciphertext))
|
||||
return null;
|
||||
|
||||
@@ -10,6 +10,7 @@ using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Credential;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Controls;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
|
||||
namespace mRemoteNG.Connection
|
||||
@@ -118,6 +119,7 @@ namespace mRemoteNG.Connection
|
||||
get { return GetPropertyValue("Panel", _panel); }
|
||||
set { SetField(ref _panel, value, "Panel"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Connection
|
||||
@@ -277,6 +279,7 @@ namespace mRemoteNG.Connection
|
||||
get { return GetPropertyValue("UseCredSsp", _useCredSsp); }
|
||||
set { SetField(ref _useCredSsp, value, "UseCredSsp"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RD Gateway
|
||||
@@ -336,6 +339,7 @@ namespace mRemoteNG.Connection
|
||||
get { return GetPropertyValue("RDGatewayDomain", _rdGatewayDomain).Trim(); }
|
||||
set { SetField(ref _rdGatewayDomain, value?.Trim(), "RDGatewayDomain"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Appearance
|
||||
@@ -418,6 +422,7 @@ namespace mRemoteNG.Connection
|
||||
get { return GetPropertyValue("EnableDesktopComposition", _enableDesktopComposition); }
|
||||
set { SetField(ref _enableDesktopComposition, value, "EnableDesktopComposition"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Redirect
|
||||
@@ -490,6 +495,7 @@ namespace mRemoteNG.Connection
|
||||
get { return GetPropertyValue("SoundQuality", _soundQuality); }
|
||||
set { SetField(ref _soundQuality, value, "SoundQuality"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Misc
|
||||
@@ -533,6 +539,7 @@ namespace mRemoteNG.Connection
|
||||
get { return GetPropertyValue("UserField", _userField); }
|
||||
set { SetField(ref _userField, value, "UserField"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region VNC
|
||||
@@ -651,26 +658,30 @@ namespace mRemoteNG.Connection
|
||||
get { return GetPropertyValue("VNCViewOnly", _vncViewOnly); }
|
||||
set { SetField(ref _vncViewOnly, value, "VNCViewOnly"); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
protected virtual TPropertyType GetPropertyValue<TPropertyType>(string propertyName, TPropertyType value)
|
||||
{
|
||||
return (TPropertyType)GetType().GetProperty(propertyName).GetValue(this, null);
|
||||
var propertyInfo = GetType().GetProperty(propertyName);
|
||||
if (propertyInfo != null)
|
||||
return (TPropertyType) propertyInfo.GetValue(this, null);
|
||||
|
||||
return default(TPropertyType);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void RaisePropertyChangedEvent(object sender, PropertyChangedEventArgs args)
|
||||
protected void RaisePropertyChangedEvent(object sender, PropertyChangedEventArgs args)
|
||||
{
|
||||
PropertyChanged?.Invoke(sender, new PropertyChangedEventArgs(args.PropertyName));
|
||||
}
|
||||
|
||||
protected bool SetField<T>(ref T field, T value, string propertyName = null)
|
||||
private void SetField<T>(ref T field, T value, string propertyName = null)
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
|
||||
if (EqualityComparer<T>.Default.Equals(field, value)) return;
|
||||
field = value;
|
||||
RaisePropertyChangedEvent(this, new PropertyChangedEventArgs(propertyName));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ namespace mRemoteNG.Connection
|
||||
{
|
||||
var inheritType = Inheritance.GetType();
|
||||
var inheritPropertyInfo = inheritType.GetProperty(propertyName);
|
||||
var inheritPropertyValue = Convert.ToBoolean(inheritPropertyInfo.GetValue(Inheritance, null));
|
||||
var inheritPropertyValue = inheritPropertyInfo != null && Convert.ToBoolean(inheritPropertyInfo.GetValue(Inheritance, null));
|
||||
return inheritPropertyValue;
|
||||
}
|
||||
|
||||
@@ -187,6 +187,8 @@ namespace mRemoteNG.Connection
|
||||
{
|
||||
var connectionInfoType = Parent.GetType();
|
||||
var parentPropertyInfo = connectionInfoType.GetProperty(propertyName);
|
||||
if (parentPropertyInfo == null)
|
||||
return default(TPropertyType); // shouldn't get here...
|
||||
var parentPropertyValue = (TPropertyType)parentPropertyInfo.GetValue(Parent, null);
|
||||
|
||||
return parentPropertyValue;
|
||||
@@ -196,6 +198,7 @@ namespace mRemoteNG.Connection
|
||||
{
|
||||
try
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (protocol)
|
||||
{
|
||||
case ProtocolType.RDP:
|
||||
|
||||
@@ -222,6 +222,12 @@ namespace mRemoteNG.Connection
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sender is VncSharp.RemoteDesktop)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strProtocolEventDisconnected, @"VncSharp Disconnected."), true);
|
||||
return;
|
||||
}
|
||||
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strProtocolEventDisconnected, disconnectedMessage), true);
|
||||
|
||||
var Prot = (ProtocolBase)sender;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace mRemoteNG.Connection
|
||||
|
||||
public void LoadFrom<TSource>(TSource sourceInstance, Func<string, string> propertyNameMutator = null)
|
||||
{
|
||||
if (propertyNameMutator == null) propertyNameMutator = (a) => a;
|
||||
if (propertyNameMutator == null) propertyNameMutator = a => a;
|
||||
var connectionProperties = GetProperties(_excludedProperties);
|
||||
foreach (var property in connectionProperties)
|
||||
{
|
||||
@@ -49,7 +49,8 @@ namespace mRemoteNG.Connection
|
||||
var propertyFromDestination = typeof(TDestination).GetProperty(propertyNameMutator(property.Name));
|
||||
var localValue = property.GetValue(Instance, null);
|
||||
var typeConverter = TypeDescriptor.GetConverter(property.PropertyType);
|
||||
if (!typeConverter.CanConvertTo(propertyFromDestination.PropertyType)) continue;
|
||||
if (propertyFromDestination != null && !typeConverter.CanConvertTo(propertyFromDestination.PropertyType)) continue;
|
||||
if (propertyFromDestination == null) continue;
|
||||
var convertedValue = typeConverter.ConvertTo(localValue, propertyFromDestination.PropertyType);
|
||||
propertyFromDestination.SetValue(destinationInstance, convertedValue, null);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Connection.Protocol
|
||||
{
|
||||
@@ -20,10 +20,13 @@ namespace mRemoteNG.Connection.Protocol
|
||||
}
|
||||
}
|
||||
|
||||
public new int Count => List.Count;
|
||||
public new int Count
|
||||
{
|
||||
get { return List.Count; }
|
||||
}
|
||||
|
||||
|
||||
public void Add(ProtocolBase cProt)
|
||||
|
||||
public void Add(ProtocolBase cProt)
|
||||
{
|
||||
List.Add(cProt);
|
||||
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, cProt));
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Windows.Forms;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tools.Cmdline;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Connection.Protocol
|
||||
{
|
||||
@@ -30,7 +30,10 @@ namespace mRemoteNG.Connection.Protocol
|
||||
|
||||
public static string PuttyPath { get; set; }
|
||||
|
||||
public bool Focused => NativeMethods.GetForegroundWindow() == PuttyHandle;
|
||||
public bool Focused
|
||||
{
|
||||
get { return NativeMethods.GetForegroundWindow() == PuttyHandle; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -76,14 +79,16 @@ namespace mRemoteNG.Connection.Protocol
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Settings.Default.EmptyCredentials == "windows")
|
||||
{
|
||||
username = Environment.UserName;
|
||||
}
|
||||
else if (Settings.Default.EmptyCredentials == "custom")
|
||||
{
|
||||
username = Settings.Default.DefaultUsername;
|
||||
}
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (Settings.Default.EmptyCredentials)
|
||||
{
|
||||
case "windows":
|
||||
username = Environment.UserName;
|
||||
break;
|
||||
case "custom":
|
||||
username = Settings.Default.DefaultUsername;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(InterfaceControl.Info.CredentialRecord?.Password.ConvertToUnsecureString()))
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Forms;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
|
||||
namespace mRemoteNG.Connection.Protocol.VNC
|
||||
@@ -12,17 +13,18 @@ namespace mRemoteNG.Connection.Protocol.VNC
|
||||
{
|
||||
#region Properties
|
||||
public bool SmartSize
|
||||
{
|
||||
get { return _VNC.Scaled; }
|
||||
set { _VNC.Scaled = value; }
|
||||
}
|
||||
|
||||
public bool ViewOnly
|
||||
{
|
||||
get { return _VNC.ViewOnly; }
|
||||
set { _VNC.ViewOnly = value; }
|
||||
}
|
||||
#endregion
|
||||
{
|
||||
get { return _VNC.Scaled; }
|
||||
set { _VNC.Scaled = value; }
|
||||
}
|
||||
|
||||
public bool ViewOnly
|
||||
{
|
||||
get { return _VNC.ViewOnly; }
|
||||
set { _VNC.ViewOnly = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Declarations
|
||||
private VncSharp.RemoteDesktop _VNC;
|
||||
@@ -89,6 +91,7 @@ namespace mRemoteNG.Connection.Protocol.VNC
|
||||
{
|
||||
try
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (Keys)
|
||||
{
|
||||
case SpecialKeys.CtrlAltDel:
|
||||
@@ -133,12 +136,12 @@ namespace mRemoteNG.Connection.Protocol.VNC
|
||||
|
||||
public void StartChat()
|
||||
{
|
||||
throw (new NotImplementedException());
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void StartFileTransfer()
|
||||
{
|
||||
throw (new NotImplementedException());
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void RefreshScreen()
|
||||
@@ -183,7 +186,8 @@ namespace mRemoteNG.Connection.Protocol.VNC
|
||||
|
||||
private void VNCEvent_Disconnected(object sender, EventArgs e)
|
||||
{
|
||||
Event_Disconnected(sender, e.ToString());
|
||||
FrmMain.ClipboardChanged -= VNCEvent_ClipboardChanged;
|
||||
Event_Disconnected(sender, e.ToString());
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Messages
|
||||
{
|
||||
@@ -11,7 +11,10 @@ namespace mRemoteNG.Messages
|
||||
{
|
||||
private readonly IList<IMessage> _messageList;
|
||||
|
||||
public IEnumerable<IMessage> Messages => _messageList;
|
||||
public IEnumerable<IMessage> Messages
|
||||
{
|
||||
get { return _messageList; }
|
||||
}
|
||||
|
||||
public MessageCollector()
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,7 @@
|
||||
using System.Security;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using Org.BouncyCastle.Security;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Security
|
||||
{
|
||||
@@ -10,7 +11,10 @@ namespace mRemoteNG.Security
|
||||
private SecureString _secureString;
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
|
||||
private static SecureString MachineKey => _machineKey ?? (_machineKey = GenerateNewMachineKey(32));
|
||||
private static SecureString MachineKey
|
||||
{
|
||||
get { return _machineKey ?? (_machineKey = GenerateNewMachineKey(32)); }
|
||||
}
|
||||
|
||||
public EncryptedSecureString()
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ using Org.BouncyCastle.Crypto.Engines;
|
||||
using Org.BouncyCastle.Crypto.Modes;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
using Org.BouncyCastle.Security;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Security.SymmetricEncryption
|
||||
{
|
||||
@@ -36,7 +37,10 @@ namespace mRemoteNG.Security.SymmetricEncryption
|
||||
protected virtual int MinPasswordLength { get; set; } = 1;
|
||||
|
||||
|
||||
public int BlockSizeInBytes => _aeadBlockCipher.GetBlockSize();
|
||||
public int BlockSizeInBytes
|
||||
{
|
||||
get { return _aeadBlockCipher.GetBlockSize(); }
|
||||
}
|
||||
|
||||
public BlockCipherEngines CipherEngine
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Text.RegularExpressions;
|
||||
using mRemoteNG.App;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Tools.Cmdline
|
||||
{
|
||||
@@ -21,7 +22,10 @@ namespace mRemoteNG.Tools.Cmdline
|
||||
private readonly StringDictionary _parameters;
|
||||
|
||||
// Retrieve a parameter value if it exists
|
||||
public string this[string param] => (_parameters[param]);
|
||||
public string this[string param]
|
||||
{
|
||||
get { return (_parameters[param]); }
|
||||
}
|
||||
|
||||
public CmdArgumentsInterpreter(IEnumerable<string> args)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using mRemoteNG.App;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Messages;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
@@ -20,9 +21,15 @@ namespace mRemoteNG.Tools
|
||||
public bool TryIntegrate { get; set; }
|
||||
public ConnectionInfo ConnectionInfo { get; set; }
|
||||
|
||||
public Icon Icon => File.Exists(FileName) ? MiscTools.GetIconFromFile(FileName) : Resources.mRemote_Icon;
|
||||
public Icon Icon
|
||||
{
|
||||
get { return File.Exists(FileName) ? MiscTools.GetIconFromFile(FileName) : Resources.mRemote_Icon; }
|
||||
}
|
||||
|
||||
public Image Image => Icon?.ToBitmap() ?? Resources.mRemote_Icon.ToBitmap();
|
||||
public Image Image
|
||||
{
|
||||
get { return Icon?.ToBitmap() ?? Resources.mRemote_Icon.ToBitmap(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Reflection;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace mRemoteNG.Tools
|
||||
continue;
|
||||
}
|
||||
|
||||
var commandAttribute = (CommandAttribute) (commandAttributes[0]);
|
||||
var commandAttribute = (CommandAttribute) commandAttributes[0];
|
||||
if (!commandAttribute.Command)
|
||||
{
|
||||
continue;
|
||||
@@ -40,7 +40,7 @@ namespace mRemoteNG.Tools
|
||||
var displayNameAttributes = method.GetCustomAttributes(typeof(DisplayNameAttribute), true);
|
||||
if (displayNameAttributes.Length != 0)
|
||||
{
|
||||
var displayNameAttribute = (DisplayNameAttribute) (displayNameAttributes[0]);
|
||||
var displayNameAttribute = (DisplayNameAttribute) displayNameAttributes[0];
|
||||
if (!string.IsNullOrEmpty(displayNameAttribute.DisplayName))
|
||||
{
|
||||
displayName = displayNameAttribute.DisplayName;
|
||||
@@ -71,7 +71,7 @@ namespace mRemoteNG.Tools
|
||||
continue;
|
||||
}
|
||||
|
||||
var commandAttribute = (CommandAttribute) (commandAttributes[0]);
|
||||
var commandAttribute = (CommandAttribute) commandAttributes[0];
|
||||
if (!commandAttribute.Command)
|
||||
{
|
||||
continue;
|
||||
@@ -81,7 +81,7 @@ namespace mRemoteNG.Tools
|
||||
var displayNameAttributes = method.GetCustomAttributes(typeof(DisplayNameAttribute), true);
|
||||
if (displayNameAttributes.Length != 0)
|
||||
{
|
||||
var displayNameAttribute = (DisplayNameAttribute) (displayNameAttributes[0]);
|
||||
var displayNameAttribute = (DisplayNameAttribute) displayNameAttributes[0];
|
||||
if (!string.IsNullOrEmpty(displayNameAttribute.DisplayName))
|
||||
{
|
||||
displayName = displayNameAttribute.DisplayName;
|
||||
@@ -101,52 +101,58 @@ namespace mRemoteNG.Tools
|
||||
|
||||
public IComponent Component
|
||||
{
|
||||
get { throw (new NotSupportedException()); }
|
||||
get { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public IContainer Container => null;
|
||||
public IContainer Container
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public bool DesignMode => true;
|
||||
public bool DesignMode
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { throw (new NotSupportedException()); }
|
||||
set { throw (new NotSupportedException()); }
|
||||
get { throw new NotSupportedException(); }
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public void AddCommand(MenuCommand command)
|
||||
{
|
||||
throw (new NotSupportedException());
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void AddVerb(DesignerVerb verb)
|
||||
{
|
||||
throw (new NotSupportedException());
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public MenuCommand FindCommand(CommandID commandId)
|
||||
{
|
||||
throw (new NotSupportedException());
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool GlobalInvoke(CommandID commandId)
|
||||
{
|
||||
throw (new NotSupportedException());
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void RemoveCommand(MenuCommand command)
|
||||
{
|
||||
throw (new NotSupportedException());
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void RemoveVerb(DesignerVerb verb)
|
||||
{
|
||||
throw (new NotSupportedException());
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void ShowContextMenu(CommandID menuId, int x, int y)
|
||||
{
|
||||
throw (new NotSupportedException());
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
@@ -88,7 +88,10 @@ namespace mRemoteNG.Tools
|
||||
|
||||
// This allows localized attributes in a derived class to override a matching
|
||||
// non-localized attribute inherited from its base class
|
||||
public override object TypeId => typeof(DefaultValueAttribute);
|
||||
public override object TypeId
|
||||
{
|
||||
get { return typeof(DefaultValueAttribute); }
|
||||
}
|
||||
}
|
||||
|
||||
#region Special localization - with String.Format
|
||||
|
||||
@@ -1,54 +1,92 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
using mRemoteNG.App;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
// ReSharper disable MemberCanBeMadeStatic.Global
|
||||
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
public class SystemMenu
|
||||
{
|
||||
public sealed class SystemMenu : SafeHandleZeroOrMinusOneIsInvalid, IDisposable
|
||||
{
|
||||
[Flags]
|
||||
public enum Flags
|
||||
{
|
||||
MF_STRING = App.NativeMethods.MF_STRING,
|
||||
MF_SEPARATOR = App.NativeMethods.MF_SEPARATOR,
|
||||
MF_BYCOMMAND = App.NativeMethods.MF_BYCOMMAND,
|
||||
MF_BYPOSITION = App.NativeMethods.MF_BYPOSITION,
|
||||
MF_POPUP = App.NativeMethods.MF_POPUP,
|
||||
WM_SYSCOMMAND = App.NativeMethods.WM_SYSCOMMAND
|
||||
MF_STRING = NativeMethods.MF_STRING,
|
||||
MF_SEPARATOR = NativeMethods.MF_SEPARATOR,
|
||||
MF_BYCOMMAND = NativeMethods.MF_BYCOMMAND,
|
||||
MF_BYPOSITION = NativeMethods.MF_BYPOSITION,
|
||||
MF_POPUP = NativeMethods.MF_POPUP,
|
||||
WM_SYSCOMMAND = NativeMethods.WM_SYSCOMMAND
|
||||
}
|
||||
|
||||
public IntPtr SystemMenuHandle;
|
||||
public IntPtr FormHandle;
|
||||
|
||||
public SystemMenu(IntPtr Handle)
|
||||
|
||||
private bool disposed;
|
||||
internal IntPtr SystemMenuHandle;
|
||||
private readonly IntPtr FormHandle;
|
||||
|
||||
public SystemMenu(IntPtr Handle) :base(true)
|
||||
{
|
||||
FormHandle = Handle;
|
||||
SystemMenuHandle = App.NativeMethods.GetSystemMenu(FormHandle, false);
|
||||
}
|
||||
SystemMenuHandle = NativeMethods.GetSystemMenu(FormHandle, false);
|
||||
SetHandle(SystemMenuHandle);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
SystemMenuHandle = App.NativeMethods.GetSystemMenu(FormHandle, true);
|
||||
SystemMenuHandle = NativeMethods.GetSystemMenu(FormHandle, true);
|
||||
}
|
||||
|
||||
public void AppendMenuItem(IntPtr ParentMenu, Flags Flags, IntPtr ID, string Text)
|
||||
{
|
||||
App.NativeMethods.AppendMenu(ParentMenu, (int)Flags, ID, Text);
|
||||
NativeMethods.AppendMenu(ParentMenu, (int)Flags, ID, Text);
|
||||
}
|
||||
|
||||
public IntPtr CreatePopupMenuItem()
|
||||
{
|
||||
return App.NativeMethods.CreatePopupMenu();
|
||||
return NativeMethods.CreatePopupMenu();
|
||||
}
|
||||
|
||||
public bool InsertMenuItem(IntPtr SysMenu, int Position, Flags Flags, IntPtr SubMenu, string Text)
|
||||
{
|
||||
return App.NativeMethods.InsertMenu(SysMenu, Position, (int)Flags, SubMenu, Text);
|
||||
return NativeMethods.InsertMenu(SysMenu, Position, (int)Flags, SubMenu, Text);
|
||||
}
|
||||
|
||||
public IntPtr SetBitmap(IntPtr Menu, int Position, Flags Flags, Bitmap Bitmap)
|
||||
{
|
||||
return new IntPtr(Convert.ToInt32(App.NativeMethods.SetMenuItemBitmaps(Menu, Position, (int)Flags, Bitmap.GetHbitmap(), Bitmap.GetHbitmap())));
|
||||
return new IntPtr(Convert.ToInt32(NativeMethods.SetMenuItemBitmaps(Menu, Position, (int)Flags, Bitmap.GetHbitmap(), Bitmap.GetHbitmap())));
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ReleaseHandle()
|
||||
{
|
||||
return NativeMethods.CloseHandle(SystemMenuHandle);
|
||||
}
|
||||
|
||||
|
||||
/* If we don't have the finalizer, then we get this warning: https://msdn.microsoft.com/library/ms182329.aspx (CA2216: Disposable types should declare finalizer)
|
||||
* If we DO have the finalizer, then we get this warning: https://msdn.microsoft.com/library/ms244737.aspx (CA1063: Implement IDisposable correctly)
|
||||
*
|
||||
* Since the handle is likely going to be in use for the entierty of the process, the finalizer isn't very important since when we're calling it
|
||||
* the process is likely exiting. Leaks would be moot once it exits. CA2216 is the lesser of 2 evils as far as I can tell. Suppress.
|
||||
~SystemMenu()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
*/
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2216:DisposableTypesShouldDeclareFinalizer")]
|
||||
public new void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposed) return;
|
||||
if (!disposing) return;
|
||||
|
||||
ReleaseHandle();
|
||||
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ using mRemoteNG.Connection;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.UI.Controls
|
||||
{
|
||||
@@ -21,7 +21,10 @@ namespace mRemoteNG.UI.Controls
|
||||
private readonly ConnectionTreeDragAndDropHandler _dragAndDropHandler = new ConnectionTreeDragAndDropHandler();
|
||||
private readonly PuttySessionsManager _puttySessionsManager = PuttySessionsManager.Instance;
|
||||
|
||||
public ConnectionInfo SelectedNode => (ConnectionInfo) SelectedObject;
|
||||
public ConnectionInfo SelectedNode
|
||||
{
|
||||
get { return (ConnectionInfo) SelectedObject; }
|
||||
}
|
||||
|
||||
public NodeSearcher NodeSearcher { get; private set; }
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.UI.Forms.CredentialManagerPages;
|
||||
|
||||
|
||||
namespace mRemoteNG.UI.Forms
|
||||
{
|
||||
public partial class CredentialManagerForm : Form
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace mRemoteNG.UI.Menu
|
||||
BuildScreenList();
|
||||
}
|
||||
|
||||
public void ResetScreenList()
|
||||
private void ResetScreenList()
|
||||
{
|
||||
_systemMenu.Reset();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.UI.Window
|
||||
{
|
||||
@@ -19,7 +19,10 @@ namespace mRemoteNG.UI.Window
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
|
||||
|
||||
public ConnectionInfo SelectedNode => olvConnections.SelectedNode;
|
||||
public ConnectionInfo SelectedNode
|
||||
{
|
||||
get { return olvConnections.SelectedNode; }
|
||||
}
|
||||
|
||||
public ConnectionTree ConnectionTree
|
||||
{
|
||||
|
||||
@@ -1553,7 +1553,7 @@ powershell.exe -ExecutionPolicy Bypass -File "%25psScriptsDir%25\postbuild_mremo
|
||||
<DebugType>none</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug Portable|x86'">
|
||||
|
||||
Reference in New Issue
Block a user