From 974eb785b0228fa3fb60e3237ddaa6b48dc32dc3 Mon Sep 17 00:00:00 2001 From: CHINBOY Date: Fri, 30 May 2025 14:04:30 +0800 Subject: [PATCH] Remove Unused properties --- .../Column/DataGridColumn.Privates.cs | 5 --- .../Column/DataGridColumnHeader.cs | 5 --- .../DataGrid.Privates.cs | 10 ++--- src/AtomUI.Controls.DataGrid/DataGrid.Rows.cs | 13 ++---- src/AtomUI.Controls.DataGrid/DataGrid.cs | 44 +++---------------- 5 files changed, 16 insertions(+), 61 deletions(-) diff --git a/src/AtomUI.Controls.DataGrid/Column/DataGridColumn.Privates.cs b/src/AtomUI.Controls.DataGrid/Column/DataGridColumn.Privates.cs index 94c5cbf8e..cb0b04575 100644 --- a/src/AtomUI.Controls.DataGrid/Column/DataGridColumn.Privates.cs +++ b/src/AtomUI.Controls.DataGrid/Column/DataGridColumn.Privates.cs @@ -246,11 +246,6 @@ public abstract partial class DataGridColumn result[!ContentControl.ContentProperty] = this[!HeaderProperty]; result[!ContentControl.ContentTemplateProperty] = this[!HeaderTemplateProperty]; result[!DataGridColumnHeader.SizeTypeProperty] = OwningGrid[!DataGrid.SizeTypeProperty]; - // TODO 需要审查,原则上我们 AtomUI 是不允许整体自定义的 - if (OwningGrid.ColumnHeaderTheme is { } columnTheme) - { - result.SetValue(StyledElement.ThemeProperty, columnTheme, BindingPriority.Template); - } result.PointerPressed += (s, e) => { HeaderPointerPressed?.Invoke(this, e); }; result.PointerReleased += (s, e) => { HeaderPointerReleased?.Invoke(this, e); }; diff --git a/src/AtomUI.Controls.DataGrid/Column/DataGridColumnHeader.cs b/src/AtomUI.Controls.DataGrid/Column/DataGridColumnHeader.cs index 23885387e..096298f3b 100644 --- a/src/AtomUI.Controls.DataGrid/Column/DataGridColumnHeader.cs +++ b/src/AtomUI.Controls.DataGrid/Column/DataGridColumnHeader.cs @@ -735,11 +735,6 @@ public class DataGridColumnHeader : ContentControl IsEnabled = false, Content = GetDragIndicatorContent(Content, ContentTemplate) }; - if (OwningGrid.ColumnHeaderTheme is { } columnHeaderTheme) - { - dragIndicator.SetValue(ThemeProperty, columnHeaderTheme, BindingPriority.Template); - } - dragIndicator.PseudoClasses.Add(StdPseudoClass.DragIndicator); Control? dropLocationIndicator = OwningGrid.DropLocationIndicatorTemplate?.Build(); diff --git a/src/AtomUI.Controls.DataGrid/DataGrid.Privates.cs b/src/AtomUI.Controls.DataGrid/DataGrid.Privates.cs index 84e4bfd2a..6bbe07067 100644 --- a/src/AtomUI.Controls.DataGrid/DataGrid.Privates.cs +++ b/src/AtomUI.Controls.DataGrid/DataGrid.Privates.cs @@ -293,7 +293,7 @@ public partial class DataGrid _previousCurrentColumn = CurrentColumn; _previousCurrentItem = CurrentItem; - OnCurrentCellChanged(EventArgs.Empty); + NotifyCurrentCellChanged(EventArgs.Empty); } _flushCurrentCellChanged = false; @@ -2446,7 +2446,7 @@ public partial class DataGrid if (raiseEvents) { DataGridRowEditEndingEventArgs e = new DataGridRowEditEndingEventArgs(EditingRow, editAction); - OnRowEditEnding(e); + NotifyRowEditEnding(e); if (e.Cancel) { // RowEditEnding has been cancelled @@ -2494,7 +2494,7 @@ public partial class DataGrid // Raise the RowEditEnded event if (raiseEvents) { - OnRowEditEnded(new DataGridRowEditEndedEventArgs(editingRow, editAction)); + NotifyRowEditEnded(new DataGridRowEditEndedEventArgs(editingRow, editAction)); } return true; @@ -2575,7 +2575,7 @@ public partial class DataGrid SelectionChangedEventArgs e = _selectedItems.GetSelectionChangedEventArgs(); if (e.AddedItems.Count > 0 || e.RemovedItems.Count > 0) { - OnSelectionChanged(e); + NotifySelectionChanged(e); } } } @@ -2825,7 +2825,7 @@ public partial class DataGrid Debug.Assert(dataGridColumn != null); Debug.Assert(_editingEventArgs != null); _uneditedValue = dataGridColumn.PrepareCellForEditInternal(editingElement, _editingEventArgs); - OnPreparingCellForEdit(new DataGridPreparingCellForEditEventArgs(dataGridColumn, EditingRow, _editingEventArgs, + NotifyPreparingCellForEdit(new DataGridPreparingCellForEditEventArgs(dataGridColumn, EditingRow, _editingEventArgs, editingElement)); } diff --git a/src/AtomUI.Controls.DataGrid/DataGrid.Rows.cs b/src/AtomUI.Controls.DataGrid/DataGrid.Rows.cs index f14420301..f3d7db62a 100644 --- a/src/AtomUI.Controls.DataGrid/DataGrid.Rows.cs +++ b/src/AtomUI.Controls.DataGrid/DataGrid.Rows.cs @@ -1155,14 +1155,9 @@ public partial class DataGrid dataGridRow.Slot = slot; dataGridRow.OwningGrid = this; dataGridRow.DataContext = dataContext; - if (RowTheme is { } rowTheme) - { - dataGridRow.SetValue(ThemeProperty, rowTheme, BindingPriority.Template); - } CompleteCellsCollection(dataGridRow); - - OnLoadingRow(new DataGridRowEventArgs(dataGridRow)); + NotifyLoadingRow(new DataGridRowEventArgs(dataGridRow)); } return dataGridRow; @@ -1776,7 +1771,7 @@ public partial class DataGrid { if (IsRowRecyclable(row)) { - OnUnloadingRow(new DataGridRowEventArgs(row)); + NotifyUnloadingRow(new DataGridRowEventArgs(row)); } } // Raise Unloading Row for all the RowGroupHeaders we're displaying @@ -2155,7 +2150,7 @@ public partial class DataGrid // Raise UnloadingRow for any row that was visible if (IsSlotVisible(row.Slot)) { - OnUnloadingRow(new DataGridRowEventArgs(row)); + NotifyUnloadingRow(new DataGridRowEventArgs(row)); } row.DetachFromDataGrid(recycle && row.IsRecyclable /*recycle*/); @@ -2194,7 +2189,7 @@ public partial class DataGrid } // Raise UnloadingRow regardless of whether the row will be recycled - OnUnloadingRow(new DataGridRowEventArgs(dataGridRow)); + NotifyUnloadingRow(new DataGridRowEventArgs(dataGridRow)); bool recycleRow = CurrentSlot != dataGridRow.Index; if (recycleRow) diff --git a/src/AtomUI.Controls.DataGrid/DataGrid.cs b/src/AtomUI.Controls.DataGrid/DataGrid.cs index 9314b3aaa..c7f292ae5 100644 --- a/src/AtomUI.Controls.DataGrid/DataGrid.cs +++ b/src/AtomUI.Controls.DataGrid/DataGrid.cs @@ -75,24 +75,12 @@ public partial class DataGrid : TemplatedControl, defaultValue: double.NaN, validate: IsValidColumnHeaderHeight); - /// - /// Identifies the dependency property. - /// - public static readonly StyledProperty ColumnHeaderThemeProperty = - AvaloniaProperty.Register(nameof(ColumnHeaderTheme)); - /// /// Identifies the ColumnWidth dependency property. /// public static readonly StyledProperty ColumnWidthProperty = AvaloniaProperty.Register(nameof(ColumnWidth), defaultValue: DataGridLength.Auto); - /// - /// Identifies the dependency property. - /// - public static readonly StyledProperty RowThemeProperty = - AvaloniaProperty.Register(nameof(RowTheme)); - /// /// Identifies the dependency property. /// @@ -276,15 +264,6 @@ public partial class DataGrid : TemplatedControl, set => SetValue(ColumnWidthProperty, value); } - /// - /// Gets or sets the theme applied to all rows. - /// - public ControlTheme RowTheme - { - get => GetValue(RowThemeProperty); - set => SetValue(RowThemeProperty, value); - } - /// /// Gets or sets the theme applied to all cells. /// @@ -293,15 +272,6 @@ public partial class DataGrid : TemplatedControl, get => GetValue(CellThemeProperty); set => SetValue(CellThemeProperty, value); } - - /// - /// Gets or sets the theme applied to all column headers. - /// - public ControlTheme ColumnHeaderTheme - { - get => GetValue(ColumnHeaderThemeProperty); - set => SetValue(ColumnHeaderThemeProperty, value); - } /// /// Gets or sets the theme applied to all row groups. @@ -1225,7 +1195,7 @@ public partial class DataGrid : TemplatedControl, /// /// Raises the CurrentCellChanged event. /// - protected virtual void OnCurrentCellChanged(EventArgs e) + protected virtual void NotifyCurrentCellChanged(EventArgs e) { CurrentCellChanged?.Invoke(this, e); } @@ -1233,7 +1203,7 @@ public partial class DataGrid : TemplatedControl, /// /// Raises the LoadingRow event for row preparation. /// - protected virtual void OnLoadingRow(DataGridRowEventArgs e) + protected virtual void NotifyLoadingRow(DataGridRowEventArgs e) { EventHandler? handler = LoadingRow; if (handler != null) @@ -1276,7 +1246,7 @@ public partial class DataGrid : TemplatedControl, /// /// Raises the PreparingCellForEdit event. /// - protected virtual void OnPreparingCellForEdit(DataGridPreparingCellForEditEventArgs e) + protected virtual void NotifyPreparingCellForEdit(DataGridPreparingCellForEditEventArgs e) { PreparingCellForEdit?.Invoke(this, e); } @@ -1284,7 +1254,7 @@ public partial class DataGrid : TemplatedControl, /// /// Raises the RowEditEnded event. /// - protected virtual void OnRowEditEnded(DataGridRowEditEndedEventArgs e) + protected virtual void NotifyRowEditEnded(DataGridRowEditEndedEventArgs e) { RowEditEnded?.Invoke(this, e); } @@ -1292,7 +1262,7 @@ public partial class DataGrid : TemplatedControl, /// /// Raises the RowEditEnding event. /// - protected virtual void OnRowEditEnding(DataGridRowEditEndingEventArgs e) + protected virtual void NotifyRowEditEnding(DataGridRowEditEndingEventArgs e) { RowEditEnding?.Invoke(this, e); } @@ -1301,7 +1271,7 @@ public partial class DataGrid : TemplatedControl, /// Raises the SelectionChanged event and clears the _selectionChanged. /// This event won't get raised again until after _selectionChanged is set back to true. /// - protected virtual void OnSelectionChanged(SelectionChangedEventArgs e) + protected virtual void NotifySelectionChanged(SelectionChangedEventArgs e) { RaiseEvent(e); } @@ -1309,7 +1279,7 @@ public partial class DataGrid : TemplatedControl, /// /// Raises the UnloadingRow event for row recycling. /// - protected virtual void OnUnloadingRow(DataGridRowEventArgs e) + protected virtual void NotifyUnloadingRow(DataGridRowEventArgs e) { EventHandler? handler = UnloadingRow; if (handler != null)