12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Threading;
- using System.Windows.Controls;
- using Comal.Classes;
- using InABox.Core;
- using InABox.DynamicGrid;
- namespace PRSDesktop
- {
- public class ContactGrid : DynamicDataGrid<Contact>
- {
- 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<Contact> criteria, Columns<Contact> columns, ref SortOrder<Contact>? sort,
- CancellationToken token, Action<CoreTable?, Exception?> action)
- {
- if (!bShowAll)
- criteria.Add(new Filter<Contact>(x => x.Favourite).IsEqualTo(true));
- base.Reload(criteria, columns, ref sort, token, action);
- }
- }
- }
|