mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
extracted a Runtime method to a different class
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Config.Connections;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree.Root;
|
||||
@@ -269,40 +268,5 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Opening Connection
|
||||
public static ConnectionInfo CreateQuickConnect(string connectionString, ProtocolType protocol)
|
||||
{
|
||||
try
|
||||
{
|
||||
var uri = new Uri("dummyscheme" + Uri.SchemeDelimiter + connectionString);
|
||||
if (string.IsNullOrEmpty(uri.Host)) return null;
|
||||
|
||||
var newConnectionInfo = new ConnectionInfo();
|
||||
newConnectionInfo.CopyFrom(DefaultConnectionInfo.Instance);
|
||||
|
||||
newConnectionInfo.Name = Settings.Default.IdentifyQuickConnectTabs ? string.Format(Language.strQuick, uri.Host) : uri.Host;
|
||||
|
||||
newConnectionInfo.Protocol = protocol;
|
||||
newConnectionInfo.Hostname = uri.Host;
|
||||
if (uri.Port == -1)
|
||||
{
|
||||
newConnectionInfo.SetDefaultPort();
|
||||
}
|
||||
else
|
||||
{
|
||||
newConnectionInfo.Port = uri.Port;
|
||||
}
|
||||
newConnectionInfo.IsQuickConnect = true;
|
||||
|
||||
return newConnectionInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageCollector.AddExceptionMessage(Language.strQuickConnectFailed, ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Config.Connections;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
@@ -78,5 +79,38 @@ namespace mRemoteNG.Connection
|
||||
{
|
||||
return ConnectionsFileInfo.DefaultConnectionsPath + "\\" + ConnectionsFileInfo.DefaultConnectionsFile;
|
||||
}
|
||||
|
||||
public ConnectionInfo CreateQuickConnect(string connectionString, ProtocolType protocol)
|
||||
{
|
||||
try
|
||||
{
|
||||
var uri = new Uri("dummyscheme" + Uri.SchemeDelimiter + connectionString);
|
||||
if (string.IsNullOrEmpty(uri.Host)) return null;
|
||||
|
||||
var newConnectionInfo = new ConnectionInfo();
|
||||
newConnectionInfo.CopyFrom(DefaultConnectionInfo.Instance);
|
||||
|
||||
newConnectionInfo.Name = Settings.Default.IdentifyQuickConnectTabs ? string.Format(Language.strQuick, uri.Host) : uri.Host;
|
||||
|
||||
newConnectionInfo.Protocol = protocol;
|
||||
newConnectionInfo.Hostname = uri.Host;
|
||||
if (uri.Port == -1)
|
||||
{
|
||||
newConnectionInfo.SetDefaultPort();
|
||||
}
|
||||
else
|
||||
{
|
||||
newConnectionInfo.Port = uri.Port;
|
||||
}
|
||||
newConnectionInfo.IsQuickConnect = true;
|
||||
|
||||
return newConnectionInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(Language.strQuickConnectFailed, ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ namespace mRemoteNG.UI.Controls
|
||||
{
|
||||
try
|
||||
{
|
||||
var connectionInfo = Runtime.CreateQuickConnect(_cmbQuickConnect.Text.Trim(), Converter.StringToProtocol(Settings.Default.QuickConnectProtocol));
|
||||
var connectionInfo = Runtime.ConnectionsService.CreateQuickConnect(_cmbQuickConnect.Text.Trim(), Converter.StringToProtocol(Settings.Default.QuickConnectProtocol));
|
||||
if (connectionInfo == null)
|
||||
{
|
||||
_cmbQuickConnect.Focus();
|
||||
|
||||
Reference in New Issue
Block a user