private void PopulateTreeView() { ApplianceTreeView.BeginUpdate(); ApplianceTreeView.Cursor = Cursors.WaitCursor; try { ApplianceTreeView.ClearAllNodes(); foreach (var vdiRef in allPoolMetadata.Keys) { PoolMetadata poolMetadata = allPoolMetadata[vdiRef]; //if (!String.IsNullOrEmpty(poolMetadata.Pool.Name)) { string description = poolMetadata.Pool.uuid == Pool.uuid ? Messages.DR_WIZARD_APPLIANCESPAGE_CURRENT_POOL : string.Empty; PoolNode poolNode = new PoolNode(vdiRef, poolMetadata.Pool.Name, description); ApplianceTreeView.AddNode(poolNode); poolNode.Enabled = (poolMetadata.Pool.uuid != Pool.uuid); PopulateTreeView(poolMetadata, poolNode); } } } finally { ApplianceTreeView.EndUpdate(); ApplianceTreeView.Cursor = Cursors.Default; } }
private void PopulateTreeView(PoolMetadata poolMetadata, CustomTreeNode parentNode) { ApplianceTreeView.BeginUpdate(); ApplianceTreeView.Cursor = Cursors.WaitCursor; try { if (poolMetadata.VmAppliances != null && poolMetadata.VmAppliances.Count > 0) { foreach (var applianceItem in poolMetadata.VmAppliances) { ApplianceNode applianceNode = new ApplianceNode(applianceItem.Key, applianceItem.Value); if (parentNode != null) { ApplianceTreeView.AddChildNode(parentNode, applianceNode); applianceNode.Enabled = parentNode.Enabled; } else { ApplianceTreeView.AddNode(applianceNode); } foreach (XenRef <VM> vmRef in applianceItem.Value.VMs) { if (poolMetadata.Vms.ContainsKey(vmRef)) { VmNode vmNode = new VmNode(vmRef, poolMetadata.Vms[vmRef], false); ApplianceTreeView.AddChildNode(applianceNode, vmNode); vmNode.Enabled = applianceNode.Enabled; } } applianceNode.Expanded = false; } } if (poolMetadata.Vms != null || poolMetadata.Vms.Count > 0) { foreach (var vmItem in poolMetadata.Vms) { if (vmItem.Value.appliance.opaque_ref != null && vmItem.Value.appliance.opaque_ref.StartsWith("OpaqueRef:") && vmItem.Value.appliance.opaque_ref != "OpaqueRef:NULL") { //VM included in an appliance continue; } VmNode vmNode = new VmNode(vmItem.Key, vmItem.Value, true); if (parentNode != null) { ApplianceTreeView.AddChildNode(parentNode, vmNode); vmNode.Enabled = parentNode.Enabled; } else { ApplianceTreeView.AddNode(vmNode); } } } } finally { ApplianceTreeView.EndUpdate(); ApplianceTreeView.Cursor = Cursors.Default; } }