Permalink
Browse files

Add support for importing files from PuTTY Connection Manager. Improv…

…e the import and export functionality.
  • Loading branch information...
1 parent 9f17b91 commit 14d1f6cde2a01e0384f850840704cf38b1373ed1 @rmcardle rmcardle committed Dec 18, 2013
Showing with 2,655 additions and 1,770 deletions.
  1. +2 −0 CHANGELOG.TXT
  2. +2 −0 TestProject/TestProject.vbproj
  3. +35 −301 mRemoteV1/App/App.Runtime.vb
  4. +79 −0 mRemoteV1/App/Export.vb
  5. +171 −0 mRemoteV1/App/Import.vb
  6. +23 −16 mRemoteV1/Config/Config.Connections.Load.vb
  7. +97 −0 mRemoteV1/Config/Import/ActiveDirectory.vb
  8. +72 −0 mRemoteV1/Config/Import/PortScan.vb
  9. +160 −0 mRemoteV1/Config/Import/PuttyConnectionManager.vb
  10. +141 −0 mRemoteV1/Config/Import/RemoteDesktopConnection.vb
  11. +25 −46 mRemoteV1/Config/Import/RemoteDesktopConnectionManager.vb
  12. +49 −0 mRemoteV1/Config/Import/mRemoteNG.vb
  13. +294 −0 mRemoteV1/Forms/ExportForm.Designer.vb
  14. 0 mRemoteV1/{UI/UI.Window.Export.resx → Forms/ExportForm.resx}
  15. +260 −0 mRemoteV1/Forms/ExportForm.vb
  16. +93 −110 mRemoteV1/Forms/frmMain.Designer.vb
  17. +6 −6 mRemoteV1/Forms/frmMain.resx
  18. +47 −38 mRemoteV1/Forms/frmMain.vb
  19. +208 −1 mRemoteV1/Language/Language.Designer.vb
  20. +69 −0 mRemoteV1/Language/Language.resx
  21. +7 −0 mRemoteV1/My Project/Resources.Designer.vb
  22. +4 −0 mRemoteV1/My Project/Resources.resx
  23. BIN mRemoteV1/Resources/Images/puttycm.png
  24. +23 −28 mRemoteV1/Tools/Tools.PortScan.vb
  25. +19 −101 mRemoteV1/Tree/Tree.Node.vb
  26. +0 −165 mRemoteV1/UI/UI.Window.ADImport.vb
  27. +93 −0 mRemoteV1/UI/UI.Window.ActiveDirectoryImport.Designer.vb
  28. 0 mRemoteV1/UI/{UI.Window.ADImport.resx → UI.Window.ActiveDirectoryImport.resx}
  29. +71 −0 mRemoteV1/UI/UI.Window.ActiveDirectoryImport.vb
  30. +0 −135 mRemoteV1/UI/UI.Window.Export.Designer.vb
  31. +0 −72 mRemoteV1/UI/UI.Window.Export.vb
  32. +309 −0 mRemoteV1/UI/UI.Window.PortScan.Designer.vb
  33. +123 −476 mRemoteV1/UI/UI.Window.PortScan.vb
  34. +106 −129 mRemoteV1/UI/UI.Window.Tree.Designer.vb
  35. +0 −16 mRemoteV1/UI/UI.Window.Tree.resx
  36. +44 −120 mRemoteV1/UI/UI.Window.Tree.vb
  37. +1 −2 mRemoteV1/UI/UI.Window.Type.vb
  38. +22 −8 mRemoteV1/mRemoteV1.vbproj
View
2 CHANGELOG.TXT
@@ -1,5 +1,7 @@
1.73 Beta 2 ():
Fixed issue MR-619 - Keyboard shortcuts stop working after locking the screen with Win+L
+ Added support for importing files from PuTTY Connection Manager.
+ Improved the import and export functionality.
1.73 Beta 1 (2013-11-19):
Added feature MR-16 - Add keyboard shortcuts to switch between tabs
View
2 TestProject/TestProject.vbproj
@@ -25,6 +25,7 @@
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>TestProject.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
+ <PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -34,6 +35,7 @@
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>TestProject.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
+ <PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<OptionExplicit>On</OptionExplicit>
View
336 mRemoteV1/App/App.Runtime.vb
@@ -7,7 +7,6 @@ Imports mRemoteNG.Connection
Imports mRemoteNG.Tools
Imports mRemoteNG.Forms.OptionsPages
Imports PSTaskDialog
-Imports mRemoteNG.Config.Putty
Imports WeifenLuo.WinFormsUI.Docking
Imports System.IO
Imports Crownwood
@@ -222,15 +221,15 @@ Namespace App
Public Shared sessionsPanel As New DockContent
Public Shared screenshotForm As UI.Window.ScreenshotManager
Public Shared screenshotPanel As New DockContent
- Public Shared exportForm As UI.Window.Export
+ Public Shared exportForm As ExportForm
Public Shared exportPanel As New DockContent
Public Shared aboutForm As UI.Window.About
Public Shared aboutPanel As New DockContent
Public Shared updateForm As UI.Window.Update
Public Shared updatePanel As New DockContent
Public Shared sshtransferForm As UI.Window.SSHTransfer
Public Shared sshtransferPanel As New DockContent
- Public Shared adimportForm As UI.Window.ADImport
+ Public Shared adimportForm As UI.Window.ActiveDirectoryImport
Public Shared adimportPanel As New DockContent
Public Shared helpForm As UI.Window.Help
Public Shared helpPanel As New DockContent
@@ -245,7 +244,7 @@ Namespace App
Public Shared AnnouncementForm As UI.Window.Announcement
Public Shared AnnouncementPanel As New DockContent
- Public Shared Sub Show(ByVal windowType As UI.Window.Type, Optional ByVal portScanMode As PortScan.PortScanMode = PortScan.PortScanMode.Normal)
+ Public Shared Sub Show(ByVal windowType As UI.Window.Type, Optional ByVal portScanImport As Boolean = False)
Try
Select Case windowType
Case UI.Window.Type.About
@@ -255,9 +254,9 @@ Namespace App
End If
aboutForm.Show(frmMain.pnlDock)
- Case UI.Window.Type.ADImport
+ Case UI.Window.Type.ActiveDirectoryImport
If adimportForm Is Nothing OrElse adimportForm.IsDisposed Then
- adimportForm = New UI.Window.ADImport(adimportPanel)
+ adimportForm = New UI.Window.ActiveDirectoryImport(adimportPanel)
adimportPanel = adimportForm
End If
@@ -266,13 +265,6 @@ Namespace App
Using optionsForm As New OptionsForm()
optionsForm.ShowDialog(frmMain)
End Using
- Case UI.Window.Type.Export
- If exportForm Is Nothing OrElse exportForm.IsDisposed Then
- exportForm = New UI.Window.Export(exportPanel)
- exportPanel = exportForm
- End If
-
- exportForm.Show(frmMain.pnlDock)
Case UI.Window.Type.SSHTransfer
sshtransferForm = New UI.Window.SSHTransfer(sshtransferPanel)
sshtransferPanel = sshtransferForm
@@ -300,7 +292,7 @@ Namespace App
externalappsForm.Show(frmMain.pnlDock)
Case UI.Window.Type.PortScan
- portscanForm = New UI.Window.PortScan(portscanPanel, portScanMode)
+ portscanForm = New UI.Window.PortScan(portscanPanel, portScanImport)
portscanPanel = portscanForm
portscanForm.Show(frmMain.pnlDock)
@@ -1211,255 +1203,6 @@ Namespace App
End If
End Function
- Public Shared Sub ImportConnections()
- Try
- Dim lD As OpenFileDialog = Tools.Controls.ConnectionsLoadDialog
- lD.Multiselect = True
-
- If lD.ShowDialog = DialogResult.OK Then
- Dim nNode As TreeNode = Nothing
-
- For i As Integer = 0 To lD.FileNames.Length - 1
- nNode = Tree.Node.AddNode(Tree.Node.Type.Container, "Import #" & i)
-
- Dim nContI As New mRemoteNG.Container.Info()
- nContI.TreeNode = nNode
- nContI.ConnectionInfo = New mRemoteNG.Connection.Info(nContI)
-
- If Tree.Node.SelectedNode IsNot Nothing Then
- If Tree.Node.GetNodeType(Tree.Node.SelectedNode) = Tree.Node.Type.Container Then
- nContI.Parent = Tree.Node.SelectedNode.Tag
- End If
- End If
-
- nNode.Tag = nContI
- ContainerList.Add(nContI)
-
- Dim conL As New Config.Connections.Load
- conL.ConnectionFileName = lD.FileNames(i)
- conL.RootTreeNode = nNode
- conL.ConnectionList = App.Runtime.ConnectionList
- conL.ContainerList = App.Runtime.ContainerList
-
- conL.Load(True)
-
- Windows.treeForm.tvConnections.SelectedNode.Nodes.Add(nNode)
- Next
- End If
- Catch ex As Exception
- MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, My.Language.strConnectionsFileCouldNotBeImported & vbNewLine & ex.Message)
- End Try
- End Sub
-
- Public Shared Sub ImportConnectionsRdpFile()
- Try
- Dim openFileDialog As OpenFileDialog = Tools.Controls.ImportConnectionsRdpFileDialog
- If Not openFileDialog.ShowDialog = DialogResult.OK Then Return
-
- For Each fileName As String In openFileDialog.FileNames
- Dim lines As String() = File.ReadAllLines(fileName)
-
- Dim treeNode As TreeNode = Tree.Node.AddNode(Tree.Node.Type.Connection, Path.GetFileNameWithoutExtension(fileName))
-
- Dim connectionInfo As New Connection.Info()
- connectionInfo.Inherit = New Connection.Info.Inheritance(connectionInfo)
-
- connectionInfo.Name = treeNode.Text
-
- For Each line As String In lines
- Dim parts() As String = line.Split(New Char() {":"}, 3)
- If parts.Length < 3 Then Continue For
-
- Dim key As String = parts(0)
- Dim value As String = parts(2)
-
- Select Case LCase(key)
- Case "full address"
- Dim uri As New Uri("dummyscheme" + uri.SchemeDelimiter + value)
- If Not String.IsNullOrEmpty(uri.Host) Then connectionInfo.Hostname = uri.Host
- If Not uri.Port = -1 Then connectionInfo.Port = uri.Port
- Case "server port"
- connectionInfo.Port = value
- Case "username"
- connectionInfo.Username = value
- Case "domain"
- connectionInfo.Domain = value
- Case "session bpp"
- Select Case value
- Case 8
- connectionInfo.Colors = Protocol.RDP.RDPColors.Colors256
- Case 15
- connectionInfo.Colors = Protocol.RDP.RDPColors.Colors15Bit
- Case 16
- connectionInfo.Colors = Protocol.RDP.RDPColors.Colors16Bit
- Case 24
- connectionInfo.Colors = Protocol.RDP.RDPColors.Colors24Bit
- Case 32
- connectionInfo.Colors = Protocol.RDP.RDPColors.Colors32Bit
- End Select
- Case "bitmapcachepersistenable"
- If value = 1 Then
- connectionInfo.CacheBitmaps = True
- Else
- connectionInfo.CacheBitmaps = False
- End If
- Case "screen mode id"
- If value = 2 Then
- connectionInfo.Resolution = Protocol.RDP.RDPResolutions.Fullscreen
- Else
- connectionInfo.Resolution = Protocol.RDP.RDPResolutions.FitToWindow
- End If
- Case "connect to console"
- If value = 1 Then
- connectionInfo.UseConsoleSession = True
- End If
- Case "disable wallpaper"
- If value = 1 Then
- connectionInfo.DisplayWallpaper = True
- Else
- connectionInfo.DisplayWallpaper = False
- End If
- Case "disable themes"
- If value = 1 Then
- connectionInfo.DisplayThemes = True
- Else
- connectionInfo.DisplayThemes = False
- End If
- Case "allow font smoothing"
- If value = 1 Then
- connectionInfo.EnableFontSmoothing = True
- Else
- connectionInfo.EnableFontSmoothing = False
- End If
- Case "allow desktop composition"
- If value = 1 Then
- connectionInfo.EnableDesktopComposition = True
- Else
- connectionInfo.EnableDesktopComposition = False
- End If
- Case "redirectsmartcards"
- If value = 1 Then
- connectionInfo.RedirectSmartCards = True
- Else
- connectionInfo.RedirectSmartCards = False
- End If
- Case "redirectdrives"
- If value = 1 Then
- connectionInfo.RedirectDiskDrives = True
- Else
- connectionInfo.RedirectDiskDrives = False
- End If
- Case "redirectcomports"
- If value = 1 Then
- connectionInfo.RedirectPorts = True
- Else
- connectionInfo.RedirectPorts = False
- End If
- Case "redirectprinters"
- If value = 1 Then
- connectionInfo.RedirectPrinters = True
- Else
- connectionInfo.RedirectPrinters = False
- End If
- Case "audiomode"
- Select Case value
- Case 0
- connectionInfo.RedirectSound = Protocol.RDP.RDPSounds.BringToThisComputer
- Case 1
- connectionInfo.RedirectSound = Protocol.RDP.RDPSounds.LeaveAtRemoteComputer
- Case 2
- connectionInfo.RedirectSound = Protocol.RDP.RDPSounds.DoNotPlay
- End Select
- End Select
- Next
-
- treeNode.Tag = connectionInfo
- Windows.treeForm.tvConnections.SelectedNode.Nodes.Add(treeNode)
-
- If Tree.Node.GetNodeType(treeNode.Parent) = Tree.Node.Type.Container Then
- connectionInfo.Parent = treeNode.Parent.Tag
- End If
-
- ConnectionList.Add(connectionInfo)
- Next
- Catch ex As Exception
- MessageCollector.AddExceptionMessage(My.Language.strRdpFileCouldNotBeImported, ex)
- End Try
- End Sub
-
- Public Shared Sub ImportConnectionsFromPortScan(ByVal Hosts As ArrayList, ByVal Protocol As mRemoteNG.Connection.Protocol.Protocols)
- For Each Host As Tools.PortScan.ScanHost In Hosts
- Dim finalProt As mRemoteNG.Connection.Protocol.Protocols
- Dim protOK As Boolean = False
-
- Dim nNode As TreeNode = Tree.Node.AddNode(Tree.Node.Type.Connection, Host.HostNameWithoutDomain)
-
- Dim nConI As New mRemoteNG.Connection.Info()
- nConI.Inherit = New Connection.Info.Inheritance(nConI)
-
- nConI.Name = Host.HostNameWithoutDomain
- nConI.Hostname = Host.HostName
-
- Select Case Protocol
- Case Connection.Protocol.Protocols.SSH2
- If Host.SSH Then
- finalProt = Connection.Protocol.Protocols.SSH2
- protOK = True
- End If
- Case Connection.Protocol.Protocols.Telnet
- If Host.Telnet Then
- finalProt = Connection.Protocol.Protocols.Telnet
- protOK = True
- End If
- Case Connection.Protocol.Protocols.HTTP
- If Host.HTTP Then
- finalProt = Connection.Protocol.Protocols.HTTP
- protOK = True
- End If
- Case Connection.Protocol.Protocols.HTTPS
- If Host.HTTPS Then
- finalProt = Connection.Protocol.Protocols.HTTPS
- protOK = True
- End If
- Case Connection.Protocol.Protocols.Rlogin
- If Host.Rlogin Then
- finalProt = Connection.Protocol.Protocols.Rlogin
- protOK = True
- End If
- Case Connection.Protocol.Protocols.RDP
- If Host.RDP Then
- finalProt = Connection.Protocol.Protocols.RDP
- protOK = True
- End If
- Case Connection.Protocol.Protocols.VNC
- If Host.VNC Then
- finalProt = Connection.Protocol.Protocols.VNC
- protOK = True
- End If
- End Select
-
- If protOK = False Then
- nConI = Nothing
- Else
- nConI.Protocol = finalProt
- nConI.SetDefaultPort()
-
- nNode.Tag = nConI
- Windows.treeForm.tvConnections.SelectedNode.Nodes.Add(nNode)
-
- If Tree.Node.GetNodeType(nNode.Parent) = Tree.Node.Type.Container Then
- nConI.Parent = nNode.Parent.Tag
- End If
-
- ConnectionList.Add(nConI)
- End If
- Next
- End Sub
-
- Public Shared Sub ImportConnectionsFromCSV()
-
- End Sub
-
Public Shared Sub SaveConnectionsBG()
_saveUpdate = True
@@ -1525,60 +1268,51 @@ Namespace App
End Try
End Sub
- Public Shared Sub SaveConnectionsAs(Optional ByVal rootNode As TreeNode = Nothing, Optional ByVal saveSecurity As Security.Save = Nothing)
- Dim connectionsSave As New Connections.Save
+ Public Shared Sub SaveConnectionsAs()
Dim previousTimerState As Boolean = False
+ Dim connectionsSave As New Connections.Save
Try
If TimerSqlWatcher IsNot Nothing Then
previousTimerState = TimerSqlWatcher.Enabled
TimerSqlWatcher.Enabled = False
End If
- Dim export As Boolean = False
- Dim saveAsDialog As SaveFileDialog
- If rootNode Is Nothing Then
- rootNode = Windows.treeForm.tvConnections.Nodes(0)
- saveAsDialog = Tools.Controls.ConnectionsSaveAsDialog
- Else
- export = True
- saveAsDialog = Tools.Controls.ConnectionsExportDialog
- End If
+ Using saveFileDialog As New SaveFileDialog()
+ With saveFileDialog
+ .CheckPathExists = True
+ .InitialDirectory = Info.Connections.DefaultConnectionsPath
+ .FileName = Info.Connections.DefaultConnectionsFile
+ .OverwritePrompt = True
- If Not saveAsDialog.ShowDialog() = DialogResult.OK Then Return
+ Dim fileTypes As New List(Of String)
+ fileTypes.AddRange({My.Language.strFiltermRemoteXML, "*.xml"})
+ fileTypes.AddRange({My.Language.strFilterAll, "*.*"})
- connectionsSave.ConnectionFileName = saveAsDialog.FileName
+ .Filter = String.Join("|", fileTypes.ToArray())
+ End With
- If export Then
- Select Case saveAsDialog.FilterIndex
- Case 1
- connectionsSave.SaveFormat = Connections.Save.Format.mRXML
- Case 2
- connectionsSave.SaveFormat = Connections.Save.Format.mRCSV
- Case 3
- connectionsSave.SaveFormat = Connections.Save.Format.vRDCSV
- End Select
- Else
- connectionsSave.SaveFormat = Connections.Save.Format.mRXML
+ If Not saveFileDialog.ShowDialog(frmMain) = DialogResult.OK Then Return
+
+ With connectionsSave
+ .SaveFormat = Connections.Save.Format.mRXML
+ .ConnectionFileName = saveFileDialog.FileName
+ .Export = False
+ .SaveSecurity = New Security.Save()
+ .ConnectionList = ConnectionList
+ .ContainerList = ContainerList
+ .RootTreeNode = Windows.treeForm.tvConnections.Nodes(0)
+ End With
- If connectionsSave.ConnectionFileName = GetDefaultStartupConnectionFileName() Then
+ connectionsSave.Save()
+
+ If saveFileDialog.FileName = GetDefaultStartupConnectionFileName() Then
My.Settings.LoadConsFromCustomLocation = False
Else
My.Settings.LoadConsFromCustomLocation = True
- My.Settings.CustomConsPath = connectionsSave.ConnectionFileName
+ My.Settings.CustomConsPath = saveFileDialog.FileName
End If
- End If
-
- connectionsSave.ConnectionList = ConnectionList
- connectionsSave.ContainerList = ContainerList
- connectionsSave.RootTreeNode = rootNode
-
- connectionsSave.Export = export
-
- If saveSecurity Is Nothing Then saveSecurity = New Security.Save
- connectionsSave.SaveSecurity = saveSecurity
-
- connectionsSave.Save()
+ End Using
Catch ex As Exception
MessageCollector.AddExceptionMessage(String.Format(My.Language.strConnectionsFileCouldNotSaveAs, connectionsSave.ConnectionFileName), ex)
Finally
View
79 mRemoteV1/App/Export.vb
@@ -0,0 +1,79 @@
+Imports mRemoteNG.Forms
+Imports mRemoteNG.App.Runtime
+
+Namespace App
+ Public Class Export
+ Public Shared Sub ExportToFile(ByVal rootTreeNode As TreeNode, ByVal selectedTreeNode As TreeNode)
+ Try
+ Dim exportTreeNode As TreeNode
+ Dim saveSecurity As New Security.Save()
+
+ Using exportForm As New ExportForm()
+ With exportForm
+ Select Case Tree.Node.GetNodeType(selectedTreeNode)
+ Case Tree.Node.Type.Container
+ .SelectedFolder = selectedTreeNode
+ Case Tree.Node.Type.Connection
+ If Tree.Node.GetNodeType(selectedTreeNode.Parent) = Tree.Node.Type.Container Then
+ .SelectedFolder = selectedTreeNode.Parent
+ End If
+ .SelectedConnection = selectedTreeNode
+ End Select
+
+ If Not exportForm.ShowDialog(frmMain) = DialogResult.OK Then Return
+
+ Select Case .Scope
+ Case exportForm.ExportScope.SelectedFolder
+ exportTreeNode = .SelectedFolder
+ Case exportForm.ExportScope.SelectedConnection
+ exportTreeNode = .SelectedConnection
+ Case Else
+ exportTreeNode = rootTreeNode
+ End Select
+
+ saveSecurity.Username = .IncludeUsername
+ saveSecurity.Password = .IncludePassword
+ saveSecurity.Domain = .IncludeDomain
+ saveSecurity.Inheritance = .IncludeInheritance
+ End With
+
+ SaveExportFile(exportForm.FileName, exportForm.SaveFormat, exportTreeNode, saveSecurity)
+ End Using
+ Catch ex As Exception
+ MessageCollector.AddExceptionMessage("App.Export.ExportToFile() failed.", ex, , True)
+ End Try
+ End Sub
+
+ Private Shared Sub SaveExportFile(ByVal fileName As String, ByVal saveFormat As Config.Connections.Save.Format, ByVal rootNode As TreeNode, ByVal saveSecurity As Security.Save)
+ Dim previousTimerEnabled As Boolean = False
+
+ Try
+ If TimerSqlWatcher IsNot Nothing Then
+ previousTimerEnabled = TimerSqlWatcher.Enabled
+ TimerSqlWatcher.Enabled = False
+ End If
+
+ Dim connectionsSave As New Config.Connections.Save
+ With connectionsSave
+ .Export = True
+ .ConnectionFileName = fileName
+ .SaveFormat = saveFormat
+
+ .ConnectionList = ConnectionList
+ .ContainerList = ContainerList
+ .RootTreeNode = rootNode
+
+ .SaveSecurity = saveSecurity
+ End With
+
+ connectionsSave.Save()
+ Catch ex As Exception
+ MessageCollector.AddExceptionMessage(String.Format("Export.SaveExportFile(""{0}"") failed.", fileName), ex)
+ Finally
+ If TimerSqlWatcher IsNot Nothing Then
+ TimerSqlWatcher.Enabled = previousTimerEnabled
+ End If
+ End Try
+ End Sub
+ End Class
+End Namespace
View
171 mRemoteV1/App/Import.vb
@@ -0,0 +1,171 @@
+Imports System.Windows.Forms
+Imports System.IO
+Imports mRemoteNG.My
+Imports mRemoteNG.App.Runtime
+Imports PSTaskDialog
+
+Namespace App
+ Public Class Import
+#Region "Public Methods"
+ Public Shared Sub ImportFromFile(ByVal rootTreeNode As TreeNode, ByVal selectedTreeNode As TreeNode, Optional ByVal alwaysUseSelectedTreeNode As Boolean = False)
+ Try
+ Using openFileDialog As New OpenFileDialog()
+ With openFileDialog
+ .CheckFileExists = True
+ .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
+ .Multiselect = True
+
+ Dim fileTypes As New List(Of String)
+ fileTypes.AddRange({Language.strFilterAllImportable, "*.xml;*.rdp;*.rdg;*.dat"})
+ fileTypes.AddRange({Language.strFiltermRemoteXML, "*.xml"})
+ fileTypes.AddRange({Language.strFilterRDP, "*.rdp"})
+ fileTypes.AddRange({Language.strFilterRdgFiles, "*.rdg"})
+ fileTypes.AddRange({Language.strFilterPuttyConnectionManager, "*.dat"})
+ fileTypes.AddRange({Language.strFilterAll, "*.*"})
+
+ .Filter = String.Join("|", fileTypes.ToArray())
+ End With
+
+ If Not openFileDialog.ShowDialog = DialogResult.OK Then Return
+
+ Dim parentTreeNode As TreeNode = GetParentTreeNode(rootTreeNode, selectedTreeNode, alwaysUseSelectedTreeNode)
+ If parentTreeNode Is Nothing Then Return
+
+ For Each fileName As String In openFileDialog.FileNames
+ Try
+ Select Case DetermineFileType(fileName)
+ Case FileType.mRemoteXml
+ Config.Import.mRemoteNG.Import(fileName, parentTreeNode)
+ Case FileType.RemoteDesktopConnection
+ Config.Import.RemoteDesktopConnection.Import(fileName, parentTreeNode)
+ Case FileType.RemoteDesktopConnectionManager
+ Config.Import.RemoteDesktopConnectionManager.Import(fileName, parentTreeNode)
+ Case FileType.PuttyConnectionManager
+ Config.Import.PuttyConnectionManager.Import(fileName, parentTreeNode)
+ Case Else
+ Throw New FileFormatException("Unrecognized file format.")
+ End Select
+ Catch ex As Exception
+ cTaskDialog.ShowTaskDialogBox(Application.ProductName, Language.strImportFileFailedMainInstruction, String.Format(Language.strImportFileFailedContent, fileName), Tools.Misc.GetExceptionMessageRecursive(ex), "", "", "", "", eTaskDialogButtons.OK, eSysIcons.Error, Nothing)
+ End Try
+ Next
+
+ parentTreeNode.Expand()
+ Dim parentContainer As Container.Info = TryCast(parentTreeNode.Tag, Container.Info)
+ If parentContainer IsNot Nothing Then parentContainer.IsExpanded = True
+
+ SaveConnectionsBG()
+ End Using
+ Catch ex As Exception
+ MessageCollector.AddExceptionMessage("App.Import.ImportFromFile() failed.", ex, , True)
+ End Try
+ End Sub
+
+ Public Shared Sub ImportFromActiveDirectory(ByVal ldapPath As String)
+ Try
+ Dim rootTreeNode As TreeNode = Tree.Node.TreeView.Nodes(0)
+ Dim selectedTreeNode As TreeNode = Tree.Node.TreeView.SelectedNode
+
+ Dim parentTreeNode As TreeNode = GetParentTreeNode(rootTreeNode, selectedTreeNode)
+ If parentTreeNode Is Nothing Then Return
+
+ Config.Import.ActiveDirectory.Import(ldapPath, parentTreeNode)
+
+ parentTreeNode.Expand()
+ Dim parentContainer As Container.Info = TryCast(parentTreeNode.Tag, Container.Info)
+ If parentContainer IsNot Nothing Then parentContainer.IsExpanded = True
+
+ SaveConnectionsBG()
+ Catch ex As Exception
+ MessageCollector.AddExceptionMessage("App.Import.ImportFromActiveDirectory() failed.", ex, , True)
+ End Try
+ End Sub
+
+ Public Shared Sub ImportFromPortScan(ByVal hosts As IEnumerable, ByVal protocol As Connection.Protocol.Protocols)
+ Try
+ Dim rootTreeNode As TreeNode = Tree.Node.TreeView.Nodes(0)
+ Dim selectedTreeNode As TreeNode = Tree.Node.TreeView.SelectedNode
+
+ Dim parentTreeNode As TreeNode = GetParentTreeNode(rootTreeNode, selectedTreeNode)
+ If parentTreeNode Is Nothing Then Return
+
+ Config.Import.PortScan.Import(hosts, protocol, parentTreeNode)
+
+ parentTreeNode.Expand()
+ Dim parentContainer As Container.Info = TryCast(parentTreeNode.Tag, Container.Info)
+ If parentContainer IsNot Nothing Then parentContainer.IsExpanded = True
+
+ SaveConnectionsBG()
+ Catch ex As Exception
+ MessageCollector.AddExceptionMessage("App.Import.ImportFromPortScan() failed.", ex, , True)
+ End Try
+ End Sub
+#End Region
+
+#Region "Private Methods"
+ Private Shared Function GetParentTreeNode(ByVal rootTreeNode As TreeNode, ByVal selectedTreeNode As TreeNode, Optional ByVal alwaysUseSelectedTreeNode As Boolean = False) As TreeNode
+ Dim parentTreeNode As TreeNode
+
+ selectedTreeNode = GetContainerTreeNode(selectedTreeNode)
+ If selectedTreeNode Is Nothing OrElse selectedTreeNode Is rootTreeNode Then
+ parentTreeNode = rootTreeNode
+ Else
+ If alwaysUseSelectedTreeNode Then
+ parentTreeNode = GetContainerTreeNode(selectedTreeNode)
+ Else
+ cTaskDialog.ShowCommandBox(Application.ProductName, Language.strImportLocationMainInstruction, Language.strImportLocationContent, "", "", "", String.Format(Language.strImportLocationCommandButtons, vbLf, rootTreeNode.Text, selectedTreeNode.Text), True, eSysIcons.Question, 0)
+ Select Case cTaskDialog.CommandButtonResult
+ Case 0 ' Root
+ parentTreeNode = rootTreeNode
+ Case 1 ' Selected Folder
+ parentTreeNode = GetContainerTreeNode(selectedTreeNode)
+ Case Else ' Cancel
+ parentTreeNode = Nothing
+ End Select
+ End If
+ End If
+
+ Return parentTreeNode
+ End Function
+
+ Private Shared Function GetContainerTreeNode(ByVal treeNode As TreeNode) As TreeNode
+ Select Case Tree.Node.GetNodeType(treeNode)
+ Case Tree.Node.Type.Root, Tree.Node.Type.Container
+ Return treeNode
+ Case Tree.Node.Type.Connection
+ Return treeNode.Parent
+ Case Else
+ Return Nothing
+ End Select
+ End Function
+
+ Private Shared Function DetermineFileType(ByVal fileName As String) As FileType
+ ' TODO: Use the file contents to determine the file type instead of trusting the extension
+ Dim fileExtension As String = Path.GetExtension(fileName).ToLowerInvariant()
+ Select Case fileExtension
+ Case ".xml"
+ Return FileType.mRemoteXml
+ Case ".rdp"
+ Return FileType.RemoteDesktopConnection
+ Case ".rdg"
+ Return FileType.RemoteDesktopConnectionManager
+ Case ".dat"
+ Return FileType.PuttyConnectionManager
+ Case Else
+ Return FileType.Unknown
+ End Select
+ End Function
+#End Region
+
+#Region "Private Enumerations"
+ Private Enum FileType As Integer
+ Unknown = 0
+ ' ReSharper disable once InconsistentNaming
+ mRemoteXml
+ RemoteDesktopConnection
+ RemoteDesktopConnectionManager
+ PuttyConnectionManager
+ End Enum
+#End Region
+ End Class
+End Namespace
View
39 mRemoteV1/Config/Config.Connections.Load.vb
@@ -604,7 +604,7 @@ Namespace Config
Private Sub LoadFromXML(ByVal cons As String, ByVal import As Boolean)
Try
- App.Runtime.IsConnectionsFileLoaded = False
+ If Not import Then IsConnectionsFileLoaded = False
' SECTION 1. Create a DOM Document and load the XML data into it.
Me.xDom = New XmlDocument()
@@ -627,20 +627,25 @@ Namespace Config
End If
' SECTION 2. Initialize the treeview control.
- Dim rootNodeName As String = ""
- If xDom.DocumentElement.HasAttribute("Name") Then rootNodeName = xDom.DocumentElement.Attributes("Name").Value.Trim()
- If Not String.IsNullOrEmpty(rootNodeName) Then
- RootTreeNode.Name = rootNodeName
+ Dim rootInfo As Root.Info
+ If import Then
+ rootInfo = Nothing
Else
- RootTreeNode.Name = xDom.DocumentElement.Name
- End If
- RootTreeNode.Text = RootTreeNode.Name
+ Dim rootNodeName As String = ""
+ If xDom.DocumentElement.HasAttribute("Name") Then rootNodeName = xDom.DocumentElement.Attributes("Name").Value.Trim()
+ If Not String.IsNullOrEmpty(rootNodeName) Then
+ RootTreeNode.Name = rootNodeName
+ Else
+ RootTreeNode.Name = xDom.DocumentElement.Name
+ End If
+ RootTreeNode.Text = RootTreeNode.Name
- Dim rootInfo As New Root.Info(Root.Info.RootType.Connection)
- rootInfo.Name = RootTreeNode.Name
- rootInfo.TreeNode = RootTreeNode
+ rootInfo = New Root.Info(Root.Info.RootType.Connection)
+ rootInfo.Name = RootTreeNode.Name
+ rootInfo.TreeNode = RootTreeNode
- RootTreeNode.Tag = rootInfo
+ RootTreeNode.Tag = rootInfo
+ End If
If Me.confVersion > 1.3 Then '1.4
If Security.Crypt.Decrypt(xDom.DocumentElement.Attributes("Protected").Value, pW) <> "ThisIsNotProtected" Then
@@ -697,7 +702,7 @@ Namespace Config
RootTreeNode.EnsureVisible()
- IsConnectionsFileLoaded = True
+ If Not import Then IsConnectionsFileLoaded = True
Windows.treeForm.InitialRefresh()
SetSelectedNode(RootTreeNode)
Catch ex As Exception
@@ -1032,7 +1037,7 @@ Namespace Config
Return conI
End Function
- Private Function Authenticate(ByVal Value As String, ByVal CompareToOriginalValue As Boolean, Optional ByVal RootInfo As mRemoteNG.Root.Info = Nothing) As Boolean
+ Private Function Authenticate(ByVal Value As String, ByVal CompareToOriginalValue As Boolean, Optional ByVal rootInfo As Root.Info = Nothing) As Boolean
Dim passwordName As String
If UseSQL Then
passwordName = Language.strSQLServer.TrimEnd(":")
@@ -1057,8 +1062,10 @@ Namespace Config
End If
Loop
- RootInfo.Password = True
- RootInfo.PasswordString = pW
+ If rootInfo IsNot Nothing Then
+ rootInfo.Password = True
+ rootInfo.PasswordString = pW
+ End If
End If
Return True
View
97 mRemoteV1/Config/Import/ActiveDirectory.vb
@@ -0,0 +1,97 @@
+Imports System.DirectoryServices
+Imports mRemoteNG.App.Runtime
+Imports System.Text.RegularExpressions
+Imports mRemoteNG.My
+
+Namespace Config.Import
+ Public Class ActiveDirectory
+ Public Shared Sub Import(ByVal ldapPath As String, ByVal parentTreeNode As TreeNode)
+ Try
+ Dim treeNode As TreeNode = Tree.Node.AddNode(Tree.Node.Type.Container)
+
+ Dim containerInfo As New Container.Info()
+ containerInfo.TreeNode = treeNode
+ containerInfo.ConnectionInfo = New Connection.Info(containerInfo)
+
+ Dim name As String
+ Dim match As Match = Regex.Match(ldapPath, "ou=([^,]*)", RegexOptions.IgnoreCase)
+ If match.Success Then
+ name = match.Groups(1).Captures(0).Value
+ Else
+ name = Language.strActiveDirectory
+ End If
+
+ containerInfo.Name = name
+
+ ' We can only inherit from a container node, not the root node or connection nodes
+ If Tree.Node.GetNodeType(parentTreeNode) = Tree.Node.Type.Container Then
+ containerInfo.Parent = parentTreeNode.Tag
+ Else
+ containerInfo.ConnectionInfo.Inherit.TurnOffInheritanceCompletely()
+ End If
+
+ treeNode.Text = name
+ treeNode.Name = name
+ treeNode.Tag = containerInfo
+ ContainerList.Add(containerInfo)
+
+ ImportComputers(ldapPath, treeNode)
+
+ parentTreeNode.Nodes.Add(treeNode)
+ Catch ex As Exception
+ MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.Import() failed.", ex, , True)
+ End Try
+ End Sub
+
+ Private Shared Sub ImportComputers(ByVal ldapPath As String, ByVal parentTreeNode As TreeNode)
+ Try
+ Dim strDisplayName, strDescription, strHostName As String
+
+ Const ldapFilter As String = "(objectClass=computer)"
+
+ Dim ldapSearcher As New DirectorySearcher
+ Dim ldapResults As SearchResultCollection
+ Dim ldapResult As SearchResult
+
+ With ldapSearcher
+ .SearchRoot = New DirectoryEntry(ldapPath)
+ .PropertiesToLoad.AddRange({"securityEquals", "cn"})
+ .Filter = ldapFilter
+ .SearchScope = SearchScope.OneLevel
+ End With
+
+ ldapResults = ldapSearcher.FindAll()
+
+ For Each ldapResult In ldapResults
+ With ldapResult.GetDirectoryEntry()
+ strDisplayName = .Properties("cn").Value
+ strDescription = .Properties("Description").Value
+ strHostName = .Properties("dNSHostName").Value
+ End With
+
+ Dim treeNode As TreeNode = Tree.Node.AddNode(Tree.Node.Type.Connection, strDisplayName)
+
+ Dim connectionInfo As New Connection.Info()
+ Dim inheritanceInfo As New Connection.Info.Inheritance(connectionInfo, True)
+ inheritanceInfo.Description = False
+ If TypeOf parentTreeNode.Tag Is Container.Info Then
+ connectionInfo.Parent = parentTreeNode.Tag
+ End If
+ connectionInfo.Inherit = inheritanceInfo
+ connectionInfo.Name = strDisplayName
+ connectionInfo.Hostname = strHostName
+ connectionInfo.Description = strDescription
+ connectionInfo.TreeNode = treeNode
+ treeNode.Name = strDisplayName
+ treeNode.Tag = connectionInfo 'set the nodes tag to the conI
+ 'add connection to connections
+ ConnectionList.Add(connectionInfo)
+
+ parentTreeNode.Nodes.Add(treeNode)
+ Next
+ Catch ex As Exception
+ MessageCollector.AddExceptionMessage("Config.Import.ActiveDirectory.ImportComputers() failed.", ex, , True)
+ End Try
+ End Sub
+ End Class
+End Namespace
View
72 mRemoteV1/Config/Import/PortScan.vb
@@ -0,0 +1,72 @@
+Imports mRemoteNG.App.Runtime
+
+Namespace Config.Import
+ Public Class PortScan
+ Public Shared Sub Import(ByVal hosts As IEnumerable, ByVal protocol As Connection.Protocol.Protocols, ByVal parentTreeNode As TreeNode)
+ For Each host As Tools.PortScan.ScanHost In hosts
+ Dim finalProtocol As Connection.Protocol.Protocols
+ Dim protocolValid As Boolean = False
+
+ Dim treeNode As TreeNode = Tree.Node.AddNode(Tree.Node.Type.Connection, host.HostNameWithoutDomain)
+
+ Dim connectionInfo As New Connection.Info()
+ connectionInfo.Inherit = New Connection.Info.Inheritance(connectionInfo)
+
+ connectionInfo.Name = host.HostNameWithoutDomain
+ connectionInfo.Hostname = host.HostName
+
+ Select Case protocol
+ Case Connection.Protocol.Protocols.SSH2
+ If host.SSH Then
+ finalProtocol = Connection.Protocol.Protocols.SSH2
+ protocolValid = True
+ End If
+ Case Connection.Protocol.Protocols.Telnet
+ If host.Telnet Then
+ finalProtocol = Connection.Protocol.Protocols.Telnet
+ protocolValid = True
+ End If
+ Case Connection.Protocol.Protocols.HTTP
+ If host.HTTP Then
+ finalProtocol = Connection.Protocol.Protocols.HTTP
+ protocolValid = True
+ End If
+ Case Connection.Protocol.Protocols.HTTPS
+ If host.HTTPS Then
+ finalProtocol = Connection.Protocol.Protocols.HTTPS
+ protocolValid = True
+ End If
+ Case Connection.Protocol.Protocols.Rlogin
+ If host.Rlogin Then
+ finalProtocol = Connection.Protocol.Protocols.Rlogin
+ protocolValid = True
+ End If
+ Case Connection.Protocol.Protocols.RDP
+ If host.RDP Then
+ finalProtocol = Connection.Protocol.Protocols.RDP
+ protocolValid = True
+ End If
+ Case Connection.Protocol.Protocols.VNC
+ If host.VNC Then
+ finalProtocol = Connection.Protocol.Protocols.VNC
+ protocolValid = True
+ End If
+ End Select
+
+ If protocolValid Then
+ connectionInfo.Protocol = finalProtocol
+ connectionInfo.SetDefaultPort()
+
+ treeNode.Tag = connectionInfo
+ parentTreeNode.Nodes.Add(treeNode)
+
+ If TypeOf parentTreeNode.Tag Is Container.Info Then
+ connectionInfo.Parent = parentTreeNode.Tag
+ End If
+
+ ConnectionList.Add(connectionInfo)
+ End If
+ Next
+ End Sub
+ End Class
+End Namespace
View
160 mRemoteV1/Config/Import/PuttyConnectionManager.vb
@@ -0,0 +1,160 @@
+Imports System.Xml
+Imports System.IO
+Imports mRemoteNG.App.Runtime
+Imports mRemoteNG.Connection.Protocol
+
+Namespace Config.Import
+ Public Class PuttyConnectionManager
+ Public Shared Sub Import(ByVal fileName As String, ByVal parentTreeNode As TreeNode)
+ Dim xmlDocument As New XmlDocument()
+ xmlDocument.Load(fileName)
+
+ Dim configurationNode As XmlNode = xmlDocument.SelectSingleNode("/configuration")
+ 'Dim version As New Version(configurationNode.Attributes("version").Value)
+ 'If Not version = New Version(0, 7, 1, 136) Then
+ ' Throw New FileFormatException(String.Format("Unsupported file version ({0}).", version))
+ 'End If
+
+ For Each rootNode As XmlNode In configurationNode.SelectNodes("./root")
+ ImportRootOrContainer(rootNode, parentTreeNode)
+ Next
+ End Sub
+
+ Private Shared Sub ImportRootOrContainer(ByVal xmlNode As XmlNode, ByVal parentTreeNode As TreeNode)
+ Dim xmlNodeType As String = xmlNode.Attributes("type").Value
+ Select Case xmlNode.Name
+ Case "root"
+ If Not String.Compare(xmlNodeType, "database", ignoreCase:=True) = 0 Then
+ Throw New FileFormatException(String.Format("Unrecognized root node type ({0}).", xmlNodeType))
+ End If
+ Case "container"
+ If Not String.Compare(xmlNodeType, "folder", ignoreCase:=True) = 0 Then
+ Throw New FileFormatException(String.Format("Unrecognized root node type ({0}).", xmlNodeType))
+ End If
+ Case Else
+ ' ReSharper disable once LocalizableElement
+ Throw New ArgumentException("Argument must be either a root or a container node.", "xmlNode")
+ End Select
+
+ If parentTreeNode Is Nothing Then
+ Throw New InvalidOperationException("parentInfo.TreeNode must not be null.")
+ End If
+
+ Dim name As String = xmlNode.Attributes("name").Value
+
+ Dim treeNode As New TreeNode(name)
+ parentTreeNode.Nodes.Add(treeNode)
+
+ Dim containerInfo As New Container.Info
+ containerInfo.TreeNode = treeNode
+ containerInfo.Name = name
+
+ Dim connectionInfo As Connection.Info = CreateConnectionInfo(name)
+ connectionInfo.Parent = containerInfo
+ connectionInfo.IsContainer = True
+ containerInfo.ConnectionInfo = connectionInfo
+
+ ' We can only inherit from a container node, not the root node or connection nodes
+ If Tree.Node.GetNodeType(parentTreeNode) = Tree.Node.Type.Container Then
+ containerInfo.Parent = parentTreeNode.Tag
+ Else
+ connectionInfo.Inherit.TurnOffInheritanceCompletely()
+ End If
+
+ treeNode.Name = name
+ treeNode.Tag = containerInfo
+ treeNode.ImageIndex = Images.Enums.TreeImage.Container
+ treeNode.SelectedImageIndex = Images.Enums.TreeImage.Container
+
+ For Each childNode As XmlNode In xmlNode.SelectNodes("./*")
+ Select Case childNode.Name
+ Case "container"
+ ImportRootOrContainer(childNode, treeNode)
+ Case "connection"
+ ImportConnection(childNode, treeNode)
+ Case Else
+ Throw New FileFormatException(String.Format("Unrecognized child node ({0}).", childNode.Name))
+ End Select
+ Next
+
+ containerInfo.IsExpanded = xmlNode.Attributes("expanded").InnerText
+ If containerInfo.IsExpanded Then treeNode.Expand()
+
+ ContainerList.Add(containerInfo)
+ End Sub
+
+ Private Shared Sub ImportConnection(ByVal connectionNode As XmlNode, ByVal parentTreeNode As TreeNode)
+ Dim connectionNodeType As String = connectionNode.Attributes("type").Value
+ If Not String.Compare(connectionNodeType, "PuTTY", ignoreCase:=True) = 0 Then
+ Throw New FileFormatException(String.Format("Unrecognized connection node type ({0}).", connectionNodeType))
+ End If
+
+ Dim name As String = connectionNode.Attributes("name").Value
+ Dim treeNode As New TreeNode(name)
+ parentTreeNode.Nodes.Add(treeNode)
+
+ Dim connectionInfo As Connection.Info = ConnectionInfoFromXml(connectionNode)
+ connectionInfo.TreeNode = treeNode
+ connectionInfo.Parent = parentTreeNode.Tag
+
+ treeNode.Name = name
+ treeNode.Tag = connectionInfo
+ treeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed
+ treeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed
+
+ ConnectionList.Add(connectionInfo)
+ End Sub
+
+ Private Shared Function CreateConnectionInfo(ByVal name As String) As Connection.Info
+ Dim connectionInfo As New Connection.Info
+ connectionInfo.Inherit = New Connection.Info.Inheritance(connectionInfo)
+ connectionInfo.Name = name
+ Return connectionInfo
+ End Function
+
+ Private Shared Function ConnectionInfoFromXml(ByVal xmlNode As XmlNode) As Connection.Info
+ Dim connectionInfoNode As XmlNode = xmlNode.SelectSingleNode("./connection_info")
+
+ Dim name As String = connectionInfoNode.SelectSingleNode("./name").InnerText
+ Dim connectionInfo As Connection.Info = CreateConnectionInfo(name)
+
+ Dim protocol As String = connectionInfoNode.SelectSingleNode("./protocol").InnerText
+ Select Case protocol.ToLowerInvariant()
+ Case "telnet"
+ connectionInfo.Protocol = Protocols.Telnet
+ Case "ssh"
+ connectionInfo.Protocol = Protocols.SSH2
+ Case Else
+ Throw New FileFormatException(String.Format("Unrecognized protocol ({0}).", protocol))
+ End Select
+
+ connectionInfo.Hostname = connectionInfoNode.SelectSingleNode("./host").InnerText
+ connectionInfo.Port = connectionInfoNode.SelectSingleNode("./port").InnerText
+ connectionInfo.PuttySession = connectionInfoNode.SelectSingleNode("./session").InnerText
+ ' ./commandline
+ connectionInfo.Description = connectionInfoNode.SelectSingleNode("./description").InnerText
+
+ Dim loginNode As XmlNode = xmlNode.SelectSingleNode("./login")
+ connectionInfo.Username = loginNode.SelectSingleNode("login").InnerText
+ connectionInfo.Password = loginNode.SelectSingleNode("password").InnerText
+ ' ./prompt
+
+ ' ./timeout/connectiontimeout
+ ' ./timeout/logintimeout
+ ' ./timeout/passwordtimeout
+ ' ./timeout/commandtimeout
+
+ ' ./command/command1
+ ' ./command/command2
+ ' ./command/command3
+ ' ./command/command4
+ ' ./command/command5
+
+ ' ./options/loginmacro
+ ' ./options/postcommands
+ ' ./options/endlinechar
+
+ Return connectionInfo
+ End Function
+ End Class
+End Namespace
View
141 mRemoteV1/Config/Import/RemoteDesktopConnection.vb
@@ -0,0 +1,141 @@
+Imports System.IO
+Imports mRemoteNG.App.Runtime
+
+Namespace Config.Import
+ Public Class RemoteDesktopConnection
+ Public Shared Sub Import(ByVal fileName As String, ByVal parentTreeNode As TreeNode)
+ Dim lines As String() = File.ReadAllLines(fileName)
+
+ Dim name As String = Path.GetFileNameWithoutExtension(fileName)
+ Dim treeNode As TreeNode = New TreeNode(name)
+ parentTreeNode.Nodes.Add(treeNode)
+
+ Dim connectionInfo As New Connection.Info
+ connectionInfo.Inherit = New Connection.Info.Inheritance(connectionInfo)
+ connectionInfo.Name = name
+ connectionInfo.TreeNode = treeNode
+
+ If TypeOf treeNode.Parent.Tag Is Container.Info Then
+ connectionInfo.Parent = treeNode.Parent.Tag
+ End If
+
+ treeNode.Name = name
+ treeNode.Tag = connectionInfo
+ treeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed
+ treeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed
+
+ For Each line As String In lines
+ Dim parts() As String = line.Split(New Char() {":"}, 3)
+ If parts.Length < 3 Then Continue For
+
+ Dim key As String = parts(0)
+ Dim value As String = parts(2)
+
+ SetConnectionInfoParameter(connectionInfo, key, value)
+ Next
+
+ ConnectionList.Add(connectionInfo)
+ End Sub
+
+ Private Shared Sub SetConnectionInfoParameter(ByRef connectionInfo As Connection.Info, ByVal key As String, ByVal value As String)
+ Select Case LCase(key)
+ Case "full address"
+ Dim uri As New Uri("dummyscheme" + uri.SchemeDelimiter + value)
+ If Not String.IsNullOrEmpty(uri.Host) Then connectionInfo.Hostname = uri.Host
+ If Not uri.Port = -1 Then connectionInfo.Port = uri.Port
+ Case "server port"
+ connectionInfo.Port = value
+ Case "username"
+ connectionInfo.Username = value
+ Case "domain"
+ connectionInfo.Domain = value
+ Case "session bpp"
+ Select Case value
+ Case 8
+ connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors256
+ Case 15
+ connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors15Bit
+ Case 16
+ connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors16Bit
+ Case 24
+ connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors24Bit
+ Case 32
+ connectionInfo.Colors = Connection.Protocol.RDP.RDPColors.Colors32Bit
+ End Select
+ Case "bitmapcachepersistenable"
+ If value = 1 Then
+ connectionInfo.CacheBitmaps = True
+ Else
+ connectionInfo.CacheBitmaps = False
+ End If
+ Case "screen mode id"
+ If value = 2 Then
+ connectionInfo.Resolution = Connection.Protocol.RDP.RDPResolutions.Fullscreen
+ Else
+ connectionInfo.Resolution = Connection.Protocol.RDP.RDPResolutions.FitToWindow
+ End If
+ Case "connect to console"
+ If value = 1 Then
+ connectionInfo.UseConsoleSession = True
+ End If
+ Case "disable wallpaper"
+ If value = 1 Then
+ connectionInfo.DisplayWallpaper = True
+ Else
+ connectionInfo.DisplayWallpaper = False
+ End If
+ Case "disable themes"
+ If value = 1 Then
+ connectionInfo.DisplayThemes = True
+ Else
+ connectionInfo.DisplayThemes = False
+ End If
+ Case "allow font smoothing"
+ If value = 1 Then
+ connectionInfo.EnableFontSmoothing = True
+ Else
+ connectionInfo.EnableFontSmoothing = False
+ End If
+ Case "allow desktop composition"
+ If value = 1 Then
+ connectionInfo.EnableDesktopComposition = True
+ Else
+ connectionInfo.EnableDesktopComposition = False
+ End If
+ Case "redirectsmartcards"
+ If value = 1 Then
+ connectionInfo.RedirectSmartCards = True
+ Else
+ connectionInfo.RedirectSmartCards = False
+ End If
+ Case "redirectdrives"
+ If value = 1 Then
+ connectionInfo.RedirectDiskDrives = True
+ Else
+ connectionInfo.RedirectDiskDrives = False
+ End If
+ Case "redirectcomports"
+ If value = 1 Then
+ connectionInfo.RedirectPorts = True
+ Else
+ connectionInfo.RedirectPorts = False
+ End If
+ Case "redirectprinters"
+ If value = 1 Then
+ connectionInfo.RedirectPrinters = True
+ Else
+ connectionInfo.RedirectPrinters = False
+ End If
+ Case "audiomode"
+ Select Case value
+ Case 0
+ connectionInfo.RedirectSound = Connection.Protocol.RDP.RDPSounds.BringToThisComputer
+ Case 1
+ connectionInfo.RedirectSound = Connection.Protocol.RDP.RDPSounds.LeaveAtRemoteComputer
+ Case 2
+ connectionInfo.RedirectSound = Connection.Protocol.RDP.RDPSounds.DoNotPlay
+ End Select
+ End Select
+ End Sub
+ End Class
+End Namespace
View
71 mRemoteV1/Config/Import/RemoteDesktopConnectionManager.vb
@@ -6,7 +6,7 @@ Imports mRemoteNG.App.Runtime
Namespace Config.Import
Public Class RemoteDesktopConnectionManager
- Public Shared Sub Import(ByVal fileName As String, ByVal rootInfo As Root.Info)
+ Public Shared Sub Import(ByVal fileName As String, ByVal parentTreeNode As TreeNode)
Dim xmlDocument As New XmlDocument()
xmlDocument.Load(fileName)
@@ -18,53 +18,22 @@ Namespace Config.Import
Dim versionNode As XmlNode = rdcManNode.SelectSingleNode("./version")
Dim version As New Version(versionNode.InnerText)
- If Not version = New Version(2.2) Then
+ If Not version = New Version(2, 2) Then
Throw New FileFormatException(String.Format("Unsupported file version ({0}).", version))
End If
Dim fileNode As XmlNode = rdcManNode.SelectSingleNode("./file")
- ImportFileOrGroup(fileNode, rootInfo)
+ ImportFileOrGroup(fileNode, parentTreeNode)
End Sub
- Private Shared Sub ImportFileOrGroup(ByVal xmlNode As XmlNode, ByVal parentInfo As Object)
- Dim parentTreeNode As TreeNode
- Dim childNodePath As String
- Select Case xmlNode.Name
- Case "file"
- Dim rootInfo As Root.Info = TryCast(parentInfo, Root.Info)
- If rootInfo Is Nothing Then
- ' ReSharper disable once LocalizableElement
- Throw New ArgumentException("Argument must be a Root.Info object.", "parentInfo")
- End If
- parentTreeNode = rootInfo.TreeNode
- childNodePath = "./group"
- Case "group"
- Dim parentContainerInfo As Container.Info = TryCast(parentInfo, Container.Info)
- If parentContainerInfo Is Nothing Then
- ' ReSharper disable once LocalizableElement
- Throw New ArgumentException("Argument must be a Container.Info object.", "parentInfo")
- End If
- parentTreeNode = parentContainerInfo.TreeNode
- childNodePath = "./server"
- Case Else
- ' ReSharper disable once LocalizableElement
- Throw New ArgumentException("Argument must be either a file or a group node.", "xmlNode")
- End Select
-
- If parentTreeNode Is Nothing Then
- Throw New InvalidOperationException("parentInfo.TreeNode must not be null.")
- End If
-
- Debug.Assert(Not String.IsNullOrEmpty(childNodePath))
-
+ Private Shared Sub ImportFileOrGroup(ByVal xmlNode As XmlNode, ByVal parentTreeNode As TreeNode)
Dim propertiesNode As XmlNode = xmlNode.SelectSingleNode("./properties")
Dim name As String = propertiesNode.SelectSingleNode("./name").InnerText
- Dim treeNode As TreeNode = New TreeNode(name)
+ Dim treeNode As New TreeNode(name)
parentTreeNode.Nodes.Add(treeNode)
Dim containerInfo As New Container.Info
- containerInfo.Parent = parentInfo
containerInfo.TreeNode = treeNode
containerInfo.Name = name
@@ -73,38 +42,48 @@ Namespace Config.Import
connectionInfo.IsContainer = True
containerInfo.ConnectionInfo = connectionInfo
+ ' We can only inherit from a container node, not the root node or connection nodes
+ If Tree.Node.GetNodeType(parentTreeNode) = Tree.Node.Type.Container Then
+ containerInfo.Parent = parentTreeNode.Tag
+ Else
+ connectionInfo.Inherit.TurnOffInheritanceCompletely()
+ End If
+
+ treeNode.Name = name
treeNode.Tag = containerInfo
treeNode.ImageIndex = Images.Enums.TreeImage.Container
treeNode.SelectedImageIndex = Images.Enums.TreeImage.Container
- For Each childNode As XmlNode In xmlNode.SelectNodes(childNodePath)
+ For Each childNode As XmlNode In xmlNode.SelectNodes("./group|./server")
Select Case childNode.Name
Case "group"
- ImportFileOrGroup(childNode, containerInfo)
+ ImportFileOrGroup(childNode, treeNode)
Case "server"
- ImportServer(childNode, containerInfo)
+ ImportServer(childNode, treeNode)
End Select
Next
containerInfo.IsExpanded = propertiesNode.SelectSingleNode("./expanded").InnerText
If containerInfo.IsExpanded Then treeNode.Expand()
- End Sub
- Private Shared Sub ImportServer(ByVal serverNode As XmlNode, ByVal parentContainerInfo As Container.Info)
- Dim parentTreeNode As TreeNode = parentContainerInfo.TreeNode
+ ContainerList.Add(containerInfo)
+ End Sub
- Dim displayName As String = serverNode.SelectSingleNode("./displayName").InnerText
- Dim treeNode As TreeNode = New TreeNode(displayName)
+ Private Shared Sub ImportServer(ByVal serverNode As XmlNode, ByVal parentTreeNode As TreeNode)
+ Dim name As String = serverNode.SelectSingleNode("./displayName").InnerText
+ Dim treeNode As New TreeNode(name)
parentTreeNode.Nodes.Add(treeNode)
Dim connectionInfo As Connection.Info = ConnectionInfoFromXml(serverNode)
connectionInfo.TreeNode = treeNode
- connectionInfo.Parent = parentContainerInfo
- connectionInfo.Name = displayName
+ connectionInfo.Parent = parentTreeNode.Tag
+ treeNode.Name = name
treeNode.Tag = connectionInfo
treeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed
treeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed
+
+ ConnectionList.Add(connectionInfo)
End Sub
Private Shared Function ConnectionInfoFromXml(ByVal xmlNode As XmlNode) As Connection.Info
View
49 mRemoteV1/Config/Import/mRemoteNG.vb
@@ -0,0 +1,49 @@
+Imports System.IO
+Imports mRemoteNG.App.Runtime
+
+Namespace Config.Import
+ ' ReSharper disable once InconsistentNaming
+ Public Class mRemoteNG
+ Public Shared Sub Import(ByVal fileName As String, ByVal parentTreeNode As TreeNode)
+ Dim name As String = Path.GetFileNameWithoutExtension(fileName)
+ Dim treeNode As New TreeNode(name)
+ parentTreeNode.Nodes.Add(treeNode)
+
+ Dim containerInfo As New Container.Info
+ containerInfo.TreeNode = treeNode
+ containerInfo.Name = name
+
+ Dim connectionInfo As New Connection.Info
+ connectionInfo.Inherit = New Connection.Info.Inheritance(connectionInfo)
+ connectionInfo.Name = name
+ connectionInfo.TreeNode = treeNode
+ connectionInfo.Parent = containerInfo
+ connectionInfo.IsContainer = True
+ containerInfo.ConnectionInfo = connectionInfo
+
+ ' We can only inherit from a container node, not the root node or connection nodes
+ If Tree.Node.GetNodeType(parentTreeNode) = Tree.Node.Type.Container Then
+ containerInfo.Parent = parentTreeNode.Tag
+ Else
+ connectionInfo.Inherit.TurnOffInheritanceCompletely()
+ End If
+
+ treeNode.Name = name
+ treeNode.Tag = containerInfo
+ treeNode.ImageIndex = Images.Enums.TreeImage.Container
+ treeNode.SelectedImageIndex = Images.Enums.TreeImage.Container
+
+ Dim connectionsLoad As New Connections.Load
+ With connectionsLoad
+ .ConnectionFileName = fileName
+ .RootTreeNode = treeNode
+ .ConnectionList = ConnectionList
+ .ContainerList = ContainerList
+ End With
+
+ connectionsLoad.Load(True)
+
+ ContainerList.Add(containerInfo)
+ End Sub
+ End Class
+End Namespace
View
294 mRemoteV1/Forms/ExportForm.Designer.vb
@@ -0,0 +1,294 @@
+Namespace Forms
+ Partial Public Class ExportForm
+ Inherits Form
+#Region " Windows Form Designer generated code "
+
+ Private Sub InitializeComponent()
+ Me.btnCancel = New System.Windows.Forms.Button()
+ Me.btnOK = New System.Windows.Forms.Button()
+ Me.lblUncheckProperties = New System.Windows.Forms.Label()
+ Me.chkUsername = New System.Windows.Forms.CheckBox()
+ Me.chkPassword = New System.Windows.Forms.CheckBox()
+ Me.chkDomain = New System.Windows.Forms.CheckBox()
+ Me.chkInheritance = New System.Windows.Forms.CheckBox()
+ Me.txtFileName = New System.Windows.Forms.TextBox()
+ Me.btnBrowse = New System.Windows.Forms.Button()
+ Me.grpProperties = New System.Windows.Forms.GroupBox()
+ Me.grpFile = New System.Windows.Forms.GroupBox()
+ Me.lblFileFormat = New System.Windows.Forms.Label()
+ Me.lblFileName = New System.Windows.Forms.Label()
+ Me.cboFileFormat = New System.Windows.Forms.ComboBox()
+ Me.grpItems = New System.Windows.Forms.GroupBox()
+ Me.lblSelectedConnection = New System.Windows.Forms.Label()
+ Me.lblSelectedFolder = New System.Windows.Forms.Label()
+ Me.rdoExportSelectedConnection = New System.Windows.Forms.RadioButton()
+ Me.rdoExportSelectedFolder = New System.Windows.Forms.RadioButton()
+ Me.rdoExportEverything = New System.Windows.Forms.RadioButton()
+ Me.grpProperties.SuspendLayout()
+ Me.grpFile.SuspendLayout()
+ Me.grpItems.SuspendLayout()
+ Me.SuspendLayout()
+ '
+ 'btnCancel
+ '
+ Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
+ Me.btnCancel.Location = New System.Drawing.Point(447, 473)
+ Me.btnCancel.Name = "btnCancel"
+ Me.btnCancel.Size = New System.Drawing.Size(75, 23)
+ Me.btnCancel.TabIndex = 3
+ Me.btnCancel.Text = "&Cancel"
+ Me.btnCancel.UseVisualStyleBackColor = True
+ '
+ 'btnOK
+ '
+ Me.btnOK.Location = New System.Drawing.Point(366, 473)
+ Me.btnOK.Name = "btnOK"
+ Me.btnOK.Size = New System.Drawing.Size(75, 23)
+ Me.btnOK.TabIndex = 2
+ Me.btnOK.Text = "&OK"
+ Me.btnOK.UseVisualStyleBackColor = True
+ '
+ 'lblUncheckProperties
+ '
+ Me.lblUncheckProperties.AutoSize = True
+ Me.lblUncheckProperties.Location = New System.Drawing.Point(12, 134)
+ Me.lblUncheckProperties.Name = "lblUncheckProperties"
+ Me.lblUncheckProperties.Size = New System.Drawing.Size(244, 13)
+ Me.lblUncheckProperties.TabIndex = 4
+ Me.lblUncheckProperties.Text = "Uncheck the properties you want not to be saved!"
+ '
+ 'chkUsername
+ '
+ Me.chkUsername.AutoSize = True
+ Me.chkUsername.Checked = True
+ Me.chkUsername.CheckState = System.Windows.Forms.CheckState.Checked
+ Me.chkUsername.Location = New System.Drawing.Point(15, 32)
+ Me.chkUsername.Name = "chkUsername"
+ Me.chkUsername.Size = New System.Drawing.Size(74, 17)
+ Me.chkUsername.TabIndex = 0
+ Me.chkUsername.Text = "Username"
+ Me.chkUsername.UseVisualStyleBackColor = True
+ '
+ 'chkPassword
+ '
+ Me.chkPassword.AutoSize = True
+ Me.chkPassword.Checked = True
+ Me.chkPassword.CheckState = System.Windows.Forms.CheckState.Checked
+ Me.chkPassword.Location = New System.Drawing.Point(15, 55)
+ Me.chkPassword.Name = "chkPassword"
+ Me.chkPassword.Size = New System.Drawing.Size(72, 17)
+ Me.chkPassword.TabIndex = 1
+ Me.chkPassword.Text = "Password"
+ Me.chkPassword.UseVisualStyleBackColor = True
+ '
+ 'chkDomain
+ '
+ Me.chkDomain.AutoSize = True
+ Me.chkDomain.Checked = True
+ Me.chkDomain.CheckState = System.Windows.Forms.CheckState.Checked
+ Me.chkDomain.Location = New System.Drawing.Point(15, 78)
+ Me.chkDomain.Name = "chkDomain"
+ Me.chkDomain.Size = New System.Drawing.Size(62, 17)
+ Me.chkDomain.TabIndex = 2
+ Me.chkDomain.Text = "Domain"
+ Me.chkDomain.UseVisualStyleBackColor = True
+ '
+ 'chkInheritance
+ '
+ Me.chkInheritance.AutoSize = True
+ Me.chkInheritance.Checked = True
+ Me.chkInheritance.CheckState = System.Windows.Forms.CheckState.Checked
+ Me.chkInheritance.Location = New System.Drawing.Point(15, 101)
+ Me.chkInheritance.Name = "chkInheritance"
+ Me.chkInheritance.Size = New System.Drawing.Size(79, 17)
+ Me.chkInheritance.TabIndex = 3
+ Me.chkInheritance.Text = "Inheritance"
+ Me.chkInheritance.UseVisualStyleBackColor = True
+ '
+ 'txtFileName
+ '
+ Me.txtFileName.Location = New System.Drawing.Point(15, 48)
+ Me.txtFileName.Name = "txtFileName"
+ Me.txtFileName.Size = New System.Drawing.Size(396, 20)
+ Me.txtFileName.TabIndex = 1
+ '
+ 'btnBrowse
+ '
+ Me.btnBrowse.Location = New System.Drawing.Point(417, 46)
+ Me.btnBrowse.Name = "btnBrowse"
+ Me.btnBrowse.Size = New System.Drawing.Size(75, 23)
+ Me.btnBrowse.TabIndex = 2
+ Me.btnBrowse.Text = "&Browse"
+ Me.btnBrowse.UseVisualStyleBackColor = True
+ '
+ 'grpProperties
+ '
+ Me.grpProperties.Controls.Add(Me.lblUncheckProperties)
+ Me.grpProperties.Controls.Add(Me.chkInheritance)
+ Me.grpProperties.Controls.Add(Me.chkUsername)
+ Me.grpProperties.Controls.Add(Me.chkDomain)
+ Me.grpProperties.Controls.Add(Me.chkPassword)
+ Me.grpProperties.Location = New System.Drawing.Point(12, 304)
+ Me.grpProperties.Name = "grpProperties"
+ Me.grpProperties.Size = New System.Drawing.Size(510, 163)
+ Me.grpProperties.TabIndex = 1
+ Me.grpProperties.TabStop = False
+ Me.grpProperties.Text = "Export Properties"
+ '
+ 'grpFile
+ '
+ Me.grpFile.Controls.Add(Me.lblFileFormat)
+ Me.grpFile.Controls.Add(Me.lblFileName)
+ Me.grpFile.Controls.Add(Me.cboFileFormat)
+ Me.grpFile.Controls.Add(Me.txtFileName)
+ Me.grpFile.Controls.Add(Me.btnBrowse)
+ Me.grpFile.Location = New System.Drawing.Point(12, 12)
+ Me.grpFile.Name = "grpFile"
+ Me.grpFile.Size = New System.Drawing.Size(510, 140)
+ Me.grpFile.TabIndex = 0
+ Me.grpFile.TabStop = False
+ Me.grpFile.Text = "Export File"
+ '
+ 'lblFileFormat
+ '
+ Me.lblFileFormat.AutoSize = True
+ Me.lblFileFormat.Location = New System.Drawing.Point(12, 84)
+ Me.lblFileFormat.Name = "lblFileFormat"
+ Me.lblFileFormat.Size = New System.Drawing.Size(61, 13)
+ Me.lblFileFormat.TabIndex = 3
+ Me.lblFileFormat.Text = "File &Format:"
+ '
+ 'lblFileName
+ '
+ Me.lblFileName.AutoSize = True
+ Me.lblFileName.Location = New System.Drawing.Point(12, 32)
+ Me.lblFileName.Name = "lblFileName"
+ Me.lblFileName.Size = New System.Drawing.Size(52, 13)
+ Me.lblFileName.TabIndex = 0
+ Me.lblFileName.Text = "Filename:"
+ '
+ 'cboFileFormat
+ '
+ Me.cboFileFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
+ Me.cboFileFormat.FormattingEnabled = True
+ Me.cboFileFormat.Location = New System.Drawing.Point(15, 100)
+ Me.cboFileFormat.Name = "cboFileFormat"
+ Me.cboFileFormat.Size = New System.Drawing.Size(294, 21)
+ Me.cboFileFormat.TabIndex = 4
+ '
+ 'grpItems
+ '
+ Me.grpItems.Controls.Add(Me.lblSelectedConnection)
+ Me.grpItems.Controls.Add(Me.lblSelectedFolder)
+ Me.grpItems.Controls.Add(Me.rdoExportSelectedConnection)
+ Me.grpItems.Controls.Add(Me.rdoExportSelectedFolder)
+ Me.grpItems.Controls.Add(Me.rdoExportEverything)
+ Me.grpItems.Location = New System.Drawing.Point(12, 158)
+ Me.grpItems.Name = "grpItems"
+ Me.grpItems.Size = New System.Drawing.Size(510, 140)
+ Me.grpItems.TabIndex = 4
+ Me.grpItems.TabStop = False
+ Me.grpItems.Text = "Export Items"
+ '
+ 'lblSelectedConnection
+ '
+ Me.lblSelectedConnection.AutoSize = True
+ Me.lblSelectedConnection.Location = New System.Drawing.Point(48, 111)
+ Me.lblSelectedConnection.Name = "lblSelectedConnection"
+ Me.lblSelectedConnection.Size = New System.Drawing.Size(92, 13)
+ Me.lblSelectedConnection.TabIndex = 4
+ Me.lblSelectedConnection.Text = "Connection Name"
+ '
+ 'lblSelectedFolder
+ '
+ Me.lblSelectedFolder.AutoSize = True
+ Me.lblSelectedFolder.Location = New System.Drawing.Point(48, 75)
+ Me.lblSelectedFolder.Name = "lblSelectedFolder"
+ Me.lblSelectedFolder.Size = New System.Drawing.Size(67, 13)
+ Me.lblSelectedFolder.TabIndex = 3
+ Me.lblSelectedFolder.Text = "Folder Name"
+ '
+ 'rdoExportSelectedConnection
+ '
+ Me.rdoExportSelectedConnection.AutoSize = True
+ Me.rdoExportSelectedConnection.Location = New System.Drawing.Point(15, 91)
+ Me.rdoExportSelectedConnection.Name = "rdoExportSelectedConnection"
+ Me.rdoExportSelectedConnection.Size = New System.Drawing.Size(215, 17)
+ Me.rdoExportSelectedConnection.TabIndex = 2
+ Me.rdoExportSelectedConnection.TabStop = True
+ Me.rdoExportSelectedConnection.Text = "Export the currently selected connection"
+ Me.rdoExportSelectedConnection.UseVisualStyleBackColor = True
+ '
+ 'rdoExportSelectedFolder
+ '
+ Me.rdoExportSelectedFolder.AutoSize = True
+ Me.rdoExportSelectedFolder.Location = New System.Drawing.Point(15, 55)
+ Me.rdoExportSelectedFolder.Name = "rdoExportSelectedFolder"
+ Me.rdoExportSelectedFolder.Size = New System.Drawing.Size(188, 17)
+ Me.rdoExportSelectedFolder.TabIndex = 1
+ Me.rdoExportSelectedFolder.TabStop = True
+ Me.rdoExportSelectedFolder.Text = "Export the currently selected folder"
+ Me.rdoExportSelectedFolder.UseVisualStyleBackColor = True
+ '
+ 'rdoExportEverything
+ '
+ Me.rdoExportEverything.AutoSize = True
+ Me.rdoExportEverything.Checked = True
+ Me.rdoExportEverything.Location = New System.Drawing.Point(15, 32)
+ Me.rdoExportEverything.Name = "rdoExportEverything"
+ Me.rdoExportEverything.Size = New System.Drawing.Size(107, 17)
+ Me.rdoExportEverything.TabIndex = 0
+ Me.rdoExportEverything.TabStop = True
+ Me.rdoExportEverything.Text = "Export everything"
+ Me.rdoExportEverything.UseVisualStyleBackColor = True
+ '
+ 'ExportForm
+ '
+ Me.AcceptButton = Me.btnOK
+ Me.CancelButton = Me.btnCancel
+ Me.ClientSize = New System.Drawing.Size(534, 508)
+ Me.Controls.Add(Me.grpItems)
+ Me.Controls.Add(Me.grpFile)
+ Me.Controls.Add(Me.grpProperties)
+ Me.Controls.Add(Me.btnCancel)
+ Me.Controls.Add(Me.btnOK)
+ Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
+ Me.Icon = Global.mRemoteNG.My.Resources.Resources.Connections_SaveAs_Icon
+ Me.MaximizeBox = False
+ Me.MinimizeBox = False
+ Me.Name = "ExportForm"
+ Me.ShowInTaskbar = False
+ Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
+ Me.Text = "Export Connections"
+ Me.grpProperties.ResumeLayout(False)
+ Me.grpProperties.PerformLayout()
+ Me.grpFile.ResumeLayout(False)
+ Me.grpFile.PerformLayout()
+ Me.grpItems.ResumeLayout(False)
+ Me.grpItems.PerformLayout()
+ Me.ResumeLayout(False)
+
+ End Sub
+ Private WithEvents btnCancel As System.Windows.Forms.Button
+ Private WithEvents btnOK As System.Windows.Forms.Button
+ Private WithEvents lblUncheckProperties As System.Windows.Forms.Label
+ Private WithEvents chkUsername As System.Windows.Forms.CheckBox
+ Private WithEvents chkPassword As System.Windows.Forms.CheckBox
+ Private WithEvents chkDomain As System.Windows.Forms.CheckBox
+ Private WithEvents chkInheritance As System.Windows.Forms.CheckBox
+ Private WithEvents txtFileName As System.Windows.Forms.TextBox
+ Private WithEvents btnBrowse As System.Windows.Forms.Button
+ Private WithEvents grpProperties As System.Windows.Forms.GroupBox
+ Private WithEvents grpFile As System.Windows.Forms.GroupBox
+ Private WithEvents lblFileFormat As System.Windows.Forms.Label
+ Private WithEvents lblFileName As System.Windows.Forms.Label
+ Private WithEvents cboFileFormat As System.Windows.Forms.ComboBox
+ Private WithEvents grpItems As System.Windows.Forms.GroupBox
+ Private WithEvents lblSelectedConnection As System.Windows.Forms.Label
+ Private WithEvents lblSelectedFolder As System.Windows.Forms.Label
+ Private WithEvents rdoExportSelectedConnection As System.Windows.Forms.RadioButton
+ Private WithEvents rdoExportSelectedFolder As System.Windows.Forms.RadioButton
+ Private WithEvents rdoExportEverything As System.Windows.Forms.RadioButton
+#End Region
+ End Class
+End Namespace
View
0 mRemoteV1/UI/UI.Window.Export.resx → mRemoteV1/Forms/ExportForm.resx
File renamed without changes.
View
260 mRemoteV1/Forms/ExportForm.vb
@@ -0,0 +1,260 @@
+Imports System.ComponentModel
+Imports mRemoteNG.Config.Connections
+Imports mRemoteNG.App
+Imports mRemoteNG.My
+
+Namespace Forms
+ Public Class ExportForm
+ Inherits Form
+
+#Region "Public Properties"
+ Public Property FileName As String
+ Get
+ Return txtFileName.Text
+ End Get
+ Set(value As String)
+ txtFileName.Text = value
+ End Set
+ End Property
+
+ Public Property SaveFormat As Config.Connections.Save.Format
+ Get
+ Dim exportFormat As ExportFormat = TryCast(cboFileFormat.SelectedItem, ExportFormat)
+ If exportFormat Is Nothing Then
+ Return Config.Connections.Save.Format.mRXML
+ Else
+ Return exportFormat.Format
+ End If
+ End Get
+ Set(value As Config.Connections.Save.Format)
+ For Each item As Object In cboFileFormat.Items
+ Dim exportFormat As ExportFormat = TryCast(item, ExportFormat)
+ If exportFormat Is Nothing Then Continue For
+ If exportFormat.Format = value Then
+ cboFileFormat.SelectedItem = item
+ Exit For
+ End If
+ Next
+ End Set
+ End Property
+
+ Public Property Scope As ExportScope
+ Get
+ If rdoExportSelectedFolder.Checked Then
+ Return ExportScope.SelectedFolder
+ ElseIf rdoExportSelectedConnection.Checked Then
+ Return ExportScope.SelectedConnection
+ Else
+ Return ExportScope.Everything
+ End If
+ End Get
+ Set(value As ExportScope)
+ Select Case value
+ Case ExportScope.Everything
+ rdoExportEverything.Checked = True
+ Case ExportScope.SelectedFolder
+ rdoExportSelectedFolder.Checked = True
+ Case ExportScope.SelectedConnection
+ rdoExportSelectedConnection.Checked = True
+ End Select
+ End Set
+ End Property
+
+ Private _selectedFolder As TreeNode
+ Public Property SelectedFolder As TreeNode
+ Get
+ Return _selectedFolder
+ End Get
+ Set(value As TreeNode)
+ _selectedFolder = value
+ If value Is Nothing Then
+ lblSelectedFolder.Text = String.Empty
+ Else
+ lblSelectedFolder.Text = value.Text
+ End If
+ rdoExportSelectedFolder.Enabled = (value IsNot Nothing)
+ End Set
+ End Property
+
+ Private _selectedConnection As TreeNode
+ Public Property SelectedConnection As TreeNode
+ Get
+ Return _selectedConnection
+ End Get
+ Set(value As TreeNode)
+ _selectedConnection = value
+ If value Is Nothing Then
+ lblSelectedConnection.Text = String.Empty
+ Else
+ lblSelectedConnection.Text = value.Text
+ End If
+ rdoExportSelectedConnection.Enabled = (value IsNot Nothing)
+ End Set
+ End Property
+
+ Public Property IncludeUsername As Boolean
+ Get
+ Return chkUsername.Checked
+ End Get
+ Set(value As Boolean)
+ chkUsername.Checked = value
+ End Set
+ End Property
+
+ Public Property IncludePassword As Boolean
+ Get
+ Return chkPassword.Checked
+ End Get
+ Set(value As Boolean)
+ chkPassword.Checked = value
+ End Set
+ End Property
+
+ Public Property IncludeDomain As Boolean
+ Get
+ Return chkDomain.Checked
+ End Get
+ Set(value As Boolean)
+ chkDomain.Checked = value
+ End Set
+ End Property
+
+ Public Property IncludeInheritance As Boolean
+ Get
+ Return chkInheritance.Checked
+ End Get
+ Set(value As Boolean)
+ chkInheritance.Checked = value
+ End Set
+ End Property
+#End Region
+
+#Region "Constructors"
+ Public Sub New()
+ InitializeComponent()
+
+ Runtime.FontOverride(Me)
+
+ SelectedFolder = Nothing
+ SelectedConnection = Nothing
+
+ btnOK.Enabled = False
+ End Sub
+#End Region
+
+#Region "Private Methods"
+#Region "Event Handlers"
+ Private Sub ExportForm_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
+ cboFileFormat.Items.Clear()
+ cboFileFormat.Items.Add(New ExportFormat(Save.Format.mRXML))
+ cboFileFormat.Items.Add(New ExportFormat(Save.Format.mRCSV))
+ cboFileFormat.Items.Add(New ExportFormat(Save.Format.vRDCSV))
+ cboFileFormat.SelectedIndex = 0
+
+ ApplyLanguage()
+ End Sub
+
+ Private Sub txtFileName_TextChanged(sender As System.Object, e As EventArgs) Handles txtFileName.TextChanged
+ btnOK.Enabled = Not String.IsNullOrEmpty(txtFileName.Text)
+ End Sub
+
+ Private Sub btnBrowse_Click(sender As System.Object, e As EventArgs) Handles btnBrowse.Click
+ Using saveFileDialog As New SaveFileDialog()
+ With saveFileDialog
+ .CheckPathExists = True
+ .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
+ .OverwritePrompt = True
+
+ Dim fileTypes As New List(Of String)
+ fileTypes.AddRange({Language.strFiltermRemoteXML, "*.xml"})
+ fileTypes.AddRange({Language.strFiltermRemoteCSV, "*.csv"})
+ fileTypes.AddRange({Language.strFiltervRD2008CSV, "*.csv"})
+ fileTypes.AddRange({Language.strFilterAll, "*.*"})
+
+ .Filter = String.Join("|", fileTypes.ToArray())
+ End With
+
+ If Not saveFileDialog.ShowDialog(Me) = DialogResult.OK Then Return
+
+ txtFileName.Text = saveFileDialog.FileName
+ End Using
+ End Sub
+
+ Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles btnOK.Click
+ DialogResult = DialogResult.OK
+ End Sub
+
+ Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles btnCancel.Click
+ DialogResult = DialogResult.Cancel
+ End Sub
+#End Region
+
+ Private Sub ApplyLanguage()
+ Text = Language.strExport
+
+ grpFile.Text = Language.strExportFile
+ lblFileName.Text = Language.strLabelFilename
+ btnBrowse.Text = Language.strButtonBrowse
+ lblFileFormat.Text = Language.strFileFormatLabel
+
+ grpItems.Text = Language.strExportItems
+ rdoExportEverything.Text = Language.strExportEverything
+ rdoExportSelectedFolder.Text = Language.strExportSelectedFolder
+ rdoExportSelectedConnection.Text = Language.strExportSelectedConnection
+
+ grpProperties.Text = Language.strExportProperties
+ chkUsername.Text = Language.strCheckboxUsername
+ chkPassword.Text = Language.strCheckboxPassword
+ chkDomain.Text = Language.strCheckboxDomain
+ chkInheritance.Text = Language.strCheckboxInheritance
+ lblUncheckProperties.Text = Language.strUncheckProperties
+
+ btnOK.Text = Language.strButtonOK
+ btnCancel.Text = Language.strButtonCancel
+ End Sub
+#End Region
+
+#Region "Public Enumerations"
+ Public Enum ExportScope As Integer
+ Everything
+ SelectedFolder
+ SelectedConnection
+ End Enum
+#End Region
+
+#Region "Private Classes"
+ <ImmutableObject(True)> _
+ Private Class ExportFormat
+#Region "Public Properties"
+ Private ReadOnly _format As Config.Connections.Save.Format
+ Public ReadOnly Property Format As Config.Connections.Save.Format
+ Get
+ Return _format
+ End Get
+ End Property
+#End Region
+
+#Region "Constructors"
+ Public Sub New(ByVal format As Config.Connections.Save.Format)
+ _format = format
+ End Sub
+#End Region
+
+#Region "Public Methods"
+ Public Overrides Function ToString() As String
+ Select Case Format
+ Case Config.Connections.Save.Format.mRXML
+ Return Language.strMremoteNgXml
+ Case Config.Connections.Save.Format.mRCSV
+ Return Language.strMremoteNgCsv
+ Case Config.Connections.Save.Format.vRDCSV
+ Return Language.strVisionAppRemoteDesktopCsv
+ Case Else
+ Return Format.ToString()
+ End Select
+ End Function
+#End Region
+ End Class
+#End Region
+ End Class
+End Namespace
View
203 mRemoteV1/Forms/frmMain.Designer.vb
@@ -23,21 +23,21 @@ Partial Class frmMain
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
- Dim DockPanelSkin1 As WeifenLuo.WinFormsUI.Docking.DockPanelSkin = New WeifenLuo.WinFormsUI.Docking.DockPanelSkin()
- Dim AutoHideStripSkin1 As WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin = New WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin()
- Dim DockPanelGradient1 As WeifenLuo.WinFormsUI.Docking.DockPanelGradient = New WeifenLuo.WinFormsUI.Docking.DockPanelGradient()
- Dim TabGradient1 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
- Dim DockPaneStripSkin1 As WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin = New WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin()
- Dim DockPaneStripGradient1 As WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient = New WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient()
- Dim TabGradient2 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
- Dim DockPanelGradient2 As WeifenLuo.WinFormsUI.Docking.DockPanelGradient = New WeifenLuo.WinFormsUI.Docking.DockPanelGradient()
- Dim TabGradient3 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
- Dim DockPaneStripToolWindowGradient1 As WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient = New WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient()
- Dim TabGradient4 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
- Dim TabGradient5 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
- Dim DockPanelGradient3 As WeifenLuo.WinFormsUI.Docking.DockPanelGradient = New WeifenLuo.WinFormsUI.Docking.DockPanelGradient()
- Dim TabGradient6 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
- Dim TabGradient7 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
+ Dim DockPanelSkin2 As WeifenLuo.WinFormsUI.Docking.DockPanelSkin = New WeifenLuo.WinFormsUI.Docking.DockPanelSkin()
+ Dim AutoHideStripSkin2 As WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin = New WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin()
+ Dim DockPanelGradient4 As WeifenLuo.WinFormsUI.Docking.DockPanelGradient = New WeifenLuo.WinFormsUI.Docking.DockPanelGradient()
+ Dim TabGradient8 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
+ Dim DockPaneStripSkin2 As WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin = New WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin()
+ Dim DockPaneStripGradient2 As WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient = New WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient()
+ Dim TabGradient9 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
+ Dim DockPanelGradient5 As WeifenLuo.WinFormsUI.Docking.DockPanelGradient = New WeifenLuo.WinFormsUI.Docking.DockPanelGradient()
+ Dim TabGradient10 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
+ Dim DockPaneStripToolWindowGradient2 As WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient = New WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient()
+ Dim TabGradient11 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
+ Dim TabGradient12 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
+ Dim DockPanelGradient6 As WeifenLuo.WinFormsUI.Docking.DockPanelGradient = New WeifenLuo.WinFormsUI.Docking.DockPanelGradient()
+ Dim TabGradient13 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
+ Dim TabGradient14 As WeifenLuo.WinFormsUI.Docking.TabGradient = New WeifenLuo.WinFormsUI.Docking.TabGradient()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMain))
Me.pnlDock = New WeifenLuo.WinFormsUI.Docking.DockPanel()
Me.msMain = New System.Windows.Forms.MenuStrip()
@@ -50,13 +50,11 @@ Partial Class frmMain
Me.mMenFileSave = New System.Windows.Forms.ToolStripMenuItem()
Me.mMenFileSaveAs = New System.Windows.Forms.ToolStripMenuItem()
Me.mMenFileSep2 = New System.Windows.Forms.ToolStripSeparator()
- Me.mMenFileImportExport = New System.Windows.Forms.ToolStripMenuItem()
- Me.ImportFromXMLFileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
- Me.ImportFromRDPFileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
- Me.ImportFromActiveDirectoryToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
- Me.ImportFromPortScanToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
- Me.ToolStripSeparator6 = New System.Windows.Forms.ToolStripSeparator()
- Me.ExportToXMLFileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
+ Me.mMenFileImport = New System.Windows.Forms.ToolStripMenuItem()
+ Me.mMenFileImportFromFile = New System.Windows.Forms.ToolStripMenuItem()
+ Me.mMenFileImportFromActiveDirectory = New System.Windows.Forms.ToolStripMenuItem()
+ Me.mMenFileImportFromPortScan = New System.Windows.Forms.ToolStripMenuItem()
+ Me.mMenFileExport = New System.Windows.Forms.ToolStripMenuItem()
Me.mMenFileSep3 = New System.Windows.Forms.ToolStripSeparator()
Me.mMenFileDelete = New System.Windows.Forms.ToolStripMenuItem()
Me.mMenFileRename = New System.Windows.Forms.ToolStripMenuItem()
@@ -143,52 +141,52 @@ Partial Class frmMain
Me.pnlDock.Location = New System.Drawing.Point(0, 0)
Me.pnlDock.Name = "pnlDock"
Me.pnlDock.Size = New System.Drawing.Size(842, 449)
- DockPanelGradient1.EndColor = System.Drawing.SystemColors.ControlLight
- DockPanelGradient1.StartColor = System.Drawing.SystemColors.ControlLight
- AutoHideStripSkin1.DockStripGradient = DockPanelGradient1
- TabGradient1.EndColor = System.Drawing.SystemColors.Control
- TabGradient1.StartColor = System.Drawing.SystemColors.Control