public override void PopulatePage() { if (DisableStep) //defensive check { return; } if (!m_checkBoxAccept.Enabled) { m_checkBoxAccept.Enabled = true; } m_tabControlEULA.TabPages.Clear(); m_checkBoxAccept.Checked = false; EulaSection_Type[] eulas = OVF.FindSections <EulaSection_Type>(SelectedOvfEnvelope); if (!PerformCheck((out string error) => CheckNumberOfEulas(eulas.Length, out error))) { m_checkBoxAccept.Enabled = false; return; } foreach (EulaSection_Type eula in eulas) { RichTextBox rtb = new RichTextBox { ReadOnly = true, Dock = DockStyle.Fill, BackColor = SystemColors.Window, BorderStyle = BorderStyle.None }; string licText = OVF.FindStringsMessage(SelectedOvfEnvelope, eula.License); if (licText.StartsWith(@"{\rtf")) { rtb.Rtf = licText; } else { rtb.Text = licText; } //RichTextBox does not support BorderStyle.FixedSingle, therefore as a workaround use //BorderStyle.None and put the RichTextBox in a panel with BorderStyle.FixedSingle Panel panel = new Panel { Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle }; panel.Controls.Add(rtb); TabPage tp = new TabPage { Text = Messages.EULA }; tp.Controls.Add(panel); m_tabControlEULA.TabPages.Add(tp); } }
// Find a name to use of a VM within an envelope that could have come from any hypervisor. // TODO: Consider refactoring this method because it is very similar to OVF.FindSystemName(). private string FindVMName(EnvelopeType ovfEnv, string systemid) { VirtualSystem_Type vSystem = OVF.FindVirtualSystemById(ovfEnv, systemid); // Use the given name if present and valid. // The given name is Envelope.VirtualSystem.Name specified in the OVF Specification 1.1 clause 7.2. // XenServer sets the name property. // vSphere 4.1 and Virtual Box 4.0.6 do not. if ((Tools.ValidateProperty("Name", vSystem)) && !String.IsNullOrEmpty(vSystem.Name[0].Value)) { return(vSystem.Name[0].Value); } // The VM wasn't given a name. // Build a list of choices from various properties. var choices = new List <string>(); // VirtualSystem.id is next preference because vSphere and Virtual Box typically set this property to the VM name. if (!string.IsNullOrEmpty(vSystem.id)) { choices.Add(vSystem.id); } // VirtualHardwareSection_Type.VirtualSystemIdentifier is next preference because Virtual Box will also set this property to the VM name. VirtualHardwareSection_Type[] vhsList = OVF.FindVirtualHardwareSection(ovfEnv, systemid); foreach (VirtualHardwareSection_Type vhs in vhsList) { if (vhs == null || vhs.System == null) { continue; } if (Tools.ValidateProperty("VirtualSystemIdentifier", vhs.System)) { choices.Add(vhs.System.VirtualSystemIdentifier.Value); } } // Operating system description is next preference. OperatingSystemSection_Type[] ossList = OVF.FindSections <OperatingSystemSection_Type>(vSystem.Items); foreach (OperatingSystemSection_Type oss in ossList) { if (Tools.ValidateProperty("Description", oss)) { choices.Add(oss.Description.Value); } } // Envelope name is the last preference for XenServer that can could be a path in some cases. // vSphere and Virtual Box usually don't set this property. choices.Add(Path.GetFileNameWithoutExtension(ovfEnv.Name)); // Last preference is file name. choices.Add(Path.GetFileNameWithoutExtension(m_pageImportSource.SelectedOvfPackage.PackageSourceFile)); // First choice is one that is not a GUID. foreach (var choice in choices) { if (!String.IsNullOrEmpty(choice) && !IsGUID(choice)) { return(choice); } } // Second choice is the first GUID. foreach (var choice in choices) { if (!String.IsNullOrEmpty(choice)) { return(choice); } } // Last resort is a new GUID. return(Guid.NewGuid().ToString()); }