Refactor into separate files
ADD
WalletWasabi.Fluent/TreeDataGrid/CustomElementFactory.cs
+using Avalonia.Controls;
+using Avalonia.Controls.Primitives;
+
+namespace WalletWasabi.Fluent.TreeDataGrid;
+
+internal class CustomElementFactory : TreeDataGridElementFactory
+{
+ protected override IControl CreateElement(object? data)
+ {
+ return data is PrivacyTextCell ?
+ new TreeDataGridPrivacyTextCell() :
+ base.CreateElement(data);
+ }
+
+ protected override string GetDataRecycleKey(object data)
+ {
+ return data is PrivacyTextCell ?
+ typeof(TreeDataGridPrivacyTextCell).FullName! :
+ base.GetDataRecycleKey(data);
+ }
+}

ADD
WalletWasabi.Fluent/TreeDataGrid/PrivacyTextCell.cs
+using Avalonia.Controls.Models.TreeDataGrid;
+
+namespace WalletWasabi.Fluent.TreeDataGrid;
+
+internal class PrivacyTextCell : ICell
+{
+ public PrivacyTextCell(string? value, int numberOfPrivacyChars)
+ {
+ Value = value;
+ NumberOfPrivacyChars = numberOfPrivacyChars;
+ }
+
+ public bool CanEdit => false;
+
+ public string? Value { get; }
+
+ public int NumberOfPrivacyChars { get; }
+
+ object? ICell.Value => Value;
+}

ADD
WalletWasabi.Fluent/TreeDataGrid/PrivacyTextColumn.cs
+using System.ComponentModel;
+using Avalonia.Controls;
+using Avalonia.Controls.Models.TreeDataGrid;
+
+namespace WalletWasabi.Fluent.TreeDataGrid;
+
+internal class PrivacyTextColumn<T> : ColumnBase<T>
+{
+ private readonly Func<T, string?> _getter;
+ private readonly Comparison<T?>? _sortAscending;
+ private readonly Comparison<T?>? _sortDescending;
+ private readonly int _numberOfPrivacyChars;
+
+ public PrivacyTextColumn(
+ object? header,
+ Func<T, string?> getter,
+ GridLength? width,
+ ColumnOptions<T>? options,
+ int numberOfPrivacyChars = 0)
+ : base(header, width, options)
+ {
+ _sortAscending = options?.CompareAscending;
+ _sortDescending = options?.CompareDescending;
+ _getter = getter;
+ _numberOfPrivacyChars = numberOfPrivacyChars;
+ }
+
+ public override ICell CreateCell(IRow<T> row)
+ {
+ return new PrivacyTextCell(_getter(row.Model), _numberOfPrivacyChars);
+ }
+
+ public override Comparison<T?>? GetComparison(ListSortDirection direction)
+ {
+ return direction switch
+ {
+ ListSortDirection.Ascending => _sortAscending,
+ ListSortDirection.Descending => _sortDescending,
+ _ => null,
+ };
+ }
+}

RENAME
WalletWasabi.Fluent/TreeDataGrid/CustomDrawCells.cs
WalletWasabi.Fluent/TreeDataGrid/TreeDataGridPrivacyTextCell.cs
using System.Collections.Generic;
-using System.ComponentModel;
using System.Reactive.Linq;
using Avalonia;
using Avalonia.Controls;
@@ -10,56 +9,6 @@ using ReactiveUI;
namespace WalletWasabi.Fluent.TreeDataGrid;
-internal class PrivacyTextCell : ICell
-{
- public PrivacyTextCell(string? value, int numberOfPrivacyChars)
- {
- Value = value;
- NumberOfPrivacyChars = numberOfPrivacyChars;
- }
- public bool CanEdit => false;
- public string? Value { get; }
- public int NumberOfPrivacyChars { get; }
- object? ICell.Value => Value;
-}
-
-internal class PrivacyTextColumn<T> : ColumnBase<T>
-{
- private readonly Func<T, string?> _getter;
- private readonly Comparison<T?>? _sortAscending;
- private readonly Comparison<T?>? _sortDescending;
- private readonly int _numberOfPrivacyChars;
-
- public PrivacyTextColumn(
- object? header,
- Func<T, string?> getter,
- GridLength? width,
- ColumnOptions<T>? options,
- int numberOfPrivacyChars = 0)
- : base(header, width, options)
- {
- _sortAscending = options?.CompareAscending;
- _sortDescending = options?.CompareDescending;
- _getter = getter;
- _numberOfPrivacyChars = numberOfPrivacyChars;
- }
-
- public override ICell CreateCell(IRow<T> row)
- {
- return new PrivacyTextCell(_getter(row.Model), _numberOfPrivacyChars);
- }
-
- public override Comparison<T?>? GetComparison(ListSortDirection direction)
- {
- return direction switch
- {
- ListSortDirection.Ascending => _sortAscending,
- ListSortDirection.Descending => _sortDescending,
- _ => null,
- };
- }
-}
-
internal class TreeDataGridPrivacyTextCell : TreeDataGridCell
{
private static readonly List<TreeDataGridPrivacyTextCell> Realized = new();
@@ -154,21 +103,3 @@ internal class TreeDataGridPrivacyTextCell : TreeDataGridCell
}
}
}
-
-internal class HistoryElementFactory : TreeDataGridElementFactory
-{
- protected override IControl CreateElement(object? data)
- {
- return data is PrivacyTextCell ?
- new TreeDataGridPrivacyTextCell() :
- base.CreateElement(data);
- }
-
- protected override string GetDataRecycleKey(object data)
- {
- return data is PrivacyTextCell ?
- typeof(TreeDataGridPrivacyTextCell).FullName! :
- base.GetDataRecycleKey(data);
- }
-}
-

MODIFY
WalletWasabi.Fluent/Views/Wallets/Home/History/HistoryTablePro.axaml
WalletWasabi.Fluent/Views/Wallets/Home/History/HistoryTablePro.axaml
CanUserResizeColumns="False"
Margin="0 0 0 0">
<TreeDataGrid.ElementFactory>
- <treeDataGrid:HistoryElementFactory />
+ <treeDataGrid:CustomElementFactory />
</TreeDataGrid.ElementFactory>
<TreeDataGrid.Styles>
<Style Selector="treeDataGrid|TreeDataGridPrivacyTextCell">

Refactor into separate files