private void LoadCdBox() { CdDropDownBox.vm = m_template; CdDropDownBox.refreshAll(); RegisterBespokeEventsAgainstCdDropDownBox(); VBD cddrive = m_template.FindVMCDROM(); VDI cd = cddrive != null && !cddrive.empty ? Connection.Resolve <VDI>(cddrive.VDI) : (CdDropDownBox.Empty ? null : GetAffinityDvdDrive()); if (cd == null) { return; // select default whatever that is } SR sr = Connection.Resolve <SR>(cd.SR); if (sr == null) { return; // select default whatever that is } CdDropDownBox.SelectedCD = cd; CdDropDownBox.SelectCD(); }
private void AddToolTipToCdDropDownBox_DrawItemEvent(object sender, DrawItemEventArgs e) { string selectedText = ""; if (e.Index != -1) { selectedText = CdDropDownBox.GetItemText(CdDropDownBox.Items[e.Index]); } Font font = (e.Index != -1 && CdDropDownBox.Items[e.Index] is ToStringWrapper <SR>) ? Program.DefaultFontBold : Program.DefaultFont; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected && CdDropDownBox.DroppedDown && TextRenderer.MeasureText(selectedText, font).Width > CdDropDownBox.DropDownWidth) { comboBoxToolTip.Show(selectedText, CdDropDownBox, e.Bounds.Right, e.Bounds.Bottom); } else { HideToolTipOnCdDropDownBox_DropDownClosedEvent(sender, e); } }
public override void PageLoaded(PageLoadedDirection direction) { base.PageLoaded(direction); VM oldTemplate = m_template; m_template = SelectedTemplate; // We only want to do all these updates if the template has changed (or has gone from null -> selected) if (oldTemplate == m_template) { return; } /* This method is supposed to do the following: * * PV -> Install from DVD drive (no empty) * Url * * HVM -> Install from DVD drive (no empty) * Boot from network * * Custom -> DVD drive (inc empty) * * Disable Installation method section if the custom template has no DVD drive (except debian etch template) */ PvBootBox.Visible = ShowBootParameters; PvBootTextBox.Text = m_template.PV_args; if (!ShowInstallationMedia) { CdRadioButton.Checked = UrlRadioButton.Checked = false; CdDropDownBox.Items.Clear(); UrlTextBox.Text = string.Empty; panelInstallationMethod.Enabled = false; return; } panelInstallationMethod.Enabled = true; defaultTemplate = m_template.DefaultTemplate(); userTemplate = !defaultTemplate; hvm = m_template.IsHVM(); eli = !hvm && m_template.PV_bootloader == "eliloader"; var tmplMethods = m_template.InstallMethods(); installMethods = !string.IsNullOrEmpty(tmplMethods); installCd = installMethods && tmplMethods.Contains("cdrom") && (hvm || eli); installUrl = installMethods && (tmplMethods.Contains("http") || tmplMethods.Contains("ftp") || tmplMethods.Contains("nfs")) && eli; cds = Helpers.CDsExist(Connection); installed = userTemplate || !installMethods; CdRadioButton.Text = installed ? Messages.NEWVMWIZARD_INSTALLMEDIA_DVD : Messages.NEWVMWIZARD_INSTALLMEDIA_INSTALLDVD; CdRadioButton.Enabled = (installed || installCd) && cds; CdDropDownBox.Empty = installed; UrlRadioButton.Text = hvm ? Messages.NEWVMWIZARD_INSTALLMEDIA_INSTALLPXE : Messages.NEWVMWIZARD_INSTALLMEDIA_INSTALLURL; UrlRadioButton.Enabled = (!installed && ((eli && installUrl) || hvm)); UrlTextBox.Visible = !hvm; UrlTextBox.Text = !installed?m_template.InstallRepository() ?? "" : ""; if (installed || (installCd && cds)) // if installed we will always have the empty cd { CdRadioButton.Checked = true; CdDropDownBox.Select(); } else if (eli && installUrl) { UrlRadioButton.Checked = true; UrlTextBox.Select(); } else { // oh dear, select anything that is enabled if (CdRadioButton.Enabled) { CdRadioButton.Checked = true; } else if (UrlRadioButton.Enabled) { UrlRadioButton.Checked = true; } else { Trace.Assert(false, string.Format("No install options were enabled, something is wrong with the template '{0}'", m_template.Name())); } } if (IsBootFromNetworkCustomTemplate(userTemplate)) { UrlRadioButton.Enabled = true; UrlRadioButton.Checked = true; CdRadioButton.Enabled = false; } LoadCdBox(); UpdateEnablement(); }