IDynamicGrid.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #define scrolling
  2. //#define newgrid
  3. using System;
  4. using System.Linq.Expressions;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Media.Imaging;
  8. using InABox.Core;
  9. using Syncfusion.Data;
  10. namespace InABox.DynamicGrid
  11. {
  12. public enum DynamicGridButtonPosition
  13. {
  14. Left,
  15. Right
  16. }
  17. public interface IDynamicGrid
  18. {
  19. Thickness Margin { get; set; }
  20. DynamicGridColumns MasterColumns { get; }
  21. DynamicGridColumns VisibleColumns { get; }
  22. CoreTable Data { get; set; }
  23. CoreRow[] SelectedRows { get; set; }
  24. double RowHeight { get; set; }
  25. double HeaderHeight { get; set; }
  26. double FontSize { get; set; }
  27. void Refresh(bool columns, bool data);
  28. void InitialiseEditorForm(IDynamicEditorForm editor, object[] items, Func<Type, CoreTable>? pageDataHandler = null, bool preloadPages = false);
  29. bool EditItems(object[] items, Func<Type, CoreTable>? PageDataHandler = null, bool PreloadPages = false);
  30. //bool DirectEdit(CoreTable data);
  31. event OnFilterRecord OnFilterRecord;
  32. event OnCreateItem OnCreateItem;
  33. event OnDoubleClick? OnDoubleClick;
  34. delegate void ReconfigureEvent(FluentList<DynamicGridOption> options);
  35. event ReconfigureEvent? OnReconfigure;
  36. public abstract void Reconfigure();
  37. /// <summary>
  38. /// Add <paramref name="onReconfigure"/> to <see cref="OnReconfigure"/>, and then call <see cref="Reconfigure"/>.
  39. /// </summary>
  40. /// <remarks>
  41. /// Probably should only be called once per grid, otherwise there will be multiple event handlers bound.<br/>
  42. /// If you want to reconfigure without specifiying
  43. /// a new reconfigure event, use <see cref="Reconfigure"/>.
  44. /// </remarks>
  45. /// <param name="onReconfigure"></param>
  46. public void Reconfigure(ReconfigureEvent onReconfigure);
  47. public bool HasOption(DynamicGridOption option);
  48. void AddVisualFilter(string column, string value, FilterType filtertype = FilterType.Contains);
  49. Button AddButton(string caption, BitmapImage? image, string? tooltip, Func<Button, CoreRow[], bool> action, DynamicGridButtonPosition position = DynamicGridButtonPosition.Left);
  50. event OnDefineFilter OnDefineFilter;
  51. event OnPrintData OnPrintData;
  52. event OnCustomiseColumns OnCustomiseColumns;
  53. event BeforeRefreshEventHandler BeforeRefresh;
  54. event AfterRefreshEventHandler AfterRefresh;
  55. event EntitySaveEvent? OnAfterSave;
  56. event EntitySaveEvent? OnBeforeSave;
  57. int DesiredWidth();
  58. void ConfigureColumns(DynamicGridColumns columns /*, bool dolookups */);
  59. void AddHiddenColumn(string column);
  60. void UpdateRow<TType>(CoreRow row, string column, TType value, bool refresh = true);
  61. void UpdateRow<T, TType>(CoreRow row, Expression<Func<T, TType>> column, TType value, bool refresh = true);
  62. }
  63. }