예제 #1
0
파일: AsmToArm.cs 프로젝트: rickrain/migAz
        private async void treeARM_AfterSelect(object sender, TreeViewEventArgs e)
        {
            LogProvider.WriteLog("treeARM_AfterSelect", "Start");
            _SourceArmNode = e.Node;

            _PropertyPanel.Clear();
            _PropertyPanel.ResourceText = String.Empty;
            if (e.Node.Tag != null)
            {
                if (e.Node.Tag.GetType() == typeof(TreeNode))
                {
                    TreeNode asmTreeNode = (TreeNode)e.Node.Tag;

                    if (asmTreeNode.Tag != null)
                    {
                        _PropertyPanel.ResourceText = e.Node.Text;

                        if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.VirtualNetwork) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.VirtualNetwork))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["VirtualNetwork"];

                            VirtualNetworkProperties properties = new VirtualNetworkProperties();
                            properties.PropertyChanged += Properties_PropertyChanged;
                            properties.Bind(e.Node);
                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.StorageAccount) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.StorageAccount))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["StorageAccount"];

                            StorageAccountProperties properties = new StorageAccountProperties();
                            properties.PropertyChanged += Properties_PropertyChanged;
                            properties.Bind(this._AzureContextTargetARM, e.Node);
                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.VirtualMachine) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.VirtualMachine))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["VirtualMachine"];

                            VirtualMachineProperties properties = new VirtualMachineProperties();
                            properties.LogProvider       = LogProvider;
                            properties.AllowManangedDisk = (await _AzureContextSourceASM.AzureRetriever.GetAzureARMManagedDisks() != null);
                            properties.PropertyChanged  += Properties_PropertyChanged;
                            await properties.Bind(e.Node, this);

                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.NetworkSecurityGroup) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.NetworkSecurityGroup))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["NetworkSecurityGroup"];

                            NetworkSecurityGroupProperties properties = new NetworkSecurityGroupProperties();
                            properties.PropertyChanged += Properties_PropertyChanged;
                            properties.Bind(e.Node, this);
                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                    }
                }
                if (e.Node.Tag.GetType() == typeof(Azure.Asm.Subnet) || e.Node.Tag.GetType() == typeof(Azure.Arm.Subnet))
                {
                    this._PropertyPanel.ResourceImage = imageList1.Images["VirtualNetwork"];

                    SubnetProperties properties = new SubnetProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind(e.Node);
                    _PropertyPanel.PropertyDetailControl = properties;
                }
                else if (e.Node.Tag.GetType() == typeof(Azure.Asm.Disk) || e.Node.Tag.GetType() == typeof(Azure.Arm.Disk))
                {
                    Azure.Asm.Disk asmDisk = (Azure.Asm.Disk)e.Node.Tag;

                    this._PropertyPanel.ResourceImage = imageList1.Images["Disk"];

                    DiskProperties properties = new DiskProperties();
                    properties.LogProvider       = this.LogProvider;
                    properties.AllowManangedDisk = (await _AzureContextSourceASM.AzureRetriever.GetAzureARMManagedDisks() != null);
                    properties.PropertyChanged  += Properties_PropertyChanged;
                    properties.Bind(this, e.Node);
                    _PropertyPanel.PropertyDetailControl = properties;
                }
                else if (e.Node.Tag.GetType() == typeof(Azure.Asm.AvailabilitySet))
                {
                    this._PropertyPanel.ResourceImage = imageList1.Images["AvailabilitySet"];

                    AvailabilitySetProperties properties = new AvailabilitySetProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind(e.Node);
                    _PropertyPanel.PropertyDetailControl = properties;
                }
                else if (e.Node.Tag.GetType() == typeof(ResourceGroup))
                {
                    this._PropertyPanel.ResourceImage = imageList1.Images["ResourceGroup"];

                    ResourceGroupProperties properties = new ResourceGroupProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    await properties.Bind(this, e.Node);

                    _PropertyPanel.PropertyDetailControl = properties;
                }
            }

            _SourceArmNode = null;
            LogProvider.WriteLog("treeARM_AfterSelect", "End");
            StatusProvider.UpdateStatus("Ready");
        }
예제 #2
0
        private async void treeARM_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ClearAzureResourceManagerProperties();

            lblAzureObjectName.Text = String.Empty;

            if (e.Node.Tag != null)
            {
                if (e.Node.Tag.GetType() == typeof(TreeNode))
                {
                    TreeNode asmTreeNode = (TreeNode)e.Node.Tag;

                    if (asmTreeNode.Tag != null)
                    {
                        lblAzureObjectName.Text = e.Node.Text;

                        if (asmTreeNode.Tag.GetType() == typeof(AsmVirtualNetwork))
                        {
                            pictureBox1.Image = imageList1.Images["VirtualNetwork"];

                            VirtualNetworkProperties properties = new VirtualNetworkProperties();
                            properties.Bind(e.Node);
                            panel1.Controls.Add(properties);
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(AsmStorageAccount))
                        {
                            pictureBox1.Image = imageList1.Images["StorageAccount"];

                            AsmStorageAccount storageAccount = (AsmStorageAccount)asmTreeNode.Tag;
                            lblAzureObjectName.Text = storageAccount.Name;

                            StorageAccountProperties properties = new StorageAccountProperties();
                            properties.Bind(this._AzureContextTargetARM, e.Node);
                            panel1.Controls.Add(properties);
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(AsmVirtualMachine))
                        {
                            pictureBox1.Image = imageList1.Images["VirtualMachine"];

                            VirtualMachineProperties properties = new VirtualMachineProperties();
                            properties.Bind(e.Node, this);
                            panel1.Controls.Add(properties);
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(AsmNetworkSecurityGroup))
                        {
                            pictureBox1.Image = imageList1.Images["NetworkSecurityGroup"];

                            NetworkSecurityGroupProperties properties = new NetworkSecurityGroupProperties();
                            properties.Bind(e.Node, this);
                            panel1.Controls.Add(properties);
                        }
                    }
                }
                if (e.Node.Tag.GetType() == typeof(AsmSubnet))
                {
                    pictureBox1.Image = imageList1.Images["VirtualNetwork"];

                    AsmSubnet asmSubnet = (AsmSubnet)e.Node.Tag;

                    SubnetProperties properties = new SubnetProperties();
                    properties.Bind(e.Node);
                    panel1.Controls.Add(properties);
                }
                else if (e.Node.Tag.GetType() == typeof(AsmDisk))
                {
                    AsmDisk asmDisk = (AsmDisk)e.Node.Tag;

                    pictureBox1.Image = imageList1.Images["Disk"];

                    DiskProperties properties = new DiskProperties();
                    properties.Bind(this, e.Node);
                    panel1.Controls.Add(properties);
                }
                else if (e.Node.Tag.GetType() == typeof(ArmAvailabilitySet))
                {
                    pictureBox1.Image = imageList1.Images["AvailabilitySet"];

                    AvailabilitySetProperties properties = new AvailabilitySetProperties();
                    properties.Bind(e.Node);
                    panel1.Controls.Add(properties);
                }
                else if (e.Node.Tag.GetType() == typeof(ArmResourceGroup))
                {
                    pictureBox1.Image = imageList1.Images["ResourceGroup"];

                    ResourceGroupProperties properties = new ResourceGroupProperties();
                    await properties.Bind(this, e.Node);

                    panel1.Controls.Add(properties);
                }
            }

            _statusProvider.UpdateStatus("Ready");
        }