IDynamicGrid.cs 3.0 KB

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