CA-147944: Use GB for VM Memory if large values

- Memory Tab uses GB units for values greater or equal to 1 GB, otherwise show in MB;
- Search Tab displays values in GB or MB in the same as the Memory Tab (e.g. 512 MB of 1 GB, 256 MB of 512 MB, 2.5 GB of 16 GB).
- The shiny bar present in the Memory Tab and in Memory Settings dialog shows the scaling in the following way: If smaller than 1 GB, then show as before, else show only labels with values multiples of half a GB.
- The units used in Memory Setting Dialog are set depending on the static_max. If it is greater or equal to 1 GB, then the units are GB, else MB. The user does not have the possibility of changing them.
This commit is contained in:
Carmen Agimof 2015-08-20 12:41:39 +01:00
parent 41fa9a5eab
commit 4da67c0590
45 changed files with 934 additions and 606 deletions

View File

@ -189,9 +189,9 @@ namespace XenAdmin.Alerts
case AlarmType.Memory:
return string.Format(Messages.ALERT_ALARM_MEMORY_DESCRIPTION,
Helpers.GetNameAndObject(XenObject),
Util.MemorySizeString(CurrentValue * Util.BINARY_KILO),//xapi unit is in kib
Util.MemorySizeStringMB(CurrentValue * Util.BINARY_KILO),//xapi unit is in kib
Util.TimeString(TriggerPeriod),
Util.MemorySizeString(TriggerLevel * Util.BINARY_KILO));
Util.MemorySizeStringMB(TriggerLevel * Util.BINARY_KILO));
case AlarmType.Dom0MemoryDemand:
return string.Format(Messages.ALERT_ALARM_DOM0_MEMORY_DEMAND_DESCRIPTION,
Helpers.GetNameAndObject(XenObject),

View File

@ -134,7 +134,6 @@ namespace XenAdmin.Controls.Ballooning
this.Controls.Add(this.labelTotal);
this.Controls.Add(this.hostShinyBar);
this.DoubleBuffered = true;
this.MinimumSize = new System.Drawing.Size(700, 90);
this.Name = "HostMemoryControls";
this.ResumeLayout(false);

View File

@ -90,10 +90,10 @@ namespace XenAdmin.Controls.Ballooning
hostShinyBar.Initialize(host, xen_memory);
// Set the text values
valueTotal.Text = Util.ToMB(total).ToString();
valueUsed.Text = Util.ToMB(used).ToString();
valueAvail.Text = Util.ToMB(avail).ToString();
valueTotDynMax.Text = Util.ToMB(tot_dyn_max).ToString();
valueTotal.Text = Util.MemorySizeStringSuitableUnits(total, true);
valueUsed.Text = Util.MemorySizeStringSuitableUnits(used, true);
valueAvail.Text = Util.MemorySizeStringSuitableUnits(avail, true);
valueTotDynMax.Text = Util.MemorySizeStringSuitableUnits(tot_dyn_max, true);
labelOvercommit.Text = string.Format(Messages.OVERCOMMIT, overcommit);
}

View File

@ -112,19 +112,19 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="labelTotal.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="labelTotal.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="labelTotal.Location" type="System.Drawing.Point, System.Drawing">
<value>490, 0</value>
</data>
@ -134,7 +134,7 @@
<data name="labelTotal.Size" type="System.Drawing.Size, System.Drawing">
<value>111, 18</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="labelTotal.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
@ -148,7 +148,7 @@
<value>labelTotal</value>
</data>
<data name="&gt;&gt;labelTotal.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelTotal.Parent" xml:space="preserve">
<value>$this</value>
@ -184,7 +184,7 @@
<value>labelUsed</value>
</data>
<data name="&gt;&gt;labelUsed.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelUsed.Parent" xml:space="preserve">
<value>$this</value>
@ -220,7 +220,7 @@
<value>labelAvail</value>
</data>
<data name="&gt;&gt;labelAvail.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelAvail.Parent" xml:space="preserve">
<value>$this</value>
@ -256,7 +256,7 @@
<value>labelTotDynMax</value>
</data>
<data name="&gt;&gt;labelTotDynMax.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelTotDynMax.Parent" xml:space="preserve">
<value>$this</value>
@ -289,7 +289,7 @@
<value>valueTotal</value>
</data>
<data name="&gt;&gt;valueTotal.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;valueTotal.Parent" xml:space="preserve">
<value>$this</value>
@ -322,7 +322,7 @@
<value>valueUsed</value>
</data>
<data name="&gt;&gt;valueUsed.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;valueUsed.Parent" xml:space="preserve">
<value>$this</value>
@ -355,7 +355,7 @@
<value>valueAvail</value>
</data>
<data name="&gt;&gt;valueAvail.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;valueAvail.Parent" xml:space="preserve">
<value>$this</value>
@ -388,7 +388,7 @@
<value>valueTotDynMax</value>
</data>
<data name="&gt;&gt;valueTotDynMax.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;valueTotDynMax.Parent" xml:space="preserve">
<value>$this</value>
@ -414,9 +414,6 @@
<data name="unitsTotal.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
</data>
<data name="unitsTotal.Text" xml:space="preserve">
<value>MB</value>
</data>
<data name="unitsTotal.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value>
</data>
@ -424,7 +421,7 @@
<value>unitsTotal</value>
</data>
<data name="&gt;&gt;unitsTotal.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;unitsTotal.Parent" xml:space="preserve">
<value>$this</value>
@ -450,9 +447,6 @@
<data name="unitsUsed.TabIndex" type="System.Int32, mscorlib">
<value>12</value>
</data>
<data name="unitsUsed.Text" xml:space="preserve">
<value>MB</value>
</data>
<data name="unitsUsed.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value>
</data>
@ -460,7 +454,7 @@
<value>unitsUsed</value>
</data>
<data name="&gt;&gt;unitsUsed.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;unitsUsed.Parent" xml:space="preserve">
<value>$this</value>
@ -486,9 +480,6 @@
<data name="unitsAvail.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
</data>
<data name="unitsAvail.Text" xml:space="preserve">
<value>MB</value>
</data>
<data name="unitsAvail.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value>
</data>
@ -496,7 +487,7 @@
<value>unitsAvail</value>
</data>
<data name="&gt;&gt;unitsAvail.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;unitsAvail.Parent" xml:space="preserve">
<value>$this</value>
@ -522,9 +513,6 @@
<data name="unitsTotDynMax.TabIndex" type="System.Int32, mscorlib">
<value>14</value>
</data>
<data name="unitsTotDynMax.Text" xml:space="preserve">
<value>MB</value>
</data>
<data name="unitsTotDynMax.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value>
</data>
@ -532,7 +520,7 @@
<value>unitsTotDynMax</value>
</data>
<data name="&gt;&gt;unitsTotDynMax.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;unitsTotDynMax.Parent" xml:space="preserve">
<value>$this</value>
@ -565,7 +553,7 @@
<value>labelOvercommit</value>
</data>
<data name="&gt;&gt;labelOvercommit.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelOvercommit.Parent" xml:space="preserve">
<value>$this</value>
@ -600,7 +588,7 @@
<data name="&gt;&gt;hostShinyBar.ZOrder" xml:space="preserve">
<value>13</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
@ -609,6 +597,9 @@
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="$this.MinimumSize" type="System.Drawing.Size, System.Drawing">
<value>700, 90</value>
</data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>700, 90</value>
</data>
@ -616,6 +607,6 @@
<value>HostMemoryControls</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

View File

@ -115,20 +115,20 @@ namespace XenAdmin.Controls.Ballooning
Rectangle rect = new Rectangle((int)left, barArea.Top,
(int)(left + width) - (int)left, // this is not necessarily the same as (int)width, which can leave a 1 pixel gap
barArea.Height);
string bytesString = Util.SuperiorSizeString(mem, 0);
string bytesString = Util.MemorySizeStringSuitableUnits(mem, false);
string caption = name + "\n" + bytesString;
string toolTip = name + "\n" + string.Format(Messages.CURRENT_MEMORY_USAGE, bytesString);
string toolTip = name + "\n" + string.Format(Messages.CURRENT_MEMORY_USAGE, Util.MemorySizeStringSuitableUnits(mem, true));
if (vm != null && vm.has_ballooning)
{
if (vm.memory_dynamic_max == vm.memory_static_max)
toolTip += string.Format("\n{0}: {1}\n{2}: {3}",
Messages.DYNAMIC_MIN, Util.SuperiorSizeString(vm.memory_dynamic_min, 0),
Messages.DYNAMIC_MAX, Util.SuperiorSizeString(vm.memory_dynamic_max, 0));
Messages.DYNAMIC_MIN, Util.MemorySizeStringSuitableUnits(vm.memory_dynamic_min, true),
Messages.DYNAMIC_MAX, Util.MemorySizeStringSuitableUnits(vm.memory_dynamic_max, true));
else
toolTip += string.Format("\n{0}: {1}\n{2}: {3}\n{4}: {5}",
Messages.DYNAMIC_MIN, Util.SuperiorSizeString(vm.memory_dynamic_min, 0),
Messages.DYNAMIC_MAX, Util.SuperiorSizeString(vm.memory_dynamic_max, 0),
Messages.STATIC_MAX, Util.SuperiorSizeString(vm.memory_static_max, 0));
Messages.DYNAMIC_MIN, Util.MemorySizeStringSuitableUnits(vm.memory_dynamic_min, true),
Messages.DYNAMIC_MAX, Util.MemorySizeStringSuitableUnits(vm.memory_dynamic_max, true),
Messages.STATIC_MAX, Util.MemorySizeStringSuitableUnits(vm.memory_static_max, true));
}
DrawToTarget(g, barArea, rect, color, caption, BallooningColors.HostShinyBar_Text, HorizontalAlignment.Center, toolTip);
left += width;

View File

@ -29,27 +29,18 @@ namespace XenAdmin.Controls.Ballooning
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MemorySpinner));
this.MB = new System.Windows.Forms.Label();
this.Spinner = new System.Windows.Forms.NumericUpDown();
this.NameLabel = new System.Windows.Forms.Label();
this.iconBox = new System.Windows.Forms.PictureBox();
this.SpinnerUnits = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.Spinner)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.iconBox)).BeginInit();
this.SuspendLayout();
//
// MB
//
resources.ApplyResources(this.MB, "MB");
this.MB.Name = "MB";
//
// Spinner
//
resources.ApplyResources(this.Spinner, "Spinner");
this.Spinner.Increment = new decimal(new int[] {
128,
0,
0,
0});
this.Spinner.DecimalPlaces = 1;
this.Spinner.Maximum = new decimal(new int[] {
99999,
0,
@ -70,27 +61,34 @@ namespace XenAdmin.Controls.Ballooning
this.iconBox.Name = "iconBox";
this.iconBox.TabStop = false;
//
// SpinnerUnits
//
resources.ApplyResources(this.SpinnerUnits, "SpinnerUnits");
this.SpinnerUnits.BackColor = System.Drawing.SystemColors.Control;
this.SpinnerUnits.Name = "SpinnerUnits";
//
// MemorySpinner
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.Controls.Add(this.MB);
this.Controls.Add(this.Spinner);
this.Controls.Add(this.SpinnerUnits);
this.Controls.Add(this.NameLabel);
this.Controls.Add(this.iconBox);
this.Controls.Add(this.Spinner);
this.DoubleBuffered = true;
this.Name = "MemorySpinner";
((System.ComponentModel.ISupportInitialize)(this.Spinner)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.iconBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label MB;
private System.Windows.Forms.NumericUpDown Spinner;
private System.Windows.Forms.Label NameLabel;
private System.Windows.Forms.PictureBox iconBox;
private System.Windows.Forms.Label SpinnerUnits;
}
}

View File

@ -32,8 +32,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
@ -42,67 +42,179 @@ namespace XenAdmin.Controls.Ballooning
public partial class MemorySpinner : UserControl
{
public event EventHandler SpinnerValueChanged;
private double valueMB;
private string previousUnitsValue;
private bool initializing= true;
public MemorySpinner()
{
InitializeComponent();
previousUnitsValue = Messages.VAL_GIGB;
}
public void Initialize(string name, Image icon, long amount)
public void Initialize(string name, Image icon, double amount, double static_max)
{
Initialize(name, icon, amount, RoundingBehaviour.Nearest);
amount = Util.CorrectRoundingErrors(amount);
if(static_max <= Util.BINARY_GIGA)
{
Units = Messages.VAL_MEGB;
}
else
{
Units = Messages.VAL_GIGB;
}
ChangeSpinnerSettings();
previousUnitsValue = Units;
Initialize(name, icon, amount, RoundingBehaviour.None);
}
public void Initialize(string name, Image icon, long amount, RoundingBehaviour rounding)
public void Initialize(string name, Image icon, double amount, RoundingBehaviour rounding)
{
NameLabel.Text = name;
if (icon != null && iconBox.Image == null) // without this line, setting iconBox.Image causes another repaint, hence an infinite loop
iconBox.Image = icon;
long amountMB = Util.ToMB(amount, rounding);
Spinner.Value = amountMB;
ValueMB = Util.ToMB(amount, rounding);
setSpinnerValueDisplay(amount);
initializing = false;
}
[Browsable(false)]
public long Value
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] 
public string Units
{
get
{
return (long)Spinner.Value * Util.BINARY_MEGA;
return SpinnerUnits.Text;
}
set
{
SpinnerUnits.Text = value;
}
}
public static void CalcMBRanges(long minBytes, long maxBytes, out long minMB, out long maxMB)
[Browsable(false)]
public double Value
{
get
{
return ValueMB * Util.BINARY_MEGA;
}
}
double ValueMB
{
get
{
return valueMB;
}
set
{
valueMB = value;
}
}
private void setSpinnerValueDisplay(double value)
{
if (Units == "GB")
{
Spinner.Value = (decimal)Util.ToGB(value, 1, RoundingBehaviour.Nearest);
}
else
{
Spinner.Value = (long)Util.ToMB(value, RoundingBehaviour.Nearest);
}
}
public static void CalcMBRanges(double minBytes, double maxBytes, out double minMB, out double maxMB)
{
// Round ranges inwards to avoid bugs like CA-34487 and CA-34996
minMB = Util.ToMB(minBytes, RoundingBehaviour.Up);
maxMB = Util.ToMB(maxBytes, RoundingBehaviour.Down);
if (minMB > maxMB) // just in case...
{
minMB = Util.ToMB(minBytes);
maxMB = Util.ToMB(maxBytes);
minMB = Util.ToMB(minBytes, RoundingBehaviour.None);
maxMB = Util.ToMB(maxBytes, RoundingBehaviour.None);
}
}
public void SetRange(long min, long max)
public static void CalcGBRanges(double minBytes, double maxBytes, out double minGB, out double maxGB)
{
// Round ranges inwards to avoid bugs like CA-34487 and CA-34996
minGB = Util.ToGB(minBytes, 1, RoundingBehaviour.Up);
maxGB = Util.ToGB(maxBytes, 1, RoundingBehaviour.Down);
if (minGB > maxGB) // just in case...
{
minGB = Util.ToGB(minBytes, 1, RoundingBehaviour.None);
maxGB = Util.ToGB(maxBytes, 1, RoundingBehaviour.None);
}
}
public void SetRange(double min, double max)
{
if (min > max)
return; // Can happen when we are adjusting several simultaneously: can cause a stack overflow
long minMB, maxMB;
CalcMBRanges(min, max, out minMB, out maxMB);
Spinner.Minimum = minMB;
Spinner.Maximum = maxMB;
double spinnerMin, spinnerMax;
if (Units == "MB")
{
CalcMBRanges(min, max, out spinnerMin, out spinnerMax);
}
else
{
CalcGBRanges(min, max, out spinnerMin, out spinnerMax);
}
Spinner.Minimum = (decimal)spinnerMin;
Spinner.Maximum = (decimal)spinnerMax;
}
[Browsable(false)]
public int Increment
public double Increment
{
set { Spinner.Increment = value; }
get
{
return (double)Spinner.Increment;
}
set
{
if (Units == "MB")
{
Spinner.Increment = (decimal)value / Util.BINARY_MEGA;
}
else
{
// When the units are GB, we simply want the numbers to increase by 1 if the spinner value is greater than 10 GB
// and by 0.1 if smaller than 10 GB, this being the reason we ignore the given value.
if (valueMB * Util.BINARY_MEGA < 10 * Util.BINARY_GIGA)
{
Spinner.Increment = 0.1M;
}
else
{
Spinner.Increment = 1;
}
}
}
}
private void Spinner_ValueChanged(object sender, EventArgs e)
{
// We do not want to modify the ValueMB if the user does not modify anything in the Spinner.Value.
// When the Memory Settings dialog is intiliazing and the units change because the new value is > 1 GB,
// we do not want any changes to be applied to ValueMB.
if (initializing)
return;
if (Units == "GB")
{
ValueMB = (double)Spinner.Value * Util.BINARY_KILO;
}
else
{
ValueMB = (double)Spinner.Value;
}
if (SpinnerValueChanged != null)
SpinnerValueChanged(this, e);
}
@ -112,5 +224,22 @@ namespace XenAdmin.Controls.Ballooning
if (sender is NumericUpDown)
((Control)sender).Text = ((NumericUpDown)sender).Value.ToString();
}
private void ChangeSpinnerSettings()
{
if (Units == previousUnitsValue)
return;
if (Units == "GB")
{
SetRange((double)Spinner.Minimum * Util.BINARY_MEGA, (double)Spinner.Maximum * Util.BINARY_MEGA);
Spinner.DecimalPlaces = 1;
}
else
{
SetRange((double)Spinner.Minimum * Util.BINARY_GIGA, (double)Spinner.Maximum * Util.BINARY_GIGA);
Spinner.DecimalPlaces = 0;
}
}
}
}

View File

@ -112,59 +112,26 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="MB.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="MB.Location" type="System.Drawing.Point, System.Drawing">
<value>194, 0</value>
</data>
<data name="MB.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="MB.Size" type="System.Drawing.Size, System.Drawing">
<value>26, 25</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="MB.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="MB.Text" xml:space="preserve">
<value>MB</value>
</data>
<data name="MB.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value>
</data>
<data name="&gt;&gt;MB.Name" xml:space="preserve">
<value>MB</value>
</data>
<data name="&gt;&gt;MB.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;MB.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;MB.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Spinner.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="Spinner.Location" type="System.Drawing.Point, System.Drawing">
<value>125, 2</value>
<value>184, 5</value>
</data>
<data name="Spinner.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="Spinner.Size" type="System.Drawing.Size, System.Drawing">
<value>69, 20</value>
<value>63, 20</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Spinner.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
@ -175,25 +142,28 @@
<value>Spinner</value>
</data>
<data name="&gt;&gt;Spinner.Type" xml:space="preserve">
<value>System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;Spinner.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;Spinner.ZOrder" xml:space="preserve">
<value>1</value>
<value>3</value>
</data>
<data name="NameLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="NameLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="NameLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 0</value>
<value>27, 2</value>
</data>
<data name="NameLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="NameLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>115, 28</value>
<value>145, 23</value>
</data>
<data name="NameLabel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -205,25 +175,25 @@
<value>NameLabel</value>
</data>
<data name="&gt;&gt;NameLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;NameLabel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;NameLabel.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="iconBox.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
<value>1</value>
</data>
<data name="iconBox.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 6</value>
<value>0, 4</value>
</data>
<data name="iconBox.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="iconBox.Size" type="System.Drawing.Size, System.Drawing">
<value>7, 13</value>
<value>27, 20</value>
</data>
<data name="iconBox.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
<value>AutoSize</value>
</data>
<data name="iconBox.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
@ -232,15 +202,51 @@
<value>iconBox</value>
</data>
<data name="&gt;&gt;iconBox.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;iconBox.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;iconBox.ZOrder" xml:space="preserve">
<value>3</value>
<value>2</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<data name="SpinnerUnits.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Right</value>
</data>
<data name="SpinnerUnits.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="SpinnerUnits.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="SpinnerUnits.Location" type="System.Drawing.Point, System.Drawing">
<value>250, 9</value>
</data>
<data name="SpinnerUnits.MinimumSize" type="System.Drawing.Size, System.Drawing">
<value>0, 14</value>
</data>
<data name="SpinnerUnits.Size" type="System.Drawing.Size, System.Drawing">
<value>22, 14</value>
</data>
<data name="SpinnerUnits.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
</data>
<data name="SpinnerUnits.Text" xml:space="preserve">
<value>GB</value>
</data>
<data name="&gt;&gt;SpinnerUnits.Name" xml:space="preserve">
<value>SpinnerUnits</value>
</data>
<data name="&gt;&gt;SpinnerUnits.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;SpinnerUnits.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;SpinnerUnits.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
@ -250,12 +256,12 @@
<value>0, 0, 0, 0</value>
</data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>220, 25</value>
<value>293, 29</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>MemorySpinner</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

View File

@ -210,7 +210,7 @@ namespace XenAdmin.Controls.Ballooning
return path;
}
protected static void DrawGrid(Graphics g, Rectangle barArea, double bytesPerPixel, long max)
protected static void DrawGrid(Graphics g, Rectangle barArea, double bytesPerPixel, double max)
{
const int min_gap = 40; // min gap between consecutive labels (which are on alternate ticks)
const int line_height = 12;
@ -220,7 +220,7 @@ namespace XenAdmin.Controls.Ballooning
int text_bottom = line_top - 2;
// Find the size of the longest label
string label = string.Format(Messages.VAL_MB, max / Util.BINARY_MEGA);
string label = string.Format(Messages.VAL_MB, Util.ToMB(max, RoundingBehaviour.Nearest));
Size labelSize = Drawing.MeasureText(g, label, Program.DefaultFont, TextFormatFlags.NoPadding);
int longest = labelSize.Width;
int text_top = text_bottom - labelSize.Height;
@ -243,16 +243,34 @@ namespace XenAdmin.Controls.Ballooning
// Label
if (withLabel)
{
label = string.Format(Messages.VAL_MB, x / Util.BINARY_MEGA);
label = Util.MemorySizeStringSuitableUnits(x, false);
Size size = Drawing.MeasureText(g, label, Program.DefaultFont);
Rectangle rect = new Rectangle(new Point(pos - size.Width/2, text_top), size);
Drawing.DrawText(g, label, Program.DefaultFont, rect, BallooningColors.Grid, Color.Transparent);
if (LabelShouldBeShown(max, label, x))
{
Drawing.DrawText(g, label, Program.DefaultFont, rect, BallooningColors.Grid, Color.Transparent);
}
}
withLabel = !withLabel;
}
}
}
/// <summary>
/// There are 2 cases:
/// 1. If the maximum is smaller or equal to 1 GB, then show all the labels.
/// 2. If the maximum is greater than 1 GB, then show only the labels that are a multiple of half a GB.
/// </summary>
/// <param name="max"></param>
/// <param name="label"></param>
/// <param name="x"></param>
/// <returns></returns>
private static bool LabelShouldBeShown(double max, string label, long x)
{
return max <= Util.BINARY_GIGA || (x % (0.5 * Util.BINARY_GIGA)) == 0;
}
protected virtual Rectangle barRect
{
get

View File

@ -31,8 +31,8 @@ namespace XenAdmin.Controls.Ballooning
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VMMemoryControlsAdvanced));
this.spinnerPanel = new System.Windows.Forms.TableLayoutPanel();
this.memorySpinnerDynMin = new XenAdmin.Controls.Ballooning.MemorySpinner();
this.memorySpinnerStatMax = new XenAdmin.Controls.Ballooning.MemorySpinner();
this.memorySpinnerDynMax = new XenAdmin.Controls.Ballooning.MemorySpinner();
this.memorySpinnerStatMax = new XenAdmin.Controls.Ballooning.MemorySpinner();
this.spinnerPanel.SuspendLayout();
this.SuspendLayout();
//
@ -40,8 +40,8 @@ namespace XenAdmin.Controls.Ballooning
//
resources.ApplyResources(this.spinnerPanel, "spinnerPanel");
this.spinnerPanel.Controls.Add(this.memorySpinnerDynMin, 0, 0);
this.spinnerPanel.Controls.Add(this.memorySpinnerStatMax, 0, 2);
this.spinnerPanel.Controls.Add(this.memorySpinnerDynMax, 0, 1);
this.spinnerPanel.Controls.Add(this.memorySpinnerStatMax, 0, 2);
this.spinnerPanel.Name = "spinnerPanel";
//
// memorySpinnerDynMin
@ -50,18 +50,18 @@ namespace XenAdmin.Controls.Ballooning
this.memorySpinnerDynMin.Name = "memorySpinnerDynMin";
this.memorySpinnerDynMin.SpinnerValueChanged += new System.EventHandler(this.Spinners_ValueChanged);
//
// memorySpinnerStatMax
//
resources.ApplyResources(this.memorySpinnerStatMax, "memorySpinnerStatMax");
this.memorySpinnerStatMax.Name = "memorySpinnerStatMax";
this.memorySpinnerStatMax.SpinnerValueChanged += new System.EventHandler(this.Spinners_ValueChanged);
//
// memorySpinnerDynMax
//
resources.ApplyResources(this.memorySpinnerDynMax, "memorySpinnerDynMax");
this.memorySpinnerDynMax.Name = "memorySpinnerDynMax";
this.memorySpinnerDynMax.SpinnerValueChanged += new System.EventHandler(this.Spinners_ValueChanged);
//
// memorySpinnerStatMax
//
resources.ApplyResources(this.memorySpinnerStatMax, "memorySpinnerStatMax");
this.memorySpinnerStatMax.Name = "memorySpinnerStatMax";
this.memorySpinnerStatMax.SpinnerValueChanged += new System.EventHandler(this.Spinners_ValueChanged);
//
// VMMemoryControlsAdvanced
//
resources.ApplyResources(this, "$this");
@ -69,6 +69,7 @@ namespace XenAdmin.Controls.Ballooning
this.Controls.Add(this.spinnerPanel);
this.Name = "VMMemoryControlsAdvanced";
this.spinnerPanel.ResumeLayout(false);
this.spinnerPanel.PerformLayout();
this.ResumeLayout(false);
}
@ -80,4 +81,4 @@ namespace XenAdmin.Controls.Ballooning
private MemorySpinner memorySpinnerStatMax;
private MemorySpinner memorySpinnerDynMax;
}
}
}

View File

@ -63,15 +63,16 @@ namespace XenAdmin.Controls.Ballooning
// Spinners
FreeSpinnerRanges();
static_min = vm0.memory_static_min;
memorySpinnerDynMin.Initialize(Messages.DYNAMIC_MIN_AMP, null, vm0.memory_dynamic_min);
memorySpinnerDynMax.Initialize(Messages.DYNAMIC_MAX_AMP, null, vm0.memory_dynamic_max);
memorySpinnerStatMax.Initialize(Messages.STATIC_MAX_AMP, null, vm0.memory_static_max);
memorySpinnerDynMin.Initialize(Messages.DYNAMIC_MIN_AMP, null, vm0.memory_dynamic_min, vm0.memory_static_max);
memorySpinnerDynMax.Initialize(Messages.DYNAMIC_MAX_AMP, null, vm0.memory_dynamic_max, vm0.memory_static_max);
memorySpinnerStatMax.Initialize(Messages.STATIC_MAX_AMP, null, vm0.memory_static_max, vm0.memory_static_max);
SetIncrements();
SetSpinnerRanges();
firstPaint = false;
}
public override long dynamic_min
public override double dynamic_min
{
get
{
@ -79,7 +80,7 @@ namespace XenAdmin.Controls.Ballooning
}
}
public override long dynamic_max
public override double dynamic_max
{
get
{
@ -87,7 +88,7 @@ namespace XenAdmin.Controls.Ballooning
}
}
public override long static_max
public override double static_max
{
get
{
@ -97,7 +98,7 @@ namespace XenAdmin.Controls.Ballooning
private void SetIncrements()
{
memorySpinnerDynMin.Increment = memorySpinnerDynMax.Increment = CalcIncrement();
memorySpinnerDynMin.Increment = memorySpinnerDynMax.Increment = memorySpinnerStatMax.Increment = CalcIncrement(memorySpinnerDynMax.Units);
}
private void Spinners_ValueChanged(object sender, EventArgs e)

View File

@ -112,25 +112,25 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="spinnerPanel.ColumnCount" type="System.Int32, mscorlib">
<value>1</value>
<value>2</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="memorySpinnerDynMin.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="memorySpinnerDynMin.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="memorySpinnerDynMin.Size" type="System.Drawing.Size, System.Drawing">
<value>220, 25</value>
<value>217, 28</value>
</data>
<data name="memorySpinnerDynMin.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -148,13 +148,13 @@
<value>0</value>
</data>
<data name="memorySpinnerStatMax.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 50</value>
<value>0, 56</value>
</data>
<data name="memorySpinnerStatMax.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="memorySpinnerStatMax.Size" type="System.Drawing.Size, System.Drawing">
<value>220, 25</value>
<value>217, 30</value>
</data>
<data name="memorySpinnerStatMax.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -171,14 +171,17 @@
<data name="&gt;&gt;memorySpinnerStatMax.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="memorySpinnerDynMax.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="memorySpinnerDynMax.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 25</value>
<value>0, 28</value>
</data>
<data name="memorySpinnerDynMax.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="memorySpinnerDynMax.Size" type="System.Drawing.Size, System.Drawing">
<value>220, 25</value>
<value>217, 28</value>
</data>
<data name="memorySpinnerDynMax.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -195,6 +198,105 @@
<data name="&gt;&gt;memorySpinnerDynMax.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="unitsDynMax.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="unitsDynMax.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="unitsDynMax.Items" xml:space="preserve">
<value>GB</value>
</data>
<data name="unitsDynMax.Items1" xml:space="preserve">
<value>MB</value>
</data>
<data name="unitsDynMax.Location" type="System.Drawing.Point, System.Drawing">
<value>220, 31</value>
</data>
<data name="unitsDynMax.Size" type="System.Drawing.Size, System.Drawing">
<value>43, 23</value>
</data>
<data name="unitsDynMax.TabIndex" type="System.Int32, mscorlib">
<value>16</value>
</data>
<data name="&gt;&gt;unitsDynMax.Name" xml:space="preserve">
<value>unitsDynMax</value>
</data>
<data name="&gt;&gt;unitsDynMax.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;unitsDynMax.Parent" xml:space="preserve">
<value>spinnerPanel</value>
</data>
<data name="&gt;&gt;unitsDynMax.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="unitsDynMin.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="unitsDynMin.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="unitsDynMin.Items" xml:space="preserve">
<value>GB</value>
</data>
<data name="unitsDynMin.Items1" xml:space="preserve">
<value>MB</value>
</data>
<data name="unitsDynMin.Location" type="System.Drawing.Point, System.Drawing">
<value>220, 3</value>
</data>
<data name="unitsDynMin.Size" type="System.Drawing.Size, System.Drawing">
<value>43, 23</value>
</data>
<data name="unitsDynMin.TabIndex" type="System.Int32, mscorlib">
<value>17</value>
</data>
<data name="&gt;&gt;unitsDynMin.Name" xml:space="preserve">
<value>unitsDynMin</value>
</data>
<data name="&gt;&gt;unitsDynMin.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;unitsDynMin.Parent" xml:space="preserve">
<value>spinnerPanel</value>
</data>
<data name="&gt;&gt;unitsDynMin.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="unitsFixedMemory.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="unitsFixedMemory.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
</data>
<data name="unitsFixedMemory.Items" xml:space="preserve">
<value>GB</value>
</data>
<data name="unitsFixedMemory.Items1" xml:space="preserve">
<value>MB</value>
</data>
<data name="unitsFixedMemory.Location" type="System.Drawing.Point, System.Drawing">
<value>220, 59</value>
</data>
<data name="unitsFixedMemory.Size" type="System.Drawing.Size, System.Drawing">
<value>43, 23</value>
</data>
<data name="unitsFixedMemory.TabIndex" type="System.Int32, mscorlib">
<value>18</value>
</data>
<data name="&gt;&gt;unitsFixedMemory.Name" xml:space="preserve">
<value>unitsFixedMemory</value>
</data>
<data name="&gt;&gt;unitsFixedMemory.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;unitsFixedMemory.Parent" xml:space="preserve">
<value>spinnerPanel</value>
</data>
<data name="&gt;&gt;unitsFixedMemory.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="spinnerPanel.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
@ -205,7 +307,7 @@
<value>3</value>
</data>
<data name="spinnerPanel.Size" type="System.Drawing.Size, System.Drawing">
<value>220, 75</value>
<value>277, 86</value>
</data>
<data name="spinnerPanel.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -214,7 +316,7 @@
<value>spinnerPanel</value>
</data>
<data name="&gt;&gt;spinnerPanel.Type" xml:space="preserve">
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;spinnerPanel.Parent" xml:space="preserve">
<value>$this</value>
@ -223,9 +325,9 @@
<value>0</value>
</data>
<data name="spinnerPanel.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="memorySpinnerDynMin" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="memorySpinnerStatMax" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="memorySpinnerDynMax" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="Percent,33.33333,Percent,33.33333,Percent,33.33333,Absolute,20,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="memorySpinnerDynMin" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="memorySpinnerStatMax" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="memorySpinnerDynMax" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="unitsDynMax" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="unitsDynMin" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="unitsFixedMemory" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100,Absolute,60" /&gt;&lt;Rows Styles="Percent,33.33333,Percent,33.33333,Percent,33.33333,Absolute,20,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
@ -235,7 +337,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>220, 75</value>
<value>282, 93</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>VMMemoryControlsAdvanced</value>

View File

@ -31,15 +31,15 @@ namespace XenAdmin.Controls.Ballooning
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VMMemoryControlsBasic));
this.spinnerPanel = new System.Windows.Forms.TableLayoutPanel();
this.memorySpinnerDynMin = new XenAdmin.Controls.Ballooning.MemorySpinner();
this.memorySpinnerDynMax = new XenAdmin.Controls.Ballooning.MemorySpinner();
this.vmShinyBar = new XenAdmin.Controls.Ballooning.VMShinyBar();
this.radioOff = new System.Windows.Forms.RadioButton();
this.memorySpinnerFixed = new XenAdmin.Controls.Ballooning.MemorySpinner();
this.radioOn = new System.Windows.Forms.RadioButton();
this.groupBoxOn = new System.Windows.Forms.GroupBox();
this.iconDMCUnavailable = new System.Windows.Forms.PictureBox();
this.labelDMCUnavailable = new System.Windows.Forms.Label();
this.linkInstallTools = new System.Windows.Forms.LinkLabel();
this.memorySpinnerFixed = new XenAdmin.Controls.Ballooning.MemorySpinner();
this.memorySpinnerDynMax = new XenAdmin.Controls.Ballooning.MemorySpinner();
this.spinnerPanel.SuspendLayout();
this.groupBoxOn.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.iconDMCUnavailable)).BeginInit();
@ -54,38 +54,33 @@ namespace XenAdmin.Controls.Ballooning
//
// memorySpinnerDynMin
//
this.memorySpinnerDynMin.Increment = 1D;
resources.ApplyResources(this.memorySpinnerDynMin, "memorySpinnerDynMin");
this.memorySpinnerDynMin.Name = "memorySpinnerDynMin";
this.memorySpinnerDynMin.Units = "GB";
this.memorySpinnerDynMin.SpinnerValueChanged += new System.EventHandler(this.DynamicSpinners_ValueChanged);
//
// memorySpinnerDynMax
//
this.memorySpinnerDynMax.Increment = 1D;
resources.ApplyResources(this.memorySpinnerDynMax, "memorySpinnerDynMax");
this.memorySpinnerDynMax.Name = "memorySpinnerDynMax";
this.memorySpinnerDynMax.Units = "GB";
this.memorySpinnerDynMax.SpinnerValueChanged += new System.EventHandler(this.DynamicSpinners_ValueChanged);
//
// vmShinyBar
//
resources.ApplyResources(this.vmShinyBar, "vmShinyBar");
this.vmShinyBar.Increment = ((long)(128));
this.vmShinyBar.MinimumSize = new System.Drawing.Size(500, 90);
this.vmShinyBar.Name = "vmShinyBar";
this.vmShinyBar.SliderDragged += new System.EventHandler(this.vmShinyBar_SliderDragged);
//
// radioOff
//
resources.ApplyResources(this.radioOff, "radioOff");
this.radioOff.MinimumSize = new System.Drawing.Size(0, 25);
this.radioOff.Name = "radioOff";
this.radioOff.TabStop = true;
this.radioOff.UseVisualStyleBackColor = true;
//
// memorySpinnerFixed
//
resources.ApplyResources(this.memorySpinnerFixed, "memorySpinnerFixed");
this.memorySpinnerFixed.Name = "memorySpinnerFixed";
this.memorySpinnerFixed.SpinnerValueChanged += new System.EventHandler(this.FixedSpinner_ValueChanged);
//
// radioOn
//
resources.ApplyResources(this.radioOn, "radioOn");
@ -103,10 +98,8 @@ namespace XenAdmin.Controls.Ballooning
//
// iconDMCUnavailable
//
this.iconDMCUnavailable.ErrorImage = null;
this.iconDMCUnavailable.Image = global::XenAdmin.Properties.Resources._000_Alert2_h32bit_16;
this.iconDMCUnavailable.InitialImage = null;
resources.ApplyResources(this.iconDMCUnavailable, "iconDMCUnavailable");
this.iconDMCUnavailable.Image = global::XenAdmin.Properties.Resources._000_Alert2_h32bit_16;
this.iconDMCUnavailable.Name = "iconDMCUnavailable";
this.iconDMCUnavailable.TabStop = false;
//
@ -123,16 +116,24 @@ namespace XenAdmin.Controls.Ballooning
this.linkInstallTools.VisitedLinkColor = System.Drawing.Color.Blue;
this.linkInstallTools.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.InstallTools_LinkClicked);
//
// memorySpinnerFixed
//
this.memorySpinnerFixed.Increment = 1D;
resources.ApplyResources(this.memorySpinnerFixed, "memorySpinnerFixed");
this.memorySpinnerFixed.Name = "memorySpinnerFixed";
this.memorySpinnerFixed.Units = "GB";
this.memorySpinnerFixed.SpinnerValueChanged += new System.EventHandler(this.FixedSpinner_ValueChanged);
//
// VMMemoryControlsBasic
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.Controls.Add(this.memorySpinnerFixed);
this.Controls.Add(this.linkInstallTools);
this.Controls.Add(this.labelDMCUnavailable);
this.Controls.Add(this.iconDMCUnavailable);
this.Controls.Add(this.groupBoxOn);
this.Controls.Add(this.radioOn);
this.Controls.Add(this.memorySpinnerFixed);
this.Controls.Add(this.radioOff);
this.DoubleBuffered = true;
this.Name = "VMMemoryControlsBasic";
@ -149,13 +150,13 @@ namespace XenAdmin.Controls.Ballooning
private VMShinyBar vmShinyBar;
private System.Windows.Forms.TableLayoutPanel spinnerPanel;
private MemorySpinner memorySpinnerDynMin;
private MemorySpinner memorySpinnerDynMax;
private System.Windows.Forms.RadioButton radioOff;
private MemorySpinner memorySpinnerFixed;
private System.Windows.Forms.RadioButton radioOn;
private System.Windows.Forms.GroupBox groupBoxOn;
private System.Windows.Forms.PictureBox iconDMCUnavailable;
private System.Windows.Forms.Label labelDMCUnavailable;
private System.Windows.Forms.LinkLabel linkInstallTools;
private MemorySpinner memorySpinnerFixed;
private MemorySpinner memorySpinnerDynMax;
}
}

View File

@ -149,15 +149,15 @@ namespace XenAdmin.Controls.Ballooning
// Spinners
FreeSpinnerRanges();
static_min = vm0.memory_static_min;
memorySpinnerDynMin.Initialize(Messages.DYNAMIC_MIN_AMP, ballooning ? XenAdmin.Properties.Resources.memory_dynmin_slider_small : null, vm0.memory_dynamic_min);
memorySpinnerDynMax.Initialize(Messages.DYNAMIC_MAX_AMP, ballooning ? XenAdmin.Properties.Resources.memory_dynmax_slider_small : null, vm0.memory_dynamic_max);
memorySpinnerFixed.Initialize("", null, vm0.memory_static_max);
memorySpinnerDynMin.Initialize(Messages.DYNAMIC_MIN_AMP, ballooning ? XenAdmin.Properties.Resources.memory_dynmin_slider_small : null, vm0.memory_dynamic_min, vm0.memory_static_max);
memorySpinnerDynMax.Initialize(Messages.DYNAMIC_MAX_AMP, ballooning ? XenAdmin.Properties.Resources.memory_dynmax_slider_small : null, vm0.memory_dynamic_max, vm0.memory_static_max);
memorySpinnerFixed.Initialize("", null, vm0.memory_static_max, vm0.memory_static_max);
SetIncrements();
SetSpinnerRanges();
firstPaint = false;
}
public override long dynamic_min
public override double dynamic_min
{
get
{
@ -166,7 +166,7 @@ namespace XenAdmin.Controls.Ballooning
}
}
public override long dynamic_max
public override double dynamic_max
{
get
{
@ -175,7 +175,7 @@ namespace XenAdmin.Controls.Ballooning
}
}
public override long static_max
public override double static_max
{
get
{
@ -185,7 +185,7 @@ namespace XenAdmin.Controls.Ballooning
private void SetIncrements()
{
vmShinyBar.Increment = memorySpinnerDynMin.Increment = memorySpinnerDynMax.Increment = CalcIncrement();
vmShinyBar.Increment = memorySpinnerDynMin.Increment = memorySpinnerDynMax.Increment = memorySpinnerFixed.Increment = CalcIncrement(memorySpinnerDynMax.Units);
}
private void DynamicSpinners_ValueChanged(object sender, EventArgs e)
@ -200,8 +200,8 @@ namespace XenAdmin.Controls.Ballooning
long min = (long)((double)static_max * GetMemoryRatio());
if (memorySpinnerDynMin.Value < min)
memorySpinnerDynMin.Initialize(Messages.DYNAMIC_MIN_AMP, XenAdmin.Properties.Resources.memory_dynmin_slider_small, min, RoundingBehaviour.Up);
SetIncrements();
}
SetIncrements();
SetSpinnerRanges();
vmShinyBar.ChangeSettings(static_min, dynamic_min, dynamic_max, static_max);
vmShinyBar.Refresh();
@ -212,26 +212,27 @@ namespace XenAdmin.Controls.Ballooning
if (firstPaint) // still initialising
return;
radioOff.Checked = true;
SetIncrements();
}
private void SetSpinnerRanges()
{
// Set the limit for the fixed spinner
long maxFixed = ((maxDynMin >= 0 && maxDynMin <= MemorySpinnerMax) ? maxDynMin : MemorySpinnerMax);
double maxFixed = ((maxDynMin >= 0 && maxDynMin <= MemorySpinnerMax) ? maxDynMin : MemorySpinnerMax);
memorySpinnerFixed.SetRange(vm0.memory_static_min >= Util.BINARY_MEGA ? vm0.memory_static_min : Util.BINARY_MEGA, maxFixed);
if (!ballooning)
return;
// Calculate limits for the dynamic spinners
long maxDM = DynMinSpinnerMax;
long minDM = DynMinSpinnerMin;
long maxSM = StatMaxSpinnerMax;
double maxDM = DynMinSpinnerMax;
double minDM = DynMinSpinnerMin;
double maxSM = StatMaxSpinnerMax;
// Set the limits
memorySpinnerDynMin.SetRange(minDM, maxDM);
memorySpinnerDynMax.SetRange(dynamic_min >= Util.BINARY_MEGA ? dynamic_min : Util.BINARY_MEGA, maxSM);
vmShinyBar.SetRanges(minDM, maxDM, dynamic_min, maxSM);
vmShinyBar.SetRanges(minDM, maxDM, dynamic_min, maxSM, memorySpinnerDynMax.Units);
}
private void FreeSpinnerRanges()
@ -243,8 +244,8 @@ namespace XenAdmin.Controls.Ballooning
private void vmShinyBar_SliderDragged(object sender, EventArgs e)
{
memorySpinnerDynMin.Initialize(Messages.DYNAMIC_MIN_AMP, XenAdmin.Properties.Resources.memory_dynmin_slider_small, vmShinyBar.Dynamic_min);
memorySpinnerDynMax.Initialize(Messages.DYNAMIC_MAX_AMP, XenAdmin.Properties.Resources.memory_dynmax_slider_small, vmShinyBar.Dynamic_max);
memorySpinnerDynMin.Initialize(Messages.DYNAMIC_MIN_AMP, XenAdmin.Properties.Resources.memory_dynmin_slider_small, vmShinyBar.Dynamic_min, RoundingBehaviour.None);
memorySpinnerDynMax.Initialize(Messages.DYNAMIC_MAX_AMP, XenAdmin.Properties.Resources.memory_dynmax_slider_small, vmShinyBar.Dynamic_max, RoundingBehaviour.None);
memorySpinnerDynMin.Refresh();
memorySpinnerDynMax.Refresh();
}

View File

@ -112,25 +112,25 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="spinnerPanel.ColumnCount" type="System.Int32, mscorlib">
<value>1</value>
<value>2</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="memorySpinnerDynMin.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="memorySpinnerDynMin.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="memorySpinnerDynMin.Size" type="System.Drawing.Size, System.Drawing">
<value>220, 25</value>
<value>257, 31</value>
</data>
<data name="memorySpinnerDynMin.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -148,13 +148,13 @@
<value>0</value>
</data>
<data name="memorySpinnerDynMax.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 25</value>
<value>0, 31</value>
</data>
<data name="memorySpinnerDynMax.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="memorySpinnerDynMax.Size" type="System.Drawing.Size, System.Drawing">
<value>220, 25</value>
<value>257, 31</value>
</data>
<data name="memorySpinnerDynMax.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -172,7 +172,7 @@
<value>1</value>
</data>
<data name="spinnerPanel.Location" type="System.Drawing.Point, System.Drawing">
<value>150, 117</value>
<value>143, 114</value>
</data>
<data name="spinnerPanel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
@ -181,7 +181,7 @@
<value>2</value>
</data>
<data name="spinnerPanel.Size" type="System.Drawing.Size, System.Drawing">
<value>220, 50</value>
<value>307, 61</value>
</data>
<data name="spinnerPanel.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
@ -190,7 +190,7 @@
<value>spinnerPanel</value>
</data>
<data name="&gt;&gt;spinnerPanel.Type" xml:space="preserve">
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;spinnerPanel.Parent" xml:space="preserve">
<value>groupBoxOn</value>
@ -199,20 +199,23 @@
<value>1</value>
</data>
<data name="spinnerPanel.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="memorySpinnerDynMin" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="memorySpinnerDynMax" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="Percent,50,Percent,50,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="memorySpinnerDynMin" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="memorySpinnerDynMax" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,Absolute,50" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="vmShinyBar.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
</data>
<data name="vmShinyBar.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 22</value>
<value>3, 16</value>
</data>
<data name="vmShinyBar.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="vmShinyBar.Size" type="System.Drawing.Size, System.Drawing">
<data name="vmShinyBar.MinimumSize" type="System.Drawing.Size, System.Drawing">
<value>500, 90</value>
</data>
<data name="vmShinyBar.Size" type="System.Drawing.Size, System.Drawing">
<value>530, 90</value>
</data>
<data name="vmShinyBar.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
@ -237,6 +240,9 @@
<data name="radioOff.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 0, 3, 0</value>
</data>
<data name="radioOff.MinimumSize" type="System.Drawing.Size, System.Drawing">
<value>0, 25</value>
</data>
<data name="radioOff.Size" type="System.Drawing.Size, System.Drawing">
<value>126, 25</value>
</data>
@ -250,7 +256,7 @@
<value>radioOff</value>
</data>
<data name="&gt;&gt;radioOff.Type" xml:space="preserve">
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;radioOff.Parent" xml:space="preserve">
<value>$this</value>
@ -258,30 +264,6 @@
<data name="&gt;&gt;radioOff.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="memorySpinnerFixed.Location" type="System.Drawing.Point, System.Drawing">
<value>135, 0</value>
</data>
<data name="memorySpinnerFixed.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="memorySpinnerFixed.Size" type="System.Drawing.Size, System.Drawing">
<value>95, 25</value>
</data>
<data name="memorySpinnerFixed.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="&gt;&gt;memorySpinnerFixed.Name" xml:space="preserve">
<value>memorySpinnerFixed</value>
</data>
<data name="&gt;&gt;memorySpinnerFixed.Type" xml:space="preserve">
<value>XenAdmin.Controls.Ballooning.MemorySpinner, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;memorySpinnerFixed.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;memorySpinnerFixed.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="radioOn.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@ -304,19 +286,19 @@
<value>radioOn</value>
</data>
<data name="&gt;&gt;radioOn.Type" xml:space="preserve">
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;radioOn.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;radioOn.ZOrder" xml:space="preserve">
<value>4</value>
<value>5</value>
</data>
<data name="groupBoxOn.Location" type="System.Drawing.Point, System.Drawing">
<value>22, 48</value>
<value>3, 48</value>
</data>
<data name="groupBoxOn.Size" type="System.Drawing.Size, System.Drawing">
<value>520, 175</value>
<value>550, 178</value>
</data>
<data name="groupBoxOn.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
@ -325,13 +307,19 @@
<value>groupBoxOn</value>
</data>
<data name="&gt;&gt;groupBoxOn.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;groupBoxOn.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;groupBoxOn.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="iconDMCUnavailable.ErrorImage" type="System.Resources.ResXNullRef, System.Windows.Forms">
<value />
</data>
<data name="iconDMCUnavailable.InitialImage" type="System.Resources.ResXNullRef, System.Windows.Forms">
<value />
</data>
<data name="iconDMCUnavailable.Location" type="System.Drawing.Point, System.Drawing">
<value>22, 229</value>
@ -346,19 +334,19 @@
<value>iconDMCUnavailable</value>
</data>
<data name="&gt;&gt;iconDMCUnavailable.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;iconDMCUnavailable.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;iconDMCUnavailable.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="labelDMCUnavailable.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labelDMCUnavailable.Location" type="System.Drawing.Point, System.Drawing">
<value>44, 231</value>
<value>44, 229</value>
</data>
<data name="labelDMCUnavailable.Size" type="System.Drawing.Size, System.Drawing">
<value>204, 13</value>
@ -373,19 +361,19 @@
<value>labelDMCUnavailable</value>
</data>
<data name="&gt;&gt;labelDMCUnavailable.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelDMCUnavailable.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;labelDMCUnavailable.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="linkInstallTools.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="linkInstallTools.Location" type="System.Drawing.Point, System.Drawing">
<value>44, 248</value>
<value>44, 247</value>
</data>
<data name="linkInstallTools.Size" type="System.Drawing.Size, System.Drawing">
<value>139, 13</value>
@ -400,15 +388,39 @@
<value>linkInstallTools</value>
</data>
<data name="&gt;&gt;linkInstallTools.Type" xml:space="preserve">
<value>System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;linkInstallTools.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;linkInstallTools.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="memorySpinnerFixed.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<data name="memorySpinnerFixed.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="memorySpinnerFixed.Size" type="System.Drawing.Size, System.Drawing">
<value>143, 27</value>
</data>
<data name="memorySpinnerFixed.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="&gt;&gt;memorySpinnerFixed.Name" xml:space="preserve">
<value>memorySpinnerFixed</value>
</data>
<data name="&gt;&gt;memorySpinnerFixed.Type" xml:space="preserve">
<value>XenAdmin.Controls.Ballooning.MemorySpinner, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;memorySpinnerFixed.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;memorySpinnerFixed.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
@ -418,7 +430,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>552, 271</value>
<value>577, 341</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>VMMemoryControlsBasic</value>

View File

@ -60,8 +60,8 @@ namespace XenAdmin.Controls.Ballooning
}
}
private long _static_min;
protected long static_min
private double _static_min;
protected double static_min
{
get
{
@ -78,19 +78,19 @@ namespace XenAdmin.Controls.Ballooning
// base class of a control, otherwise the control can't be edited in the Designer.
[Browsable(false)]
public virtual long dynamic_min
public virtual double dynamic_min
{
get { return 0; }
}
[Browsable(false)]
public virtual long dynamic_max
public virtual double dynamic_max
{
get { return 0; }
}
[Browsable(false)]
public virtual long static_max
public virtual double static_max
{
get { return 0; }
}
@ -114,7 +114,7 @@ namespace XenAdmin.Controls.Ballooning
return ans;
}
protected long maxDynMin = -1; // signal value for no constraint
protected double maxDynMin = -1; // signal value for no constraint
protected void CalcMaxDynMin()
{
maxDynMin = -1;
@ -128,7 +128,7 @@ namespace XenAdmin.Controls.Ballooning
Host_metrics host_metrics = host.Connection.Resolve(host.metrics);
if (host_metrics != null)
{
long sum_dyn_min = host.memory_overhead;
double sum_dyn_min = host.memory_overhead;
foreach (VM vm in host.Connection.ResolveAll(host.resident_VMs))
{
@ -156,11 +156,11 @@ namespace XenAdmin.Controls.Ballooning
// Maximum for dynamic_min spinner: if we have set a maxDynMin, use it,
// except constrained by static_min and dynamic_max.
protected long DynMinSpinnerMax
protected double DynMinSpinnerMax
{
get
{
long maxDM = dynamic_max;
double maxDM = dynamic_max;
if (maxDynMin >= 0 && maxDynMin < maxDM)
{
maxDM = maxDynMin;
@ -175,12 +175,12 @@ namespace XenAdmin.Controls.Ballooning
}
// Minimum for dynamic_min spinner: constrained by both static_min, and a proportion of static_max
protected long DynMinSpinnerMin
protected double DynMinSpinnerMin
{
get
{
long minDM = static_min;
long limit = (long)((double)static_max * GetMemoryRatio());
double minDM = static_min;
long limit = (long)(static_max * GetMemoryRatio());
if (limit > minDM)
minDM = limit;
if (minDM > dynamic_min)
@ -191,13 +191,13 @@ namespace XenAdmin.Controls.Ballooning
// Static_max also has a corresponding limit: it can't go to more than 1/frac of maxDynMin,
// or there is no legal value of dynamic_min.
protected long StatMaxSpinnerMax
protected double StatMaxSpinnerMax
{
get
{
double frac = GetMemoryRatio();
long maxSM = maxDynMin >= 0 && MemorySpinnerMax * frac > maxDynMin
? (long)((double)maxDynMin / frac)
double maxSM = maxDynMin >= 0 && MemorySpinnerMax * frac > (long)maxDynMin
? maxDynMin / frac
: MemorySpinnerMax;
if (maxSM < static_max)
maxSM = static_max;
@ -205,22 +205,29 @@ namespace XenAdmin.Controls.Ballooning
}
}
protected long MemorySpinnerMax
protected double MemorySpinnerMax
{
get
{
long server = vm0.memory_static_max;
double server = vm0.memory_static_max;
return (server > maxMemAllowed ? server : maxMemAllowed);
}
}
protected int CalcIncrement()
protected double CalcIncrement(string units)
{
// Calculate a suitable increment for dynamic_min and dynamic_max, if static_max small
int i;
for (i = 1; i < static_max / Util.BINARY_MEGA / 8 && i < 128; i *= 2)
;
return i;
if (units == "MB")
{
// Calculate a suitable increment for dynamic_min and dynamic_max, if static_max small
int i;
for (i = 1; i < static_max / Util.BINARY_MEGA / 8 && i < 128; i *= 2)
;
return i * Util.BINARY_MEGA;
}
else
{
return (0.1 * Util.BINARY_GIGA);
}
}
protected double GetMemoryRatio()

View File

@ -51,7 +51,6 @@ namespace XenAdmin.Controls.Ballooning
resources.ApplyResources(this.iconBoxDynMin, "iconBoxDynMin");
this.iconBoxDynMin.BackColor = System.Drawing.Color.Transparent;
this.iconBoxDynMin.Image = global::XenAdmin.Properties.Resources.memory_dynmin_slider_noedit_small;
this.iconBoxDynMin.InitialImage = null;
this.iconBoxDynMin.Name = "iconBoxDynMin";
this.iconBoxDynMin.TabStop = false;
//
@ -60,7 +59,6 @@ namespace XenAdmin.Controls.Ballooning
resources.ApplyResources(this.iconBoxDynMax, "iconBoxDynMax");
this.iconBoxDynMax.BackColor = System.Drawing.Color.Transparent;
this.iconBoxDynMax.Image = global::XenAdmin.Properties.Resources.memory_dynmax_slider_noedit_small;
this.iconBoxDynMax.InitialImage = null;
this.iconBoxDynMax.Name = "iconBoxDynMax";
this.iconBoxDynMax.TabStop = false;
//
@ -128,7 +126,6 @@ namespace XenAdmin.Controls.Ballooning
// vmShinyBar
//
resources.ApplyResources(this.vmShinyBar, "vmShinyBar");
this.vmShinyBar.Increment = ((long)(0));
this.vmShinyBar.Name = "vmShinyBar";
//
// VMMemoryControlsNoEdit
@ -148,7 +145,6 @@ namespace XenAdmin.Controls.Ballooning
this.Controls.Add(this.iconBoxDynMax);
this.Controls.Add(this.iconBoxDynMin);
this.Controls.Add(this.vmShinyBar);
this.MinimumSize = new System.Drawing.Size(700, 90);
this.Name = "VMMemoryControlsNoEdit";
((System.ComponentModel.ISupportInitialize)(this.iconBoxDynMin)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.iconBoxDynMax)).EndInit();

View File

@ -84,16 +84,16 @@ namespace XenAdmin.Controls.Ballooning
bool ballooning = vm0.has_ballooning;
if (ballooning)
{
valueDynMin.Text = Util.ToMB(vm0.memory_dynamic_min).ToString();
valueDynMax.Text = Util.ToMB(vm0.memory_dynamic_max).ToString();
valueDynMin.Text = Util.MemorySizeStringSuitableUnits(vm0.memory_dynamic_min, true);
valueDynMax.Text = Util.MemorySizeStringSuitableUnits(vm0.memory_dynamic_max, true);
if (vm0.memory_dynamic_max == vm0.memory_static_max)
labelStatMax.Visible = valueStatMax.Visible = unitsStatMax.Visible = false;
else
valueStatMax.Text = Util.ToMB(vm0.memory_static_max).ToString();
valueStatMax.Text = Util.MemorySizeStringSuitableUnits(vm0.memory_static_max, true);
}
else
{
valueDynMin.Text = Util.ToMB(vm0.memory_static_max).ToString();
valueDynMin.Text = Util.MemorySizeStringSuitableUnits(vm0.memory_static_max, true);
iconBoxDynMin.Visible = false;
labelDynMin.Text = Messages.MEMORY;

View File

@ -112,19 +112,22 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="iconBoxDynMin.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="iconBoxDynMin.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="iconBoxDynMin.InitialImage" type="System.Resources.ResXNullRef, System.Windows.Forms">
<value />
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="iconBoxDynMin.Location" type="System.Drawing.Point, System.Drawing">
<value>480, 35</value>
</data>
@ -134,7 +137,7 @@
<data name="iconBoxDynMin.Size" type="System.Drawing.Size, System.Drawing">
<value>7, 13</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="iconBoxDynMin.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
@ -142,7 +145,7 @@
<value>iconBoxDynMin</value>
</data>
<data name="&gt;&gt;iconBoxDynMin.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;iconBoxDynMin.Parent" xml:space="preserve">
<value>$this</value>
@ -156,6 +159,9 @@
<data name="iconBoxDynMax.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="iconBoxDynMax.InitialImage" type="System.Resources.ResXNullRef, System.Windows.Forms">
<value />
</data>
<data name="iconBoxDynMax.Location" type="System.Drawing.Point, System.Drawing">
<value>480, 54</value>
</data>
@ -169,7 +175,7 @@
<value>iconBoxDynMax</value>
</data>
<data name="&gt;&gt;iconBoxDynMax.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;iconBoxDynMax.Parent" xml:space="preserve">
<value>$this</value>
@ -208,7 +214,7 @@
<value>labelDynMin</value>
</data>
<data name="&gt;&gt;labelDynMin.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelDynMin.Parent" xml:space="preserve">
<value>$this</value>
@ -244,7 +250,7 @@
<value>labelDynMax</value>
</data>
<data name="&gt;&gt;labelDynMax.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelDynMax.Parent" xml:space="preserve">
<value>$this</value>
@ -280,7 +286,7 @@
<value>labelStatMax</value>
</data>
<data name="&gt;&gt;labelStatMax.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelStatMax.Parent" xml:space="preserve">
<value>$this</value>
@ -313,7 +319,7 @@
<value>valueDynMin</value>
</data>
<data name="&gt;&gt;valueDynMin.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;valueDynMin.Parent" xml:space="preserve">
<value>$this</value>
@ -346,7 +352,7 @@
<value>valueDynMax</value>
</data>
<data name="&gt;&gt;valueDynMax.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;valueDynMax.Parent" xml:space="preserve">
<value>$this</value>
@ -379,7 +385,7 @@
<value>valueStatMax</value>
</data>
<data name="&gt;&gt;valueStatMax.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;valueStatMax.Parent" xml:space="preserve">
<value>$this</value>
@ -405,9 +411,6 @@
<data name="unitsDynMin.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="unitsDynMin.Text" xml:space="preserve">
<value>MB</value>
</data>
<data name="unitsDynMin.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value>
</data>
@ -415,7 +418,7 @@
<value>unitsDynMin</value>
</data>
<data name="&gt;&gt;unitsDynMin.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;unitsDynMin.Parent" xml:space="preserve">
<value>$this</value>
@ -441,9 +444,6 @@
<data name="unitsDynMax.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="unitsDynMax.Text" xml:space="preserve">
<value>MB</value>
</data>
<data name="unitsDynMax.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value>
</data>
@ -451,7 +451,7 @@
<value>unitsDynMax</value>
</data>
<data name="&gt;&gt;unitsDynMax.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;unitsDynMax.Parent" xml:space="preserve">
<value>$this</value>
@ -477,9 +477,6 @@
<data name="unitsStatMax.TabIndex" type="System.Int32, mscorlib">
<value>11</value>
</data>
<data name="unitsStatMax.Text" xml:space="preserve">
<value>MB</value>
</data>
<data name="unitsStatMax.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleCenter</value>
</data>
@ -487,7 +484,7 @@
<value>unitsStatMax</value>
</data>
<data name="&gt;&gt;unitsStatMax.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;unitsStatMax.Parent" xml:space="preserve">
<value>$this</value>
@ -520,7 +517,7 @@
<value>editButton</value>
</data>
<data name="&gt;&gt;editButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;editButton.Parent" xml:space="preserve">
<value>$this</value>
@ -555,7 +552,7 @@
<data name="&gt;&gt;vmShinyBar.ZOrder" xml:space="preserve">
<value>12</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
@ -564,6 +561,9 @@
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="$this.MinimumSize" type="System.Drawing.Size, System.Drawing">
<value>700, 90</value>
</data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>700, 90</value>
</data>

View File

@ -53,26 +53,27 @@ namespace XenAdmin.Controls.Ballooning
// Variables passed in
private long memoryUsed;
private long static_min, static_max, dynamic_min, dynamic_max, dynamic_min_orig, dynamic_max_orig;
public long dynamic_min_lowlimit, dynamic_min_highlimit, dynamic_max_lowlimit, dynamic_max_highlimit;
private double static_min, static_max, dynamic_min, dynamic_max, dynamic_min_orig, dynamic_max_orig;
public double dynamic_min_lowlimit, dynamic_min_highlimit, dynamic_max_lowlimit, dynamic_max_highlimit;
private bool has_ballooning;
private bool allowEdit;
private bool multiple;
// The increment in which the user can move the draggers, in MB
long increment;
public long Increment
// The increment in which the user can move the draggers, in bytes
double increment;
public double Increment
{
get { return increment; }
set { increment = value; }
}
public long Dynamic_min
public double Dynamic_min
{
get { return dynamic_min; }
}
public long Dynamic_max
public double Dynamic_max
{
get { return dynamic_max; }
}
@ -82,19 +83,33 @@ namespace XenAdmin.Controls.Ballooning
get { return Dynamic_min == Dynamic_max; }
}
public void SetRanges(long dynamic_min_lowlimit, long dynamic_min_highlimit, long dynamic_max_lowlimit, long dynamic_max_highlimit)
public void SetRanges(double dynamic_min_lowlimit, double dynamic_min_highlimit, double dynamic_max_lowlimit, double dynamic_max_highlimit, string units)
{
// Round to nearest MB inwards to agree with MemorySpinner and avoid bugs like CA-34996.
long lowMB, highMB;
MemorySpinner.CalcMBRanges(dynamic_min_lowlimit, dynamic_min_highlimit, out lowMB, out highMB);
this.dynamic_min_lowlimit = lowMB * Util.BINARY_MEGA;
this.dynamic_min_highlimit = highMB * Util.BINARY_MEGA;
MemorySpinner.CalcMBRanges(dynamic_max_lowlimit, dynamic_max_highlimit, out lowMB, out highMB);
this.dynamic_max_lowlimit = lowMB * Util.BINARY_MEGA;
this.dynamic_max_highlimit = highMB * Util.BINARY_MEGA;
if(units == "MB")
{
// Round to nearest MB inwards to agree with MemorySpinner and avoid bugs like CA-34996.
double lowMB, highMB;
MemorySpinner.CalcMBRanges(dynamic_min_lowlimit, dynamic_min_highlimit, out lowMB, out highMB);
this.dynamic_min_lowlimit = lowMB * Util.BINARY_MEGA;
this.dynamic_min_highlimit = highMB * Util.BINARY_MEGA;
MemorySpinner.CalcMBRanges(dynamic_max_lowlimit, dynamic_max_highlimit, out lowMB, out highMB);
this.dynamic_max_lowlimit = lowMB * Util.BINARY_MEGA;
this.dynamic_max_highlimit = highMB * Util.BINARY_MEGA;
}
else
{
// Round to nearest GB inwards to agree with MemorySpinner and avoid bugs like CA-34996.
double lowGB, highGB;
MemorySpinner.CalcGBRanges(dynamic_min_lowlimit, dynamic_min_highlimit, out lowGB, out highGB);
this.dynamic_min_lowlimit = lowGB * Util.BINARY_GIGA;
this.dynamic_min_highlimit = highGB * Util.BINARY_GIGA;
MemorySpinner.CalcGBRanges(dynamic_max_lowlimit, dynamic_max_highlimit, out lowGB, out highGB);
this.dynamic_max_lowlimit = lowGB * Util.BINARY_GIGA;
this.dynamic_max_highlimit = highGB * Util.BINARY_GIGA;
}
}
private long SliderMinLimit
private double SliderMinLimit
{
get
{
@ -103,7 +118,7 @@ namespace XenAdmin.Controls.Ballooning
}
}
private long SliderMaxLimit
private double SliderMaxLimit
{
get
{
@ -127,13 +142,13 @@ namespace XenAdmin.Controls.Ballooning
this.memoryUsed = memoryUsed;
this.static_min = vm.memory_static_min;
this.static_max = vm.memory_static_max;
this.dynamic_min = dynamic_min_orig = vm.memory_dynamic_min;
this.dynamic_max = dynamic_max_orig = vm.memory_dynamic_max;
this.dynamic_min = dynamic_min_orig = Util.CorrectRoundingErrors(vm.memory_dynamic_min);
this.dynamic_max = dynamic_max_orig = Util.CorrectRoundingErrors(vm.memory_dynamic_max);
this.has_ballooning = vm.has_ballooning;
this.allowEdit = allowEdit;
}
public void ChangeSettings(long static_min, long dynamic_min, long dynamic_max, long static_max)
public void ChangeSettings(double static_min, double dynamic_min, double dynamic_max, double static_max)
{
this.static_min = static_min;
@ -150,7 +165,7 @@ namespace XenAdmin.Controls.Ballooning
this.dynamic_max = dynamic_max_orig = dynamic_max;
}
private void SetMemory(Slider slider, long bytes)
private void SetMemory(Slider slider, double bytes)
{
bool dragged = false;
if (slider == Slider.MIN && dynamic_min != bytes)
@ -192,7 +207,7 @@ namespace XenAdmin.Controls.Ballooning
if (left_width > barArea.Width) // Happens if the user is reducing static_max to below current memory usage.
left_width = barArea.Width; // I wanted to add a right-arrow to the bytesString in that case too, but the glyph isn't present in the font: and too much work to add an image.
Rectangle rect = new Rectangle(barArea.Left, barArea.Top, left_width, barArea.Height);
string bytesString = Util.SuperiorSizeString(memoryUsed, 0);
string bytesString = Util.MemorySizeStringSuitableUnits(memoryUsed, false);
string toolTip = string.Format(multiple ? Messages.CURRENT_MEMORY_USAGE_MULTIPLE : Messages.CURRENT_MEMORY_USAGE, bytesString);
DrawToTarget(g, barArea, rect, BallooningColors.VMShinyBar_Used, bytesString, BallooningColors.VMShinyBar_Text, HorizontalAlignment.Right, toolTip);
@ -215,26 +230,28 @@ namespace XenAdmin.Controls.Ballooning
mouseLocation = e.Location;
if (activeSlider != Slider.NONE)
{
long min = SliderMinLimit;
long max = SliderMaxLimit;
long orig = (activeSlider == Slider.MIN ? dynamic_min_orig : dynamic_max_orig);
long posBytes = (long)((mouseLocation.X - barRect.Left) * BytesPerPixel);
double min = SliderMinLimit;
double max = SliderMaxLimit;
double orig = (activeSlider == Slider.MIN ? dynamic_min_orig : dynamic_max_orig);
double posBytes = (mouseLocation.X - barRect.Left) * BytesPerPixel;
if (posBytes <= min)
posBytes = min;
else if (posBytes >= max)
posBytes = max;
else
{
long incrBytes = Increment * Util.BINARY_MEGA;
double incrBytes = Increment;
// round to nearest incrBytes
long roundedBytes = (posBytes + incrBytes / 2) / incrBytes * incrBytes;
// We need to do a rounding because the result should always have only 1 dp. If it does not have
// 1 dp it is not because of the formula, but because of the way the computer does the calculation.
double roundedBytes = Math.Round((int)((posBytes + incrBytes / 2) / incrBytes) * incrBytes, 1);
// We also allow the original value, even if it's not a multiple of
// incrBytes. That's so that we don't jump as soon as we click it
// (also so that we can get back to the original value if we want to).
long distRound = (posBytes - roundedBytes > 0 ? posBytes - roundedBytes : roundedBytes - posBytes);
long distOrig = (posBytes - orig > 0 ? posBytes - orig : orig - posBytes);
double distRound = (posBytes - roundedBytes > 0 ? posBytes - roundedBytes : roundedBytes - posBytes);
double distOrig = (posBytes - orig > 0 ? posBytes - orig : orig - posBytes);
if (distRound >= distOrig)
roundedBytes = orig;
@ -303,8 +320,8 @@ namespace XenAdmin.Controls.Ballooning
Rectangle barArea = barRect;
const int Height = 10;
int min = barArea.Left + (int)((double)SliderMinLimit / BytesPerPixel);
int max = barArea.Left + (int)((double)SliderMaxLimit / BytesPerPixel);
int min = barArea.Left + (int)(SliderMinLimit / BytesPerPixel);
int max = barArea.Left + (int)(SliderMaxLimit / BytesPerPixel);
using (Brush brush = new SolidBrush(BallooningColors.SliderLimits))
{
@ -312,7 +329,7 @@ namespace XenAdmin.Controls.Ballooning
}
}
private void DrawSliders(Graphics g, long min, long max)
private void DrawSliders(Graphics g, double min, double max)
{
Rectangle barArea = barRect;
Image min_image, max_image;
@ -328,8 +345,8 @@ namespace XenAdmin.Controls.Ballooning
}
// Calculate where to draw the sliders
Point min_pt = new Point(barArea.Left + (int)((double)min / BytesPerPixel) - min_image.Width + (allowEdit ? 0 : 1), barArea.Bottom);
Point max_pt = new Point(barArea.Left + (int)((double)max / BytesPerPixel) - (allowEdit ? 0 : 1), barArea.Bottom);
Point min_pt = new Point(barArea.Left + (int)(min / BytesPerPixel) - min_image.Width + (allowEdit ? 0 : 1), barArea.Bottom);
Point max_pt = new Point(barArea.Left + (int)(max / BytesPerPixel) - (allowEdit ? 0 : 1), barArea.Bottom);
min_slider_rect = new Rectangle(min_pt, min_image.Size);
max_slider_rect = new Rectangle(max_pt, max_image.Size);

View File

@ -206,7 +206,7 @@ namespace XenAdmin.Controls.CustomDataGraph
dataSet.Name = Helpers.GetFriendlyDataSourceName("memory_internal_used", dataSet.XenObject);
VM vm = (VM)xo;
VM_metrics metrics = vm.Connection.Resolve(vm.metrics);
long max = metrics != null ? metrics.memory_actual : vm.memory_dynamic_max;
long max = metrics != null ? metrics.memory_actual : (long)vm.memory_dynamic_max;
dataSet.CustomYRange = new DataRange(max, 0, max / 10d, Unit.Bytes, RangeScaleMode.Delegate)
{
UpdateMax = dataSet.GetMemoryMax,
@ -396,7 +396,7 @@ namespace XenAdmin.Controls.CustomDataGraph
{
VM vm = (VM)xmo;
VM_metrics metrics = vm.Connection.Resolve(vm.metrics);
return ((metrics != null ? metrics.memory_actual : vm.memory_dynamic_max) / 10d);
return ((metrics != null ? metrics.memory_actual : (long)vm.memory_dynamic_max) / 10d);
}
return 10;
}

View File

@ -210,7 +210,7 @@ namespace XenAdmin.Controls.GPU
else
maxDisplaysColumn.Value = string.Empty;
videoRamColumn.Value = VGpuType.framebuffer_size != 0 ? Util.SuperiorSizeString(VGpuType.framebuffer_size, 0) : string.Empty;
videoRamColumn.Value = VGpuType.framebuffer_size != 0 ? Util.MemorySizeStringMB(VGpuType.framebuffer_size) : string.Empty;
}
private void SetupCheckBoxCell()

View File

@ -112,16 +112,16 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="rubric.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
<value>Segoe UI, 9pt</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="rubric.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
@ -131,7 +131,7 @@
<data name="rubric.Size" type="System.Drawing.Size, System.Drawing">
<value>263, 36</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="rubric.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
@ -139,7 +139,7 @@
<value>rubric</value>
</data>
<data name="&gt;&gt;rubric.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;rubric.Parent" xml:space="preserve">
<value>$this</value>
@ -148,7 +148,7 @@
<value>3</value>
</data>
<data name="memoryControlsAdvanced.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
<value>Segoe UI, 9pt</value>
</data>
<data name="memoryControlsAdvanced.Location" type="System.Drawing.Point, System.Drawing">
<value>9, 20</value>
@ -157,7 +157,7 @@
<value>6, 6, 6, 6</value>
</data>
<data name="memoryControlsAdvanced.Size" type="System.Drawing.Size, System.Drawing">
<value>220, 75</value>
<value>267, 86</value>
</data>
<data name="memoryControlsAdvanced.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
@ -178,10 +178,10 @@
<value>Bottom, Right</value>
</data>
<data name="buttonOK.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
<value>Segoe UI, 9pt</value>
</data>
<data name="buttonOK.Location" type="System.Drawing.Point, System.Drawing">
<value>130, 187</value>
<value>135, 187</value>
</data>
<data name="buttonOK.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
@ -196,7 +196,7 @@
<value>buttonOK</value>
</data>
<data name="&gt;&gt;buttonOK.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonOK.Parent" xml:space="preserve">
<value>$this</value>
@ -208,10 +208,10 @@
<value>Bottom, Right</value>
</data>
<data name="buttonCancel.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
<value>Segoe UI, 9pt</value>
</data>
<data name="buttonCancel.Location" type="System.Drawing.Point, System.Drawing">
<value>211, 187</value>
<value>216, 187</value>
</data>
<data name="buttonCancel.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
@ -226,7 +226,7 @@
<value>buttonCancel</value>
</data>
<data name="&gt;&gt;buttonCancel.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonCancel.Parent" xml:space="preserve">
<value>$this</value>
@ -238,13 +238,13 @@
<value>Top, Left, Right</value>
</data>
<data name="groupBox1.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>
<value>Segoe UI, 9pt</value>
</data>
<data name="groupBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 51</value>
</data>
<data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>246, 115</value>
<value>279, 115</value>
</data>
<data name="groupBox1.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
@ -253,7 +253,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;groupBox1.Type" xml:space="preserve">
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;groupBox1.Parent" xml:space="preserve">
<value>$this</value>
@ -261,14 +261,14 @@
<data name="&gt;&gt;groupBox1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>96, 96</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>298, 222</value>
<value>303, 222</value>
</data>
<data name="$this.Font" type="System.Drawing.Font, System.Drawing">
<value>Tahoma, 8pt</value>

View File

@ -62,7 +62,7 @@ namespace XenAdmin.Dialogs
vmList = new List<VM>(1);
vmList.Add(vm);
origStaticMax = vm.memory_static_max;
origStaticMax = (long)vm.memory_static_max;
this.advanced = advanced;
}
@ -82,9 +82,9 @@ namespace XenAdmin.Dialogs
{
memoryControls.UnfocusSpinners();
if (ConfirmAndChange(this, vmList,
vmList[0].has_ballooning ? memoryControls.dynamic_min : memoryControls.static_max, // dynamic_min and _max should stay equal to static_max for VMs without ballooning
vmList[0].has_ballooning ? memoryControls.dynamic_max : memoryControls.static_max,
memoryControls.static_max, origStaticMax, advanced))
vmList[0].has_ballooning ? (long)memoryControls.dynamic_min : (long)memoryControls.static_max, // dynamic_min and _max should stay equal to static_max for VMs without ballooning
vmList[0].has_ballooning ? (long)memoryControls.dynamic_max : (long)memoryControls.static_max,
(long)memoryControls.static_max, origStaticMax, advanced))
{
Close();
}
@ -134,7 +134,7 @@ namespace XenAdmin.Dialogs
ChangeMemorySettingsAction action = new ChangeMemorySettingsAction(
vm,
string.Format(Messages.ACTION_CHANGE_MEMORY_SETTINGS, vm.Name),
vm.memory_static_min, dynamic_min, dynamic_max, static_max,VMOperationCommand.WarningDialogHAInvalidConfig,VMOperationCommand.StartDiagnosisForm, suppressHistory);
(long)vm.memory_static_min, dynamic_min, dynamic_max, static_max,VMOperationCommand.WarningDialogHAInvalidConfig,VMOperationCommand.StartDiagnosisForm, suppressHistory);
actions.Add(action);
}

View File

@ -90,7 +90,7 @@ namespace XenAdmin.Dialogs.VMDialogs
PoolMemoryFree += host.memory_free_calc;
}
return Util.MemorySizeString(PoolMemoryFree);
return Util.MemorySizeStringMB(PoolMemoryFree);
}
private void UpdateRequiredMemory()
@ -101,10 +101,10 @@ namespace XenAdmin.Dialogs.VMDialogs
if (row.Action != ActionCellAction.Migrate)
continue;
required += row.Vm.memory_dynamic_max;
required += (long)row.Vm.memory_dynamic_max;
}
RequiredLabel.ForeColor = required > PoolMemoryFree ? Color.Red : ForeColor;
RequiredLabel.Text = Util.MemorySizeString(required);
RequiredLabel.Text = Util.MemorySizeStringMB(required);
OKButton.Enabled = required == 0 ? true : required < PoolMemoryFree;
}
@ -206,7 +206,7 @@ namespace XenAdmin.Dialogs.VMDialogs
{
ImageCell.Value = Images.GetImage16For(Images.GetIconFor(Vm));
NameCell.Value = Vm.Name;
MemoryCell.Value = Util.MemorySizeString(Vm.memory_dynamic_max);
MemoryCell.Value = Util.MemorySizeStringMB(Vm.memory_dynamic_max);
ActionCell.ValueType = typeof(ActionCellItem);
ActionCell.ValueMember = "ActionCell";
ActionCell.DisplayMember = "Text";

View File

@ -549,16 +549,16 @@ namespace XenAdmin
log.InfoFormat("GDI handles open: {0}", Win32.GetGuiResourcesGDICount(p.Handle));
log.InfoFormat("Thread count: {0}", p.Threads.Count);
log.InfoFormat("Virtual memory size: {0}", Util.MemorySizeString(p.VirtualMemorySize64));
log.InfoFormat("Working set: {0}", Util.MemorySizeString(p.WorkingSet64));
log.InfoFormat("Private memory size: {0}", Util.MemorySizeString(p.PrivateMemorySize64));
log.InfoFormat("Nonpaged system memory size: {0}", Util.MemorySizeString(p.NonpagedSystemMemorySize64));
log.InfoFormat("Paged memory size: {0}", Util.MemorySizeString(p.PagedMemorySize64));
log.InfoFormat("Paged system memory size: {0}", Util.MemorySizeString(p.PagedSystemMemorySize64));
log.InfoFormat("Virtual memory size: {0}", Util.MemorySizeStringMB(p.VirtualMemorySize64));
log.InfoFormat("Working set: {0}", Util.MemorySizeStringMB(p.WorkingSet64));
log.InfoFormat("Private memory size: {0}", Util.MemorySizeStringMB(p.PrivateMemorySize64));
log.InfoFormat("Nonpaged system memory size: {0}", Util.MemorySizeStringMB(p.NonpagedSystemMemorySize64));
log.InfoFormat("Paged memory size: {0}", Util.MemorySizeStringMB(p.PagedMemorySize64));
log.InfoFormat("Paged system memory size: {0}", Util.MemorySizeStringMB(p.PagedSystemMemorySize64));
log.InfoFormat("Peak paged memory size: {0}", Util.MemorySizeString(p.PeakPagedMemorySize64));
log.InfoFormat("Peak virtual memory size: {0}", Util.MemorySizeString(p.PeakVirtualMemorySize64));
log.InfoFormat("Peak working set: {0}", Util.MemorySizeString(p.PeakWorkingSet64));
log.InfoFormat("Peak paged memory size: {0}", Util.MemorySizeStringMB(p.PeakPagedMemorySize64));
log.InfoFormat("Peak virtual memory size: {0}", Util.MemorySizeStringMB(p.PeakVirtualMemorySize64));
log.InfoFormat("Peak working set: {0}", Util.MemorySizeStringMB(p.PeakWorkingSet64));
log.InfoFormat("Process priority class: {0}", p.PriorityClass.ToString());
log.InfoFormat("Privileged processor time: {0}", p.PrivilegedProcessorTime.ToString());

View File

@ -67,7 +67,7 @@ namespace XenAdmin.SettingsPanels
if (MROrGreater && HasMemoryChanged)
{
long mem = Convert.ToInt64(this.nudMemory.Value * Util.BINARY_MEGA);
memoryAction = BallooningDialogBase.ConfirmAndReturnAction(Program.MainWindow, vm, mem, mem, mem, vm.memory_static_max, false);
memoryAction = BallooningDialogBase.ConfirmAndReturnAction(Program.MainWindow, vm, mem, mem, mem, (long)vm.memory_static_max, false);
if (memoryAction == null)
return false;
}
@ -106,7 +106,7 @@ namespace XenAdmin.SettingsPanels
void nudMemory_LostFocus(object sender, EventArgs e)
{
ValidateNud(nudMemory, vm.memory_static_max / Util.BINARY_MEGA);
ValidateNud(nudMemory, (decimal)vm.memory_static_max / Util.BINARY_MEGA);
}
private void ValidateNud(NumericUpDown nud, Decimal defaultValue)

View File

@ -317,9 +317,9 @@ namespace XenAdmin.TabPages
{
MemSettings settings =
vm.has_ballooning?
new MemSettings(true, vm.power_state, vm.memory_static_min, vm.memory_static_max,
vm.memory_dynamic_min, vm.memory_dynamic_max) :
new MemSettings(false, vm.power_state, 0, vm.memory_static_max, 0, 0); // don't consider other mem settings if ballooning off
new MemSettings(true, vm.power_state, (long)vm.memory_static_min, (long)vm.memory_static_max,
(long)vm.memory_dynamic_min, (long)vm.memory_dynamic_max) :
new MemSettings(false, vm.power_state, 0, (long)vm.memory_static_max, 0, 0); // don't consider other mem settings if ballooning off
if (!settingsToVMs.ContainsKey(settings)) // we've not seen these settings on another VM
{
settingsToVMs.Add(settings, new List<VM>());

View File

@ -112,20 +112,20 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="tableLayoutPanel.ColumnCount" type="System.Int32, mscorlib">
<value>1</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="buttonNewSearch.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="buttonNewSearch.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 6</value>
</data>
@ -145,7 +145,7 @@
<value>buttonNewSearch</value>
</data>
<data name="&gt;&gt;buttonNewSearch.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonNewSearch.Parent" xml:space="preserve">
<value>panel2</value>
@ -172,7 +172,7 @@
<value>buttonEditSearch</value>
</data>
<data name="&gt;&gt;buttonEditSearch.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonEditSearch.Parent" xml:space="preserve">
<value>panel2</value>
@ -180,7 +180,7 @@
<data name="&gt;&gt;buttonEditSearch.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<metadata name="contextMenuStripSearches.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="contextMenuStripSearches.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>31, 21</value>
</metadata>
<data name="contextMenuStripSearches.Size" type="System.Drawing.Size, System.Drawing">
@ -190,7 +190,7 @@
<value>contextMenuStripSearches</value>
</data>
<data name="&gt;&gt;contextMenuStripSearches.Type" xml:space="preserve">
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="ddButtonSavedSearches.Location" type="System.Drawing.Point, System.Drawing">
<value>186, 6</value>
@ -244,7 +244,7 @@
<value>buttonExport</value>
</data>
<data name="&gt;&gt;buttonExport.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonExport.Parent" xml:space="preserve">
<value>panel2</value>
@ -271,7 +271,7 @@
<value>buttonImport</value>
</data>
<data name="&gt;&gt;buttonImport.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;buttonImport.Parent" xml:space="preserve">
<value>panel2</value>
@ -298,7 +298,7 @@
<value>panel2</value>
</data>
<data name="&gt;&gt;panel2.Type" xml:space="preserve">
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;panel2.Parent" xml:space="preserve">
<value>tableLayoutPanel</value>
@ -355,7 +355,7 @@
<value>panel4</value>
</data>
<data name="&gt;&gt;panel4.Type" xml:space="preserve">
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;panel4.Parent" xml:space="preserve">
<value>tableLayoutPanel</value>
@ -418,7 +418,7 @@
<value>tableLayoutPanel</value>
</data>
<data name="&gt;&gt;tableLayoutPanel.Type" xml:space="preserve">
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;tableLayoutPanel.Parent" xml:space="preserve">
<value>pageContainerPanel</value>
@ -439,7 +439,7 @@
<value>pageContainerPanel</value>
</data>
<data name="&gt;&gt;pageContainerPanel.Type" xml:space="preserve">
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pageContainerPanel.Parent" xml:space="preserve">
<value>$this</value>
@ -447,7 +447,7 @@
<data name="&gt;&gt;pageContainerPanel.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">

View File

@ -89,10 +89,10 @@ namespace XenAdmin.Wizards
{
xenTabPageSettings.UnfocusSpinners();
bool canCloseWizard = BallooningDialogBase.ConfirmAndChange(this, xenTabPageVMs.CheckedVMs,
has_ballooning ? xenTabPageSettings.dynamic_min : xenTabPageSettings.static_max,
has_ballooning ? (long)xenTabPageSettings.dynamic_min : (long)xenTabPageSettings.static_max,
// dynamic_min and _max should stay equal to static_max for VMs without ballooning
has_ballooning ? xenTabPageSettings.dynamic_max : xenTabPageSettings.static_max,
xenTabPageSettings.static_max, origStaticMax, xenTabPageSettings.AdvancedMode);
has_ballooning ? (long)xenTabPageSettings.dynamic_max : (long)xenTabPageSettings.static_max,
(long)xenTabPageSettings.static_max, origStaticMax, xenTabPageSettings.AdvancedMode);
if (canCloseWizard)
base.FinishWizard();
else

View File

@ -90,17 +90,17 @@ namespace XenAdmin.Wizards.BallooningWizard_Pages
memoryControls.Visible = true;
}
public long static_max
public double static_max
{
get { return memoryControls.static_max; }
}
public long dynamic_min
public double dynamic_min
{
get { return memoryControls.dynamic_min; }
}
public long dynamic_max
public double dynamic_max
{
get { return memoryControls.dynamic_max; }
}

View File

@ -112,16 +112,16 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="memoryControlsBasic.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="memoryControlsBasic.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 74</value>
</data>
@ -131,7 +131,7 @@
<data name="memoryControlsBasic.Size" type="System.Drawing.Size, System.Drawing">
<value>558, 319</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="memoryControlsBasic.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
@ -196,7 +196,7 @@
<value>label1</value>
</data>
<data name="&gt;&gt;label1.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label1.Parent" xml:space="preserve">
<value>$this</value>
@ -204,7 +204,7 @@
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AccessibleDescription" xml:space="preserve">

View File

@ -167,9 +167,9 @@ namespace XenAdmin.Wizards.NewVMWizard
page_3_InstallationMedia.SelectedUrl,
m_affinity,
page_5_CpuMem.SelectedVcpus,
page_5_CpuMem.SelectedMemoryDynamicMin,
page_5_CpuMem.SelectedMemoryDynamicMax,
page_5_CpuMem.SelectedMemoryStaticMax,
(long)page_5_CpuMem.SelectedMemoryDynamicMin,
(long)page_5_CpuMem.SelectedMemoryDynamicMax,
(long)page_5_CpuMem.SelectedMemoryStaticMax,
page_6b_LunPerVdi.MapLunsToVdisRequired
? page_6b_LunPerVdi.MappedDisks
: page_6_Storage.SelectedDisks,

View File

@ -62,7 +62,7 @@ namespace XenAdmin.Wizards.NewVMWizard
//
// label5
//
this.tableLayoutPanel1.SetColumnSpan(this.label5, 3);
this.tableLayoutPanel1.SetColumnSpan(this.label5, 2);
resources.ApplyResources(this.label5, "label5");
this.label5.Name = "label5";
//
@ -90,6 +90,7 @@ namespace XenAdmin.Wizards.NewVMWizard
this.tableLayoutPanel1.SetColumnSpan(this.spinnerDynMin, 2);
resources.ApplyResources(this.spinnerDynMin, "spinnerDynMin");
this.spinnerDynMin.Name = "spinnerDynMin";
this.spinnerDynMin.Units = "GB";
this.spinnerDynMin.SpinnerValueChanged += new System.EventHandler(this.memory_ValueChanged);
//
// spinnerDynMax
@ -97,6 +98,7 @@ namespace XenAdmin.Wizards.NewVMWizard
this.tableLayoutPanel1.SetColumnSpan(this.spinnerDynMax, 2);
resources.ApplyResources(this.spinnerDynMax, "spinnerDynMax");
this.spinnerDynMax.Name = "spinnerDynMax";
this.spinnerDynMax.Units = "GB";
this.spinnerDynMax.SpinnerValueChanged += new System.EventHandler(this.memory_ValueChanged);
//
// spinnerStatMax
@ -104,6 +106,7 @@ namespace XenAdmin.Wizards.NewVMWizard
this.tableLayoutPanel1.SetColumnSpan(this.spinnerStatMax, 2);
resources.ApplyResources(this.spinnerStatMax, "spinnerStatMax");
this.spinnerStatMax.Name = "spinnerStatMax";
this.spinnerStatMax.Units = "GB";
this.spinnerStatMax.SpinnerValueChanged += new System.EventHandler(this.memory_ValueChanged);
//
// tableLayoutPanel1
@ -111,13 +114,13 @@ namespace XenAdmin.Wizards.NewVMWizard
resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1");
this.tableLayoutPanel1.Controls.Add(this.labelInvalidVCPUWarning, 1, 3);
this.tableLayoutPanel1.Controls.Add(this.comboBoxTopology, 1, 2);
this.tableLayoutPanel1.Controls.Add(this.labelTopology, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.label5, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.spinnerStatMax, 0, 6);
this.tableLayoutPanel1.Controls.Add(this.labelVCPUs, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.spinnerDynMax, 0, 5);
this.tableLayoutPanel1.Controls.Add(this.spinnerDynMin, 0, 4);
this.tableLayoutPanel1.Controls.Add(this.VcpuSpinner, 1, 1);
this.tableLayoutPanel1.Controls.Add(this.labelTopology, 0, 2);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
//
// labelInvalidVCPUWarning

View File

@ -92,19 +92,19 @@ namespace XenAdmin.Wizards.NewVMWizard
if (memoryMode == 1)
{
spinnerDynMin.Initialize(Messages.MEMORY_COLON, null, Template.memory_static_max);
spinnerDynMin.Initialize(Messages.MEMORY_COLON, null, Template.memory_static_max, Template.memory_static_max);
spinnerDynMax.Visible = spinnerStatMax.Visible = false;
}
else
{
spinnerDynMax.Visible = true;
spinnerDynMin.Initialize(Messages.DYNAMIC_MIN_COLON, null, Template.memory_dynamic_min);
spinnerDynMin.Initialize(Messages.DYNAMIC_MIN_COLON, null, Template.memory_dynamic_min, Template.memory_static_max);
FreeSpinnerLimits(); // same as CA-33831
spinnerDynMax.Initialize(Messages.DYNAMIC_MAX_COLON, null, Template.memory_dynamic_max);
spinnerDynMax.Initialize(Messages.DYNAMIC_MAX_COLON, null, Template.memory_dynamic_max, Template.memory_static_max);
if (memoryMode == 3)
{
FreeSpinnerLimits();
spinnerStatMax.Initialize(Messages.STATIC_MAX_COLON, null, Template.memory_static_max);
spinnerStatMax.Initialize(Messages.STATIC_MAX_COLON, null, Template.memory_static_max, Template.memory_static_max);
}
else
spinnerStatMax.Visible = false;
@ -145,16 +145,16 @@ namespace XenAdmin.Wizards.NewVMWizard
private void SetSpinnerLimits()
{
long maxMemAllowed = MaxMemAllowed;
long min = Template.memory_static_min;
double min = Template.memory_static_min;
if (memoryMode == 1)
{
spinnerDynMin.SetRange(min, maxMemAllowed);
return;
}
long min2 = (long)((double)SelectedMemoryStaticMax * memoryRatio);
long min2 = (long)(SelectedMemoryStaticMax * memoryRatio);
if (min < min2)
min = min2;
long max = SelectedMemoryDynamicMax;
double max = SelectedMemoryDynamicMax;
if (max < min)
max = min;
spinnerDynMin.SetRange(min, max);
@ -170,7 +170,7 @@ namespace XenAdmin.Wizards.NewVMWizard
spinnerStatMax.Enabled = false;
}
public long SelectedMemoryDynamicMin
public double SelectedMemoryDynamicMin
{
get
{
@ -178,7 +178,7 @@ namespace XenAdmin.Wizards.NewVMWizard
}
}
public long SelectedMemoryDynamicMax
public double SelectedMemoryDynamicMax
{
get
{
@ -186,7 +186,7 @@ namespace XenAdmin.Wizards.NewVMWizard
}
}
public long SelectedMemoryStaticMax
public double SelectedMemoryStaticMax
{
get
{
@ -221,13 +221,13 @@ namespace XenAdmin.Wizards.NewVMWizard
sum.Add(new KeyValuePair<string, string>(Messages.NEWVMWIZARD_CPUMEMPAGE_VCPUS, SelectedVcpus.ToString()));
sum.Add(new KeyValuePair<string, string>(Messages.NEWVMWIZARD_CPUMEMPAGE_TOPOLOGY, comboBoxTopology.Text));
if (memoryMode == 1)
sum.Add(new KeyValuePair<string, string>(Messages.MEMORY, Util.MemorySizeString(SelectedMemoryStaticMax)));
sum.Add(new KeyValuePair<string, string>(Messages.MEMORY, Util.MemorySizeStringMB(SelectedMemoryStaticMax)));
else
{
sum.Add(new KeyValuePair<string, string>(Messages.DYNAMIC_MIN, Util.MemorySizeString(SelectedMemoryDynamicMin)));
sum.Add(new KeyValuePair<string, string>(Messages.DYNAMIC_MAX, Util.MemorySizeString(SelectedMemoryDynamicMax)));
sum.Add(new KeyValuePair<string, string>(Messages.DYNAMIC_MIN, Util.MemorySizeStringMB(SelectedMemoryDynamicMin)));
sum.Add(new KeyValuePair<string, string>(Messages.DYNAMIC_MAX, Util.MemorySizeStringMB(SelectedMemoryDynamicMax)));
if (memoryMode == 3)
sum.Add(new KeyValuePair<string, string>(Messages.STATIC_MAX, Util.MemorySizeString(SelectedMemoryStaticMax)));
sum.Add(new KeyValuePair<string, string>(Messages.STATIC_MAX, Util.MemorySizeStringMB(SelectedMemoryStaticMax)));
}
return sum;
}
@ -288,12 +288,12 @@ namespace XenAdmin.Wizards.NewVMWizard
if (max_mem_total_host != null && SelectedMemoryDynamicMin > max_mem_total)
{
ErrorPanel.Visible = true;
ErrorLabel.Text = string.Format(Messages.NEWVMWIZARD_CPUMEMPAGE_MEMORYWARN1, Helpers.GetName(max_mem_total_host), Util.MemorySizeString(max_mem_total));
ErrorLabel.Text = string.Format(Messages.NEWVMWIZARD_CPUMEMPAGE_MEMORYWARN1, Helpers.GetName(max_mem_total_host), Util.MemorySizeStringMB(max_mem_total));
}
else if (max_mem_free_host != null && SelectedMemoryDynamicMin > max_mem_free)
{
ErrorPanel.Visible = true;
ErrorLabel.Text = string.Format(Messages.NEWVMWIZARD_CPUMEMPAGE_MEMORYWARN2, Helpers.GetName(max_mem_free_host), Util.MemorySizeString(max_mem_free));
ErrorLabel.Text = string.Format(Messages.NEWVMWIZARD_CPUMEMPAGE_MEMORYWARN2, Helpers.GetName(max_mem_free_host), Util.MemorySizeStringMB(max_mem_free));
}
else if (max_vcpus_host != null && SelectedVcpus > max_vcpus)
{

View File

@ -145,16 +145,19 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;VcpuSpinner.ZOrder" xml:space="preserve">
<value>8</value>
<value>7</value>
</data>
<data name="labelVCPUs.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>None</value>
</data>
<data name="labelVCPUs.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 40</value>
<value>24, 40</value>
</data>
<data name="labelVCPUs.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>10, 0, 0, 0</value>
</data>
<data name="labelVCPUs.Size" type="System.Drawing.Size, System.Drawing">
<value>111, 25</value>
<value>131, 25</value>
</data>
<data name="labelVCPUs.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -175,7 +178,7 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;labelVCPUs.ZOrder" xml:space="preserve">
<value>5</value>
<value>4</value>
</data>
<data name="tableLayoutPanel1.ColumnCount" type="System.Int32, mscorlib">
<value>2</value>
@ -246,17 +249,92 @@
<data name="&gt;&gt;comboBoxTopology.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="spinnerStatMax.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 190</value>
</data>
<data name="spinnerStatMax.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="spinnerStatMax.Size" type="System.Drawing.Size, System.Drawing">
<value>280, 31</value>
</data>
<data name="spinnerStatMax.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="&gt;&gt;spinnerStatMax.Name" xml:space="preserve">
<value>spinnerStatMax</value>
</data>
<data name="&gt;&gt;spinnerStatMax.Type" xml:space="preserve">
<value>XenAdmin.Controls.Ballooning.MemorySpinner, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;spinnerStatMax.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;spinnerStatMax.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="spinnerDynMax.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 159</value>
</data>
<data name="spinnerDynMax.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="spinnerDynMax.Size" type="System.Drawing.Size, System.Drawing">
<value>280, 31</value>
</data>
<data name="spinnerDynMax.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="&gt;&gt;spinnerDynMax.Name" xml:space="preserve">
<value>spinnerDynMax</value>
</data>
<data name="&gt;&gt;spinnerDynMax.Type" xml:space="preserve">
<value>XenAdmin.Controls.Ballooning.MemorySpinner, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;spinnerDynMax.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;spinnerDynMax.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="spinnerDynMin.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 128</value>
</data>
<data name="spinnerDynMin.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="spinnerDynMin.Size" type="System.Drawing.Size, System.Drawing">
<value>280, 31</value>
</data>
<data name="spinnerDynMin.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="&gt;&gt;spinnerDynMin.Name" xml:space="preserve">
<value>spinnerDynMin</value>
</data>
<data name="&gt;&gt;spinnerDynMin.Type" xml:space="preserve">
<value>XenAdmin.Controls.Ballooning.MemorySpinner, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;spinnerDynMin.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;spinnerDynMin.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="labelTopology.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>None</value>
</data>
<data name="labelTopology.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="labelTopology.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 66</value>
<value>24, 68</value>
</data>
<data name="labelTopology.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>10, 0, 0, 0</value>
</data>
<data name="labelTopology.Size" type="System.Drawing.Size, System.Drawing">
<value>111, 25</value>
<value>131, 25</value>
</data>
<data name="labelTopology.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
@ -277,80 +355,8 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;labelTopology.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="spinnerStatMax.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 178</value>
</data>
<data name="spinnerStatMax.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="spinnerStatMax.Size" type="System.Drawing.Size, System.Drawing">
<value>265, 25</value>
</data>
<data name="spinnerStatMax.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="&gt;&gt;spinnerStatMax.Name" xml:space="preserve">
<value>spinnerStatMax</value>
</data>
<data name="&gt;&gt;spinnerStatMax.Type" xml:space="preserve">
<value>XenAdmin.Controls.Ballooning.MemorySpinner, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;spinnerStatMax.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;spinnerStatMax.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="spinnerDynMax.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 153</value>
</data>
<data name="spinnerDynMax.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="spinnerDynMax.Size" type="System.Drawing.Size, System.Drawing">
<value>265, 25</value>
</data>
<data name="spinnerDynMax.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="&gt;&gt;spinnerDynMax.Name" xml:space="preserve">
<value>spinnerDynMax</value>
</data>
<data name="&gt;&gt;spinnerDynMax.Type" xml:space="preserve">
<value>XenAdmin.Controls.Ballooning.MemorySpinner, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;spinnerDynMax.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;spinnerDynMax.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="spinnerDynMin.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 128</value>
</data>
<data name="spinnerDynMin.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="spinnerDynMin.Size" type="System.Drawing.Size, System.Drawing">
<value>265, 25</value>
</data>
<data name="spinnerDynMin.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="&gt;&gt;spinnerDynMin.Name" xml:space="preserve">
<value>spinnerDynMin</value>
</data>
<data name="&gt;&gt;spinnerDynMin.Type" xml:space="preserve">
<value>XenAdmin.Controls.Ballooning.MemorySpinner, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;spinnerDynMin.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;spinnerDynMin.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="tableLayoutPanel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
@ -361,7 +367,7 @@
<value>7</value>
</data>
<data name="tableLayoutPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>515, 193</value>
<value>515, 223</value>
</data>
<data name="tableLayoutPanel1.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
@ -379,7 +385,7 @@
<value>0</value>
</data>
<data name="tableLayoutPanel1.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="labelInvalidVCPUWarning" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="comboBoxTopology" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="labelTopology" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="label5" Row="0" RowSpan="1" Column="0" ColumnSpan="3" /&gt;&lt;Control Name="spinnerStatMax" Row="6" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="labelVCPUs" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="spinnerDynMax" Row="5" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="spinnerDynMin" Row="4" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="VcpuSpinner" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Absolute,170,Percent,100" /&gt;&lt;Rows Styles="AutoSize,50,AutoSize,50,AutoSize,0,AutoSize,0,AutoSize,20,AutoSize,20,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="labelInvalidVCPUWarning" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="comboBoxTopology" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="label5" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="spinnerStatMax" Row="6" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="labelVCPUs" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="spinnerDynMax" Row="5" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="spinnerDynMin" Row="4" RowSpan="1" Column="0" ColumnSpan="2" /&gt;&lt;Control Name="VcpuSpinner" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="labelTopology" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Absolute,170,Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="label5.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Top</value>
@ -406,7 +412,7 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;label5.ZOrder" xml:space="preserve">
<value>3</value>
<value>2</value>
</data>
<data name="pictureBox1.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
@ -466,7 +472,7 @@
<value>Bottom</value>
</data>
<data name="ErrorPanel.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 193</value>
<value>0, 223</value>
</data>
<data name="ErrorPanel.Size" type="System.Drawing.Size, System.Drawing">
<value>515, 112</value>
@ -496,7 +502,7 @@
<value>96, 96</value>
</data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>515, 305</value>
<value>515, 335</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>Page_CpuMem</value>

View File

@ -33,6 +33,7 @@ using NUnit.Framework;
using XenAdmin;
using System.Linq;
using System.Collections.Generic;
using System;
namespace XenAdminTests.UnitTests.MiscTests
{
@ -121,20 +122,30 @@ namespace XenAdminTests.UnitTests.MiscTests
#endregion
[Test]
public void TestMemorySizeString()
public void TestMemorySizeStringMB()
{
foreach (var pair in memoryMBpairs)
{
string expected = string.Format("{0} {1}", pair.Value[0], pair.Value[1]);
Assert.AreEqual(expected, Util.MemorySizeString(pair.Key));
Assert.AreEqual(expected, Util.MemorySizeStringMB(pair.Key));
}
}
[Test]
public void TestMemorySizeStringWithoutUnits()
{
foreach (var pair in memoryMBpairs)
Assert.AreEqual(pair.Value[0], Util.MemorySizeStringWithoutUnits(pair.Key));
public void TestMemorySizeStringSuitableUnits()
{
var pairs = new Dictionary<string[], string>
{
{ new [] {"1072693248", "false"}, "1023 MB"},
{ new [] {"1073741824", "false"}, "1 GB"},
{ new [] {"1073741824", "true"}, "1.0 GB"},
{ new [] {"1825361100.8", "false"}, "1.7 GB"},
{ new [] {"1825361100.8", "true"}, "1.7 GB"},
{ new [] {"536870912", "true"}, "512 MB"},
{ new [] {"537290342.4", "true"}, "512 MB"}
};
foreach(var pair in pairs)
Assert.AreEqual(pair.Value, Util.MemorySizeStringSuitableUnits(Convert.ToDouble(pair.Key[0]),Convert.ToBoolean(pair.Key[1])));
}
[Test]
@ -189,28 +200,6 @@ namespace XenAdminTests.UnitTests.MiscTests
Assert.AreEqual("17179869184 GB", Util.DiskSizeString(ulong.MaxValue));
}
[Test]
public void TestSuperiorSizeString()
{
var pairs = new Dictionary<double[], string>
{
{ new [] { 0, 1d }, "0 B" },
{ new [] { 1000, 2d }, "1000 B" },
{ new [] { 1024, 3d }, "1024 B" },
{ new [] { 100000, 2d }, "97.66 kB" },
{ new [] { 1000000, 1d }, "976.6 kB" },
{ new [] { 1048576, 3d }, "1024 kB" }, //1024*1024
{ new [] { 2100000, 3d }, "2050.781 kB" },
{ new [] { 2900000, 2d }, "2832.03 kB" },
{ new [] { 1073741824, 3d }, "1024 MB" }, //1024*1024*1024
{ new [] { 2100000000, 3d }, "2002.716 MB" },
{ new [] { 21000000000, 3d }, "19.558 GB" }
};
foreach (var pair in pairs)
Assert.AreEqual(pair.Value, Util.SuperiorSizeString(pair.Key[0], (int)pair.Key[1]));
}
[Test]
public void TestDiskSizeString()
{

View File

@ -76,7 +76,7 @@ namespace XenAdmin.Actions
switch (type)
{
case HostBackupRestoreType.backup:
this.Description = String.Format(Messages.BACKINGUP_HOST_WITH_DATA, Host.Name, Util.MemorySizeString(0));
this.Description = String.Format(Messages.BACKINGUP_HOST_WITH_DATA, Host.Name, Util.MemorySizeStringMB(0));
LogDescriptionChanges = false;
try
@ -111,7 +111,7 @@ namespace XenAdmin.Actions
private void DataReceived(long bytes)
{
this.Description = String.Format(Messages.BACKINGUP_HOST_WITH_DATA, Host.Name, Util.MemorySizeString(bytes));
this.Description = String.Format(Messages.BACKINGUP_HOST_WITH_DATA, Host.Name, Util.MemorySizeStringMB(bytes));
}
public override void RecomputeCanCancel()

View File

@ -86,7 +86,7 @@ namespace XenAdmin.Actions
case HostStatus.compiling:
return Messages.BUGTOOL_HOST_STATUS_COMPILING;
case HostStatus.downloading:
return string.Format(Messages.BUGTOOL_HOST_STATUS_DOWNLOADING, Util.MemorySizeString(DataTransferred));
return string.Format(Messages.BUGTOOL_HOST_STATUS_DOWNLOADING, Util.MemorySizeStringMB(DataTransferred));
default:
return Messages.BUGTOOL_HOST_STATUS_PENDING;
}

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -33707,6 +33707,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to {0:0} GB.
/// </summary>
public static string VAL_GB_ONE_DECIMAL {
get {
return ResourceManager.GetString("VAL_GB_ONE_DECIMAL", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to GB.
/// </summary>

View File

@ -11682,6 +11682,9 @@ To learn more about the XenServer Dynamic Workload Balancing feature or to start
<data name="VAL_GB" xml:space="preserve">
<value>{0} GB</value>
</data>
<data name="VAL_GB_ONE_DECIMAL" xml:space="preserve">
<value>{0:F1} GB</value>
</data>
<data name="VAL_GIGB" xml:space="preserve">
<value>GB</value>
</data>

View File

@ -39,7 +39,7 @@ namespace XenAdmin
{
public enum RoundingBehaviour
{
Up, Down, Nearest
Up, Down, Nearest, None
}
/// <summary>
@ -60,14 +60,46 @@ namespace XenAdmin
/// </summary>
public const UInt16 DEFAULT_ISCSI_PORT = 3260;
public static string MemorySizeString(double bytes)
public static string MemorySizeStringSuitableUnits(double bytes, bool showPoint0Decimal)
{
return string.Format(Messages.VAL_MB, Math.Round(bytes / BINARY_MEGA));
if (bytes >= 1 * BINARY_GIGA)
{
string format = Messages.VAL_GB_ONE_DECIMAL;
int dp = 1;
double valGB = bytes / BINARY_GIGA;
if (valGB > 100)
{
dp = 0;
format = Messages.VAL_GB;
}
if(!showPoint0Decimal)
{
format = Messages.VAL_GB;
}
return string.Format(format, Math.Round(valGB, dp, MidpointRounding.AwayFromZero));
}
else if (bytes >= 1 * BINARY_MEGA)
{
return string.Format(Messages.VAL_MB, Math.Round(bytes / BINARY_MEGA));
}
else if (bytes >= 1 * BINARY_KILO)
{
return string.Format(Messages.VAL_KB, Math.Round(bytes / BINARY_KILO));
}
if(bytes == 0)
{
return bytes.ToString();
}
else
{
return string.Format(Messages.VAL_B, bytes);
}
}
public static string MemorySizeStringWithoutUnits(double bytes)
public static string MemorySizeStringMB(double bytes)
{
return Math.Round(bytes / BINARY_MEGA).ToString();
return string.Format(Messages.VAL_MB, Math.Round(bytes / BINARY_MEGA));
}
public static string DataRateString(double bytesPerSec)
@ -87,27 +119,7 @@ namespace XenAdmin
string unit;
string value = ByteSizeString(bytes, 1, false, out unit);
return string.Format(Messages.VAL_FORMAT, value, unit);
}
public static string SuperiorSizeString(double bytes, int dp)
{
if (bytes >= 10 * BINARY_GIGA)
{
return string.Format(Messages.VAL_GB, Math.Round(bytes / BINARY_GIGA, dp));
}
else if (bytes >= 10 * BINARY_MEGA)
{
return string.Format(Messages.VAL_MB, Math.Round(bytes / BINARY_MEGA, dp));
}
else if (bytes >= 10 * BINARY_KILO)
{
return string.Format(Messages.VAL_KB, Math.Round(bytes / BINARY_KILO, dp));
}
else
{
return string.Format(Messages.VAL_B, bytes);
}
}
}
public static string DiskSizeString(long bytes)
{
@ -229,24 +241,51 @@ namespace XenAdmin
return t.ToString("0");
}
public static long ToMB(long bytes)
public static double ToGB(double bytes, int dp, RoundingBehaviour rounding)
{
return ToMB(bytes, RoundingBehaviour.Nearest);
double value = (double)bytes / BINARY_GIGA;
int decimalsAdjustment = (int)Math.Pow(10, dp);
switch (rounding)
{
case RoundingBehaviour.None:
return value;
case RoundingBehaviour.Down:
return (Math.Floor(value * decimalsAdjustment) / decimalsAdjustment);
case RoundingBehaviour.Up:
return (Math.Ceiling(value * decimalsAdjustment) / decimalsAdjustment);
default: // case RoundingBehaviour.Nearest:
return (Math.Round(value, 1, MidpointRounding.AwayFromZero));
}
}
public static long ToMB(long bytes, RoundingBehaviour rounding)
public static double ToMB(double bytes, RoundingBehaviour rounding)
{
switch (rounding)
{
case RoundingBehaviour.None:
return bytes / BINARY_MEGA;
case RoundingBehaviour.Down:
return (long)Math.Floor(bytes / (double)BINARY_MEGA);
return Math.Floor(bytes / BINARY_MEGA);
case RoundingBehaviour.Up:
return (long)Math.Ceiling(bytes / (double)BINARY_MEGA);
return Math.Ceiling(bytes / BINARY_MEGA);
default: // case RoundingBehaviour.Nearest:
return (long)Math.Round(bytes / (double)BINARY_MEGA, MidpointRounding.AwayFromZero);
return Math.Round(bytes / BINARY_MEGA, MidpointRounding.AwayFromZero);
}
}
public static double CorrectRoundingErrors(double amount)
{
// Special case to cope with choosing an amount that's a multiple of 0.1G but not 0.5G --
// sending it to the server as the nearest byte and getting it back later --
// and finding it's fractionally changed, messing up our spinner permitted ranges.
double amountRounded = ToGB(amount, 1, RoundingBehaviour.Nearest) * BINARY_GIGA;
double roundingDiff = amountRounded - amount;
if (roundingDiff > -1.0 && roundingDiff < 1.0) // within 1 byte: although I think it will always be positive in the case we want to correct
return amountRounded;
else
return amount;
}
public static double ToUnixTime(DateTime time)
{
TimeSpan diff = time - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);

View File

@ -1209,8 +1209,8 @@ namespace XenAPI
long ServerMBTotal = m.memory_total;
return string.Format(Messages.GENERAL_MEMORY_SERVER_FREE,
Util.MemorySizeString(ServerMBAvail),
Util.MemorySizeString(ServerMBTotal));
Util.MemorySizeStringMB(ServerMBAvail),
Util.MemorySizeStringMB(ServerMBTotal));
}
}
@ -1224,7 +1224,7 @@ namespace XenAPI
if (Connection.Resolve(metrics) == null)
return Messages.GENERAL_UNKNOWN;
return Util.MemorySizeString(xen_memory_calc);
return Util.MemorySizeStringMB(xen_memory_calc);
}
}
@ -1253,7 +1253,7 @@ namespace XenAPI
continue;
string message = string.Format(Messages.GENERAL_MEMORY_VM_USED, vm.Name,
Util.MemorySizeString(VMMetrics.memory_actual));
Util.MemorySizeStringMB(VMMetrics.memory_actual));
lines.Add(message);
}

View File

@ -55,7 +55,7 @@ namespace XenAPI
if (IsPassthrough)
return Messages.VGPU_PASSTHRU_TOSTRING;
var videoRam = framebuffer_size != 0 ? Util.SuperiorSizeString(framebuffer_size, 0): string.Empty;
var videoRam = framebuffer_size != 0 ? Util.MemorySizeStringMB(framebuffer_size): string.Empty;
return string.Format(Messages.VGPU_DESCRIPTION, model_name, Capacity, MaxResolution, max_heads);
}

View File

@ -90,7 +90,7 @@ namespace XenAdmin.XenSearch
if (total == 0)
return Messages.HYPHEN;
return Util.MemorySizeString(total);
return Util.MemorySizeStringSuitableUnits(total, false);
}
public static string vmMemoryUsageString(VM vm)
@ -106,7 +106,7 @@ namespace XenAdmin.XenSearch
if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free) || total < (free * Util.BINARY_KILO))
return Messages.HYPHEN;
return String.Format(Messages.QUERY_MEMORY_USAGE, Util.MemorySizeStringWithoutUnits((total - (free * Util.BINARY_KILO))), Util.MemorySizeString(total));
return String.Format(Messages.QUERY_MEMORY_USAGE, Util.MemorySizeStringSuitableUnits((total - (free * Util.BINARY_KILO)), false), Util.MemorySizeStringSuitableUnits(total, false));
}
public static string vmMemoryUsagePercentageStringByMetric(VM vm, MetricUpdater MetricUpdater)
@ -117,7 +117,7 @@ namespace XenAdmin.XenSearch
if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
return Messages.HYPHEN;
return String.Format(Messages.QUERY_MEMORY_PERCENT, ((total - (free * Util.BINARY_KILO))/total * 100.0).ToString("0."), Util.MemorySizeString(total));
return String.Format(Messages.QUERY_MEMORY_PERCENT, ((total - (free * Util.BINARY_KILO)) / total * 100.0).ToString("0."), Util.MemorySizeStringSuitableUnits(total, false));
}
public static int vmMemoryUsageRank(VM vm)
@ -229,7 +229,7 @@ namespace XenAdmin.XenSearch
if (total == 0 || Double.IsNaN(total)|| Double.IsNaN(free))
return Messages.HYPHEN;
return String.Format(Messages.QUERY_MEMORY_USAGE, Util.MemorySizeStringWithoutUnits((total - free) * Util.BINARY_KILO), Util.MemorySizeString(total * Util.BINARY_KILO));
return String.Format(Messages.QUERY_MEMORY_USAGE, Util.MemorySizeStringSuitableUnits((total - free) * Util.BINARY_KILO, false), Util.MemorySizeStringSuitableUnits(total * Util.BINARY_KILO, false));
}
public static string hostMemoryUsagePercentageStringByMetric(Host host, MetricUpdater MetricUpdater)
@ -240,7 +240,7 @@ namespace XenAdmin.XenSearch
if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
return Messages.HYPHEN;
return String.Format(Messages.QUERY_MEMORY_PERCENT, ((total - free) / total * 100.0).ToString("0."), Util.MemorySizeString(total * Util.BINARY_KILO));
return String.Format(Messages.QUERY_MEMORY_PERCENT, ((total - free) / total * 100.0).ToString("0."), Util.MemorySizeStringSuitableUnits(total * Util.BINARY_KILO, false));
}
public static string hostMemoryUsageString(Host host)
@ -332,7 +332,7 @@ namespace XenAdmin.XenSearch
if (total == 0 || Double.IsNaN(total) || Double.IsNaN(free))
return Messages.HYPHEN;
else
return String.Format(Messages.QUERY_MEMORY_USAGE, (used / (free + used) * 100).ToString("0.") + "%", Util.MemorySizeString(free + used));
return String.Format(Messages.QUERY_MEMORY_USAGE, (used / (free + used) * 100).ToString("0.") + "%", Util.MemorySizeStringMB(free + used));
}