Example #1
0
        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;
            SetNumUpDownIncrementAndDecimals(DiskSizeNumericUpDown, SelectedUnits.ToString());
            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;
        }
Example #2
0
 private void comboBoxUnits_SelectedIndexChanged(object sender, EventArgs e)
 {
     //Check if the new unit is different than the previous one otherwise discard the change
     if (currentSelectedUnits != SelectedUnits)
     {
         currentSelectedUnits = SelectedUnits;
         SetupDiskSizeNumericUpDown();
         //Convert the current value to the new units
         decimal newValue = (decimal)Math.Round(SelectedUnits == DiskSizeUnits.GB ? ((double)DiskSizeNumericUpDown.Value / 1024) : ((double)DiskSizeNumericUpDown.Value * 1024), DiskSizeNumericUpDown.DecimalPlaces);
         DiskSizeNumericUpDown.Value = newValue >= DiskSizeNumericUpDown.Minimum && newValue <= DiskSizeNumericUpDown.Maximum ?
                                       newValue : DiskSizeNumericUpDown.Maximum;
         UpdateDiskSize();
     }
 }
Example #3
0
        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;
        }
Example #4
0
 private void comboBoxUnits_SelectedIndexChanged(object sender, EventArgs e)
 {
     //Check if the new unit is different than the previous one otherwise discard the change
     if (currentSelectedUnits != SelectedUnits)
     {
         currentSelectedUnits = SelectedUnits;
         SetupDiskSizeNumericUpDown();
         //Convert the current value to the new units
         decimal newValue = (decimal)Math.Round(SelectedUnits == DiskSizeUnits.GB ? ((double)DiskSizeNumericUpDown.Value / 1024) : ((double)DiskSizeNumericUpDown.Value * 1024), DiskSizeNumericUpDown.DecimalPlaces);
         DiskSizeNumericUpDown.Value = newValue >= DiskSizeNumericUpDown.Minimum && newValue <= DiskSizeNumericUpDown.Maximum ?
             newValue : DiskSizeNumericUpDown.Maximum;
         UpdateDiskSize();
     }
 }