using System.Collections.Generic;
using System.Linq;
namespace Avalonia.PropertyGrid.Models;
///
/// Represents a category group of properties
///
public class PropertyCategory
{
///
/// Gets or sets the category name.
///
public string Name { get; set; } = string.Empty;
///
/// Gets or sets the list of properties in this category.
///
public List Properties { get; set; } = new();
///
/// Gets or sets whether the category is expanded in the UI.
///
public bool IsExpanded { get; set; } = true;
///
/// Gets or sets the display order of the category.
///
public int Order { get; set; }
}
///
/// Helper for grouping properties by category
///
public static class PropertyCategoryHelper
{
///
/// Groups a list of properties by their category.
///
public static List GroupByCategory(List properties)
{
return properties.GroupBy(p => p.Category)
.Select(g => new PropertyCategory
{
Name = g.Key,
Properties = g.ToList(),
IsExpanded = true,
Order = g.Min(p => p.Order)
})
.OrderBy(c => c.Order)
.ThenBy(c => c.Name)
.ToList();
}
}