CA-166091 Correct sort order for vGPU types

This commit is contained in:
Stephen Turner 2015-07-14 17:29:53 +01:00
parent f99cb25525
commit eed38cc613
5 changed files with 27 additions and 9 deletions

View File

@ -95,7 +95,7 @@ namespace XenAdmin.Controls.GPU
let supportedVGpuType = pGpu.Connection.Resolve(supportedVGpuTypeRef)
let enabled = pGpu.enabled_VGPU_types.Contains(supportedVGpuTypeRef)
let isInUse = pGpuList.Any(p => p.Connection.ResolveAll(p.resident_VGPUs).Any(v => v.type.opaque_ref == supportedVGpuTypeRef.opaque_ref))
orderby supportedVGpuType.Capacity ascending
orderby supportedVGpuType descending
select new VGpuDetailWithCheckBoxRow(supportedVGpuTypeRef, supportedVGpuType, enabled, isInUse)
)

View File

@ -235,7 +235,7 @@ namespace XenAdmin.Controls.GPU
allowedTypesGrid.Rows.AddRange((from vGpuTypeRef in pGpu.supported_VGPU_types
let vGpuType = pGpu.Connection.Resolve(vGpuTypeRef)
let enabledType = pGpu.enabled_VGPU_types.Contains(vGpuTypeRef)
orderby vGpuType.Capacity ascending
orderby vGpuType descending
select new VGpuTypeRow(vGpuType, enabledType)).ToArray());
}
allowedTypesGrid.Height = allowedTypesGrid.Rows[0].Height * (allowedTypesGrid.RowCount);

View File

@ -257,13 +257,8 @@ namespace XenAdmin.SettingsPanels
if (gpu_group.HasVGpu)
{
allTypes.Sort((t1, t2) =>
{
int result = t1.Capacity.CompareTo(t2.Capacity);
if (result != 0)
return result;
return t1.Name.CompareTo(t2.Name);
});
allTypes.Sort();
allTypes.Reverse();
comboBoxGpus.Items.Add(new GpuTuple(gpu_group, allTypes.ToArray())); // Group item
}

View File

@ -4579,6 +4579,7 @@
</EmbeddedResource>
<EmbeddedResource Include="Controls\GPU\GpuRow.resx">
<DependentUpon>GpuRow.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Controls\GPU\GpuRow.zh-CN.resx">
<DependentUpon>GpuRow.cs</DependentUpon>

View File

@ -82,6 +82,28 @@ namespace XenAPI
}
#endregion
// CA-166091: Default sort order for VGPU types is:
// * Pass-through is "biggest"
// * Then others in capacity order, lowest capacity is biggest
// * In case of ties, highest resolution is biggest
public override int CompareTo(VGPU_type other)
{
if (this.IsPassthrough != other.IsPassthrough)
return this.IsPassthrough ? 1 : -1;
long thisCapacity = this.Capacity;
long otherCapacity = other.Capacity;
if (thisCapacity != otherCapacity)
return (int)(otherCapacity - thisCapacity);
long thisResolution = this.max_resolution_x * this.max_resolution_y;
long otherResolution = other.max_resolution_x * other.max_resolution_y;
if (thisResolution != otherResolution)
return (int)(thisResolution - otherResolution);
return base.CompareTo(other);
}
/// <summary>
/// vGPUs per GPU