using System; using System.Threading; using System.Windows.Controls; using Comal.Classes; using InABox.Core; using InABox.DynamicGrid; namespace PRSDesktop { public class ContactGrid : DynamicDataGrid { private bool bShowAll; public ContactGrid() { AddButton("Show All", null, ToggleFavourites); } protected override void DoReconfigure(DynamicGridOptions options) { base.DoReconfigure(options); options.RecordCount = true; options.FilterRows = true; options.SelectColumns = true; } private bool ToggleFavourites(Button sender, CoreRow[] rows) { bShowAll = !bShowAll; UpdateButton(sender, null, bShowAll ? "Favourites" : "Show All"); return true; } protected override void Reload( Filters criteria, Columns columns, ref SortOrder? sort, CancellationToken token, Action action) { if (!bShowAll) criteria.Add(new Filter(x => x.Favourite).IsEqualTo(true)); base.Reload(criteria, columns, ref sort, token, action); } } }