IDynamicGrid.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. Button AddButton(string? caption, BitmapImage? image, Func<Button, CoreRow[], bool> action, DynamicGridButtonPosition position = DynamicGridButtonPosition.Left);
  52. void UpdateButton(Button button, BitmapImage? image, string? text, string? tooltip = null);
  53. event OnDefineFilter OnDefineFilter;
  54. event OnPrintData OnPrintData;
  55. event OnCustomiseColumns OnCustomiseColumns;
  56. event BeforeRefreshEventHandler BeforeRefresh;
  57. event AfterRefreshEventHandler AfterRefresh;
  58. event EntitySaveEvent? OnAfterSave;
  59. event EntitySaveEvent? OnBeforeSave;
  60. int DesiredWidth();
  61. void ConfigureColumns(DynamicGridColumns columns /*, bool dolookups */);
  62. void AddHiddenColumn(string column);
  63. void UpdateRow<TType>(CoreRow row, string column, TType value, bool refresh = true);
  64. void UpdateRow<T, TType>(CoreRow row, Expression<Func<T, TType>> column, TType value, bool refresh = true);
  65. }
  66. }