better sorting for Associations
This commit is contained in:
parent
b3761f679d
commit
6f5d7150d9
@ -28,7 +28,7 @@ namespace UniversalEditor
|
||||
/// <summary>
|
||||
/// Associates <see cref="ObjectModel" />s, <see cref="DataFormat" />s, and other related Universal Editor objects.
|
||||
/// </summary>
|
||||
public class Association
|
||||
public class Association : IComparable<Association>
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a collection of <see cref="Association" />s.
|
||||
@ -233,5 +233,24 @@ namespace UniversalEditor
|
||||
}
|
||||
return associations.ToArray();
|
||||
}
|
||||
|
||||
public int CompareTo(Association other)
|
||||
{
|
||||
int nFileFormatFilters = 0, nMagicBytes = 0;
|
||||
foreach (DataFormatFilter filter in Filters)
|
||||
{
|
||||
nFileFormatFilters += filter.FileNameFilters.Count;
|
||||
nMagicBytes += filter.MagicBytes.Count;
|
||||
}
|
||||
|
||||
int nFileFormatFiltersOther = 0, nMagicBytesOther = 0;
|
||||
foreach (DataFormatFilter filter in other.Filters)
|
||||
{
|
||||
nFileFormatFiltersOther += filter.FileNameFilters.Count;
|
||||
nMagicBytesOther += filter.MagicBytes.Count;
|
||||
}
|
||||
|
||||
return (nFileFormatFilters + nMagicBytes).CompareTo(nFileFormatFiltersOther + nMagicBytesOther);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -550,15 +550,17 @@ namespace UniversalEditor.Common
|
||||
}
|
||||
|
||||
Association[] associations = Association.FromCriteria(new AssociationCriteria() { Accessor = accessor });
|
||||
List<Association> listAssocs = new List<Association>(associations);
|
||||
listAssocs.Sort();
|
||||
|
||||
List<DataFormatReference> list = new List<DataFormatReference>();
|
||||
foreach (Association association in associations)
|
||||
foreach (Association association in listAssocs)
|
||||
{
|
||||
for (int i = 0; i < association.DataFormats.Count; i++)
|
||||
{
|
||||
list.Add(association.DataFormats[i]);
|
||||
}
|
||||
}
|
||||
list.Sort(new Comparison<DataFormatReference>(_DataFormatReferenceComparer));
|
||||
|
||||
if (needsOpen)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user