using System; using Mirage.NetworkProfiler.ModuleGUI.Messages; namespace Mirage.NetworkProfiler.ModuleGUI.UITable { internal class ColumnInfo { public string Header { get; private set; } public int Width { get; private set; } public bool AllowSort { get; private set; } public Func SortGroup { get; private set; } public Func SortMessages { get; private set; } public Func TextGetter { get; private set; } public bool HasToolTip { get; private set; } public Func ToolTipGetter { get; private set; } public ColumnInfo(string header, int width, Func textGetter) { Header = header; Width = width; TextGetter = textGetter; } /// /// Enables sorting for column. If sort functions are null they will use default sort from /// /// /// /// public void AddSort(Func sortGroup, Func sortMessages) { AllowSort = true; SortGroup = sortGroup ?? GroupSorter.DefaultGroupSort; SortMessages = sortMessages ?? GroupSorter.DefaultMessageSort; } /// /// Enables sorting for column. If sort functions are null they will use default sort from /// Uses member getting to sort via that member /// /// /// /// public void AddSort(Func groupGetter, Func messageGetter) where T : IComparable { Func sortGroup = groupGetter != null ? (x, y) => GroupSorter.Compare(x, y, groupGetter) : null; Func sortMessages = messageGetter != null ? (x, y) => GroupSorter.Compare(x, y, messageGetter) : null; AddSort(sortGroup, sortMessages); } public void AddToolTip(Func getter) { HasToolTip = true; ToolTipGetter = getter; } } }