DynamicGridTreeUIComponent.cs 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  1. using InABox.Clients;
  2. using InABox.Core;
  3. using InABox.Wpf;
  4. using InABox.WPF;
  5. using Syncfusion.Data;
  6. using Syncfusion.UI.Xaml.Grid;
  7. using Syncfusion.UI.Xaml.ScrollAxis;
  8. using Syncfusion.UI.Xaml.TreeGrid;
  9. using Syncfusion.UI.Xaml.TreeGrid.Helpers;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.ComponentModel;
  13. using System.Linq;
  14. using System.Linq.Expressions;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. using System.Windows;
  18. using System.Windows.Controls;
  19. using System.Windows.Data;
  20. using System.Windows.Input;
  21. using System.Windows.Media;
  22. using System.Windows.Media.Imaging;
  23. using Syncfusion.UI.Xaml.TreeGrid.Filtering;
  24. using Syncfusion.UI.Xaml.TreeGrid.Cells;
  25. namespace InABox.DynamicGrid;
  26. public enum DynamicTreeGridLines
  27. {
  28. Both,
  29. Horizontal,
  30. Vertical,
  31. None
  32. }
  33. public enum DynamicTreeGridExpandMode
  34. {
  35. All,
  36. Root,
  37. None
  38. }
  39. public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynamicGridGridUIComponent<T>
  40. where T : BaseObject, new()
  41. {
  42. private IDynamicGridUIComponentParent<T> _parent;
  43. public IDynamicGridUIComponentParent<T> Parent
  44. {
  45. get => _parent;
  46. set
  47. {
  48. _parent = value;
  49. CellBackgroundConverter = new DynamicGridCellStyleConverter<System.Windows.Media.Brush?>(Parent, GetCellBackground);
  50. CellForegroundConverter = new DynamicGridCellStyleConverter<System.Windows.Media.Brush?>(Parent, GetCellForeground);
  51. CellFontSizeConverter = new DynamicGridCellStyleConverter<double?>(Parent, GetCellFontSize);
  52. CellFontStyleConverter = new DynamicGridCellStyleConverter<System.Windows.FontStyle?>(Parent, GetCellFontStyle);
  53. CellFontWeightConverter = new DynamicGridCellStyleConverter<System.Windows.FontWeight?>(Parent, GetCellFontWeight);
  54. Parent.AddHiddenColumn(IDColumn.Property);
  55. Parent.AddHiddenColumn(ParentColumn.Property);
  56. }
  57. }
  58. private Column<T> IDColumn;
  59. private Column<T> ParentColumn;
  60. private ContextMenu _menu;
  61. private SfTreeGrid _tree;
  62. private readonly ContextMenu ColumnsMenu;
  63. public event OnContextMenuOpening OnContextMenuOpening;
  64. FrameworkElement IDynamicGridUIComponent<T>.Control => _tree;
  65. private bool _shownumbers = false;
  66. public bool ShowNumbers
  67. {
  68. get => _shownumbers;
  69. set
  70. {
  71. _shownumbers = value;
  72. //_tree.Columns[1].Width = value ? 50 : 0;
  73. }
  74. }
  75. private bool _showHeader = false;
  76. public bool ShowHeader
  77. {
  78. get => _showHeader;
  79. set
  80. {
  81. _showHeader = value;
  82. _tree.HeaderRowHeight = value ? 30 : 0;
  83. }
  84. }
  85. private bool _autoSizeExpander = false;
  86. public bool AutoSizeExpander
  87. {
  88. get => _autoSizeExpander;
  89. set
  90. {
  91. _autoSizeExpander = value;
  92. _tree.AllowAutoSizingExpanderColumn = value;
  93. }
  94. }
  95. private DynamicTreeGridLines _gridLines = DynamicTreeGridLines.Both;
  96. public DynamicTreeGridLines GridLines
  97. {
  98. get => _gridLines;
  99. set
  100. {
  101. _gridLines = value;
  102. _tree.GridLinesVisibility = value switch
  103. {
  104. DynamicTreeGridLines.Both => GridLinesVisibility.Both,
  105. DynamicTreeGridLines.Vertical => GridLinesVisibility.Vertical,
  106. DynamicTreeGridLines.Horizontal => GridLinesVisibility.Horizontal,
  107. _ => GridLinesVisibility.None,
  108. };
  109. }
  110. }
  111. public DynamicTreeGridExpandMode ExpandMode
  112. {
  113. get
  114. {
  115. return _tree.AutoExpandMode switch
  116. {
  117. AutoExpandMode.AllNodesExpanded => DynamicTreeGridExpandMode.All,
  118. AutoExpandMode.RootNodesExpanded => DynamicTreeGridExpandMode.Root,
  119. _ => DynamicTreeGridExpandMode.None,
  120. };
  121. }
  122. set
  123. {
  124. _tree.AutoExpandMode = value switch
  125. {
  126. DynamicTreeGridExpandMode.All => AutoExpandMode.AllNodesExpanded,
  127. DynamicTreeGridExpandMode.Root => AutoExpandMode.RootNodesExpanded,
  128. _ => AutoExpandMode.None
  129. };
  130. }
  131. }
  132. private double minRowHeight = 30D;
  133. private double maxRowHeight = 30D;
  134. public double MinRowHeight
  135. {
  136. get => minRowHeight;
  137. set
  138. {
  139. minRowHeight = value;
  140. CalculateRowHeight();
  141. }
  142. }
  143. public double MaxRowHeight
  144. {
  145. get => maxRowHeight;
  146. set
  147. {
  148. maxRowHeight = value;
  149. CalculateRowHeight();
  150. }
  151. }
  152. #region IDynamicGridGridUIComponent
  153. IList<DynamicColumnBase> IDynamicGridGridUIComponent<T>.ColumnList => ColumnList;
  154. int IDynamicGridGridUIComponent<T>.RowHeight => (int)RowHeight;
  155. #endregion
  156. private DynamicGridCellStyleConverter<System.Windows.Media.Brush?> CellBackgroundConverter;
  157. private DynamicGridCellStyleConverter<System.Windows.Media.Brush?> CellForegroundConverter;
  158. private DynamicGridCellStyleConverter<double?> CellFontSizeConverter;
  159. private DynamicGridCellStyleConverter<System.Windows.FontStyle?> CellFontStyleConverter;
  160. private DynamicGridCellStyleConverter<System.Windows.FontWeight?> CellFontWeightConverter;
  161. protected virtual Brush? GetCellBackground(CoreRow row, DynamicColumnBase column) => null;
  162. protected virtual Brush? GetCellForeground(CoreRow row, DynamicColumnBase column) => null;
  163. protected virtual double? GetCellFontSize(CoreRow row, DynamicColumnBase column) => null;
  164. protected virtual FontStyle? GetCellFontStyle(CoreRow row, DynamicColumnBase column) => null;
  165. protected virtual FontWeight? GetCellFontWeight(CoreRow row, DynamicColumnBase column) => null;
  166. public DynamicGridTreeUIComponent(Expression<Func<T, Guid>> idColumn, Expression<Func<T, Guid>> parentIDColumn)
  167. {
  168. IDColumn = new Column<T>(CoreUtils.GetFullPropertyName(idColumn, "."));
  169. ParentColumn = new Column<T>(CoreUtils.GetFullPropertyName(parentIDColumn, "."));
  170. ColumnsMenu = new ContextMenu();
  171. ColumnsMenu.Opened += ColumnsMenu_ContextMenuOpening;
  172. _tree = new SfTreeGrid();
  173. _tree.ChildPropertyName = "Children";
  174. //_tree.ParentPropertyName = "Parent";
  175. _tree.AutoGenerateColumns = false;
  176. ExpandMode = DynamicTreeGridExpandMode.All;
  177. //_tree.NodeCollapsing += (o, e) => { e.Cancel = true; };
  178. //_tree.HeaderRowHeight = 0D;
  179. _tree.HeaderRowHeight = 30;
  180. _tree.HeaderContextMenu = ColumnsMenu;
  181. _tree.SelectionChanging += _tree_SelectionChanging;
  182. _tree.SelectionChanged += _tree_SelectionChanged;
  183. _tree.AllowSelectionOnExpanderClick = false;
  184. _tree.AllowAutoSizingExpanderColumn = false;
  185. _tree.CellTapped += _tree_CellTapped;
  186. _tree.CellDoubleTapped += _tree_CellDoubleTapped;
  187. _tree.KeyUp += _tree_KeyUp;
  188. _tree.CellToolTipOpening += _tree_CellToolTipOpening;
  189. _menu = new ContextMenu();
  190. var additem = new MenuItem() { Header = "Add Child Folder" };
  191. additem.Click += (o, e) => { DoAddItem((_tree.SelectedItem as CoreTreeNode)!.ID, true); };
  192. _menu.Items.Add(additem);
  193. _tree.ContextMenuOpening += _tree_ContextMenuOpening;
  194. _tree.ContextMenu = _menu;
  195. _tree.Background = new SolidColorBrush(Colors.DimGray);
  196. var cellStyle = new Style(typeof(TreeGridRowControl));
  197. cellStyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.White)));
  198. _tree.RowStyle = cellStyle;
  199. var filterstyle = new Style(typeof(TreeGridFilterControl));
  200. filterstyle.Setters.Add(new Setter(TreeGridFilterControl.SortOptionVisibilityProperty, Visibility.Collapsed));
  201. filterstyle.Setters.Add(new Setter(TreeGridFilterControl.ImmediateUpdateColumnFilterProperty, false));
  202. _tree.FilterPopupStyle = filterstyle;
  203. _tree.FilterChanged += _tree_FilterChanged;
  204. _tree.FilterItemsPopulating += _tree_FilterItemsPopulating;
  205. _tree.FilterLevel = FilterLevel.Extended;
  206. _tree.SelectionForeground = DynamicGridUtils.SelectionForeground;
  207. _tree.SelectionBackground = DynamicGridUtils.SelectionBackground;
  208. _tree.ColumnSizer = TreeColumnSizer.None;
  209. _tree.RowHeight = 30D;
  210. _tree.SetValue(Grid.RowProperty, 0);
  211. _tree.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Visible);
  212. _tree.AllowDraggingRows = false;
  213. _tree.Drop += _tree_Drop;
  214. _tree.DragOver += _tree_DragOver;
  215. _tree.RowDragDropTemplate = TemplateGenerator.CreateDataTemplate(() =>
  216. {
  217. var border = new Border();
  218. border.Width = 100;
  219. border.Height = 100;
  220. border.BorderBrush = new SolidColorBrush(Colors.Firebrick);
  221. border.Background = new SolidColorBrush(Colors.Red);
  222. border.CornerRadius = new CornerRadius(5);
  223. return border;
  224. });
  225. _tree.SizeChanged += _tree_SizeChanged;
  226. }
  227. #region Public Interface
  228. public IEnumerable<CoreRow> GetChildren(Guid id)
  229. {
  230. return Nodes.GetChildren(id).Select(x => MapRow(x.Row)).NotNull();
  231. }
  232. #endregion
  233. #region Input
  234. private CoreRow? GetRowFromIndex(int rowIndex)
  235. {
  236. // Syncfusion has given us the row index, so it also will give us the correct row, after sorting.
  237. // Hence, here we use the syncfusion DataGrid.GetRecordAtRowIndex, which *should* always return a DataRowView.
  238. var row = _tree.GetNodeAtRowIndex(rowIndex);
  239. return MapRow((row.Item as CoreTreeNode)?.Row);
  240. }
  241. private void _tree_CellDoubleTapped(object? sender, TreeGridCellDoubleTappedEventArgs e)
  242. {
  243. _tree.Dispatcher.BeginInvoke(() =>
  244. {
  245. // This needs to happen outside the event handler, because the items source for the tree view might change during this method, and that causes an internal exception in Syncfusion. We need to finish the event before resetting the items source.
  246. Parent.DoubleClickCell(GetRowFromIndex(e.RowColumnIndex.RowIndex), GetColumn(e.RowColumnIndex.ColumnIndex));
  247. });
  248. }
  249. private void _tree_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
  250. {
  251. if (sender != _tree) return;
  252. Parent.HandleKey(e);
  253. }
  254. private void HeaderCell_LeftMouseButtonEvent(object sender, MouseButtonEventArgs e)
  255. {
  256. if (sender is not TreeGridHeaderCell header) return;
  257. var index = _tree.Columns.IndexOf(header.Column);
  258. if (GetColumn(index) is not DynamicColumnBase column)
  259. return;
  260. if(column is DynamicActionColumn dac)
  261. {
  262. Parent.ExecuteActionColumn(dac, null);
  263. }
  264. }
  265. private void _tree_CellTapped(object? sender, TreeGridCellTappedEventArgs e)
  266. {
  267. if (!_tree.IsEnabled)
  268. return;
  269. if (GetColumn(e.RowColumnIndex.ColumnIndex) is not DynamicColumnBase column)
  270. return;
  271. if(e.ChangedButton == MouseButton.Left)
  272. {
  273. if(column is DynamicActionColumn dac)
  274. {
  275. Parent.ExecuteActionColumn(dac, SelectedRows);
  276. }
  277. }
  278. else if(e.ChangedButton == MouseButton.Right)
  279. {
  280. if(column is DynamicMenuColumn dmc)
  281. {
  282. Parent.ExecuteActionColumn(dmc, null);
  283. }
  284. else
  285. {
  286. Parent.OpenColumnMenu(column);
  287. }
  288. }
  289. }
  290. #endregion
  291. #region Selection
  292. public CoreRow[] SelectedRows
  293. {
  294. get
  295. {
  296. return _tree.SelectedItems.OfType<CoreTreeNode>()
  297. .Select(x => GetRow(x)).NotNull().ToArray();
  298. }
  299. set
  300. {
  301. _tree.SelectedItems.Clear();
  302. foreach (var row in value)
  303. {
  304. _tree.SelectedItems.Add(Nodes.Find(row.Get<Guid>(IDColumn.Property)));
  305. }
  306. }
  307. }
  308. private void _tree_SelectionChanged(object? sender, GridSelectionChangedEventArgs e)
  309. {
  310. if(Parent.IsReady && !Parent.IsRefreshing)
  311. {
  312. Parent.SelectItems(SelectedRows);
  313. }
  314. }
  315. private void _tree_SelectionChanging(object? sender, GridSelectionChangingEventArgs e)
  316. {
  317. var cancel = new CancelEventArgs();
  318. Parent.BeforeSelection(cancel);
  319. if (cancel.Cancel)
  320. {
  321. e.Cancel = true;
  322. }
  323. }
  324. #endregion
  325. private void _tree_FilterItemsPopulating(object? sender, Syncfusion.UI.Xaml.TreeGrid.Filtering.TreeGridFilterItemsPopulatingEventArgs e)
  326. {
  327. var colIdx = _tree.Columns.IndexOf(e.Column);
  328. var column = GetColumn(colIdx);
  329. if(column is not null)
  330. {
  331. var filterItems = Parent.GetColumnFilterItems(column);
  332. if(filterItems is not null)
  333. {
  334. e.ItemsSource = filterItems.Select(x => new FilterElement
  335. {
  336. DisplayText = x, ActualValue = x
  337. });
  338. }
  339. else if (column is DynamicActionColumn dac && dac.Filters is not null)
  340. {
  341. e.ItemsSource = dac.Filters.Select(x => new FilterElement
  342. {
  343. DisplayText = x, ActualValue = x,
  344. IsSelected = dac.SelectedFilters is null || dac.SelectedFilters.Contains(x)
  345. });
  346. }
  347. else if (column is DynamicGridColumn dgc)
  348. {
  349. var preds = e.Column.FilterPredicates.Select(x => x.FilterValue).ToArray();
  350. var data = Parent.Data.Rows.Select(r => r.Get<String>(dgc.ColumnName)).OrderBy(x=>x);
  351. e.ItemsSource = data.Select(x => new FilterElement()
  352. { DisplayText = x ?? "(Blanks)", ActualValue = x, IsSelected = preds.Length == 0 || preds.Contains(x) });
  353. }
  354. }
  355. }
  356. private void _tree_FilterChanged(object? sender, Syncfusion.UI.Xaml.TreeGrid.Filtering.TreeGridFilterChangedEventArgs e)
  357. {
  358. var col = _tree.Columns.IndexOf(e.Column);
  359. if (GetColumn(col) is DynamicActionColumn column)
  360. {
  361. if (e.FilterPredicates != null)
  362. {
  363. var filter = e.FilterPredicates.Select(x => x.FilterValue.ToString()!).ToArray();
  364. bool include = e.FilterPredicates.Any(x => x.FilterType == FilterType.Equals);
  365. column.SelectedFilters = include ? filter : (column.Filters ?? Enumerable.Empty<string>()).Except(filter).ToArray();
  366. }
  367. else
  368. column.SelectedFilters = Array.Empty<string>();
  369. _tree.ClearFilter(e.Column);
  370. //e.FilterPredicates?.Clear();
  371. //e.FilterPredicates?.Add(new FilterPredicate() { PredicateType = PredicateType.Or, FilterBehavior = Syncfusion.Data.FilterBehavior.StringTyped, FilterMode = ColumnFilter.DisplayText, FilterType = Syncfusion.Data.FilterType.NotEquals, FilterValue = "" });
  372. //e.FilterPredicates?.Add(new FilterPredicate() { PredicateType = PredicateType.Or, FilterBehavior = Syncfusion.Data.FilterBehavior.StringTyped, FilterMode = ColumnFilter.DisplayText, FilterType = Syncfusion.Data.FilterType.Equals, FilterValue = "" });
  373. Parent.Refresh(false, false);
  374. }
  375. if (e.FilterPredicates == null)
  376. {
  377. if (FilterPredicates.ContainsKey(e.Column.MappingName))
  378. FilterPredicates.Remove(e.Column.MappingName);
  379. }
  380. else
  381. {
  382. FilterPredicates[e.Column.MappingName] = Serialization.Serialize(e.FilterPredicates, true);
  383. }
  384. Parent.UIFilterChanged(this);
  385. UpdateRecordCount();
  386. }
  387. private CoreRow? GetRow(CoreTreeNode? node)
  388. {
  389. return MapRow(node?.Row);
  390. }
  391. private CoreRow? MapRow(CoreRow? row)
  392. {
  393. if (row is null) return null;
  394. var index = row.Index;
  395. if (index < 0 || index >= Parent.Data.Rows.Count) return null;
  396. return Parent.Data.Rows[row.Index];
  397. }
  398. private void ColumnsMenu_ContextMenuOpening(object sender, RoutedEventArgs e)
  399. {
  400. if (sender is not ContextMenu menu) return;
  401. menu.Items.Clear();
  402. Parent.LoadColumnsMenu(menu);
  403. }
  404. public bool OptionsChanged()
  405. {
  406. ColumnsMenu.Visibility = Parent.HasOption(DynamicGridOption.SelectColumns) ? Visibility.Visible : Visibility.Hidden;
  407. _tree.AllowFiltering = Parent.HasOption(DynamicGridOption.FilterRows);
  408. if (Parent.HasOption(DynamicGridOption.DragSource))
  409. {
  410. if (!_tree.AllowDraggingRows)
  411. {
  412. _tree.AllowDraggingRows = true;
  413. _tree.RowDragDropController.DragStart += RowDragDropController_DragStart;
  414. }
  415. }
  416. else
  417. {
  418. if (_tree.AllowDraggingRows)
  419. {
  420. _tree.AllowDraggingRows = false;
  421. _tree.RowDragDropController.DragStart -= RowDragDropController_DragStart;
  422. }
  423. }
  424. _tree.AllowDrop = Parent.HasOption(DynamicGridOption.DragTarget);
  425. _tree.SelectionMode = Parent.HasOption(DynamicGridOption.MultiSelect) ? GridSelectionMode.Extended : GridSelectionMode.Single;
  426. return false;
  427. }
  428. private void _tree_CellToolTipOpening(object? sender, TreeGridCellToolTipOpeningEventArgs e)
  429. {
  430. if (GetColumn(e.RowColumnIndex.ColumnIndex) is not DynamicActionColumn col)
  431. return;
  432. var toolTip = col.ToolTip;
  433. if (toolTip is null)
  434. return;
  435. var row = GetRowFromIndex(e.RowColumnIndex.RowIndex);
  436. e.ToolTip.Template = TemplateGenerator.CreateControlTemplate(
  437. typeof(ToolTip),
  438. () => toolTip.Invoke(col, row)
  439. );
  440. }
  441. #region Sizing
  442. public double RowHeight
  443. {
  444. get => _tree.RowHeight;
  445. set => _tree.RowHeight = value;
  446. }
  447. public double HeaderRowHeight
  448. {
  449. get => _tree.HeaderRowHeight;
  450. set => _tree.HeaderRowHeight = value;
  451. }
  452. private void _tree_SizeChanged(object sender, SizeChangedEventArgs e)
  453. {
  454. CalculateRowHeight();
  455. if (Parent.IsReady && !Parent.IsRefreshing)
  456. ResizeColumns(_tree, e.NewSize.Width - 2, e.NewSize.Height - 2);
  457. }
  458. int IDynamicGridUIComponent<T>.DesiredWidth()
  459. {
  460. return this.DesiredWidth();
  461. }
  462. #endregion
  463. #region Context Menu
  464. private void _tree_ContextMenuOpening(object sender, ContextMenuEventArgs e)
  465. {
  466. _menu.Items.Clear();
  467. if (OnContextMenuOpening is not null)
  468. {
  469. OnContextMenuOpening.Invoke((_tree.SelectedItem as CoreTreeNode)!, _menu);
  470. if(_menu.Items.Count == 0)
  471. {
  472. e.Handled = true;
  473. }
  474. }
  475. else
  476. {
  477. if (Parent.HasOption(DynamicGridOption.AddRows))
  478. {
  479. _menu.AddItem("Add Item", null, (_tree.SelectedItem as CoreTreeNode)!.ID, (id) => DoAddItem(id, true));
  480. }
  481. }
  482. }
  483. #endregion
  484. #region CRUD
  485. protected T DoCreateItem(Guid parent)
  486. {
  487. var result = Parent.CreateItem();
  488. CoreUtils.SetPropertyValue(result, ParentColumn.Property, parent);
  489. return result;
  490. }
  491. protected void DoAddItem(Guid id, bool edit)
  492. {
  493. try
  494. {
  495. var item = DoCreateItem(id);
  496. if (edit)
  497. {
  498. if (Parent.EditItems(new[] { item }))
  499. {
  500. Parent.DoChanged();
  501. Parent.Refresh(false, true);
  502. }
  503. }
  504. else
  505. {
  506. Parent.SaveItem(item);
  507. Parent.DoChanged();
  508. Parent.Refresh(false, true);
  509. }
  510. }
  511. catch (Exception e)
  512. {
  513. MessageWindow.ShowError("An error occurred while adding an item", e);
  514. }
  515. }
  516. #endregion
  517. #region Columns
  518. private class StackedHeaderRenderer : TreeGridStackedHeaderCellRenderer
  519. {
  520. private Style Style;
  521. public StackedHeaderRenderer()
  522. {
  523. var headstyle = new Style(typeof(TreeGridStackedHeaderCell));
  524. headstyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
  525. headstyle.Setters.Add(new Setter(Control.ForegroundProperty, new SolidColorBrush(Colors.Black)));
  526. headstyle.Setters.Add(new Setter(Control.FontSizeProperty, 12D));
  527. headstyle.Setters.Add(new Setter(Control.BorderThicknessProperty, new Thickness(0.0, 0.0, 0, 0)));
  528. headstyle.Setters.Add(new Setter(Control.MarginProperty, new Thickness(0, 0, 1, 1)));
  529. Style = headstyle;
  530. }
  531. public override void OnInitializeEditElement(TreeDataColumnBase dataColumn, TreeGridStackedHeaderCell uiElement, object dataContext)
  532. {
  533. uiElement.Style = Style;
  534. base.OnInitializeEditElement(dataColumn, uiElement, dataContext);
  535. }
  536. }
  537. private readonly List<DynamicColumnBase> ColumnList = new();
  538. private List<DynamicActionColumn> ActionColumns = new();
  539. private readonly Dictionary<string, string> FilterPredicates = new();
  540. private DynamicColumnBase? GetColumn(int index) =>
  541. index >= 0 && index < ColumnList.Count ? ColumnList[index] : null;
  542. private void ApplyFilterStyle(TreeGridColumn column, bool filtering, bool isactioncolumn)
  543. {
  544. var filterstyle = new Style();
  545. if (filtering)
  546. {
  547. filterstyle.Setters.Add(new Setter(Control.BackgroundProperty, DynamicGridUtils.FilterBackground));
  548. column.ImmediateUpdateColumnFilter = true;
  549. column.ColumnFilter = ColumnFilter.DisplayText;
  550. column.AllowBlankFilters = true;
  551. column.AllowSorting = isactioncolumn
  552. ? false
  553. : Parent.CanSort();
  554. }
  555. else
  556. {
  557. filterstyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
  558. filterstyle.Setters.Add(new Setter(Control.IsEnabledProperty, false));
  559. column.ColumnFilter = ColumnFilter.Value;
  560. column.AllowFiltering = false;
  561. column.AllowSorting = false;
  562. }
  563. }
  564. public class TemplateColumnSelector(DynamicGridTreeUIComponent<T> parent, Func<CoreRow, FrameworkElement?> dataTemplate) : DataTemplateSelector
  565. {
  566. public Func<CoreRow, FrameworkElement?> DataTemplate { get; init; } = dataTemplate;
  567. public DynamicGridTreeUIComponent<T> Parent { get; init; } = parent;
  568. public override DataTemplate? SelectTemplate(object item, DependencyObject container)
  569. {
  570. if (item is not CoreTreeNode node) return null;
  571. var row = Parent.MapRow(node.Row);
  572. if (row is null) return null;
  573. return TemplateGenerator.CreateDataTemplate(() =>
  574. {
  575. return DataTemplate(row);
  576. });
  577. }
  578. }
  579. private void LoadActionColumns(DynamicActionColumnPosition position)
  580. {
  581. for (var i = 0; i < ActionColumns.Count; i++)
  582. {
  583. var column = ActionColumns[i];
  584. if (column.Position == position)
  585. {
  586. var sColName = $"[_ActionColumn{i}]";
  587. if (column is DynamicImageColumn imgcol)
  588. {
  589. var newcol = new TreeGridTemplateColumn();
  590. newcol.CellTemplateSelector = new TemplateColumnSelector(this, row =>
  591. {
  592. var image = new Image
  593. {
  594. Width = _tree.RowHeight - 8,
  595. Height = _tree.RowHeight - 8,
  596. };
  597. image.SetBinding(Image.SourceProperty, new Binding(sColName));
  598. return image;
  599. });
  600. newcol.AllowEditing = false;
  601. newcol.UpdateTrigger = UpdateSourceTrigger.PropertyChanged;
  602. newcol.Width = column.Width == 0 ? _tree.RowHeight : column.Width;
  603. newcol.Padding = new Thickness(4);
  604. newcol.ColumnSizer = TreeColumnSizer.None;
  605. newcol.HeaderText = column.HeaderText;
  606. newcol.MappingName = sColName;
  607. ApplyFilterStyle(newcol, false, true);
  608. newcol.ShowToolTip = column.ToolTip != null;
  609. newcol.ShowHeaderToolTip = column.ToolTip != null;
  610. var headstyle = new Style(typeof(TreeGridHeaderCell));
  611. headstyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
  612. headstyle.Setters.Add(new Setter(Control.ForegroundProperty, new SolidColorBrush(Colors.Black)));
  613. headstyle.Setters.Add(new Setter(Control.FontSizeProperty, 12D));
  614. headstyle.Setters.Add(new EventSetter(Control.MouseLeftButtonUpEvent, new MouseButtonEventHandler(HeaderCell_LeftMouseButtonEvent)));
  615. if (!string.IsNullOrWhiteSpace(column.HeaderText))
  616. {
  617. //headstyle.Setters.Add(new Setter(LayoutTransformProperty, new RotateTransform(270.0F)));
  618. headstyle.Setters.Add(new Setter(Control.BorderThicknessProperty, new Thickness(0.0, 0.0, 0, 0)));
  619. headstyle.Setters.Add(new Setter(Control.MarginProperty, new Thickness(0, 0, 1, 1)));
  620. if (imgcol.VerticalHeader)
  621. headstyle.Setters.Add(new Setter(Control.TemplateProperty,
  622. Application.Current.Resources["VerticalColumnHeader"] as ControlTemplate));
  623. }
  624. else
  625. {
  626. var image = imgcol.Image?.Invoke(null);
  627. if (image != null)
  628. {
  629. var template = new DataTemplate(typeof(TreeGridHeaderCell));
  630. var border = new FrameworkElementFactory(typeof(Border));
  631. border.SetValue(Border.BackgroundProperty, new SolidColorBrush(Colors.Gainsboro));
  632. border.SetValue(Border.PaddingProperty, new Thickness(4));
  633. border.SetValue(Control.MarginProperty, new Thickness(0, 0, 1, 1));
  634. var img = new FrameworkElementFactory(typeof(Image));
  635. img.SetValue(Image.SourceProperty, image);
  636. border.AppendChild(img);
  637. template.VisualTree = border;
  638. headstyle.Setters.Add(new Setter(TreeGridHeaderCell.PaddingProperty, new Thickness(0)));
  639. headstyle.Setters.Add(new Setter(TreeGridHeaderCell.ContentTemplateProperty, template));
  640. }
  641. }
  642. newcol.HeaderStyle = headstyle;
  643. _tree.Columns.Add(newcol);
  644. ColumnList.Add(column);
  645. }
  646. else if (column is DynamicTextColumn txtCol)
  647. {
  648. var newcol = new TreeGridTextColumn();
  649. newcol.TextWrapping = TextWrapping.NoWrap;
  650. newcol.TextAlignment = txtCol.Alignment == Alignment.NotSet
  651. ? TextAlignment.Left
  652. : txtCol.Alignment == Alignment.BottomLeft || txtCol.Alignment == Alignment.MiddleLeft ||
  653. txtCol.Alignment == Alignment.TopLeft
  654. ? TextAlignment.Left
  655. : txtCol.Alignment == Alignment.BottomCenter || txtCol.Alignment == Alignment.MiddleCenter ||
  656. txtCol.Alignment == Alignment.TopCenter
  657. ? TextAlignment.Center
  658. : TextAlignment.Right;
  659. newcol.AllowEditing = false;
  660. newcol.UpdateTrigger = UpdateSourceTrigger.PropertyChanged;
  661. newcol.MappingName = sColName;
  662. newcol.Width = column.Width;
  663. newcol.ColumnSizer = TreeColumnSizer.None;
  664. newcol.HeaderText = column.HeaderText;
  665. //newcol.AllowFiltering = column.Filters != null && column.Filters.Any();
  666. newcol.AllowSorting = false;
  667. newcol.ShowHeaderToolTip = column.ToolTip != null;
  668. ApplyFilterStyle(newcol, false, true);
  669. var headstyle = new Style(typeof(TreeGridHeaderCell));
  670. headstyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
  671. headstyle.Setters.Add(new Setter(Control.ForegroundProperty, new SolidColorBrush(Colors.Black)));
  672. headstyle.Setters.Add(new Setter(Control.FontSizeProperty, 12D));
  673. headstyle.Setters.Add(new Setter(Control.MarginProperty, new Thickness(0, -0.75, 0, 0.75)));
  674. headstyle.Setters.Add(new Setter(Control.BorderThicknessProperty, new Thickness(0.75)));
  675. headstyle.Setters.Add(new EventSetter(Control.MouseLeftButtonUpEvent, new MouseButtonEventHandler(HeaderCell_LeftMouseButtonEvent)));
  676. if (txtCol.VerticalHeader)
  677. {
  678. headstyle.Setters.Add(new Setter(Control.HorizontalContentAlignmentProperty, HorizontalAlignment.Left));
  679. headstyle.Setters.Add(new Setter(Control.TemplateProperty,
  680. Application.Current.Resources["VerticalColumnHeader"] as ControlTemplate));
  681. }
  682. newcol.HeaderStyle = headstyle;
  683. _tree.Columns.Add(newcol);
  684. ColumnList.Add(column);
  685. }
  686. else if (column is DynamicTemplateColumn tmplCol)
  687. {
  688. var newcol = new TreeGridTemplateColumn();
  689. newcol.CellTemplateSelector = new TemplateColumnSelector(this, tmplCol.Template);
  690. newcol.AllowEditing = false;
  691. newcol.UpdateTrigger = UpdateSourceTrigger.PropertyChanged;
  692. newcol.Width = tmplCol.Width;
  693. newcol.ColumnSizer = TreeColumnSizer.None;
  694. newcol.HeaderText = column.HeaderText;
  695. //newcol.AllowFiltering = false;
  696. newcol.AllowSorting = false;
  697. newcol.ShowToolTip = false;
  698. newcol.ShowHeaderToolTip = false;
  699. newcol.MappingName = sColName;
  700. ApplyFilterStyle(newcol, false, true);
  701. var headstyle = new Style(typeof(TreeGridHeaderCell));
  702. headstyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
  703. headstyle.Setters.Add(new Setter(Control.ForegroundProperty, new SolidColorBrush(Colors.Black)));
  704. headstyle.Setters.Add(new Setter(Control.FontSizeProperty, 12D));
  705. headstyle.Setters.Add(new Setter(Control.MarginProperty, new Thickness(0, -0.75, 0, 0.75)));
  706. headstyle.Setters.Add(new Setter(Control.BorderThicknessProperty, new Thickness(0.75)));
  707. headstyle.Setters.Add(new EventSetter(Control.MouseLeftButtonUpEvent, new MouseButtonEventHandler(HeaderCell_LeftMouseButtonEvent)));
  708. newcol.HeaderStyle = headstyle;
  709. _tree.Columns.Add(newcol);
  710. ColumnList.Add(column);
  711. }
  712. }
  713. }
  714. }
  715. private void LoadDataColumns(DynamicGridColumns columns)
  716. {
  717. foreach (var column in columns)
  718. {
  719. if(this.CreateEditorColumn(column, out var newcol, out var prop))
  720. {
  721. //newcol.GetEntity = () => _editingObject.Object;
  722. //newcol.EntityChanged += DoEntityChanged;
  723. var newColumn = newcol.CreateTreeGridColumn();
  724. //newColumn.AllowEditing = newcol.Editable && Parent.IsDirectEditMode();
  725. ApplyFilterStyle(newColumn, newcol.Filtered, false);
  726. var headstyle = new Style(typeof(TreeGridHeaderCell));
  727. headstyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
  728. headstyle.Setters.Add(new Setter(Control.ForegroundProperty, new SolidColorBrush(Colors.Black)));
  729. headstyle.Setters.Add(new Setter(Control.FontSizeProperty, 12D));
  730. newColumn.HeaderStyle = headstyle;
  731. var cellstyle = new Style();
  732. if (Parent.IsDirectEditMode())
  733. {
  734. if (prop.Editor is null || !prop.Editor.Editable.IsDirectEditable())
  735. {
  736. cellstyle.Setters.Add(new Setter(Control.BackgroundProperty,
  737. new SolidColorBrush(Colors.WhiteSmoke)));
  738. newColumn.AllowEditing = false;
  739. }
  740. else
  741. {
  742. cellstyle.Setters.Add(new Setter(Control.BackgroundProperty,
  743. new SolidColorBrush(Colors.LightYellow)));
  744. newColumn.AllowEditing = true;
  745. }
  746. cellstyle.Setters.Add(new Setter(Control.ForegroundProperty, new SolidColorBrush(Colors.Black)));
  747. newColumn.CellStyle = cellstyle;
  748. }
  749. else
  750. {
  751. cellstyle.Setters.Add(new Setter(Control.BackgroundProperty,
  752. new Binding()
  753. {
  754. Path = new PropertyPath("."), Converter = CellBackgroundConverter,
  755. ConverterParameter = new DynamicGridCellStyleParameters(column,DependencyProperty.UnsetValue)
  756. }));
  757. cellstyle.Setters.Add(new Setter(Control.ForegroundProperty,
  758. new Binding()
  759. {
  760. Converter = CellForegroundConverter,
  761. ConverterParameter = new DynamicGridCellStyleParameters(column,DependencyProperty.UnsetValue)
  762. }));
  763. cellstyle.Setters.Add(new Setter(Control.FontSizeProperty,
  764. new Binding()
  765. {
  766. Converter = CellFontSizeConverter,
  767. ConverterParameter = new DynamicGridCellStyleParameters(column,DependencyProperty.UnsetValue)
  768. }));
  769. cellstyle.Setters.Add(new Setter(Control.FontStyleProperty,
  770. new Binding()
  771. {
  772. Converter = CellFontStyleConverter,
  773. ConverterParameter = new DynamicGridCellStyleParameters(column,DependencyProperty.UnsetValue)
  774. }));
  775. cellstyle.Setters.Add(new Setter(Control.FontWeightProperty,
  776. new Binding()
  777. {
  778. Converter = CellFontWeightConverter,
  779. ConverterParameter = new DynamicGridCellStyleParameters(column,DependencyProperty.UnsetValue)
  780. }));
  781. newColumn.CellStyle = cellstyle;
  782. }
  783. _tree.Columns.Add(newColumn);
  784. ColumnList.Add(column);
  785. foreach (var extra in newcol.ExtraColumns)
  786. Parent.AddHiddenColumn(extra);
  787. }
  788. }
  789. }
  790. private void LoadStackedHeaders(DynamicGridColumnGroupings groupings)
  791. {
  792. _tree.StackedHeaderRows.Clear();
  793. foreach(var grouping in groupings)
  794. {
  795. var row = new StackedHeaderRow();
  796. var i = 0;
  797. foreach(var group in grouping.Groups)
  798. {
  799. var start = Math.Max(i, ColumnList.IndexOf(group.StartColumn));
  800. var end = Math.Max(start, ColumnList.IndexOf(group.EndColumn));
  801. if(end < start)
  802. {
  803. i = end + 1;
  804. continue;
  805. }
  806. var cols = Enumerable.Range(start, end - start + 1).Select(i => _tree.Columns[i]).ToArray();
  807. var stackedColumn = new StackedColumn
  808. {
  809. HeaderText = group.Header,
  810. ChildColumns = string.Join(',', cols.Select(x => x.MappingName))
  811. };
  812. row.StackedColumns.Add(stackedColumn);
  813. i = end + 1;
  814. }
  815. _tree.StackedHeaderRows.Add(row);
  816. }
  817. if(groupings.Count > 0)
  818. {
  819. _tree.CellRenderers.Remove("StackedHeader");
  820. _tree.CellRenderers.Add("StackedHeader", new StackedHeaderRenderer());
  821. }
  822. }
  823. public void RefreshColumns(DynamicGridColumns columns, DynamicActionColumns actionColumns, DynamicGridColumnGroupings groupings)
  824. {
  825. _tree.ItemsSource = null;
  826. _tree.Columns.Suspend();
  827. ColumnList.Clear();
  828. _tree.Columns.Clear();
  829. ActionColumns = actionColumns.ToList();
  830. //_tree.Columns.Add(new TreeGridTextColumn()
  831. // {
  832. // MappingName = "Number",
  833. // Width = _shownumbers ? 50 : 0,
  834. // TextAlignment = TextAlignment.Right
  835. // }
  836. //);
  837. LoadActionColumns(DynamicActionColumnPosition.Start);
  838. LoadDataColumns(columns);
  839. LoadActionColumns(DynamicActionColumnPosition.End);
  840. LoadStackedHeaders(groupings);
  841. _tree.Columns.Resume();
  842. _tree.RefreshColumns();
  843. foreach (var key in FilterPredicates.Keys.ToArray())
  844. if (_tree.Columns.Any(x => string.Equals(x.MappingName, key)))
  845. {
  846. var predicates = Serialization.Deserialize<List<FilterPredicate>>(FilterPredicates[key]);
  847. foreach (var predicate in predicates)
  848. {
  849. _tree.Columns[key].FilterPredicates.Add(predicate);
  850. }
  851. }
  852. else
  853. {
  854. FilterPredicates.Remove(key);
  855. }
  856. ResizeColumns(_tree, _tree.ActualWidth - 2, _tree.ActualHeight - 2);
  857. }
  858. private void ResizeColumns(SfTreeGrid grid, double width, double height)
  859. {
  860. if (Parent.Data == null || width <= 0)
  861. return;
  862. grid.Dispatcher.BeginInvoke(() =>
  863. {
  864. foreach (var (index, size) in this.CalculateColumnSizes(width))
  865. _tree.Columns[index].Width = Math.Max(0.0F, size);
  866. });
  867. }
  868. #endregion
  869. #region Refresh
  870. public CoreTreeNodes Nodes { get; set; }
  871. private CoreTable? _innerTable;
  872. public void BeforeRefresh()
  873. {
  874. _tree.SelectionForeground = DynamicGridUtils.SelectionForeground;
  875. _tree.SelectionBackground = DynamicGridUtils.SelectionBackground;
  876. }
  877. public void RefreshData(CoreTable data)
  878. {
  879. var nodes = new CoreTreeNodes();
  880. _innerTable = new CoreTable();
  881. _innerTable.LoadColumns(data.Columns);
  882. for (var i = 0; i < ActionColumns.Count; i++)
  883. _innerTable.Columns.Add(
  884. new CoreColumn
  885. {
  886. ColumnName = $"_ActionColumn{i}",
  887. DataType = ActionColumns[i] is DynamicImageColumn
  888. ? typeof(BitmapImage)
  889. : typeof(String)
  890. });
  891. foreach (var row in data.Rows)
  892. {
  893. var newRow = _innerTable.NewRow();
  894. ProcessRow(newRow, row);
  895. _innerTable.Rows.Add(newRow);
  896. var _id = row.Get<Guid>(IDColumn.Property);
  897. var _parent = row.Get<Guid>(ParentColumn.Property);
  898. nodes.Add(_id, _parent, newRow);
  899. }
  900. Nodes = nodes;
  901. _tree.ItemsSource = nodes.Nodes;
  902. CalculateRowHeight();
  903. ResizeColumns(_tree, _tree.ActualWidth - 1, _tree.ActualHeight);
  904. UpdateRecordCount();
  905. }
  906. private void ProcessRow(CoreRow innerRow, CoreRow row)
  907. {
  908. innerRow.LoadValues(row.Values);
  909. for (var i = 0; i < ActionColumns.Count; i++)
  910. {
  911. var ac = ActionColumns[i];
  912. innerRow[$"_ActionColumn{i}"] = ac.Data(row);
  913. }
  914. }
  915. private void CalculateRowHeight()
  916. {
  917. if(Parent.Data != null && Parent.Data.Rows.Count > 0)
  918. {
  919. var contentHeight = _tree.ActualHeight - (_tree.Padding.Top + _tree.Padding.Bottom) - 2; // Two extra pixels of space
  920. var targetHeight = contentHeight / Parent.Data.Rows.Count;
  921. _tree.RowHeight = Math.Max(Math.Min(targetHeight, MaxRowHeight), MinRowHeight);
  922. }
  923. }
  924. private void UpdateRecordCount()
  925. {
  926. var count = _tree.View != null ? _tree.View.Nodes.Count : Parent.Data.Rows.Count;
  927. Parent.UpdateRecordCount(count);
  928. }
  929. #endregion
  930. public void AddVisualFilter(string column, string value, FilterType filtertype = FilterType.Contains)
  931. {
  932. if (value.IsNullOrWhiteSpace())
  933. return;
  934. var col = _tree.Columns.FirstOrDefault((x => string.Equals(x.MappingName?.ToUpper(),column?.Replace(".", "_").ToUpper())));
  935. if (col != null)
  936. {
  937. col.FilterPredicates.Add(new FilterPredicate { FilterType = filtertype, FilterValue = value });
  938. }
  939. }
  940. public List<Tuple<string, Func<CoreRow, bool>>> GetFilterPredicates()
  941. {
  942. var list = new List<Tuple<string, Func<CoreRow, bool>>>();
  943. foreach (var column in _tree.Columns)
  944. {
  945. var colIndex = _tree.Columns.IndexOf(column);
  946. var col = ColumnList[colIndex];
  947. if (col is DynamicGridColumn gridColumn)
  948. {
  949. var rowPredicate = DynamicGridGridUIComponentExtension.ConvertColumnPredicates(gridColumn, column.FilterPredicates);
  950. if(rowPredicate is not null)
  951. {
  952. list.Add(new(gridColumn.ColumnName, rowPredicate));
  953. }
  954. }
  955. else if(col is DynamicActionColumn dac && dac.FilterRecord is not null && dac.SelectedFilters is not null && dac.SelectedFilters.Length > 0)
  956. {
  957. list.Add(new(column.MappingName, (row) => dac.FilterRecord(row, dac.SelectedFilters)));
  958. }
  959. }
  960. return list;
  961. }
  962. public CoreRow[] GetVisibleRows()
  963. {
  964. return _tree.View?.Nodes.Select(x => MapRow((x.Item as CoreTreeNode)?.Row)).NotNull().ToArray() ?? new CoreRow[] { };
  965. }
  966. public void InvalidateRow(CoreRow row)
  967. {
  968. if (_innerTable is null || row.Index < 0 || row.Index >= _innerTable.Rows.Count) return;
  969. var _innerRow = _innerTable.Rows[row.Index];
  970. ProcessRow(_innerRow, row);
  971. var coreTreeNode = Nodes.Find(_innerRow);
  972. coreTreeNode?.InvalidateData();
  973. }
  974. public void ScrollIntoView(CoreRow row)
  975. {
  976. _tree.ScrollInView(new RowColumnIndex(row.Index + 1, 0));
  977. }
  978. public void UpdateCell(CoreRow row, string column, object? value)
  979. {
  980. throw new NotImplementedException();
  981. }
  982. public void UpdateRow(CoreRow row)
  983. {
  984. throw new NotImplementedException();
  985. }
  986. #region Drag + Drop
  987. private void _tree_DragOver(object sender, DragEventArgs e)
  988. {
  989. Parent.DragOver(sender, e);
  990. }
  991. private void _tree_Drop(object sender, DragEventArgs e)
  992. {
  993. Parent.Drop(sender, e);
  994. }
  995. private void RowDragDropController_DragStart(object? sender, TreeGridRowDragStartEventArgs e)
  996. {
  997. var rows = e.DraggingNodes.Select(node => MapRow((node.Item as CoreTreeNode)?.Row)).NotNull().ToArray();
  998. Parent.DragStart(sender, rows);
  999. }
  1000. #endregion
  1001. }