private void txtTargetName_TextChanged(object sender, EventArgs e) { TextBox txtSender = (TextBox)sender; TreeNode asmStorageAccountNode = (TreeNode)_ArmStorageAccountNode.Tag; AsmStorageAccount asmStorageAccount = (AsmStorageAccount)asmStorageAccountNode.Tag; asmStorageAccount.TargetName = txtSender.Text; _ArmStorageAccountNode.Text = asmStorageAccount.GetFinalTargetName(); }
private async Task AddASMNodeToARMTree(TreeNode asmTreeNode) { TreeNode targetResourceGroupNode = SeekARMChildTreeNode(treeARM.Nodes, _TargetResourceGroup.Name, _TargetResourceGroup.Name, _TargetResourceGroup, true); Type tagType = asmTreeNode.Tag.GetType(); if (tagType == typeof(AsmVirtualNetwork)) { AsmVirtualNetwork asmVirtualNetwork = (AsmVirtualNetwork)asmTreeNode.Tag; TreeNode virtualNetworksNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Virtual Networks", "Virtual Networks", "Virtual Networks", true); TreeNode virtualNetworkNode = SeekARMChildTreeNode(virtualNetworksNode.Nodes, asmTreeNode.Name, asmVirtualNetwork.GetFinalTargetName(), asmTreeNode, true); foreach (AsmSubnet asmSubnet in asmVirtualNetwork.Subnets) { // Property dialog not made available for Gateway Subnet if (!asmSubnet.IsGatewaySubnet) { TreeNode subnetNode = SeekARMChildTreeNode(virtualNetworkNode.Nodes, asmSubnet.Name, asmSubnet.Name, asmSubnet, true); } } virtualNetworkNode.ExpandAll(); treeARM.SelectedNode = virtualNetworkNode; treeARM.Focus(); } else if (tagType == typeof(AsmStorageAccount)) { AsmStorageAccount asmStorageAccount = (AsmStorageAccount)asmTreeNode.Tag; TreeNode storageAccountsNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Storage Accounts", "Storage Accounts", "Storage Accounts", true); TreeNode storageAccountNode = SeekARMChildTreeNode(storageAccountsNode.Nodes, asmTreeNode.Name, asmStorageAccount.GetFinalTargetName(), asmTreeNode, true); treeARM.SelectedNode = storageAccountNode; treeARM.Focus(); } else if (tagType == typeof(AsmVirtualMachine)) { AsmVirtualMachine asmVirtualMachine = (AsmVirtualMachine)asmTreeNode.Tag; TreeNode availabilitySets = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Availability Sets", "Availability Sets", "Availability Sets", true); TreeNode availabilitySet = SeekARMChildTreeNode(availabilitySets.Nodes, asmVirtualMachine.TargetAvailabilitySet.TargetName, asmVirtualMachine.TargetAvailabilitySet.GetFinalTargetName(), asmVirtualMachine.TargetAvailabilitySet, true); TreeNode virtualMachineNode = SeekARMChildTreeNode(availabilitySet.Nodes, asmVirtualMachine.RoleName, asmVirtualMachine.RoleName, asmTreeNode, true); foreach (AsmDisk asmDataDisk in asmVirtualMachine.DataDisks) { TreeNode dataDiskNode = SeekARMChildTreeNode(virtualMachineNode.Nodes, asmDataDisk.DiskName, asmDataDisk.DiskName, asmDataDisk, true); } foreach (AsmNetworkInterface asmNetworkInterface in asmVirtualMachine.NetworkInterfaces) { TreeNode dataDiskNode = SeekARMChildTreeNode(virtualMachineNode.Nodes, asmNetworkInterface.Name, asmNetworkInterface.Name, asmNetworkInterface, true); } treeARM.SelectedNode = virtualMachineNode; treeARM.Focus(); } else if (tagType == typeof(AsmNetworkSecurityGroup)) { AsmNetworkSecurityGroup asmNetworkSecurityGroup = (AsmNetworkSecurityGroup)asmTreeNode.Tag; TreeNode networkSecurityGroups = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Network Security Groups", "Network Security Groups", "Network Security Groups", true); TreeNode networkSecurityGroupNode = SeekARMChildTreeNode(networkSecurityGroups.Nodes, asmNetworkSecurityGroup.Name, asmNetworkSecurityGroup.Name, asmTreeNode, true); treeARM.SelectedNode = networkSecurityGroupNode; treeARM.Focus(); } else { throw new Exception("Unhandled Node Type: " + tagType); } }