mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Refactored App.Runtime.cL and Tree.Node.CloneNode().
This commit is contained in:
@@ -12,7 +12,7 @@ Namespace App
|
||||
Public Shared sL As Config.Settings.Load
|
||||
Public Shared sS As Config.Settings.Save
|
||||
|
||||
Public Shared cL As Connection.List
|
||||
Public Shared connectionList As Connection.List
|
||||
Public Shared prevCL As Connection.List
|
||||
Public Shared containerList As Container.List
|
||||
Public Shared prevCTL As Container.List
|
||||
@@ -673,7 +673,7 @@ Namespace App
|
||||
#Region "Connections Loading/Saving"
|
||||
Public Shared Sub NewConnections(ByVal filename As String)
|
||||
Try
|
||||
cL = New Connection.List
|
||||
connectionList = New Connection.List
|
||||
containerList = New Container.List
|
||||
|
||||
Dim conL As New Config.Connections.Load
|
||||
@@ -695,7 +695,7 @@ Namespace App
|
||||
|
||||
xW.Close()
|
||||
|
||||
conL.ConnectionList = cL
|
||||
conL.ConnectionList = connectionList
|
||||
conL.ContainerList = containerList
|
||||
conL.Import = False
|
||||
|
||||
@@ -736,12 +736,12 @@ Namespace App
|
||||
End If
|
||||
End If
|
||||
|
||||
If cL IsNot Nothing And containerList IsNot Nothing Then
|
||||
prevCL = cL.Copy
|
||||
If connectionList IsNot Nothing And containerList IsNot Nothing Then
|
||||
prevCL = connectionList.Copy
|
||||
prevCTL = containerList.Copy
|
||||
End If
|
||||
|
||||
cL = New Connection.List
|
||||
connectionList = New Connection.List
|
||||
containerList = New Container.List
|
||||
|
||||
Dim conL As New Config.Connections.Load
|
||||
@@ -798,7 +798,7 @@ Namespace App
|
||||
End Try
|
||||
End If
|
||||
|
||||
conL.ConnectionList = cL
|
||||
conL.ConnectionList = connectionList
|
||||
conL.ContainerList = containerList
|
||||
|
||||
If prevCL IsNot Nothing And prevCTL IsNot Nothing Then
|
||||
@@ -865,7 +865,7 @@ Namespace App
|
||||
conL.ConnectionFileName = lD.FileNames(i)
|
||||
conL.RootTreeNode = nNode
|
||||
conL.Import = True
|
||||
conL.ConnectionList = App.Runtime.cL
|
||||
conL.ConnectionList = App.Runtime.connectionList
|
||||
conL.ContainerList = App.Runtime.containerList
|
||||
|
||||
conL.Load()
|
||||
@@ -1003,7 +1003,7 @@ Namespace App
|
||||
nConI.Parent = nNode.Parent.Tag
|
||||
End If
|
||||
|
||||
cL.Add(nConI)
|
||||
connectionList.Add(nConI)
|
||||
Next
|
||||
End If
|
||||
Catch ex As Exception
|
||||
@@ -1075,7 +1075,7 @@ Namespace App
|
||||
nConI.Parent = nNode.Parent.Tag
|
||||
End If
|
||||
|
||||
cL.Add(nConI)
|
||||
connectionList.Add(nConI)
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
@@ -1124,7 +1124,7 @@ Namespace App
|
||||
End If
|
||||
End If
|
||||
|
||||
conS.ConnectionList = cL
|
||||
conS.ConnectionList = connectionList
|
||||
conS.ContainerList = containerList
|
||||
conS.Export = False
|
||||
conS.SaveSecurity = New Security.Save(False)
|
||||
@@ -1194,7 +1194,7 @@ Namespace App
|
||||
End If
|
||||
End If
|
||||
|
||||
conS.ConnectionList = cL
|
||||
conS.ConnectionList = connectionList
|
||||
conS.ContainerList = containerList
|
||||
If RootNode IsNot Windows.treeForm.tvConnections.Nodes(0) Then
|
||||
conS.Export = True
|
||||
|
||||
11
mRemoteV1/My Project/Resources.Designer.vb
generated
11
mRemoteV1/My Project/Resources.Designer.vb
generated
@@ -1,7 +1,7 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:2.0.50727.4959
|
||||
' Runtime Version:2.0.50727.5444
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
@@ -2159,6 +2159,15 @@ Namespace My.Resources
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Looks up a localized string similar to CloneNode (Tree.Node) failed . {0}.
|
||||
'''</summary>
|
||||
Friend ReadOnly Property strErrorCloneNodeFailed() As String
|
||||
Get
|
||||
Return ResourceManager.GetString("strErrorCloneNodeFailed", resourceCulture)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Looks up a localized string similar to Error code {0}..
|
||||
'''</summary>
|
||||
|
||||
@@ -2340,4 +2340,7 @@ Error Description: {1}</value>
|
||||
<data name="strErrorAddFolderFailed" xml:space="preserve">
|
||||
<value>AddFolder (UI.Window.Tree) failed. {0}</value>
|
||||
</data>
|
||||
<data name="strErrorCloneNodeFailed" xml:space="preserve">
|
||||
<value>CloneNode (Tree.Node) failed . {0}</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -55,7 +55,7 @@ Namespace Tree
|
||||
End Function
|
||||
|
||||
Public Shared Function GetNodeFromPositionID(ByVal id As Integer) As TreeNode
|
||||
For Each conI As Connection.Info In cL
|
||||
For Each conI As Connection.Info In connectionList
|
||||
If conI.PositionID = id Then
|
||||
If conI.IsContainer Then
|
||||
Return TryCast(conI.Parent, Container.Info).TreeNode
|
||||
@@ -69,7 +69,7 @@ Namespace Tree
|
||||
End Function
|
||||
|
||||
Public Shared Function GetNodeFromConstantID(ByVal id As String) As TreeNode
|
||||
For Each conI As Connection.Info In cL
|
||||
For Each conI As Connection.Info In connectionList
|
||||
If conI.ConstantID = id Then
|
||||
If conI.IsContainer Then
|
||||
Return TryCast(conI.Parent, Container.Info).TreeNode
|
||||
@@ -287,7 +287,7 @@ Namespace Tree
|
||||
nConI.TreeNode = adNode
|
||||
adNode.Tag = nConI 'set the nodes tag to the conI
|
||||
'add connection to connections
|
||||
cL.Add(nConI)
|
||||
connectionList.Add(nConI)
|
||||
|
||||
rNode.Nodes.Add(adNode)
|
||||
Next
|
||||
@@ -296,53 +296,53 @@ Namespace Tree
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Shared Sub CloneNode(ByVal tNode As TreeNode, Optional ByVal ParentNode As TreeNode = Nothing)
|
||||
Public Shared Sub CloneNode(ByVal oldTreeNode As TreeNode, Optional ByVal parentNode As TreeNode = Nothing)
|
||||
Try
|
||||
If GetNodeType(tNode) = Type.Connection Then
|
||||
Dim conI As Connection.Info = tNode.Tag
|
||||
If GetNodeType(oldTreeNode) = Type.Connection Then
|
||||
Dim oldConnectionInfo As Connection.Info = oldTreeNode.Tag
|
||||
|
||||
Dim nConI As Connection.Info = conI.Copy
|
||||
Dim nInh As Connection.Info.Inheritance = conI.Inherit.Copy()
|
||||
nConI.Inherit = nInh
|
||||
Dim newConnectionInfo As Connection.Info = oldConnectionInfo.Copy
|
||||
Dim newInheritance As Connection.Info.Inheritance = oldConnectionInfo.Inherit.Copy()
|
||||
newConnectionInfo.Inherit = newInheritance
|
||||
|
||||
cL.Add(nConI)
|
||||
connectionList.Add(newConnectionInfo)
|
||||
|
||||
Dim nNode As New TreeNode(nConI.Name)
|
||||
nNode.Tag = nConI
|
||||
nNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed
|
||||
nNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed
|
||||
Dim newTreeNode As New TreeNode(newConnectionInfo.Name)
|
||||
newTreeNode.Tag = newConnectionInfo
|
||||
newTreeNode.ImageIndex = Images.Enums.TreeImage.ConnectionClosed
|
||||
newTreeNode.SelectedImageIndex = Images.Enums.TreeImage.ConnectionClosed
|
||||
|
||||
nConI.TreeNode = nNode
|
||||
newConnectionInfo.TreeNode = newTreeNode
|
||||
|
||||
If ParentNode Is Nothing Then
|
||||
tNode.Parent.Nodes.Add(nNode)
|
||||
Tree.Node.TreeView.SelectedNode = nNode
|
||||
If parentNode Is Nothing Then
|
||||
oldTreeNode.Parent.Nodes.Add(newTreeNode)
|
||||
Tree.Node.TreeView.SelectedNode = newTreeNode
|
||||
Else
|
||||
ParentNode.Nodes.Add(nNode)
|
||||
parentNode.Nodes.Add(newTreeNode)
|
||||
End If
|
||||
ElseIf GetNodeType(tNode) = Type.Container Then
|
||||
Dim nCont As Container.Info = TryCast(tNode.Tag, Container.Info).Copy
|
||||
Dim nConI As Connection.Info = TryCast(tNode.Tag, Container.Info).ConnectionInfo.Copy
|
||||
nCont.ConnectionInfo = nConI
|
||||
ElseIf GetNodeType(oldTreeNode) = Type.Container Then
|
||||
Dim newContainerInfo As Container.Info = TryCast(oldTreeNode.Tag, Container.Info).Copy
|
||||
Dim newConnectionInfo As Connection.Info = TryCast(oldTreeNode.Tag, Container.Info).ConnectionInfo.Copy
|
||||
newContainerInfo.ConnectionInfo = newConnectionInfo
|
||||
|
||||
Dim nNode As New TreeNode(nCont.Name)
|
||||
nNode.Tag = nCont
|
||||
nNode.ImageIndex = Images.Enums.TreeImage.Container
|
||||
nNode.SelectedImageIndex = Images.Enums.TreeImage.Container
|
||||
nCont.ConnectionInfo.Parent = nCont
|
||||
Dim newTreeNode As New TreeNode(newContainerInfo.Name)
|
||||
newTreeNode.Tag = newContainerInfo
|
||||
newTreeNode.ImageIndex = Images.Enums.TreeImage.Container
|
||||
newTreeNode.SelectedImageIndex = Images.Enums.TreeImage.Container
|
||||
newContainerInfo.ConnectionInfo.Parent = newContainerInfo
|
||||
|
||||
containerList.Add(nCont)
|
||||
containerList.Add(newContainerInfo)
|
||||
|
||||
tNode.Parent.Nodes.Add(nNode)
|
||||
oldTreeNode.Parent.Nodes.Add(newTreeNode)
|
||||
|
||||
Tree.Node.TreeView.SelectedNode = nNode
|
||||
Tree.Node.TreeView.SelectedNode = newTreeNode
|
||||
|
||||
For Each cNode As TreeNode In tNode.Nodes
|
||||
CloneNode(cNode, nNode)
|
||||
For Each childTreeNode As TreeNode In oldTreeNode.Nodes
|
||||
CloneNode(childTreeNode, newTreeNode)
|
||||
Next
|
||||
End If
|
||||
Catch ex As Exception
|
||||
mC.AddMessage(Messages.MessageClass.WarningMsg, "CloneNode failed (Tree.Node)" & vbNewLine & ex.Message)
|
||||
mC.AddMessage(Messages.MessageClass.WarningMsg, String.Format(My.Resources.strErrorCloneNodeFailed, ex.Message))
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -1053,7 +1053,7 @@ Namespace UI
|
||||
nConI.TreeNode = nNode
|
||||
|
||||
nNode.Tag = nConI
|
||||
cL.Add(nConI)
|
||||
connectionList.Add(nConI)
|
||||
|
||||
If mRemoteNG.Tree.Node.GetNodeType(Me.tvConnections.SelectedNode) = mRemoteNG.Tree.Node.Type.Connection Then
|
||||
Me.tvConnections.SelectedNode.Parent.Nodes.Add(nNode)
|
||||
|
||||
Reference in New Issue
Block a user