public static Connection.Info.Inheritance DefaultInheritanceFromSettings() { DefaultInheritance = new Connection.Info.Inheritance(null); DefaultInheritance.IsDefault = true; return DefaultInheritance; }
public static void CloneNode(TreeNode oldTreeNode, TreeNode parentNode = null) { try { if (GetNodeType(oldTreeNode) == Type.Connection) { Connection.Info oldConnectionInfo = (Info)oldTreeNode.Tag; Connection.Info newConnectionInfo = oldConnectionInfo.Copy(); Connection.Info.Inheritance newInheritance = oldConnectionInfo.Inherit.Copy(); newInheritance.Parent = newConnectionInfo; newConnectionInfo.Inherit = newInheritance; Runtime.ConnectionList.Add(newConnectionInfo); TreeNode newTreeNode = new TreeNode((string)newConnectionInfo.Name); newTreeNode.Tag = newConnectionInfo; newTreeNode.ImageIndex = System.Convert.ToInt32(Images.Enums.TreeImage.ConnectionClosed); newTreeNode.SelectedImageIndex = System.Convert.ToInt32(Images.Enums.TreeImage.ConnectionClosed); newConnectionInfo.TreeNode = newTreeNode; if (parentNode == null) { oldTreeNode.Parent.Nodes.Add(newTreeNode); Tree.Node.TreeView.SelectedNode = newTreeNode; } else { var parentContainerInfo = parentNode.Tag as Container.Info; if (parentContainerInfo != null) { newConnectionInfo.Parent = parentContainerInfo; } parentNode.Nodes.Add(newTreeNode); } } else if (GetNodeType(oldTreeNode) == Type.Container) { Container.Info newContainerInfo = (oldTreeNode.Tag as Container.Info).Copy(); Connection.Info newConnectionInfo = (oldTreeNode.Tag as Container.Info).ConnectionInfo.Copy(); newContainerInfo.ConnectionInfo = newConnectionInfo; TreeNode newTreeNode = new TreeNode(newContainerInfo.Name); newTreeNode.Tag = newContainerInfo; newTreeNode.ImageIndex = System.Convert.ToInt32(Images.Enums.TreeImage.Container); newTreeNode.SelectedImageIndex = System.Convert.ToInt32(Images.Enums.TreeImage.Container); newContainerInfo.ConnectionInfo.Parent = newContainerInfo; Runtime.ContainerList.Add(newContainerInfo); oldTreeNode.Parent.Nodes.Add(newTreeNode); Tree.Node.TreeView.SelectedNode = newTreeNode; foreach (TreeNode childTreeNode in oldTreeNode.Nodes) { CloneNode(childTreeNode, newTreeNode); } } } catch (Exception ex) { Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, string.Format(Language.strErrorCloneNodeFailed, ex.Message)); } }