IDynamicGridUIComponent.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using InABox.Core;
  2. using InABox.Wpf;
  3. using Syncfusion.Data;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Input;
  12. namespace InABox.DynamicGrid;
  13. public interface IDynamicGridUIComponentParent : IBaseDynamicGrid
  14. {
  15. bool IsRefreshing { get; }
  16. bool CanFilter();
  17. bool CanSort();
  18. DynamicGridRowStyleSelector RowStyleSelector { get; }
  19. void BeforeSelection(CancelEventArgs cancel);
  20. void SelectItems(CoreRow[] rows);
  21. void HandleKey(KeyEventArgs args);
  22. void LoadColumnsMenu(ContextMenu menu);
  23. BaseEditor CustomiseEditor(DynamicGridColumn column, BaseEditor editor);
  24. void DoubleClickCell(CoreRow? row, DynamicColumnBase? column);
  25. void ExecuteActionColumn(DynamicActionColumn column, CoreRow[]? rows);
  26. void OpenColumnMenu(DynamicColumnBase column);
  27. void UpdateRecordCount(int count);
  28. public bool IsDirectEditMode();
  29. void DragOver(object sender, DragEventArgs e);
  30. void Drop(object sender, DragEventArgs e);
  31. void DragStart(object? sender, CoreRow[] rows);
  32. /// <summary>
  33. /// Move the given rows from where they are, inserting them at <paramref name="index"/>. (i.e., before the row at the given index).
  34. /// To insert at the end, set <paramref name="index"/> to the number of rows.
  35. /// </summary>
  36. /// <remarks>
  37. /// Only applicable if <typeparamref name="T"/> is <see cref="ISequenceable"/>.
  38. /// </remarks>
  39. void MoveRows(CoreRow[] rows, int index);
  40. void UIFilterChanged(object sender);
  41. void UpdateData(CoreRow row, string changedColumn, Dictionary<CoreColumn, object?> updates);
  42. }
  43. public interface IDynamicGridUIComponentParent<T> : IDynamicGrid<T>, IDynamicGridUIComponentParent
  44. where T : BaseObject, new()
  45. {
  46. void UpdateData(T obj, CoreRow row, string changedColumn, Dictionary<CoreColumn, object?> updates);
  47. void EntityChanged(T obj, CoreRow row, string changedColumn, Dictionary<string, object?> changes);
  48. }
  49. public interface IDynamicGridUIComponent
  50. {
  51. IDynamicGridUIComponentParent Parent { get; set; }
  52. FrameworkElement Control { get; }
  53. CoreRow[] SelectedRows { get; set; }
  54. double RowHeight { get; set; }
  55. double HeaderRowHeight { get; set; }
  56. int DesiredWidth();
  57. /// <summary>
  58. /// Do any required updates when the options list is changed.
  59. /// </summary>
  60. /// <returns>Whether the columns need to be reloaded.</returns>
  61. bool OptionsChanged();
  62. void UpdateRow(CoreRow row);
  63. void UpdateCell(CoreRow row, string column, object? value);
  64. void UpdateCell(CoreRow row, DynamicColumnBase column);
  65. void AddVisualFilter(string column, string value, FilterType filtertype = FilterType.Contains);
  66. List<Tuple<string, Func<CoreRow, bool>>> GetFilterPredicates();
  67. void BeforeRefresh();
  68. void RefreshColumns(IEnumerable<DynamicColumnBase> columns, DynamicGridColumnGroupings groupings);
  69. void RefreshData(CoreTable data);
  70. void AddPage(IEnumerable<CoreRow> page);
  71. void InvalidateRow(CoreRow row);
  72. void ScrollIntoView(CoreRow row);
  73. CoreRow[] GetVisibleRows();
  74. }
  75. public interface IDynamicGridUIComponent<T> : IDynamicGridUIComponent
  76. where T : BaseObject, new()
  77. {
  78. new IDynamicGridUIComponentParent<T> Parent { get; set; }
  79. IDynamicGridUIComponentParent IDynamicGridUIComponent.Parent
  80. {
  81. get => Parent;
  82. set => Parent = (IDynamicGridUIComponentParent<T>)value;
  83. }
  84. }