private void UpdateDiskSize() { // Don't use DiskSizeNumericUpDown.Value here, as it will fire the NumericUpDown built-in validation. Use Text property instead. (CA-46028) decimal newValue; if (decimal.TryParse(DiskSizeNumericUpDown.Text.Trim(), out newValue)) { try { SrListBox.DiskSize = (long)(Math.Round(newValue * GetUnits())); if (IsSelectedSRThinProvisioned && userChangedInitialAllocationValue) { SrListBox.OverridenInitialAllocationRate = initialAllocationNumericUpDown.Value / 100; } } catch (OverflowException) { //CA-71312 SrListBox.DiskSize = newValue < 0 ? long.MinValue : long.MaxValue; } SrListBox.refresh(); } RefreshMinSize(); updateErrorsAndButtons(); }
private void UpdateDiskSize() { // Don't use DiskSizeNumericUpDown.Value here, as it will fire the NumericUpDown built-in validation. Use Text property instead. (CA-46028) decimal newValue; if (decimal.TryParse(DiskSizeNumericUpDown.Text.Trim(), out newValue)) { try { SrListBox.DiskSize = (long)(Math.Round(newValue * GetUnits())); if (IsSelectedSRThinProvisioned && userChangedInitialAllocationValue) { SrListBox.OverridenInitialAllocationRate = (long)(init_alloc_units.SelectedItem.ToString() == Messages.VAL_MEGB ? initialAllocationNumericUpDown.Value * Util.BINARY_MEGA : initialAllocationNumericUpDown.Value * Util.BINARY_GIGA); } } catch (OverflowException) { //CA-71312 SrListBox.DiskSize = newValue < 0 ? long.MinValue : long.MaxValue; } SrListBox.UpdateDiskSize(); if (IsSelectedSRThinProvisioned) { DefaultToSRsConfig(userChangedInitialAllocationValue); } } RefreshMinSize(); updateErrorsAndButtons(); }
private void LoadValues() { if (DiskTemplate == null) { return; } NameTextBox.Text = DiskTemplate.Name; DescriptionTextBox.Text = DiskTemplate.Description; SrListBox.selectSRorDefaultorAny(connection.Resolve(DiskTemplate.SR)); // select the appropriate unit, based on size (CA-45905) currentSelectedUnits = DiskTemplate.virtual_size >= Util.BINARY_GIGA ? DiskSizeUnits.GB : DiskSizeUnits.MB; SelectedUnits = currentSelectedUnits; SetupDiskSizeNumericUpDown(); decimal newValue = (decimal)Math.Round((double)DiskTemplate.virtual_size / GetUnits(), DiskSizeNumericUpDown.DecimalPlaces); DiskSizeNumericUpDown.Value = newValue >= DiskSizeNumericUpDown.Minimum && newValue <= DiskSizeNumericUpDown.Maximum ? newValue : DiskSizeNumericUpDown.Maximum; if (MinSize > 0) { min = (decimal)((double)MinSize / GetUnits()); } DiskSizeNumericUpDown.Enabled = CanResize; Text = Messages.EDIT_DISK; OkButton.Text = Messages.OK; }
public NewDiskDialog(IXenConnection connection, VM vm, Host affinity, SrPicker.SRPickerType pickerUsage = SrPicker.SRPickerType.VM, VDI diskTemplate = null, bool canResize = true, long minSize = 0, IEnumerable <VDI> vdiNamesInUse = null) : base(connection ?? throw new ArgumentNullException(nameof(connection))) { InitializeComponent(); TheVM = vm; _VDINamesInUse = vdiNamesInUse ?? new List <VDI>(); diskSpinner1.CanResize = canResize; if (diskTemplate == null) { NameTextBox.Text = GetDefaultVDIName(); diskSpinner1.Populate(minSize: minSize); UpdateErrorsAndButtons(); SrListBox.PopulateAsync(pickerUsage, connection, affinity, null, null); } else { DiskTemplate = diskTemplate; NameTextBox.Text = DiskTemplate.Name(); DescriptionTextBox.Text = DiskTemplate.Description(); Text = Messages.EDIT_DISK; OkButton.Text = Messages.OK; diskSpinner1.Populate(DiskTemplate.virtual_size, minSize); UpdateErrorsAndButtons(); SrListBox.PopulateAsync(pickerUsage, connection, affinity, connection.Resolve(DiskTemplate.SR), null); } }
public NewDiskDialog(IXenConnection connection, SR sr) : this(connection, new List <VDI>()) { TheSR = sr; PickerUsage = SrPicker.SRPickerType.InstallFromTemplate; SrListBox.SetAffinity(null); SrListBox.selectSRorNone(TheSR); }
public NewDiskDialog(IXenConnection connection, SR sr) : base(connection ?? throw new ArgumentNullException(nameof(connection))) { InitializeComponent(); NameTextBox.Text = GetDefaultVDIName(); diskSpinner1.Populate(); UpdateErrorsAndButtons(); SrListBox.PopulateAsync(SrPicker.SRPickerType.InstallFromTemplate, connection, null, sr, null); }
public NewDiskDialog(IXenConnection connection, SR sr) : base(connection ?? throw new ArgumentNullException(nameof(connection))) { InitializeComponent(); NameTextBox.Text = GetDefaultVDIName(); SrListBox.Connection = connection; SrListBox.Usage = SrPicker.SRPickerType.InstallFromTemplate; SrListBox.SetAffinity(null); SrListBox.selectSRorNone(sr); diskSpinner1.Populate(); }
public NewDiskDialog(IXenConnection connection, VM vm, SrPicker.SRPickerType PickerUsage, VDI diskTemplate, Host affinity, bool canResize, long minSize, IEnumerable <VDI> vdiNamesInUse) : this(connection, vdiNamesInUse) { TheVM = vm; DiskTemplate = diskTemplate; CanResize = canResize; MinSize = minSize; this.PickerUsage = PickerUsage; SrListBox.SetAffinity(affinity); Pool pool_sr = Helpers.GetPoolOfOne(connection); if (pool_sr != null) { SrListBox.DefaultSR = connection.Resolve(pool_sr.default_SR); //if default sr resolves to null the first sr in the list will be selected } SrListBox.selectDefaultSROrAny(); LoadValues(); }
private void UpdateDiskSize() { // Don't use DiskSizeNumericUpDown.Value here, as it will fire the NumericUpDown built-in validation. Use Text property instead. (CA-46028) decimal newValue; if (decimal.TryParse(DiskSizeNumericUpDown.Text.Trim(), out newValue)) { try { SrListBox.DiskSize = (long)(Math.Round(newValue * GetUnits())); } catch (OverflowException) { //CA-71312 SrListBox.DiskSize = newValue < 0 ? long.MinValue : long.MaxValue; } SrListBox.UpdateDiskSize(); } RefreshMinSize(); updateErrorsAndButtons(); }
public NewDiskDialog(IXenConnection connection, VM vm, Host affinity, SrPicker.SRPickerType pickerUsage = SrPicker.SRPickerType.VM, VDI diskTemplate = null, bool canResize = true, long minSize = 0, IEnumerable <VDI> vdiNamesInUse = null) : base(connection ?? throw new ArgumentNullException(nameof(connection))) { InitializeComponent(); TheVM = vm; _VDINamesInUse = vdiNamesInUse ?? new List <VDI>(); SrListBox.Connection = connection; SrListBox.Usage = pickerUsage; SrListBox.SetAffinity(affinity); Pool pool_sr = Helpers.GetPoolOfOne(connection); if (pool_sr != null) { SrListBox.DefaultSR = connection.Resolve(pool_sr.default_SR); //if default sr resolves to null the first sr in the list will be selected } if (diskTemplate == null) { NameTextBox.Text = GetDefaultVDIName(); SrListBox.selectDefaultSROrAny(); diskSpinner1.Populate(minSize: minSize); } else { DiskTemplate = diskTemplate; NameTextBox.Text = DiskTemplate.Name(); DescriptionTextBox.Text = DiskTemplate.Description(); SrListBox.selectSRorDefaultorAny(connection.Resolve(DiskTemplate.SR)); Text = Messages.EDIT_DISK; OkButton.Text = Messages.OK; diskSpinner1.Populate(DiskTemplate.virtual_size, minSize); } diskSpinner1.CanResize = canResize; }
private void UpdateErrorsAndButtons() { // Ordering is important here, we want to show the most relevant message // The error should be shown only for size errors if (!diskSpinner1.IsSizeValid) { OkButton.Enabled = false; return; } SrListBox.DiskSize = diskSpinner1.SelectedSize; SrListBox.UpdateDiskSize(); if (!SrListBox.ValidSelectionExists)//all SRs disabled { OkButton.Enabled = false; diskSpinner1.SetError(Messages.NO_VALID_DISK_LOCATION); return; } if (SrListBox.SR == null) //enabled SR exists but the user selects a disabled one { OkButton.Enabled = false; diskSpinner1.SetError(null); return; } if (string.IsNullOrEmpty(NameTextBox.Text.Trim())) { OkButton.Enabled = false; diskSpinner1.SetError(null); return; } OkButton.Enabled = true; diskSpinner1.SetError(null); }