diff --git a/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs b/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs index 915dbe1e51..897a7ebf45 100644 --- a/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs +++ b/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs @@ -51,24 +51,18 @@ namespace Avalonia.Collections /// A custom view for specialized sorting, filtering, grouping, and currency. IDataGridCollectionView CreateView(); } - + /// /// PagedCollectionView view over an IEnumerable. /// public sealed class CollectionViewBase : IDataGridCollectionView, IDataGridEditableCollectionView, INotifyPropertyChanged //IPagedCollectionView, { - #region Static Fields and Constants - /// /// Since there's nothing in the un-cancelable event args that is mutable, /// just create one instance to be used universally. /// private static readonly DataGridCurrentChangingEventArgs uncancelableCurrentChangingEventArgs = new DataGridCurrentChangingEventArgs(false); - #endregion Static Fields and Constants - - #region Private Fields - /// /// Value that we cache for the PageIndex if we are in a DeferRefresh, /// and the user has attempted to move to a different page. @@ -201,10 +195,6 @@ namespace Avalonia.Collections /// private IEnumerator _trackingEnumerator; - #endregion Private Fields - - #region Constructors - /// /// Helper constructor that sets default values for isDataSorted and isDataInGroupOrder. /// @@ -261,14 +251,6 @@ namespace Avalonia.Collections } } - #endregion Constructors - - #region Private Delegates - - #endregion Private Delegates - - #region Events - /// /// Raise this event when the (filtered) view changes /// @@ -319,10 +301,6 @@ namespace Avalonia.Collections remove { PropertyChanged -= value; } } - #endregion Events - - #region Enumerators - /// /// Enum for CollectionViewFlags /// @@ -382,8 +360,6 @@ namespace Avalonia.Collections IsUpdatePageSizeDeferred = 0x200 } - #endregion Enumerators - private Type _itemType; private Type ItemType { @@ -396,8 +372,6 @@ namespace Avalonia.Collections } } - #region Public Properties - /// /// Gets a value indicating whether the view supports AddNew. /// @@ -804,7 +778,6 @@ namespace Avalonia.Collections { get { return CheckFlag(CollectionViewFlags.NeedsRefresh); } } - /// /// Gets the current page we are on. (zero based) @@ -996,10 +969,6 @@ namespace Avalonia.Collections } } - #endregion Public Properties - - #region Private Properties - /// /// Gets a value indicating whether we have a valid ItemConstructor of the correct type /// @@ -1175,10 +1144,6 @@ namespace Avalonia.Collections get { return SortDescriptions.Count > 0 || Filter != null || _pageSize > 0 || GroupDescriptions.Count > 0; } } - #endregion Private Properties - - #region Indexers - /// /// Return the item at the specified index /// @@ -1189,10 +1154,6 @@ namespace Avalonia.Collections get { return GetItemAt(index); } } - #endregion Indexers - - #region Public Methods - /// /// Add a new item to the underlying collection. Returns the new item. /// After calling AddNew and changing the new item as desired, either @@ -2493,10 +2454,6 @@ namespace Avalonia.Collections } } - #endregion Public Methods - - #region Static Methods - /// /// Helper for SortList to handle nested properties (e.g. Address.Street) /// @@ -2514,10 +2471,6 @@ namespace Avalonia.Collections return propertyValue; } - #endregion Static Methods - - #region Private Methods - /// /// Fix up CurrentPosition and CurrentItem after a collection change /// @@ -3983,7 +3936,6 @@ namespace Avalonia.Collections IComparer comparer = new CultureSensitiveComparer(Culture); var itemType = ItemType; - foreach (DataGridSortDescription sort in SortDescriptions) { sort.Initialize(itemType); @@ -4016,10 +3968,6 @@ namespace Avalonia.Collections } } - #endregion Private Methods - - #region Private Classes - /// /// Creates a comparer class that takes in a CultureInfo as a parameter, /// which it will use when comparing strings. @@ -4042,8 +3990,6 @@ namespace Avalonia.Collections _culture = culture ?? CultureInfo.InvariantCulture; } - #region IComparer Members - /// /// Compares two objects and returns a value indicating whether one is less than, equal to or greater than the other. /// @@ -4078,8 +4024,6 @@ namespace Avalonia.Collections return Comparer.Default.Compare(x, y); } } - - #endregion } /// @@ -4367,8 +4311,6 @@ namespace Avalonia.Collections return min; } - } - - #endregion Private Classes + } } -} +} \ No newline at end of file diff --git a/src/Avalonia.Controls.DataGrid/Collections/DataGridGroupDescription.cs b/src/Avalonia.Controls.DataGrid/Collections/DataGridGroupDescription.cs index d04870ac2f..9d8ebbfac1 100644 --- a/src/Avalonia.Controls.DataGrid/Collections/DataGridGroupDescription.cs +++ b/src/Avalonia.Controls.DataGrid/Collections/DataGridGroupDescription.cs @@ -221,7 +221,6 @@ namespace Avalonia.Collections _parentGroup?.OnGroupByChanged(); } - /// /// Gets or sets the most recent index where activity took place /// @@ -254,7 +253,7 @@ namespace Avalonia.Collections } // we shouldn't get here, but just in case... - + return AvaloniaProperty.UnsetValue; } else @@ -536,7 +535,6 @@ namespace Avalonia.Collections } } - /// /// Update the item count of the CollectionViewGroup /// @@ -569,7 +567,6 @@ namespace Avalonia.Collections } } - /// /// Enumerator for the leaves in the CollectionViewGroupInternal class. /// @@ -602,8 +599,6 @@ namespace Avalonia.Collections _subEnum = null; } - #region Implement IEnumerator - /// /// Reset implementation for IEnumerator /// @@ -675,7 +670,6 @@ namespace Avalonia.Collections } } - #endregion Implement IEnumerator } // / @@ -925,7 +919,6 @@ namespace Avalonia.Collections set { _isDataInGroupOrder = value; } } - /// /// Finds the index of the specified item /// @@ -1087,7 +1080,6 @@ namespace Avalonia.Collections subgroup = new DataGridCollectionViewGroupInternal(key, group); InitializeGroup(subgroup, level + 1, item); - if (loading) { group.Add(subgroup); @@ -1104,7 +1096,6 @@ namespace Avalonia.Collections AddToSubgroups(item, subgroup, level + 1, loading); } - /// /// Add an item to the desired subgroup(s) of the given group /// @@ -1345,7 +1336,6 @@ namespace Avalonia.Collections } } - /// /// TopLevelGroupDescription class /// diff --git a/src/Avalonia.Controls.DataGrid/Collections/DataGridSortDescription.cs b/src/Avalonia.Controls.DataGrid/Collections/DataGridSortDescription.cs index e6b604b75f..86113da87e 100644 --- a/src/Avalonia.Controls.DataGrid/Collections/DataGridSortDescription.cs +++ b/src/Avalonia.Controls.DataGrid/Collections/DataGridSortDescription.cs @@ -69,8 +69,6 @@ namespace Avalonia.Collections _culture = culture ?? CultureInfo.InvariantCulture; } - #region IComparer Members - /// /// Compares two objects and returns a value indicating whether one is less than, equal to or greater than the other. /// @@ -106,7 +104,6 @@ namespace Avalonia.Collections } } - #endregion } private class DataGridPathSortDescription : DataGridSortDescription diff --git a/src/Avalonia.Controls.DataGrid/Collections/IDataGridCollectionView.cs b/src/Avalonia.Controls.DataGrid/Collections/IDataGridCollectionView.cs index ab4c1383f9..12f44fc4f8 100644 --- a/src/Avalonia.Controls.DataGrid/Collections/IDataGridCollectionView.cs +++ b/src/Avalonia.Controls.DataGrid/Collections/IDataGridCollectionView.cs @@ -104,7 +104,7 @@ namespace Avalonia.Collections /// Gets a collection of objects that describe how the items in the collection are grouped in the view. /// A collection of objects that describe how the items in the collection are grouped in the view. //ObservableCollection GroupDescriptions { get; } - + bool IsGrouping { get; } int GroupingDepth { get; } string GetGroupingPropertyNameAtDepth(int level); @@ -112,7 +112,7 @@ namespace Avalonia.Collections /// Gets the top-level groups. /// A read-only collection of the top-level groups or null if there are no groups. IAvaloniaReadOnlyList Groups { get; } - + /// Gets a value that indicates whether the view is empty. /// true if the view is empty; otherwise, false. bool IsEmpty { get; } diff --git a/src/Avalonia.Controls.DataGrid/DataGrid.cs b/src/Avalonia.Controls.DataGrid/DataGrid.cs index 31c5476640..893ad7d8ff 100644 --- a/src/Avalonia.Controls.DataGrid/DataGrid.cs +++ b/src/Avalonia.Controls.DataGrid/DataGrid.cs @@ -1,7 +1,7 @@ // (c) Copyright Microsoft Corporation. // This source is subject to the Microsoft Public License (Ms-PL). // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. +// All other rights reserved. using Avalonia.Collections; using Avalonia.Controls.Primitives; @@ -23,7 +23,7 @@ using System.Text; using System.Linq; using Avalonia.Input.Platform; using System.ComponentModel.DataAnnotations; -using Avalonia.Controls.Utils; +using Avalonia.Controls.Utils; namespace Avalonia.Controls { @@ -40,14 +40,14 @@ namespace Avalonia.Controls private const string DATAGRID_elementTopLeftCornerHeaderName = "PART_TopLeftCornerHeader"; private const string DATAGRID_elementTopRightCornerHeaderName = "PART_TopRightCornerHeader"; private const string DATAGRID_elementValidationSummary = "PART_ValidationSummary"; - private const string DATAGRID_elementVerticalScrollbarName = "PART_VerticalScrollbar"; + private const string DATAGRID_elementVerticalScrollbarName = "PART_VerticalScrollbar"; private const bool DATAGRID_defaultAutoGenerateColumns = true; internal const bool DATAGRID_defaultCanUserReorderColumns = true; internal const bool DATAGRID_defaultCanUserResizeColumns = true; internal const bool DATAGRID_defaultCanUserSortColumns = true; private const DataGridRowDetailsVisibilityMode DATAGRID_defaultRowDetailsVisibility = DataGridRowDetailsVisibilityMode.VisibleWhenSelected; - private const DataGridSelectionMode DATAGRID_defaultSelectionMode = DataGridSelectionMode.Extended; + private const DataGridSelectionMode DATAGRID_defaultSelectionMode = DataGridSelectionMode.Extended; /// /// The default order to use for columns when there is no @@ -57,7 +57,7 @@ namespace Avalonia.Controls /// The value of 10,000 comes from the DataAnnotations spec, allowing /// some properties to be ordered at the beginning and some at the end. /// - private const int DATAGRID_defaultColumnDisplayOrder = 10000; + private const int DATAGRID_defaultColumnDisplayOrder = 10000; private const double DATAGRID_horizontalGridLinesThickness = 1; private const double DATAGRID_minimumRowHeaderWidth = 4; @@ -65,32 +65,32 @@ namespace Avalonia.Controls internal const double DATAGRID_maximumStarColumnWidth = 10000; internal const double DATAGRID_minimumStarColumnWidth = 0.001; private const double DATAGRID_mouseWheelDelta = 48.0; - private const double DATAGRID_maxHeadersThickness = 32768; + private const double DATAGRID_maxHeadersThickness = 32768; private const double DATAGRID_defaultRowHeight = 22; internal const double DATAGRID_defaultRowGroupSublevelIndent = 20; private const double DATAGRID_defaultMinColumnWidth = 20; - private const double DATAGRID_defaultMaxColumnWidth = double.PositiveInfinity; + private const double DATAGRID_defaultMaxColumnWidth = double.PositiveInfinity; private List _validationErrors; private List _bindingValidationErrors; - private IDisposable _validationSubscription; + private IDisposable _validationSubscription; private INotifyCollectionChanged _topLevelGroup; - private ContentControl _clipboardContentControl; + private ContentControl _clipboardContentControl; private DataGridColumnHeadersPresenter _columnHeadersPresenter; private DataGridRowsPresenter _rowsPresenter; private ScrollBar _vScrollBar; - private ScrollBar _hScrollBar; + private ScrollBar _hScrollBar; private ContentControl _topLeftCornerHeader; private ContentControl _topRightCornerHeader; - private Control _frozenColumnScrollBarSpacer; + private Control _frozenColumnScrollBarSpacer; // the sum of the widths in pixels of the scrolling columns preceding // the first displayed scrolling column - private double _horizontalOffset; + private double _horizontalOffset; // the number of pixels of the firstDisplayedScrollingCol which are not displayed private double _negHorizontalOffset; @@ -99,11 +99,11 @@ namespace Avalonia.Controls private bool _autoSizingColumns; private IndexToValueTable _collapsedSlotsTable; private DataGridCellCoordinates _currentCellCoordinates; - private Control _clickedElement; - + private Control _clickedElement; + // used to store the current column during a Reset private int _desiredCurrentColumnIndex; - private int _editingColumnIndex; + private int _editingColumnIndex; // this is a workaround only for the scenarios where we need it, it is not all encompassing nor always updated private RoutedEventArgs _editingEventArgs; @@ -113,11 +113,11 @@ namespace Avalonia.Controls private IVisual _focusedObject; private byte _horizontalScrollChangesIgnored; private DataGridRow _focusedRow; - private bool _ignoreNextScrollBarsLayout; + private bool _ignoreNextScrollBarsLayout; // Nth row of rows 0..N that make up the RowHeightEstimate private int _lastEstimatedRow; - private List _loadedRows; + private List _loadedRows; // prevents reentry into the VerticalScroll event handler private Queue _lostFocusActions; @@ -137,22 +137,22 @@ namespace Avalonia.Controls private DataGridSelectedItemsCollection _selectedItems; private bool _temporarilyResetCurrentCell; private object _uneditedValue; // Represents the original current cell value at the time it enters editing mode. - private ICellEditBinding _currentCellEditBinding; + private ICellEditBinding _currentCellEditBinding; // An approximation of the sum of the heights in pixels of the scrolling rows preceding // the first displayed scrolling row. Since the scrolled off rows are discarded, the grid // does not know their actual height. The heights used for the approximation are the ones // set as the rows were scrolled off. private double _verticalOffset; - private byte _verticalScrollChangesIgnored; + private byte _verticalScrollChangesIgnored; - private IEnumerable _items; + private IEnumerable _items; /// /// Identifies the CanUserReorderColumns dependency property. /// public static readonly StyledProperty CanUserReorderColumnsProperty = - AvaloniaProperty.Register(nameof(CanUserReorderColumns)); + AvaloniaProperty.Register(nameof(CanUserReorderColumns)); /// /// Gets or sets a value that indicates whether the user can change @@ -162,13 +162,13 @@ namespace Avalonia.Controls { get { return GetValue(CanUserReorderColumnsProperty); } set { SetValue(CanUserReorderColumnsProperty, value); } - } + } /// /// Identifies the CanUserResizeColumns dependency property. /// public static readonly StyledProperty CanUserResizeColumnsProperty = - AvaloniaProperty.Register(nameof(CanUserResizeColumns)); + AvaloniaProperty.Register(nameof(CanUserResizeColumns)); /// /// Gets or sets a value that indicates whether the user can adjust column widths using the mouse. @@ -177,13 +177,13 @@ namespace Avalonia.Controls { get { return GetValue(CanUserResizeColumnsProperty); } set { SetValue(CanUserResizeColumnsProperty, value); } - } + } /// /// Identifies the CanUserSortColumns dependency property. /// public static readonly StyledProperty CanUserSortColumnsProperty = - AvaloniaProperty.Register(nameof(CanUserSortColumns), true); + AvaloniaProperty.Register(nameof(CanUserSortColumns), true); /// /// Gets or sets a value that indicates whether the user can sort columns by clicking the column header. @@ -192,7 +192,7 @@ namespace Avalonia.Controls { get { return GetValue(CanUserSortColumnsProperty); } set { SetValue(CanUserSortColumnsProperty, value); } - } + } /// /// Identifies the ColumnHeaderHeight dependency property. @@ -201,7 +201,7 @@ namespace Avalonia.Controls AvaloniaProperty.Register( nameof(ColumnHeaderHeight), defaultValue: double.NaN, - validate: ValidateColumnHeaderHeight); + validate: ValidateColumnHeaderHeight); private static double ValidateColumnHeaderHeight(DataGrid grid, double value) { @@ -212,10 +212,10 @@ namespace Avalonia.Controls if(value > DATAGRID_maxHeadersThickness) { throw DataGridError.DataGrid.ValueMustBeGreaterThanOrEqualTo(nameof(value), nameof(ColumnHeaderHeight), DATAGRID_maxHeadersThickness); - } + } return value; - } + } /// /// Gets or sets the height of the column headers row. @@ -224,13 +224,13 @@ namespace Avalonia.Controls { get { return GetValue(ColumnHeaderHeightProperty); } set { SetValue(ColumnHeaderHeightProperty, value); } - } + } /// /// Identifies the ColumnWidth dependency property. /// public static readonly StyledProperty ColumnWidthProperty = - AvaloniaProperty.Register(nameof(ColumnWidth), defaultValue: DataGridLength.Auto); + AvaloniaProperty.Register(nameof(ColumnWidth), defaultValue: DataGridLength.Auto); /// /// Gets or sets the standard width or automatic sizing mode of columns in the control. @@ -239,10 +239,10 @@ namespace Avalonia.Controls { get { return GetValue(ColumnWidthProperty); } set { SetValue(ColumnWidthProperty, value); } - } + } public static readonly StyledProperty AlternatingRowBackgroundProperty = - AvaloniaProperty.Register(nameof(AlternatingRowBackground)); + AvaloniaProperty.Register(nameof(AlternatingRowBackground)); /// /// Gets or sets the that is used to paint the background of odd-numbered rows. @@ -256,12 +256,12 @@ namespace Avalonia.Controls { get { return GetValue(AlternatingRowBackgroundProperty); } set { SetValue(AlternatingRowBackgroundProperty, value); } - } + } public static readonly StyledProperty FrozenColumnCountProperty = AvaloniaProperty.Register( nameof(FrozenColumnCount), - validate: ValidateFrozenColumnCount); + validate: ValidateFrozenColumnCount); /// /// Gets or sets the number of columns that the user cannot scroll horizontally. @@ -270,20 +270,20 @@ namespace Avalonia.Controls { get { return GetValue(FrozenColumnCountProperty); } set { SetValue(FrozenColumnCountProperty, value); } - } + } private static int ValidateFrozenColumnCount(DataGrid grid, int value) { if (value < 0) { throw DataGridError.DataGrid.ValueMustBeGreaterThanOrEqualTo(nameof(value), nameof(FrozenColumnCount), 0); - } + } return value; - } + } public static readonly StyledProperty GridLinesVisibilityProperty = - AvaloniaProperty.Register(nameof(GridLinesVisibility)); + AvaloniaProperty.Register(nameof(GridLinesVisibility)); /// /// Gets or sets a value that indicates which grid lines separating inner cells are shown. @@ -292,10 +292,10 @@ namespace Avalonia.Controls { get { return GetValue(GridLinesVisibilityProperty); } set { SetValue(GridLinesVisibilityProperty, value); } - } + } public static readonly StyledProperty HeadersVisibilityProperty = - AvaloniaProperty.Register(nameof(HeadersVisibility)); + AvaloniaProperty.Register(nameof(HeadersVisibility)); /// /// Gets or sets a value that indicates the visibility of row and column headers. @@ -304,10 +304,10 @@ namespace Avalonia.Controls { get { return GetValue(HeadersVisibilityProperty); } set { SetValue(HeadersVisibilityProperty, value); } - } + } public static readonly StyledProperty HorizontalGridLinesBrushProperty = - AvaloniaProperty.Register(nameof(HorizontalGridLinesBrush)); + AvaloniaProperty.Register(nameof(HorizontalGridLinesBrush)); /// /// Gets or sets the that is used to paint grid lines separating rows. @@ -316,10 +316,10 @@ namespace Avalonia.Controls { get { return GetValue(HorizontalGridLinesBrushProperty); } set { SetValue(HorizontalGridLinesBrushProperty, value); } - } + } public static readonly StyledProperty HorizontalScrollBarVisibilityProperty = - AvaloniaProperty.Register(nameof(HorizontalScrollBarVisibility)); + AvaloniaProperty.Register(nameof(HorizontalScrollBarVisibility)); /// /// Gets or sets a value that indicates how the horizontal scroll bar is displayed. @@ -328,10 +328,10 @@ namespace Avalonia.Controls { get { return GetValue(HorizontalScrollBarVisibilityProperty); } set { SetValue(HorizontalScrollBarVisibilityProperty, value); } - } + } public static readonly StyledProperty IsReadOnlyProperty = - AvaloniaProperty.Register(nameof(IsReadOnly)); + AvaloniaProperty.Register(nameof(IsReadOnly)); /// /// Gets or sets a value that indicates whether the user can edit the values in the control. @@ -340,13 +340,12 @@ namespace Avalonia.Controls { get { return GetValue(IsReadOnlyProperty); } set { SetValue(IsReadOnlyProperty, value); } - } - + } public static readonly StyledProperty AreRowGroupHeadersFrozenProperty = AvaloniaProperty.Register( nameof(AreRowGroupHeadersFrozen), - defaultValue: true); + defaultValue: true); /// /// Gets or sets a value that indicates whether the row group header sections @@ -356,12 +355,12 @@ namespace Avalonia.Controls { get { return GetValue(AreRowGroupHeadersFrozenProperty); } set { SetValue(AreRowGroupHeadersFrozenProperty, value); } - } + } private void OnAreRowGroupHeadersFrozenChanged(AvaloniaPropertyChangedEventArgs e) { var value = (bool)e.NewValue; - ProcessFrozenColumnCount(); + ProcessFrozenColumnCount(); // Update elements in the RowGroupHeader that were previously frozen if (value) @@ -377,27 +376,26 @@ namespace Avalonia.Controls } } } - } - - private bool _isValid = true; + } + + private bool _isValid = true; public static readonly DirectProperty IsValidProperty = AvaloniaProperty.RegisterDirect( nameof(IsValid), - o => o.IsValid); + o => o.IsValid); public bool IsValid { get { return _isValid; } internal set { SetAndRaise(IsValidProperty, ref _isValid, value); } - } - + } public static readonly StyledProperty MaxColumnWidthProperty = AvaloniaProperty.Register( nameof(MaxColumnWidth), defaultValue: DATAGRID_defaultMaxColumnWidth, - validate: ValidateMaxColumnWidth); + validate: ValidateMaxColumnWidth); private static double ValidateMaxColumnWidth(DataGrid grid, double value) { @@ -412,15 +410,15 @@ namespace Avalonia.Controls if (grid.MinColumnWidth > value) { throw DataGridError.DataGrid.ValueMustBeGreaterThanOrEqualTo(nameof(value), nameof(MaxColumnWidth), nameof(MinColumnWidth)); - } + } if (value < 0) { throw DataGridError.DataGrid.ValueMustBeGreaterThanOrEqualTo(nameof(value), nameof(FrozenColumnCount), 0); - } + } return value; - } + } /// /// Gets or sets the maximum width of columns in the . @@ -429,13 +427,13 @@ namespace Avalonia.Controls { get { return GetValue(MaxColumnWidthProperty); } set { SetValue(MaxColumnWidthProperty, value); } - } + } public static readonly StyledProperty MinColumnWidthProperty = AvaloniaProperty.Register( nameof(MinColumnWidth), defaultValue: DATAGRID_defaultMinColumnWidth, - validate: ValidateMinColumnWidth); + validate: ValidateMinColumnWidth); private static double ValidateMinColumnWidth(DataGrid grid, double value) { @@ -454,11 +452,10 @@ namespace Avalonia.Controls if (grid.MaxColumnWidth < value) { throw DataGridError.DataGrid.ValueMustBeLessThanOrEqualTo(nameof(value), nameof(MinColumnWidth), nameof(MaxColumnWidth)); - } + } return value; - } - + } /// /// Gets or sets the minimum width of columns in the . @@ -467,11 +464,10 @@ namespace Avalonia.Controls { get { return GetValue(MinColumnWidthProperty); } set { SetValue(MinColumnWidthProperty, value); } - } - + } public static readonly StyledProperty RowBackgroundProperty = - AvaloniaProperty.Register(nameof(RowBackground)); + AvaloniaProperty.Register(nameof(RowBackground)); /// /// Gets or sets the that is used to paint row backgrounds. @@ -480,7 +476,7 @@ namespace Avalonia.Controls { get { return GetValue(RowBackgroundProperty); } set { SetValue(RowBackgroundProperty, value); } - } + } public static readonly StyledProperty RowHeightProperty = AvaloniaProperty.Register( @@ -496,10 +492,10 @@ namespace Avalonia.Controls if (value > DataGridRow.DATAGRIDROW_maximumHeight) { throw DataGridError.DataGrid.ValueMustBeLessThanOrEqualTo(nameof(value), nameof(RowHeight), DataGridRow.DATAGRIDROW_maximumHeight); - } + } return value; - } + } /// /// Gets or sets the standard height of rows in the control. @@ -508,8 +504,7 @@ namespace Avalonia.Controls { get { return GetValue(RowHeightProperty); } set { SetValue(RowHeightProperty, value); } - } - + } public static readonly StyledProperty RowHeaderWidthProperty = AvaloniaProperty.Register( @@ -525,10 +520,10 @@ namespace Avalonia.Controls if (value > DATAGRID_maxHeadersThickness) { throw DataGridError.DataGrid.ValueMustBeLessThanOrEqualTo(nameof(value), nameof(RowHeaderWidth), DATAGRID_maxHeadersThickness); - } + } return value; - } + } /// /// Gets or sets the width of the row header column. @@ -537,10 +532,10 @@ namespace Avalonia.Controls { get { return GetValue(RowHeaderWidthProperty); } set { SetValue(RowHeaderWidthProperty, value); } - } + } public static readonly StyledProperty SelectionModeProperty = - AvaloniaProperty.Register(nameof(SelectionMode)); + AvaloniaProperty.Register(nameof(SelectionMode)); /// /// Gets or sets the selection behavior of the data grid. @@ -549,11 +544,10 @@ namespace Avalonia.Controls { get { return GetValue(SelectionModeProperty); } set { SetValue(SelectionModeProperty, value); } - } - + } public static readonly StyledProperty VerticalGridLinesBrushProperty = - AvaloniaProperty.Register(nameof(VerticalGridLinesBrush)); + AvaloniaProperty.Register(nameof(VerticalGridLinesBrush)); /// /// Gets or sets the that is used to paint grid lines separating columns. @@ -562,10 +556,10 @@ namespace Avalonia.Controls { get { return GetValue(VerticalGridLinesBrushProperty); } set { SetValue(VerticalGridLinesBrushProperty, value); } - } + } public static readonly StyledProperty VerticalScrollBarVisibilityProperty = - AvaloniaProperty.Register(nameof(VerticalScrollBarVisibility)); + AvaloniaProperty.Register(nameof(VerticalScrollBarVisibility)); /// /// Gets or sets a value that indicates how the vertical scroll bar is displayed. @@ -574,10 +568,10 @@ namespace Avalonia.Controls { get { return GetValue(VerticalScrollBarVisibilityProperty); } set { SetValue(VerticalScrollBarVisibilityProperty, value); } - } + } public static readonly StyledProperty> DropLocationIndicatorTemplateProperty = - AvaloniaProperty.Register>(nameof(DropLocationIndicatorTemplate)); + AvaloniaProperty.Register>(nameof(DropLocationIndicatorTemplate)); /// /// Gets or sets the template that is used when rendering the column headers. @@ -586,16 +580,16 @@ namespace Avalonia.Controls { get { return GetValue(DropLocationIndicatorTemplateProperty); } set { SetValue(DropLocationIndicatorTemplateProperty, value); } - } - + } + private int _selectedIndex = -1; - private object _selectedItem; + private object _selectedItem; public static readonly DirectProperty SelectedIndexProperty = AvaloniaProperty.RegisterDirect( nameof(SelectedIndex), o => o.SelectedIndex, - (o, v) => o.SelectedIndex = v); + (o, v) => o.SelectedIndex = v); /// /// Gets or sets the index of the current selection. @@ -607,13 +601,13 @@ namespace Avalonia.Controls { get { return _selectedIndex; } set { SetAndRaise(SelectedIndexProperty, ref _selectedIndex, value); } - } + } public static readonly DirectProperty SelectedItemProperty = AvaloniaProperty.RegisterDirect( nameof(SelectedItem), o => o.SelectedItem, - (o, v) => o.SelectedItem = v); + (o, v) => o.SelectedItem = v); /// /// Gets or sets the data item corresponding to the selected row. @@ -622,13 +616,12 @@ namespace Avalonia.Controls { get { return _selectedItem; } set { SetAndRaise(SelectedItemProperty, ref _selectedItem, value); } - } - + } public static readonly StyledProperty ClipboardCopyModeProperty = AvaloniaProperty.Register( nameof(ClipboardCopyMode), - defaultValue: DataGridClipboardCopyMode.ExcludeHeader); + defaultValue: DataGridClipboardCopyMode.ExcludeHeader); /// /// The property which determines how DataGrid content is copied to the Clipboard. @@ -637,10 +630,10 @@ namespace Avalonia.Controls { get { return GetValue(ClipboardCopyModeProperty); } set { SetValue(ClipboardCopyModeProperty, value); } - } + } public static readonly StyledProperty AutoGenerateColumnsProperty = - AvaloniaProperty.Register(nameof(AutoGenerateColumns)); + AvaloniaProperty.Register(nameof(AutoGenerateColumns)); /// /// Gets or sets a value that indicates whether columns are created @@ -650,7 +643,7 @@ namespace Avalonia.Controls { get { return GetValue(AutoGenerateColumnsProperty); } set { SetValue(AutoGenerateColumnsProperty, value); } - } + } private void OnAutoGenerateColumnsChanged(AvaloniaPropertyChangedEventArgs e) { @@ -663,8 +656,8 @@ namespace Avalonia.Controls { RemoveAutoGeneratedColumns(); } - } - + } + /// /// Identifies the ItemsSource dependency property. /// @@ -672,7 +665,7 @@ namespace Avalonia.Controls AvaloniaProperty.RegisterDirect( nameof(Items), o => o.Items, - (o, v) => o.Items = v); + (o, v) => o.Items = v); /// /// Gets or sets a collection that is used to generate the content of the control. @@ -681,11 +674,10 @@ namespace Avalonia.Controls { get { return _items; } set { SetAndRaise(ItemsProperty, ref _items, value); } - } - + } public static readonly StyledProperty AreRowDetailsFrozenProperty = - AvaloniaProperty.Register(nameof(AreRowDetailsFrozen)); + AvaloniaProperty.Register(nameof(AreRowDetailsFrozen)); /// /// Gets or sets a value that indicates whether the row details sections remain @@ -695,10 +687,10 @@ namespace Avalonia.Controls { get { return GetValue(AreRowDetailsFrozenProperty); } set { SetValue(AreRowDetailsFrozenProperty, value); } - } + } public static readonly StyledProperty RowDetailsTemplateProperty = - AvaloniaProperty.Register(nameof(RowDetailsTemplate)); + AvaloniaProperty.Register(nameof(RowDetailsTemplate)); /// /// Gets or sets the template that is used to display the content of the details section of rows. @@ -707,11 +699,10 @@ namespace Avalonia.Controls { get { return GetValue(RowDetailsTemplateProperty); } set { SetValue(RowDetailsTemplateProperty, value); } - } - + } public static readonly StyledProperty RowDetailsVisibilityModeProperty = - AvaloniaProperty.Register(nameof(RowDetailsVisibilityMode)); + AvaloniaProperty.Register(nameof(RowDetailsVisibilityMode)); /// /// Gets or sets a value that indicates when the details sections of rows are displayed. @@ -720,16 +711,16 @@ namespace Avalonia.Controls { get { return GetValue(RowDetailsVisibilityModeProperty); } set { SetValue(RowDetailsVisibilityModeProperty, value); } - } + } static DataGrid() { AffectsMeasure( ColumnHeaderHeightProperty, HorizontalScrollBarVisibilityProperty, - VerticalScrollBarVisibilityProperty); + VerticalScrollBarVisibilityProperty); - PseudoClass(IsValidProperty, x => !x, ":invalid"); + PseudoClass(IsValidProperty, x => !x, ":invalid"); ItemsProperty.Changed.AddClassHandler(x => x.OnItemsPropertyChanged); CanUserResizeColumnsProperty.Changed.AddClassHandler(x => x.OnCanUserResizeColumnsChanged); @@ -754,7 +745,7 @@ namespace Avalonia.Controls RowDetailsTemplateProperty.Changed.AddClassHandler(x => x.OnRowDetailsTemplateChanged); RowDetailsVisibilityModeProperty.Changed.AddClassHandler(x => x.OnRowDetailsVisibilityModeChanged); AutoGenerateColumnsProperty.Changed.AddClassHandler(x => x.OnAutoGenerateColumnsChanged); - } + } /// /// Initializes a new instance of the class. @@ -762,38 +753,38 @@ namespace Avalonia.Controls public DataGrid() { KeyDown += DataGrid_KeyDown; - KeyUp += DataGrid_KeyUp; + KeyUp += DataGrid_KeyUp; //TODO: Check if override works GotFocus += DataGrid_GotFocus; - LostFocus += DataGrid_LostFocus; + LostFocus += DataGrid_LostFocus; _loadedRows = new List(); _lostFocusActions = new Queue(); _selectedItems = new DataGridSelectedItemsCollection(this); RowGroupHeadersTable = new IndexToValueTable(); - _bindingValidationErrors = new List(); + _bindingValidationErrors = new List(); DisplayData = new DataGridDisplayData(this); - ColumnsInternal = CreateColumnsInstance(); + ColumnsInternal = CreateColumnsInstance(); RowHeightEstimate = DATAGRID_defaultRowHeight; RowDetailsHeightEstimate = 0; - _rowHeaderDesiredWidth = 0; + _rowHeaderDesiredWidth = 0; DataConnection = new DataGridDataConnection(this); _showDetailsTable = new IndexToValueTable(); - _collapsedSlotsTable = new IndexToValueTable(); + _collapsedSlotsTable = new IndexToValueTable(); AnchorSlot = -1; _lastEstimatedRow = -1; _editingColumnIndex = -1; _mouseOverRowIndex = null; - CurrentCellCoordinates = new DataGridCellCoordinates(-1, -1); + CurrentCellCoordinates = new DataGridCellCoordinates(-1, -1); RowGroupHeaderHeightEstimate = DATAGRID_defaultRowHeight; - } - + } + private void SetValueNoCallback(AvaloniaProperty property, T value, BindingPriority priority = BindingPriority.LocalValue) { _areHandlersSuspended = true; @@ -805,15 +796,15 @@ namespace Avalonia.Controls { _areHandlersSuspended = false; } - } + } private void OnRowDetailsVisibilityModeChanged(AvaloniaPropertyChangedEventArgs e) { UpdateRowDetailsVisibilityMode((DataGridRowDetailsVisibilityMode)e.NewValue); - } - + } + private void OnRowDetailsTemplateChanged(AvaloniaPropertyChangedEventArgs e) - { + { // Update the RowDetails templates if necessary if (_rowsPresenter != null) @@ -826,11 +817,11 @@ namespace Avalonia.Controls row.ApplyDetailsTemplate(initializeDetailsPreferredHeight: false); } } - } + } UpdateRowDetailsHeightEstimate(); InvalidateMeasure(); - } + } /// /// ItemsProperty property changed handler. @@ -840,33 +831,33 @@ namespace Avalonia.Controls { if (!_areHandlersSuspended) { - Debug.Assert(DataConnection != null); + Debug.Assert(DataConnection != null); var oldValue = (IEnumerable)e.OldValue; - var newItemsSource = (IEnumerable)e.NewValue; + var newItemsSource = (IEnumerable)e.NewValue; if (LoadingOrUnloadingRow) { SetValueNoCallback(ItemsProperty, oldValue); throw DataGridError.DataGrid.CannotChangeItemsWhenLoadingRows(); - } + } // Try to commit edit on the old DataSource, but force a cancel if it fails if (!CommitEdit()) { CancelEdit(DataGridEditingUnit.Row, false); - } + } DataConnection.UnWireEvents(DataConnection.DataSource); DataConnection.ClearDataProperties(); - ClearRowGroupHeadersTable(); + ClearRowGroupHeadersTable(); // The old selected indexes are no longer relevant. There's a perf benefit from // updating the selected indexes with a null DataSource, because we know that all // of the previously selected indexes have been removed from selection DataConnection.DataSource = null; _selectedItems.UpdateIndexes(); - CoerceSelectedItem(); + CoerceSelectedItem(); // Wrap an IEnumerable in an ICollectionView if it's not already one bool setDefaultSelection = false; @@ -878,7 +869,7 @@ namespace Avalonia.Controls { DataConnection.DataSource = newItemsSource; setDefaultSelection = true; - } + } if (DataConnection.DataSource != null) { @@ -894,14 +885,14 @@ namespace Avalonia.Controls } } DataConnection.WireEvents(DataConnection.DataSource); - } + } // Wait for the current cell to be set before we raise any SelectionChanged events - _makeFirstDisplayedCellCurrentCellPending = true; + _makeFirstDisplayedCellCurrentCellPending = true; // Clear out the old rows and remove the generated columns ClearRows(false); //recycle - RemoveAutoGeneratedColumns(); + RemoveAutoGeneratedColumns(); // Set the SlotCount (from the data count and number of row group headers) before we make the default selection PopulateRowGroupHeadersTable(); @@ -909,7 +900,7 @@ namespace Avalonia.Controls if (DataConnection.CollectionView != null && setDefaultSelection) { SelectedItem = DataConnection.CollectionView.CurrentItem; - } + } // Treat this like the DataGrid has never been measured because all calculations at // this point are invalid until the next layout cycle. For instance, the ItemsSource @@ -917,13 +908,13 @@ namespace Avalonia.Controls _measured = false; InvalidateMeasure(); } - } + } private void OnSelectedIndexChanged(AvaloniaPropertyChangedEventArgs e) { if (!_areHandlersSuspended) { - int index = (int)e.NewValue; + int index = (int)e.NewValue; // GetDataItem returns null if index is >= Count, we do not check newValue // against Count here to avoid enumerating through an Enumerable twice @@ -935,7 +926,7 @@ namespace Avalonia.Controls SetValueNoCallback(SelectedIndexProperty, (int)e.OldValue); } } - } + } private void OnSelectedItemChanged(AvaloniaPropertyChangedEventArgs e) { @@ -950,7 +941,7 @@ namespace Avalonia.Controls // Edited value couldn't be committed or aborted SetValueNoCallback(SelectedItemProperty, e.OldValue); return; - } + } // Clear all row selections ClearRowSelection(resetAnchorSlot: true); @@ -973,14 +964,14 @@ namespace Avalonia.Controls DataConnection.CollectionView.MoveCurrentToPosition(rowIndex); } } - } + } int oldSelectedIndex = SelectedIndex; SetValueNoCallback(SelectedIndexProperty, rowIndex); try { _noSelectionChangeCount++; - int columnIndex = CurrentColumnIndex; + int columnIndex = CurrentColumnIndex; if (columnIndex == -1) { @@ -990,14 +981,14 @@ namespace Avalonia.Controls { ClearRowSelection(slotException: slot, setAnchorSlot: true); return; - } + } UpdateSelectionAndCurrency(columnIndex, slot, DataGridSelectionAction.SelectCurrent, scrollIntoView: false); } finally { NoSelectionChangeCount--; - } + } if (!_successfullyUpdatedSelection) { @@ -1006,7 +997,7 @@ namespace Avalonia.Controls } } } - } + } private void OnVerticalGridLinesBrushChanged(AvaloniaPropertyChangedEventArgs e) { @@ -1017,7 +1008,7 @@ namespace Avalonia.Controls row.EnsureGridLines(); } } - } + } private void OnSelectionModeChanged(AvaloniaPropertyChangedEventArgs e) { @@ -1025,7 +1016,7 @@ namespace Avalonia.Controls { ClearRowSelection(resetAnchorSlot: true); } - } + } private void OnRowHeaderWidthChanged(AvaloniaPropertyChangedEventArgs e) { @@ -1033,7 +1024,7 @@ namespace Avalonia.Controls { EnsureRowHeaderWidth(); } - } + } private void OnRowHeightChanged(AvaloniaPropertyChangedEventArgs e) { @@ -1045,7 +1036,7 @@ namespace Avalonia.Controls // DataGrid needs to update the layout information and the ScrollBars InvalidateMeasure(); } - } + } private void OnMinColumnWidthChanged(AvaloniaPropertyChangedEventArgs e) { @@ -1057,7 +1048,7 @@ namespace Avalonia.Controls OnColumnMinWidthChanged(column, Math.Max(column.MinWidth, oldValue)); } } - } + } private void OnMaxColumnWidthChanged(AvaloniaPropertyChangedEventArgs e) { @@ -1069,7 +1060,7 @@ namespace Avalonia.Controls OnColumnMaxWidthChanged(column, Math.Min(column.MaxWidth, oldValue)); } } - } + } private void OnIsReadOnlyChanged(AvaloniaPropertyChangedEventArgs e) { @@ -1081,7 +1072,7 @@ namespace Avalonia.Controls CancelEdit(DataGridEditingUnit.Row, raiseEvents: false); } } - } + } private void OnHorizontalGridLinesBrushChanged(AvaloniaPropertyChangedEventArgs e) { @@ -1092,18 +1083,18 @@ namespace Avalonia.Controls row.EnsureGridLines(); } } - } + } private void OnHeadersVisibilityChanged(AvaloniaPropertyChangedEventArgs e) { var oldValue = (DataGridHeadersVisibility)e.OldValue; var newValue = (DataGridHeadersVisibility)e.NewValue; - bool hasFlags(DataGridHeadersVisibility value, DataGridHeadersVisibility flags) => ((value & flags) == flags); + bool hasFlags(DataGridHeadersVisibility value, DataGridHeadersVisibility flags) => ((value & flags) == flags); bool newValueCols = hasFlags(newValue, DataGridHeadersVisibility.Column); bool newValueRows = hasFlags(newValue, DataGridHeadersVisibility.Row); bool oldValueCols = hasFlags(oldValue, DataGridHeadersVisibility.Column); - bool oldValueRows = hasFlags(oldValue, DataGridHeadersVisibility.Row); + bool oldValueRows = hasFlags(oldValue, DataGridHeadersVisibility.Row); // Columns if (newValueCols != oldValueCols) @@ -1121,7 +1112,7 @@ namespace Avalonia.Controls } InvalidateMeasure(); } - } + } // Rows if (newValueRows != oldValueRows) @@ -1147,7 +1138,7 @@ namespace Avalonia.Controls InvalidateRowHeightEstimate(); InvalidateRowsMeasure(invalidateIndividualElements: true); } - } + } if (_topLeftCornerHeader != null) { @@ -1156,9 +1147,9 @@ namespace Avalonia.Controls { _topLeftCornerHeader.Measure(Size.Empty); } - } + } - } + } private void OnGridLinesVisibilityChanged(AvaloniaPropertyChangedEventArgs e) { @@ -1167,21 +1158,21 @@ namespace Avalonia.Controls row.EnsureGridLines(); row.InvalidateHorizontalArrange(); } - } + } private void OnFrozenColumnCountChanged(AvaloniaPropertyChangedEventArgs e) { ProcessFrozenColumnCount(); - } + } private void ProcessFrozenColumnCount() { CorrectColumnFrozenStates(); - ComputeScrollBarsLayout(); + ComputeScrollBarsLayout(); InvalidateColumnHeadersArrange(); InvalidateCellsArrange(); - } + } private void OnRowBackgroundChanged(AvaloniaPropertyChangedEventArgs e) { @@ -1189,104 +1180,102 @@ namespace Avalonia.Controls { row.EnsureBackground(); } - } + } private void OnColumnWidthChanged(AvaloniaPropertyChangedEventArgs e) { - var value = (DataGridLength)e.NewValue; - + var value = (DataGridLength)e.NewValue; + foreach (DataGridColumn column in ColumnsInternal.GetDisplayedColumns()) { if (column.InheritsWidth) { column.SetWidthInternalNoCallback(value); } - } + } EnsureHorizontalLayout(); - } + } private void OnCanUserResizeColumnsChanged(AvaloniaPropertyChangedEventArgs e) { EnsureHorizontalLayout(); - } + } - #region Events - /// /// Occurs one time for each public, non-static property in the bound data type when the /// property is changed and the /// property is true. /// - public event EventHandler AutoGeneratingColumn; + public event EventHandler AutoGeneratingColumn; /// /// Occurs before a cell or row enters editing mode. /// - public event EventHandler BeginningEdit; + public event EventHandler BeginningEdit; /// /// Occurs after cell editing has ended. /// - public event EventHandler CellEditEnded; + public event EventHandler CellEditEnded; /// /// Occurs immediately before cell editing has ended. /// - public event EventHandler CellEditEnding; + public event EventHandler CellEditEnding; /// /// Occurs when cell is mouse-pressed. /// - public event EventHandler CellPointerPressed; + public event EventHandler CellPointerPressed; /// /// Occurs when the /// property of a column changes. /// - public event EventHandler ColumnDisplayIndexChanged; + public event EventHandler ColumnDisplayIndexChanged; /// /// Raised when column reordering ends, to allow subscribers to clean up. /// - public event EventHandler ColumnReordered; + public event EventHandler ColumnReordered; /// /// Raised when starting a column reordering action. Subscribers to this event can /// set tooltip and caret UIElements, constrain tooltip position, indicate that /// a preview should be shown, or cancel reordering. /// - public event EventHandler ColumnReordering; + public event EventHandler ColumnReordering; /// /// Occurs when a different cell becomes the current cell. /// - public event EventHandler CurrentCellChanged; + public event EventHandler CurrentCellChanged; /// /// Occurs after a /// is instantiated, so that you can customize it before it is used. /// - public event EventHandler LoadingRow; + public event EventHandler LoadingRow; /// /// Occurs when a cell in a enters editing mode. /// /// - public event EventHandler PreparingCellForEdit; + public event EventHandler PreparingCellForEdit; /// /// Occurs when the row has been successfully committed or cancelled. /// - public event EventHandler RowEditEnded; + public event EventHandler RowEditEnded; /// /// Occurs immediately before the row has been successfully committed or cancelled. /// - public event EventHandler RowEditEnding; + public event EventHandler RowEditEnding; public static readonly RoutedEvent SelectionChangedEvent = - RoutedEvent.Register(nameof(SelectionChanged), RoutingStrategies.Bubble); + RoutedEvent.Register(nameof(SelectionChanged), RoutingStrategies.Bubble); /// /// Occurs when the or @@ -1296,32 +1285,30 @@ namespace Avalonia.Controls { add { AddHandler(SelectionChangedEvent, value); } remove { AddHandler(SelectionChangedEvent, value); } - } + } /// /// Occurs when a /// object becomes available for reuse. /// - public event EventHandler UnloadingRow; + public event EventHandler UnloadingRow; /// /// Occurs when a new row details template is applied to a row, so that you can customize /// the details section before it is used. /// - public event EventHandler LoadingRowDetails; + public event EventHandler LoadingRowDetails; /// /// Occurs when the /// property value changes. /// - public event EventHandler RowDetailsVisibilityChanged; + public event EventHandler RowDetailsVisibilityChanged; /// /// Occurs when a row details element becomes available for reuse. /// - public event EventHandler UnloadingRowDetails; - - #endregion Events + public event EventHandler UnloadingRowDetails; /// /// Gets a collection that contains all the columns in the control. @@ -1334,7 +1321,7 @@ namespace Avalonia.Controls // is a subclass of the property's return ColumnsInternal; } - } + } /// /// Gets or sets the column that contains the current cell. @@ -1374,17 +1361,17 @@ namespace Avalonia.Controls // There is no current row so the current column cannot be set throw DataGridError.DataGrid.NoCurrentRow(); } - bool beginEdit = _editingColumnIndex != -1; + bool beginEdit = _editingColumnIndex != -1; //exitEditingMode, keepFocus, raiseEvents if (!EndCellEdit(DataGridEditAction.Commit, true, ContainsFocus, true)) { // Edited value couldn't be committed or aborted return; - } + } UpdateSelectionAndCurrency(dataGridColumn.Index, CurrentSlot, DataGridSelectionAction.None, false); //scrollIntoView - Debug.Assert(_successfullyUpdatedSelection); + Debug.Assert(_successfullyUpdatedSelection); if (beginEdit && _editingColumnIndex == -1 && @@ -1399,7 +1386,7 @@ namespace Avalonia.Controls } } } - } + } /// /// Gets a list that contains the data items corresponding to the selected rows. @@ -1407,20 +1394,19 @@ namespace Avalonia.Controls public IList SelectedItems { get { return _selectedItems as IList; } - } - + } internal DataGridColumnCollection ColumnsInternal { get; private set; - } + } internal int AnchorSlot { get; private set; - } + } internal double ActualRowHeaderWidth { @@ -1435,7 +1421,7 @@ namespace Avalonia.Controls return !double.IsNaN(RowHeaderWidth) ? RowHeaderWidth : RowHeadersDesiredWidth; } } - } + } internal double ActualRowsPresenterHeight { @@ -1447,7 +1433,7 @@ namespace Avalonia.Controls } return 0; } - } + } internal bool AreColumnHeadersVisible { @@ -1455,7 +1441,7 @@ namespace Avalonia.Controls { return (HeadersVisibility & DataGridHeadersVisibility.Column) == DataGridHeadersVisibility.Column; } - } + } internal bool AreRowHeadersVisible { @@ -1463,7 +1449,7 @@ namespace Avalonia.Controls { return (HeadersVisibility & DataGridHeadersVisibility.Row) == DataGridHeadersVisibility.Row; } - } + } /// /// Indicates whether or not at least one auto-sizing column is waiting for all the rows @@ -1492,13 +1478,13 @@ namespace Avalonia.Controls } _autoSizingColumns = value; } - } + } internal double AvailableSlotElementRoom { get; set; - } + } // Height currently available for cells this value is smaller. This height is reduced by the existence of ColumnHeaders // or a horizontal scrollbar. Layout is asynchronous so changes to the ColumnHeaders or the horizontal scrollbar are @@ -1509,7 +1495,7 @@ namespace Avalonia.Controls { return RowsPresenterEstimatedAvailableHeight ?? 0; } - } + } // Width currently available for cells this value is smaller. This width is reduced by the existence of RowHeaders // or a vertical scrollbar. Layout is asynchronous so changes to the RowHeaders or the vertical scrollbar are @@ -1525,69 +1511,69 @@ namespace Avalonia.Controls } return double.IsPositiveInfinity(rowsWidth) ? ColumnsInternal.VisibleEdgedColumnsWidth : rowsWidth; } - } + } - internal DataGridColumnHeadersPresenter ColumnHeaders => _columnHeadersPresenter; + internal DataGridColumnHeadersPresenter ColumnHeaders => _columnHeadersPresenter; - internal List ColumnsItemsInternal => ColumnsInternal.ItemsInternal; + internal List ColumnsItemsInternal => ColumnsInternal.ItemsInternal; internal bool ContainsFocus { get; private set; - } + } internal int CurrentColumnIndex { get { return CurrentCellCoordinates.ColumnIndex; - } + } private set { CurrentCellCoordinates.ColumnIndex = value; } - } + } internal int CurrentSlot { get { return CurrentCellCoordinates.Slot; - } + } private set { CurrentCellCoordinates.Slot = value; } - } + } internal DataGridDataConnection DataConnection { get; private set; - } + } internal DataGridDisplayData DisplayData { get; private set; - } + } internal int EditingColumnIndex { get; private set; - } + } internal DataGridRow EditingRow { get; private set; - } + } - internal double FirstDisplayedScrollingColumnHiddenWidth => _negHorizontalOffset; + internal double FirstDisplayedScrollingColumnHiddenWidth => _negHorizontalOffset; // When the RowsPresenter's width increases, the HorizontalOffset will be incorrect until // the scrollbar's layout is recalculated, which doesn't occur until after the cells are measured. @@ -1596,9 +1582,9 @@ namespace Avalonia.Controls { get; private set; - } + } - internal static double HorizontalGridLinesThickness => DATAGRID_horizontalGridLinesThickness; + internal static double HorizontalGridLinesThickness => DATAGRID_horizontalGridLinesThickness; // the sum of the widths in pixels of the scrolling columns preceding // the first displayed scrolling column @@ -1622,39 +1608,39 @@ namespace Avalonia.Controls if (value == _horizontalOffset) { return; - } + } if (_hScrollBar != null && value != _hScrollBar.Value) { _hScrollBar.Value = value; } - _horizontalOffset = value; + _horizontalOffset = value; DisplayData.FirstDisplayedScrollingCol = ComputeFirstVisibleScrollingColumn(); // update the lastTotallyDisplayedScrollingCol ComputeDisplayedColumns(); } - } + } - internal ScrollBar HorizontalScrollBar => _hScrollBar; + internal ScrollBar HorizontalScrollBar => _hScrollBar; internal IndexToValueTable RowGroupHeadersTable { get; private set; - } + } internal bool LoadingOrUnloadingRow { get; private set; - } + } internal bool InDisplayIndexAdjustments { get; set; - } + } internal int? MouseOverRowIndex { @@ -1674,15 +1660,15 @@ namespace Avalonia.Controls { oldMouseOverRow = DisplayData.GetDisplayedElement(oldSlot) as DataGridRow; } - } + } - _mouseOverRowIndex = value; + _mouseOverRowIndex = value; // State for the old row needs to be applied after setting the new value if (oldMouseOverRow != null) { oldMouseOverRow.UpdatePseudoClasses(); - } + } if (_mouseOverRowIndex.HasValue) { @@ -1699,13 +1685,13 @@ namespace Avalonia.Controls } } } - } + } internal double NegVerticalOffset { get; private set; - } + } internal int NoCurrentCellChangeCount { @@ -1721,13 +1707,13 @@ namespace Avalonia.Controls FlushCurrentCellChanged(); } } - } + } internal double RowDetailsHeightEstimate { get; private set; - } + } internal double RowHeadersDesiredWidth { @@ -1748,19 +1734,19 @@ namespace Avalonia.Controls } } } - } + } internal double RowGroupHeaderHeightEstimate { get; private set; - } + } internal double RowHeightEstimate { get; private set; - } + } internal Size? RowsPresenterAvailableSize { @@ -1797,13 +1783,13 @@ namespace Avalonia.Controls { get; set; - } + } internal double[] RowGroupSublevelIndents { get; private set; - } + } // This flag indicates whether selection has actually changed during a selection operation, // and exists to ensure that FlushSelectionChanged doesn't unnecessarily raise SelectionChanged. @@ -1811,19 +1797,19 @@ namespace Avalonia.Controls { get; set; - } + } internal int SlotCount { get; private set; - } + } internal bool UpdatedStateOnMouseLeftButtonDown { get; set; - } + } /// /// Indicates whether or not to use star-sizing logic. If the DataGrid has infinite available space, @@ -1841,17 +1827,15 @@ namespace Avalonia.Controls } return false; } - } + } - internal ScrollBar VerticalScrollBar => _vScrollBar; + internal ScrollBar VerticalScrollBar => _vScrollBar; internal int VisibleSlotCount { get; set; - } - - #region Protected Properties + } /// /// Gets the data item bound to the row that contains the current cell. @@ -1866,15 +1850,13 @@ namespace Avalonia.Controls } return DataConnection.GetDataItem(RowIndexFromSlot(CurrentSlot)); } - } - - #endregion Protected Properties + } private DataGridCellCoordinates CurrentCellCoordinates { get; set; - } + } private int FirstDisplayedNonFillerColumnIndex { @@ -1901,7 +1883,7 @@ namespace Avalonia.Controls } return -1; } - } + } private int NoSelectionChangeCount { @@ -1917,9 +1899,7 @@ namespace Avalonia.Controls FlushSelectionChanged(); } } - } - - #region Public Methods + } /// /// Enters editing mode for the current cell and current row (if they're not already in editing mode). @@ -1928,7 +1908,7 @@ namespace Avalonia.Controls public bool BeginEdit() { return BeginEdit(null); - } + } /// /// Enters editing mode for the current cell and current row (if they're not already in editing mode). @@ -1940,13 +1920,13 @@ namespace Avalonia.Controls if (CurrentColumnIndex == -1 || !GetRowSelection(CurrentSlot)) { return false; - } + } Debug.Assert(CurrentColumnIndex >= 0); Debug.Assert(CurrentColumnIndex < ColumnsItemsInternal.Count); Debug.Assert(CurrentSlot >= -1); Debug.Assert(CurrentSlot < SlotCount); - Debug.Assert(EditingRow == null || EditingRow.Slot == CurrentSlot); + Debug.Assert(EditingRow == null || EditingRow.Slot == CurrentSlot); if (GetColumnEffectiveReadOnlyState(CurrentColumn)) { @@ -1954,7 +1934,7 @@ namespace Avalonia.Controls return false; } return BeginCellEdit(editingEventArgs); - } + } /// /// Cancels editing mode and restores the original value. @@ -1963,7 +1943,7 @@ namespace Avalonia.Controls public bool CancelEdit() { return CancelEdit(DataGridEditingUnit.Row); - } + } /// /// Cancels editing mode for the specified DataGridEditingUnit and restores its original value. @@ -1973,7 +1953,7 @@ namespace Avalonia.Controls public bool CancelEdit(DataGridEditingUnit editingUnit) { return CancelEdit(editingUnit, raiseEvents: true); - } + } /// /// Commits editing mode and pushes changes to the backend. @@ -1982,7 +1962,7 @@ namespace Avalonia.Controls public bool CommitEdit() { return CommitEdit(DataGridEditingUnit.Row, true); - } + } /// /// Commits editing mode for the specified DataGridEditingUnit and pushes changes to the backend. @@ -2005,7 +1985,7 @@ namespace Avalonia.Controls return EndRowEdit(DataGridEditAction.Commit, exitEditingMode, raiseEvents: true); } return true; - } + } /// /// Scrolls the specified item or RowGroupHeader and/or column into view. @@ -2055,9 +2035,9 @@ namespace Avalonia.Controls return; } slot = SlotFromRowIndex(rowIndex); - } + } - int columnIndex = (column == null) ? FirstDisplayedNonFillerColumnIndex : column.Index; + int columnIndex = (column == null) ? FirstDisplayedNonFillerColumnIndex : column.Index; if (_collapsedSlotsTable.Contains(slot)) { @@ -2074,7 +2054,7 @@ namespace Avalonia.Controls { ExpandRowGroupParentChain(rowGroupInfo.Level, rowGroupInfo.Slot); } - } + } // Update Scrollbar and display information NegVerticalOffset = 0; @@ -2082,18 +2062,14 @@ namespace Avalonia.Controls ResetDisplayedRows(); DisplayData.FirstScrollingSlot = 0; ComputeScrollBarsLayout(); - } + } ScrollSlotIntoView( columnIndex, slot, forCurrentCellChange: true, forceHorizontalScroll: true); } - } - - #endregion Public Methods - - #region Protected Methods + } /// /// Arranges the content of the . @@ -2109,17 +2085,17 @@ namespace Avalonia.Controls if (_makeFirstDisplayedCellCurrentCellPending) { MakeFirstDisplayedCellCurrentCell(); - } - + } + if (Bounds.Width != finalSize.Width) { // If our final width has changed, we might need to update the filler InvalidateColumnHeadersArrange(); InvalidateCellsArrange(); - } + } return base.ArrangeOverride(finalSize); - } + } /// /// Measures the children of a to prepare for @@ -2139,20 +2115,20 @@ namespace Avalonia.Controls // DataGrid is not part of the visual tree if (!_measured) { - _measured = true; + _measured = true; // We don't need to clear the rows because it was already done when the ItemsSource changed - RefreshRowsAndColumns(clearRows: false); + RefreshRowsAndColumns(clearRows: false); //// Update our estimates now that the DataGrid has all of the information necessary - UpdateRowDetailsHeightEstimate(); + UpdateRowDetailsHeightEstimate(); // Update frozen columns to account for columns added prior to loading or autogenerated columns if (FrozenColumnCountWithFiller > 0) { ProcessFrozenColumnCount(); } - } + } Size desiredSize; // This is a shortcut to skip layout if we don't have any columns @@ -2173,17 +2149,17 @@ namespace Avalonia.Controls if (_rowsPresenter != null) { _rowsPresenter.InvalidateMeasure(); - } + } - InvalidateColumnHeadersMeasure(); + InvalidateColumnHeadersMeasure(); - desiredSize = base.MeasureOverride(availableSize); + desiredSize = base.MeasureOverride(availableSize); ComputeScrollBarsLayout(); - } + } return desiredSize; - } + } /// /// Raises the BeginningEdit event. @@ -2191,7 +2167,7 @@ namespace Avalonia.Controls protected virtual void OnBeginningEdit(DataGridBeginningEditEventArgs e) { BeginningEdit?.Invoke(this, e); - } + } /// /// Raises the CellEditEnded event. @@ -2199,7 +2175,7 @@ namespace Avalonia.Controls protected virtual void OnCellEditEnded(DataGridCellEditEndedEventArgs e) { CellEditEnded?.Invoke(this, e); - } + } /// /// Raises the CellEditEnding event. @@ -2207,7 +2183,7 @@ namespace Avalonia.Controls protected virtual void OnCellEditEnding(DataGridCellEditEndingEventArgs e) { CellEditEnding?.Invoke(this, e); - } + } /// /// Raises the CellPointerPressed event. @@ -2215,15 +2191,15 @@ namespace Avalonia.Controls internal virtual void OnCellPointerPressed(DataGridCellPointerPressedEventArgs e) { CellPointerPressed?.Invoke(this, e); - } - + } + /// /// Raises the CurrentCellChanged event. /// protected virtual void OnCurrentCellChanged(EventArgs e) { CurrentCellChanged?.Invoke(this, e); - } + } /// /// Raises the LoadingRow event for row preparation. @@ -2241,7 +2217,7 @@ namespace Avalonia.Controls Debug.Assert(_loadedRows.Contains(e.Row)); _loadedRows.Remove(e.Row); } - } + } /// /// Scrolls the DataGrid according to the direction of the delta. @@ -2275,15 +2251,15 @@ namespace Avalonia.Controls e.Handled = true; } } - } - + } + /// /// Raises the PreparingCellForEdit event. /// protected virtual void OnPreparingCellForEdit(DataGridPreparingCellForEditEventArgs e) { PreparingCellForEdit?.Invoke(this, e); - } + } /// /// Raises the RowEditEnded event. @@ -2291,7 +2267,7 @@ namespace Avalonia.Controls protected virtual void OnRowEditEnded(DataGridRowEditEndedEventArgs e) { RowEditEnded?.Invoke(this, e); - } + } /// /// Raises the RowEditEnding event. @@ -2299,7 +2275,7 @@ namespace Avalonia.Controls protected virtual void OnRowEditEnding(DataGridRowEditEndingEventArgs e) { RowEditEnding?.Invoke(this, e); - } + } /// /// Raises the SelectionChanged event and clears the _selectionChanged. @@ -2308,7 +2284,7 @@ namespace Avalonia.Controls protected virtual void OnSelectionChanged(SelectionChangedEventArgs e) { RaiseEvent(e); - } + } /// /// Raises the UnloadingRow event for row recycling. @@ -2322,9 +2298,7 @@ namespace Avalonia.Controls handler(this, e); LoadingOrUnloadingRow = false; } - } - - #endregion Protected Methods + } /// /// Builds the visual tree for the column header when a new template is applied. @@ -2333,15 +2307,15 @@ namespace Avalonia.Controls protected override void OnTemplateApplied(TemplateAppliedEventArgs e) { // The template has changed, so we need to refresh the visuals - _measured = false; + _measured = false; if (_columnHeadersPresenter != null) { // If we're applying a new template, we want to remove the old column headers first _columnHeadersPresenter.Children.Clear(); - } + } - _columnHeadersPresenter = e.NameScope.Find(DATAGRID_elementColumnHeadersPresenterName); + _columnHeadersPresenter = e.NameScope.Find(DATAGRID_elementColumnHeadersPresenterName); if (_columnHeadersPresenter != null) { @@ -2355,31 +2329,31 @@ namespace Avalonia.Controls { InsertDisplayedColumnHeader(column); } - } + } if (_rowsPresenter != null) { // If we're applying a new template, we want to remove the old rows first UnloadElements(recycle: false); - } + } - _rowsPresenter = e.NameScope.Find(DATAGRID_elementRowsPresenterName); + _rowsPresenter = e.NameScope.Find(DATAGRID_elementRowsPresenterName); if (_rowsPresenter != null) { _rowsPresenter.OwningGrid = this; InvalidateRowHeightEstimate(); UpdateRowDetailsHeightEstimate(); - } + } - _frozenColumnScrollBarSpacer = e.NameScope.Find(DATAGRID_elementFrozenColumnScrollBarSpacerName); + _frozenColumnScrollBarSpacer = e.NameScope.Find(DATAGRID_elementFrozenColumnScrollBarSpacerName); if (_hScrollBar != null) { _hScrollBar.Scroll -= HorizontalScrollBar_Scroll; - } + } - _hScrollBar = e.NameScope.Find(DATAGRID_elementHorizontalScrollbarName); + _hScrollBar = e.NameScope.Find(DATAGRID_elementHorizontalScrollbarName); if (_hScrollBar != null) { @@ -2388,15 +2362,15 @@ namespace Avalonia.Controls _hScrollBar.Orientation = Orientation.Horizontal; _hScrollBar.IsVisible = false; _hScrollBar.Scroll += HorizontalScrollBar_Scroll; - } + } if (_vScrollBar != null) { _vScrollBar.Scroll -= VerticalScrollBar_Scroll; - } + } + + _vScrollBar = e.NameScope.Find(DATAGRID_elementVerticalScrollbarName); - _vScrollBar = e.NameScope.Find(DATAGRID_elementVerticalScrollbarName); - if (_vScrollBar != null) { //_vScrollBar.IsTabStop = false; @@ -2404,14 +2378,12 @@ namespace Avalonia.Controls _vScrollBar.Orientation = Orientation.Vertical; _vScrollBar.IsVisible = false; _vScrollBar.Scroll += VerticalScrollBar_Scroll; - } + } _topLeftCornerHeader = e.NameScope.Find(DATAGRID_elementTopLeftCornerHeaderName); EnsureTopLeftCornerHeader(); // EnsureTopLeftCornerHeader checks for a null _topLeftCornerHeader; _topRightCornerHeader = e.NameScope.Find(DATAGRID_elementTopRightCornerHeaderName); - } - - #region Internal Methods + } /// /// Cancels editing mode for the specified DataGridEditingUnit and restores its original value. @@ -2428,22 +2400,22 @@ namespace Avalonia.Controls raiseEvents: raiseEvents)) { return false; - } + } if (editingUnit == DataGridEditingUnit.Row) { return EndRowEdit(DataGridEditAction.Cancel, true, raiseEvents); - } + } return true; - } + } /// /// call when: selection changes or SelectedItems object changes /// internal void CoerceSelectedItem() { - object selectedItem = null; + object selectedItem = null; if (SelectionMode == DataGridSelectionMode.Extended && CurrentSlot != -1 && @@ -2454,20 +2426,20 @@ namespace Avalonia.Controls else if (_selectedItems.Count > 0) { selectedItem = _selectedItems[0]; - } + } - SetValueNoCallback(SelectedItemProperty, selectedItem); + SetValueNoCallback(SelectedItemProperty, selectedItem); // Update the SelectedIndex - int newIndex = -1; + int newIndex = -1; if (selectedItem != null) { newIndex = DataConnection.IndexOf(selectedItem); - } + } SetValueNoCallback(SelectedIndexProperty, newIndex); - } + } internal static DataGridCell GetOwningCell(Control element) { @@ -2479,7 +2451,7 @@ namespace Avalonia.Controls cell = element as DataGridCell; } return cell; - } + } internal IEnumerable GetSelectionInclusive(int startRowIndex, int endRowIndex) { @@ -2492,20 +2464,20 @@ namespace Avalonia.Controls } yield return DataConnection.GetDataItem(RowIndexFromSlot(slot)); } - } + } internal void InitializeElements(bool recycleRows) { try { - _noCurrentCellChangeCount++; + _noCurrentCellChangeCount++; // The underlying collection has changed and our editing row (if there is one) // is no longer relevant, so we should force a cancel edit. - CancelEdit(DataGridEditingUnit.Row, raiseEvents: false); + CancelEdit(DataGridEditingUnit.Row, raiseEvents: false); // We want to persist selection throughout a reset, so store away the selected items - List selectedItemsCache = new List(_selectedItems.SelectedItemsCache); + List selectedItemsCache = new List(_selectedItems.SelectedItemsCache); if (recycleRows) { @@ -2514,7 +2486,7 @@ namespace Avalonia.Controls else { RefreshRowsAndColumns(clearRows: true); - } + } // Re-select the old items _selectedItems.SelectedItemsCache = selectedItemsCache; @@ -2522,7 +2494,7 @@ namespace Avalonia.Controls if (RowDetailsVisibilityMode != DataGridRowDetailsVisibilityMode.Collapsed) { UpdateRowDetailsVisibilityMode(RowDetailsVisibilityMode); - } + } // The currently displayed rows may have incorrect visual states because of the selection change ApplyDisplayedRowsState(DisplayData.FirstScrollingSlot, DisplayData.LastScrollingSlot); @@ -2531,8 +2503,8 @@ namespace Avalonia.Controls { NoCurrentCellChangeCount--; } - } - + } + internal bool IsDoubleClickRecordsClickOnCall(Control element) { if (_clickedElement == element) @@ -2545,7 +2517,7 @@ namespace Avalonia.Controls _clickedElement = element; return false; } - } + } // Returns the item or the CollectionViewGroup that is used as the DataContext for a given slot. // If the DataContext is an item, rowIndex is set to the index of the item within the collection @@ -2560,38 +2532,38 @@ namespace Avalonia.Controls rowIndex = RowIndexFromSlot(slot); return DataConnection.GetDataItem(rowIndex); } - } - + } + internal bool ProcessDownKey(KeyEventArgs e) { KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); return ProcessDownKeyInternal(shift, ctrl); - } + } internal bool ProcessEndKey(KeyEventArgs e) { KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); return ProcessEndKey(shift, ctrl); - } + } internal bool ProcessEnterKey(KeyEventArgs e) { KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); return ProcessEnterKey(shift, ctrl); - } + } internal bool ProcessHomeKey(KeyEventArgs e) { KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); return ProcessHomeKey(shift, ctrl); - } + } internal void ProcessHorizontalScroll(ScrollEventType scrollEventType) { if (_horizontalScrollChangesIgnored > 0) { return; - } + } // If the user scrolls with the buttons, we need to update the new value of the scroll bar since we delay // this calculation. If they scroll in another other way, the scroll bar's correct value has already been set @@ -2618,31 +2590,31 @@ namespace Avalonia.Controls { _horizontalScrollChangesIgnored--; } - } + } internal bool ProcessLeftKey(KeyEventArgs e) { KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); return ProcessLeftKey(shift, ctrl); - } + } internal bool ProcessNextKey(KeyEventArgs e) { KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); return ProcessNextKey(shift, ctrl); - } + } internal bool ProcessPriorKey(KeyEventArgs e) { KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); return ProcessPriorKey(shift, ctrl); - } + } internal bool ProcessRightKey(KeyEventArgs e) { KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); return ProcessRightKey(shift, ctrl); - } + } /// /// Selects items and updates currency based on parameters @@ -2678,7 +2650,7 @@ namespace Avalonia.Controls if (slot < 0 || slot > SlotCount) { return; - } + } switch (action) { @@ -2712,7 +2684,7 @@ namespace Avalonia.Controls break; case DataGridSelectionAction.None: break; - } + } if (CurrentSlot != slot || (CurrentColumnIndex != columnIndex && columnIndex != -1)) { @@ -2754,13 +2726,13 @@ namespace Avalonia.Controls NoCurrentCellChangeCount--; NoSelectionChangeCount--; } - } + } internal bool ProcessUpKey(KeyEventArgs e) { KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); return ProcessUpKey(shift, ctrl); - } + } //internal void ProcessVerticalScroll(double oldValue, double newValue) internal void ProcessVerticalScroll(ScrollEventType scrollEventType) @@ -2769,7 +2741,7 @@ namespace Avalonia.Controls { return; } - Debug.Assert(DoubleUtil.LessThanOrClose(_vScrollBar.Value, _vScrollBar.Maximum)); + Debug.Assert(DoubleUtil.LessThanOrClose(_vScrollBar.Value, _vScrollBar.Maximum)); _verticalScrollChangesIgnored++; try @@ -2803,7 +2775,7 @@ namespace Avalonia.Controls else { DisplayData.PendingVerticalScrollHeight = _vScrollBar.Value - _verticalOffset; - } + } if (!DoubleUtil.IsZero(DisplayData.PendingVerticalScrollHeight)) { @@ -2815,7 +2787,7 @@ namespace Avalonia.Controls { _verticalScrollChangesIgnored--; } - } + } internal void RefreshRowsAndColumns(bool clearRows) { @@ -2823,7 +2795,7 @@ namespace Avalonia.Controls { try { - _noCurrentCellChangeCount++; + _noCurrentCellChangeCount++; if (clearRows) { @@ -2843,9 +2815,9 @@ namespace Avalonia.Controls { column.HeaderCell.ApplyState(); } - } + } - RefreshRows(recycleRows: false, clearRows: false); + RefreshRows(recycleRows: false, clearRows: false); if (Columns.Count > 0 && CurrentColumnIndex == -1) { @@ -2872,7 +2844,7 @@ namespace Avalonia.Controls ClearRowGroupHeadersTable(); PopulateRowGroupHeadersTable(); } - } + } internal bool ScrollSlotIntoView(int columnIndex, int slot, bool forCurrentCellChange, bool forceHorizontalScroll) { @@ -2881,7 +2853,7 @@ namespace Avalonia.Controls Debug.Assert(DisplayData.LastTotallyDisplayedScrollingCol >= -1 && DisplayData.LastTotallyDisplayedScrollingCol < ColumnsItemsInternal.Count); Debug.Assert(!IsSlotOutOfBounds(slot)); Debug.Assert(DisplayData.FirstScrollingSlot >= -1 && DisplayData.FirstScrollingSlot < SlotCount); - Debug.Assert(ColumnsItemsInternal[columnIndex].IsVisible); + Debug.Assert(ColumnsItemsInternal[columnIndex].IsVisible); if (CurrentColumnIndex >= 0 && (CurrentColumnIndex != columnIndex || CurrentSlot != slot)) @@ -2890,46 +2862,46 @@ namespace Avalonia.Controls { return false; } - } + } - double oldHorizontalOffset = HorizontalOffset; + double oldHorizontalOffset = HorizontalOffset; //scroll horizontally unless we're on a RowGroupHeader and we're not forcing horizontal scrolling if ((forceHorizontalScroll || (slot != -1)) && !ScrollColumnIntoView(columnIndex)) { return false; - } + } //scroll vertically if (!ScrollSlotIntoView(slot, scrolledHorizontally: oldHorizontalOffset != HorizontalOffset)) { return false; - } + } return true; - } + } // Convenient overload that commits the current edit. internal bool SetCurrentCellCore(int columnIndex, int slot) { return SetCurrentCellCore(columnIndex, slot, commitEdit: true, endRowEdit: true); - } + } internal void UpdateHorizontalOffset(double newValue) { if (HorizontalOffset != newValue) { - HorizontalOffset = newValue; + HorizontalOffset = newValue; InvalidateColumnHeadersMeasure(); InvalidateRowsMeasure(true); } - } + } internal bool UpdateSelectionAndCurrency(int columnIndex, int slot, DataGridSelectionAction action, bool scrollIntoView) { - _successfullyUpdatedSelection = false; + _successfullyUpdatedSelection = false; _noSelectionChangeCount++; _noCurrentCellChangeCount++; @@ -2943,15 +2915,15 @@ namespace Avalonia.Controls if (IsSlotOutOfSelectionBounds(slot) || (columnIndex != -1 && IsColumnOutOfBounds(columnIndex))) { return false; - } + } int newCurrentPosition = -1; - object item = ItemFromSlot(slot, ref newCurrentPosition); + object item = ItemFromSlot(slot, ref newCurrentPosition); if (EditingRow != null && slot != EditingRow.Slot && !CommitEdit(DataGridEditingUnit.Row, true)) { return false; - } + } if (DataConnection.CollectionView != null && DataConnection.CollectionView.CurrentPosition != newCurrentPosition) @@ -2967,10 +2939,10 @@ namespace Avalonia.Controls { NoCurrentCellChangeCount--; NoSelectionChangeCount--; - } + } return _successfullyUpdatedSelection; - } + } internal void UpdateStateOnCurrentChanged(object currentItem, int currentPosition) { @@ -2978,7 +2950,7 @@ namespace Avalonia.Controls { // The DataGrid's CurrentItem is already up-to-date, so we don't need to do anything return; - } + } int columnIndex = CurrentColumnIndex; if (columnIndex == -1) @@ -2993,17 +2965,17 @@ namespace Avalonia.Controls columnIndex = _desiredCurrentColumnIndex; } } - _desiredCurrentColumnIndex = -1; + _desiredCurrentColumnIndex = -1; try { _noSelectionChangeCount++; - _noCurrentCellChangeCount++; + _noCurrentCellChangeCount++; if (!CommitEdit()) { CancelEdit(DataGridEditingUnit.Row, false); - } + } ClearRowSelection(true); if (currentItem == null) @@ -3021,14 +2993,14 @@ namespace Avalonia.Controls NoCurrentCellChangeCount--; NoSelectionChangeCount--; } - } + } //TODO: Ensure left button is checked for internal bool UpdateStateOnMouseLeftButtonDown(PointerPressedEventArgs pointerPressedEventArgs, int columnIndex, int slot, bool allowEdit) { KeyboardHelper.GetMetaKeyState(pointerPressedEventArgs.InputModifiers, out bool ctrl, out bool shift); return UpdateStateOnMouseLeftButtonDown(pointerPressedEventArgs, columnIndex, slot, allowEdit, shift, ctrl); - } + } internal void UpdateVerticalScrollBar() { @@ -3042,7 +3014,7 @@ namespace Avalonia.Controls totalVisibleHeight: edgedRowsHeightCalculated, cellsHeight: cellsHeight); } - } + } /// /// If the editing element has focus, this method will set focus to the DataGrid itself @@ -3073,11 +3045,7 @@ namespace Avalonia.Controls } } return false; - } - - #endregion Internal Methods - - #region Details + } /// /// Raises the LoadingRowDetails for row details preparation @@ -3091,7 +3059,7 @@ namespace Avalonia.Controls handler(this, e); LoadingOrUnloadingRow = false; } - } + } /// /// Raises the UnloadingRowDetails event @@ -3105,7 +3073,7 @@ namespace Avalonia.Controls handler(this, e); LoadingOrUnloadingRow = false; } - } + } internal void OnRowDetailsChanged() { @@ -3115,7 +3083,7 @@ namespace Avalonia.Controls // since rows could be added or removed InvalidateMeasure(); } - } + } private void UpdateRowDetailsVisibilityMode(DataGridRowDetailsVisibilityMode newDetailsMode) { @@ -3136,7 +3104,7 @@ namespace Avalonia.Controls case DataGridRowDetailsVisibilityMode.VisibleWhenSelected: _showDetailsTable.Clear(); break; - } + } bool updated = false; foreach (DataGridRow row in GetAllRows()) @@ -3150,7 +3118,7 @@ namespace Avalonia.Controls } if (row.AreDetailsVisible != newDetailsVisibility) { - updated = true; + updated = true; row.SetDetailsVisibilityInternal(newDetailsVisibility, raiseNotification: true, animate: false); } @@ -3162,12 +3130,7 @@ namespace Avalonia.Controls InvalidateRowsMeasure(invalidateIndividualElements: false); } } - } - - - #endregion - - #region Private Methods + } //TODO Styles private void AddNewCellPrivate(DataGridRow row, DataGridColumn column) @@ -3185,14 +3148,14 @@ namespace Avalonia.Controls } //newCell.EnsureStyle(null); row.Cells.Insert(column.Index, newCell); - } + } private bool BeginCellEdit(RoutedEventArgs editingEventArgs) { if (CurrentColumnIndex == -1 || !GetRowSelection(CurrentSlot)) { return false; - } + } Debug.Assert(CurrentColumnIndex >= 0); Debug.Assert(CurrentColumnIndex < ColumnsItemsInternal.Count); @@ -3200,14 +3163,14 @@ namespace Avalonia.Controls Debug.Assert(CurrentSlot < SlotCount); Debug.Assert(EditingRow == null || EditingRow.Slot == CurrentSlot); Debug.Assert(!GetColumnEffectiveReadOnlyState(CurrentColumn)); - Debug.Assert(CurrentColumn.IsVisible); + Debug.Assert(CurrentColumn.IsVisible); if (_editingColumnIndex != -1) { // Current cell is already in edit mode Debug.Assert(_editingColumnIndex == CurrentColumnIndex); return true; - } + } // Get or generate the editing row if it doesn't exist DataGridRow dataGridRow = EditingRow; @@ -3223,11 +3186,11 @@ namespace Avalonia.Controls dataGridRow = GenerateRow(RowIndexFromSlot(CurrentSlot), CurrentSlot); } } - Debug.Assert(dataGridRow != null); + Debug.Assert(dataGridRow != null); // Cache these to see if they change later int currentRowIndex = CurrentSlot; - int currentColumnIndex = CurrentColumnIndex; + int currentColumnIndex = CurrentColumnIndex; // Raise the BeginningEdit event DataGridCell dataGridCell = dataGridRow.Cells[CurrentColumnIndex]; @@ -3244,7 +3207,7 @@ namespace Avalonia.Controls return false; } Debug.Assert(EditingRow != null); - Debug.Assert(EditingRow.Slot == CurrentSlot); + Debug.Assert(EditingRow.Slot == CurrentSlot); // Finally, we can prepare the cell for editing _editingColumnIndex = CurrentColumnIndex; @@ -3256,16 +3219,16 @@ namespace Avalonia.Controls dataGridRow: dataGridRow, dataGridCell: dataGridCell); return true; - } + } //TODO Validation private bool BeginRowEdit(DataGridRow dataGridRow) { Debug.Assert(EditingRow == null); - Debug.Assert(dataGridRow != null); + Debug.Assert(dataGridRow != null); Debug.Assert(CurrentSlot >= -1); - Debug.Assert(CurrentSlot < SlotCount); + Debug.Assert(CurrentSlot < SlotCount); if (DataConnection.BeginEdit(dataGridRow.DataContext)) { @@ -3274,7 +3237,7 @@ namespace Avalonia.Controls return true; } return false; - } + } private bool CancelRowEdit(bool exitEditingMode) { @@ -3284,7 +3247,7 @@ namespace Avalonia.Controls } Debug.Assert(EditingRow != null && EditingRow.Index >= -1); Debug.Assert(EditingRow.Slot < SlotCount); - Debug.Assert(CurrentColumn != null); + Debug.Assert(CurrentColumn != null); object dataItem = EditingRow.DataContext; if (!DataConnection.CancelEdit(dataItem)) @@ -3304,7 +3267,7 @@ namespace Avalonia.Controls dataGridCell: EditingRow.Cells[column.Index]); } return true; - } + } private bool CommitEditForOperation(int columnIndex, int slot, bool forCurrentCellChange) { @@ -3319,7 +3282,7 @@ namespace Avalonia.Controls { return false; } - } + } if (IsColumnOutOfBounds(columnIndex)) { @@ -3342,7 +3305,7 @@ namespace Avalonia.Controls return false; } return true; - } + } //TODO Validation private bool CommitRowEdit(bool exitEditingMode) @@ -3352,22 +3315,22 @@ namespace Avalonia.Controls return true; } Debug.Assert(EditingRow != null && EditingRow.Index >= -1); - Debug.Assert(EditingRow.Slot < SlotCount); - + Debug.Assert(EditingRow.Slot < SlotCount); + //if (!ValidateEditingRow(scrollIntoView: true, wireEvents: false)) if(!EditingRow.IsValid) { return false; - } + } - DataConnection.EndEdit(EditingRow.DataContext); + DataConnection.EndEdit(EditingRow.DataContext); if (!exitEditingMode) { DataConnection.BeginEdit(EditingRow.DataContext); } return true; - } + } private void CompleteCellsCollection(DataGridRow dataGridRow) { @@ -3380,19 +3343,18 @@ namespace Avalonia.Controls AddNewCellPrivate(dataGridRow, ColumnsItemsInternal[columnIndex]); } } - } + } private void ComputeScrollBarsLayout() { if (_ignoreNextScrollBarsLayout) { _ignoreNextScrollBarsLayout = false; - // - + // } double cellsWidth = CellsWidth; - double cellsHeight = CellsHeight; + double cellsHeight = CellsHeight; bool allowHorizScrollbar = false; bool forceHorizScrollbar = false; @@ -3425,23 +3387,23 @@ namespace Avalonia.Controls cellsWidth += _vScrollBar.DesiredSize.Width; } vertScrollBarWidth = _vScrollBar.Width + _vScrollBar.Margin.Left + _vScrollBar.Margin.Right; - } + } // Now cellsWidth is the width potentially available for displaying data cells. - // Now cellsHeight is the height potentially available for displaying data cells. + // Now cellsHeight is the height potentially available for displaying data cells. bool needHorizScrollbar = false; - bool needVertScrollbar = false; + bool needVertScrollbar = false; double totalVisibleWidth = ColumnsInternal.VisibleEdgedColumnsWidth; - double totalVisibleFrozenWidth = ColumnsInternal.GetVisibleFrozenEdgedColumnsWidth(); + double totalVisibleFrozenWidth = ColumnsInternal.GetVisibleFrozenEdgedColumnsWidth(); UpdateDisplayedRows(DisplayData.FirstScrollingSlot, CellsHeight); - double totalVisibleHeight = EdgedRowsHeightCalculated; + double totalVisibleHeight = EdgedRowsHeightCalculated; if (!forceHorizScrollbar && !forceVertScrollbar) { - bool needHorizScrollbarWithoutVertScrollbar = false; + bool needHorizScrollbarWithoutVertScrollbar = false; if (allowHorizScrollbar && DoubleUtil.GreaterThan(totalVisibleWidth, cellsWidth) && @@ -3461,14 +3423,14 @@ namespace Avalonia.Controls { needHorizScrollbar = DoubleUtil.LessThan(totalVisibleFrozenWidth, cellsWidth - vertScrollBarWidth); } - } + } if (!needHorizScrollbar) { // Restore old data height because turns out a horizontal scroll bar wouldn't make sense cellsHeight = oldDataHeight; } - } + } UpdateDisplayedRows(DisplayData.FirstScrollingSlot, cellsHeight); if (allowVertScrollbar && @@ -3479,11 +3441,11 @@ namespace Avalonia.Controls cellsWidth -= vertScrollBarWidth; Debug.Assert(cellsWidth >= 0); needVertScrollbar = true; - } + } DisplayData.FirstDisplayedScrollingCol = ComputeFirstVisibleScrollingColumn(); // we compute the number of visible columns only after we set up the vertical scroll bar. - ComputeDisplayedColumns(); + ComputeDisplayedColumns(); if (allowHorizScrollbar && needVertScrollbar && !needHorizScrollbar && @@ -3494,7 +3456,7 @@ namespace Avalonia.Controls cellsWidth += vertScrollBarWidth; cellsHeight -= horizScrollBarHeight; Debug.Assert(cellsHeight >= 0); - needVertScrollbar = false; + needVertScrollbar = false; UpdateDisplayedRows(DisplayData.FirstScrollingSlot, cellsHeight); if (cellsHeight > 0 && @@ -3559,10 +3521,10 @@ namespace Avalonia.Controls ComputeDisplayedColumns(); needVertScrollbar = DisplayData.NumTotallyDisplayedScrollingElements != VisibleSlotCount; needHorizScrollbar = totalVisibleWidth > cellsWidth && totalVisibleFrozenWidth < cellsWidth; - } + } UpdateHorizontalScrollBar(needHorizScrollbar, forceHorizScrollbar, totalVisibleWidth, totalVisibleFrozenWidth, cellsWidth); - UpdateVerticalScrollBar(needVertScrollbar, forceVertScrollbar, totalVisibleHeight, cellsHeight); + UpdateVerticalScrollBar(needVertScrollbar, forceVertScrollbar, totalVisibleHeight, cellsHeight); if (_topRightCornerHeader != null) { @@ -3578,7 +3540,7 @@ namespace Avalonia.Controls } } DisplayData.FullyRecycleElements(); - } + } /// /// Handles the current editing element's LostFocus event by performing any actions that @@ -3609,7 +3571,7 @@ namespace Avalonia.Controls _executingLostFocusActions = false; } } - } + } // Makes sure horizontal layout is updated to reflect any changes that affect it private void EnsureHorizontalLayout() @@ -3618,7 +3580,7 @@ namespace Avalonia.Controls InvalidateColumnHeadersMeasure(); InvalidateRowsMeasure(true); InvalidateMeasure(); - } + } private void EnsureRowHeaderWidth() { @@ -3627,12 +3589,12 @@ namespace Avalonia.Controls if (AreColumnHeadersVisible) { EnsureTopLeftCornerHeader(); - } + } if (_rowsPresenter != null) - { + { - bool updated = false; + bool updated = false; foreach (Control element in _rowsPresenter.Children) { @@ -3651,7 +3613,7 @@ namespace Avalonia.Controls groupHeader.HeaderCell.InvalidateMeasure(); updated = true; } - } + } if (updated) { @@ -3660,7 +3622,7 @@ namespace Avalonia.Controls } } } - } + } private void EnsureRowsPresenterVisibility() { @@ -3669,13 +3631,13 @@ namespace Avalonia.Controls // RowCount doesn't need to be considered, doing so might cause extra Visibility changes _rowsPresenter.IsVisible = (ColumnsInternal.FirstVisibleNonFillerColumn != null); } - } + } private void EnsureTopLeftCornerHeader() { if (_topLeftCornerHeader != null) { - _topLeftCornerHeader.IsVisible = (HeadersVisibility == DataGridHeadersVisibility.All); + _topLeftCornerHeader.IsVisible = (HeadersVisibility == DataGridHeadersVisibility.All); if (_topLeftCornerHeader.IsVisible) { @@ -3691,7 +3653,7 @@ namespace Avalonia.Controls } } } - } + } private void InvalidateCellsArrange() { @@ -3699,7 +3661,7 @@ namespace Avalonia.Controls { row.InvalidateHorizontalArrange(); } - } + } private void InvalidateColumnHeadersArrange() { @@ -3707,7 +3669,7 @@ namespace Avalonia.Controls { _columnHeadersPresenter.InvalidateArrange(); } - } + } private void InvalidateColumnHeadersMeasure() { @@ -3716,7 +3678,7 @@ namespace Avalonia.Controls EnsureColumnHeadersVisibility(); _columnHeadersPresenter.InvalidateMeasure(); } - } + } private void InvalidateRowsArrange() { @@ -3724,13 +3686,13 @@ namespace Avalonia.Controls { _rowsPresenter.InvalidateArrange(); } - } + } private void InvalidateRowsMeasure(bool invalidateIndividualElements) { if (_rowsPresenter != null) { - _rowsPresenter.InvalidateMeasure(); + _rowsPresenter.InvalidateMeasure(); if (invalidateIndividualElements) { @@ -3740,7 +3702,7 @@ namespace Avalonia.Controls } } } - } + } //TODO: Make override? private void DataGrid_GotFocus(object sender, RoutedEventArgs e) @@ -3756,7 +3718,7 @@ namespace Avalonia.Controls row.Cells[CurrentColumnIndex].UpdatePseudoClasses(); } } - } + } // Keep track of which row contains the newly focused element DataGridRow focusedRow = null; @@ -3773,12 +3735,12 @@ namespace Avalonia.Controls } focusedElement = focusedElement.GetVisualParent(); } - } + } //TODO: Check private void DataGrid_IsEnabledChanged(AvaloniaPropertyChangedEventArgs e) { - } + } private void DataGrid_KeyDown(object sender, KeyEventArgs e) { @@ -3786,7 +3748,7 @@ namespace Avalonia.Controls { e.Handled = ProcessDataGridKey(e); } - } + } private void DataGrid_KeyUp(object sender, KeyEventArgs e) { @@ -3803,7 +3765,7 @@ namespace Avalonia.Controls SetRowSelection(CurrentSlot, isSelected: true, setAnchorSlot: true); } } - } + } //TODO: Make override? private void DataGrid_LostFocus(object sender, RoutedEventArgs e) @@ -3813,7 +3775,7 @@ namespace Avalonia.Controls { bool focusLeftDataGrid = true; bool dataGridWillReceiveRoutedEvent = true; - IVisual focusedObject = FocusManager.Instance.Current; + IVisual focusedObject = FocusManager.Instance.Current; while (focusedObject != null) { @@ -3821,7 +3783,7 @@ namespace Avalonia.Controls { focusLeftDataGrid = false; break; - } + } // Walk up the visual tree. If we hit the root, try using the framework element's // parent. We do this because Popups behave differently with respect to the visual tree, @@ -3839,7 +3801,7 @@ namespace Avalonia.Controls } } focusedObject = parent; - } + } if (focusLeftDataGrid) { @@ -3866,8 +3828,8 @@ namespace Avalonia.Controls } } } - } - + } + private void EditingElement_Initialized(object sender, EventArgs e) { var element = sender as Control; @@ -3876,8 +3838,8 @@ namespace Avalonia.Controls element.Initialized -= EditingElement_Initialized; } PreparingCellForEditPrivate(element); - } - + } + //TODO Validation //TODO Binding //TODO TabStop @@ -3886,17 +3848,17 @@ namespace Avalonia.Controls if (_editingColumnIndex == -1) { return true; - } + } Debug.Assert(EditingRow != null); Debug.Assert(_editingColumnIndex >= 0); Debug.Assert(_editingColumnIndex < ColumnsItemsInternal.Count); Debug.Assert(_editingColumnIndex == CurrentColumnIndex); - Debug.Assert(EditingRow != null && EditingRow.Slot == CurrentSlot); + Debug.Assert(EditingRow != null && EditingRow.Slot == CurrentSlot); // Cache these to see if they change later int currentSlot = CurrentSlot; - int currentColumnIndex = CurrentColumnIndex; + int currentColumnIndex = CurrentColumnIndex; // We're ready to start ending, so raise the event DataGridCell editingCell = EditingRow.Cells[_editingColumnIndex]; @@ -3913,7 +3875,7 @@ namespace Avalonia.Controls { // CellEditEnding has been cancelled return false; - } + } // Ensure that the current cell wasn't changed in the user's CellEditEnding handler if (_editingColumnIndex == -1 || @@ -3926,12 +3888,12 @@ namespace Avalonia.Controls Debug.Assert(EditingRow.Slot == currentSlot); Debug.Assert(_editingColumnIndex != -1); Debug.Assert(_editingColumnIndex == CurrentColumnIndex); - } + } // If we're canceling, let the editing column repopulate its old value if it wants if (editAction == DataGridEditAction.Cancel) { - CurrentColumn.CancelCellEditInternal(editingElement, _uneditedValue); + CurrentColumn.CancelCellEditInternal(editingElement, _uneditedValue); // Ensure that the current cell wasn't changed in the user column's CancelCellEdit if (_editingColumnIndex == -1 || @@ -3944,7 +3906,7 @@ namespace Avalonia.Controls Debug.Assert(EditingRow.Slot == currentSlot); Debug.Assert(_editingColumnIndex != -1); Debug.Assert(_editingColumnIndex == CurrentColumnIndex); - } + } // If we're committing, explicitly update the source but watch out for any validation errors if (editAction == DataGridEditAction.Commit) @@ -3967,69 +3929,69 @@ namespace Avalonia.Controls { editingCell.IsValid = false; editingCell.UpdatePseudoClasses(); - } + } if (EditingRow.IsValid) { EditingRow.IsValid = false; EditingRow.UpdatePseudoClasses(); } - } + } if(editingElement != null) { var errorList = binding.ValidationErrors .SelectMany(ex => ValidationUtil.UnpackException(ex)) - .ToList(); + .ToList(); DataValidationErrors.SetErrors(editingElement, errorList); } } - } + } var editBinding = CurrentColumn?.CellEditBinding; if(editBinding != null && !editBinding.CommitEdit()) { SetValidationStatus(editBinding); _validationSubscription?.Dispose(); - _validationSubscription = editBinding.ValidationChanged.Subscribe(v => SetValidationStatus(editBinding)); + _validationSubscription = editBinding.ValidationChanged.Subscribe(v => SetValidationStatus(editBinding)); ScrollSlotIntoView(CurrentColumnIndex, CurrentSlot, forCurrentCellChange: false, forceHorizontalScroll: true); return false; } - } + } - ResetValidationStatus(); + ResetValidationStatus(); if (exitEditingMode) { _editingColumnIndex = -1; - editingCell.UpdatePseudoClasses(); + editingCell.UpdatePseudoClasses(); //IsTabStop = true; if (keepFocus && editingElement.ContainsFocusedElement()) { Focus(); - } + } PopulateCellContent( isCellEdited: !exitEditingMode, dataGridColumn: CurrentColumn, dataGridRow: EditingRow, dataGridCell: editingCell); - } + } // We're done, so raise the CellEditEnded event if (raiseEvents) { OnCellEditEnded(new DataGridCellEditEndedEventArgs(CurrentColumn, EditingRow, editAction)); - } + } // There's a chance that somebody reopened this cell for edit within the CellEditEnded handler, // so we should return false if we were supposed to exit editing mode, but we didn't return !(exitEditingMode && currentColumnIndex == _editingColumnIndex); - } + } //TODO Validation private bool EndRowEdit(DataGridEditAction editAction, bool exitEditingMode, bool raiseEvents) @@ -4048,7 +4010,7 @@ namespace Avalonia.Controls // if raiseEvents == false, which means we're internally forcing a cancel. return false; } - DataGridRow editingRow = EditingRow; + DataGridRow editingRow = EditingRow; if (raiseEvents) { @@ -4058,7 +4020,7 @@ namespace Avalonia.Controls { // RowEditEnding has been cancelled return false; - } + } // Editing states might have been changed in the RowEditEnding handlers if (_editingColumnIndex != -1) @@ -4069,7 +4031,7 @@ namespace Avalonia.Controls { return true; } - } + } // Call the appropriate commit or cancel methods if (editAction == DataGridEditAction.Commit) @@ -4087,23 +4049,23 @@ namespace Avalonia.Controls return false; } } - ResetValidationStatus(); + ResetValidationStatus(); // Update the previously edited row's state if (exitEditingMode && editingRow == EditingRow) { RemoveEditingElements(); ResetEditingRow(); - } + } // Raise the RowEditEnded event if (raiseEvents) { OnRowEditEnded(new DataGridRowEditEndedEventArgs(editingRow, editAction)); - } + } return true; - } + } private void EnsureColumnHeadersVisibility() { @@ -4111,8 +4073,7 @@ namespace Avalonia.Controls { _columnHeadersPresenter.IsVisible = AreColumnHeadersVisible; } - } - + } private void EnsureVerticalGridLines() { @@ -4121,17 +4082,17 @@ namespace Avalonia.Controls double totalColumnsWidth = 0; foreach (DataGridColumn column in ColumnsInternal) { - totalColumnsWidth += column.ActualWidth; + totalColumnsWidth += column.ActualWidth; column.HeaderCell.AreSeparatorsVisible = (column != ColumnsInternal.LastVisibleColumn || totalColumnsWidth < CellsWidth); } - } + } foreach (DataGridRow row in GetAllRows()) { row.EnsureGridLines(); } - } + } /// /// Exits editing mode without trying to commit or revert the editing, and @@ -4144,14 +4105,14 @@ namespace Avalonia.Controls { Debug.Assert(_editingColumnIndex == -1); return; - } + } if (_editingColumnIndex != -1) { Debug.Assert(_editingColumnIndex >= 0); Debug.Assert(_editingColumnIndex < ColumnsItemsInternal.Count); Debug.Assert(_editingColumnIndex == CurrentColumnIndex); - Debug.Assert(EditingRow != null && EditingRow.Slot == CurrentSlot); + Debug.Assert(EditingRow != null && EditingRow.Slot == CurrentSlot); _editingColumnIndex = -1; EditingRow.Cells[CurrentColumnIndex].UpdatePseudoClasses(); @@ -4166,7 +4127,7 @@ namespace Avalonia.Controls { Focus(); } - } + } private void ExternalEditingElement_LostFocus(object sender, RoutedEventArgs e) { @@ -4175,7 +4136,7 @@ namespace Avalonia.Controls element.LostFocus -= ExternalEditingElement_LostFocus; DataGrid_LostFocus(sender, e); } - } + } private void FlushCurrentCellChanged() { @@ -4189,7 +4150,7 @@ namespace Avalonia.Controls _flushCurrentCellChanged = true; FlushSelectionChanged(); return; - } + } // We don't want to expand all intermediate currency positions, so we only expand // the last current item before we flush the event @@ -4201,20 +4162,20 @@ namespace Avalonia.Controls { ExpandRowGroupParentChain(rowGroupInfo.Level, rowGroupInfo.Slot); } - } + } if (CurrentColumn != _previousCurrentColumn || CurrentItem != _previousCurrentItem) { CoerceSelectedItem(); _previousCurrentColumn = CurrentColumn; - _previousCurrentItem = CurrentItem; + _previousCurrentItem = CurrentItem; OnCurrentCellChanged(EventArgs.Empty); - } + } _flushCurrentCellChanged = false; - } + } private void FlushSelectionChanged() { @@ -4226,12 +4187,12 @@ namespace Avalonia.Controls // current cell is changing, don't raise SelectionChanged until it's done return; } - SelectionHasChanged = false; + SelectionHasChanged = false; if (_flushCurrentCellChanged) { FlushCurrentCellChanged(); - } + } SelectionChangedEventArgs e = _selectedItems.GetSelectionChangedEventArgs(); if (e.AddedItems.Count > 0 || e.RemovedItems.Count > 0) @@ -4239,7 +4200,7 @@ namespace Avalonia.Controls OnSelectionChanged(e); } } - } + } //TODO TabStop private bool FocusEditingCell(bool setFocus) @@ -4249,10 +4210,10 @@ namespace Avalonia.Controls Debug.Assert(CurrentSlot >= -1); Debug.Assert(CurrentSlot < SlotCount); Debug.Assert(EditingRow != null && EditingRow.Slot == CurrentSlot); - Debug.Assert(_editingColumnIndex != -1); + Debug.Assert(_editingColumnIndex != -1); //IsTabStop = false; - _focusEditingControl = false; + _focusEditingControl = false; bool success = false; DataGridCell dataGridCell = EditingRow.Cells[_editingColumnIndex]; @@ -4272,8 +4233,8 @@ namespace Avalonia.Controls _focusEditingControl = !success; } return success; - } - + } + // Calculates the amount to scroll for the ScrollLeft button // This is a method rather than a property to emphasize a calculation private double GetHorizontalSmallScrollDecrease() @@ -4299,7 +4260,7 @@ namespace Avalonia.Controls return 0; } } - } + } // Calculates the amount to scroll for the ScrollRight button // This is a method rather than a property to emphasize a calculation @@ -4310,7 +4271,7 @@ namespace Avalonia.Controls return GetEdgedColumnWidth(ColumnsItemsInternal[DisplayData.FirstDisplayedScrollingCol]) - _negHorizontalOffset; } return 0; - } + } // Calculates the amount the ScrollDown button should scroll // This is a method rather than a property to emphasize that calculations are taking place @@ -4321,32 +4282,32 @@ namespace Avalonia.Controls return GetExactSlotElementHeight(DisplayData.FirstScrollingSlot) - NegVerticalOffset; } return 0; - } + } private void HorizontalScrollBar_Scroll(object sender, ScrollEventArgs e) { ProcessHorizontalScroll(e.ScrollEventType); - } + } private bool IsColumnOutOfBounds(int columnIndex) { return columnIndex >= ColumnsItemsInternal.Count || columnIndex < 0; - } + } private bool IsInnerCellOutOfBounds(int columnIndex, int slot) { return IsColumnOutOfBounds(columnIndex) || IsSlotOutOfBounds(slot); - } + } private bool IsInnerCellOutOfSelectionBounds(int columnIndex, int slot) { return IsColumnOutOfBounds(columnIndex) || IsSlotOutOfSelectionBounds(slot); - } + } private bool IsSlotOutOfBounds(int slot) { return slot >= SlotCount || slot < -1 || _collapsedSlotsTable.Contains(slot); - } + } private bool IsSlotOutOfSelectionBounds(int slot) { @@ -4360,7 +4321,7 @@ namespace Avalonia.Controls int rowIndex = RowIndexFromSlot(slot); return rowIndex < 0 || rowIndex >= DataConnection.Count; } - } + } private void MakeFirstDisplayedCellCurrentCell() { @@ -4375,7 +4336,7 @@ namespace Avalonia.Controls { _makeFirstDisplayedCellCurrentCellPending = true; return; - } + } // No current cell, therefore no selection either - try to set the current cell to the // ItemsSource's ICollectionView.CurrentItem if it exists, otherwise use the first displayed cell. @@ -4412,14 +4373,14 @@ namespace Avalonia.Controls if (_desiredCurrentColumnIndex >= 0 && _desiredCurrentColumnIndex < ColumnsItemsInternal.Count) { columnIndex = _desiredCurrentColumnIndex; - } - + } + SetAndSelectCurrentCell(columnIndex, slot, forceCurrentCellSelection: false); AnchorSlot = slot; _makeFirstDisplayedCellCurrentCellPending = false; _desiredCurrentColumnIndex = -1; FlushCurrentCellChanged(); - } + } //TODO Styles private void PopulateCellContent(bool isCellEdited, @@ -4429,7 +4390,7 @@ namespace Avalonia.Controls { Debug.Assert(dataGridColumn != null); Debug.Assert(dataGridRow != null); - Debug.Assert(dataGridCell != null); + Debug.Assert(dataGridCell != null); IControl element = null; DataGridBoundColumn dataGridBoundColumn = dataGridColumn as DataGridBoundColumn; @@ -4447,10 +4408,10 @@ namespace Avalonia.Controls { // Generate Element and apply column style if available element = dataGridColumn.GenerateElementInternal(dataGridCell, dataGridRow.DataContext); - } + } dataGridCell.Content = element; - } + } private void PreparingCellForEditPrivate(Control editingElement) { @@ -4461,25 +4422,25 @@ namespace Avalonia.Controls // The current cell has changed since the call to BeginCellEdit, so the fact // that this element has loaded is no longer relevant return; - } + } Debug.Assert(EditingRow != null); Debug.Assert(_editingColumnIndex >= 0); Debug.Assert(_editingColumnIndex < ColumnsItemsInternal.Count); Debug.Assert(_editingColumnIndex == CurrentColumnIndex); - Debug.Assert(EditingRow != null && EditingRow.Slot == CurrentSlot); + Debug.Assert(EditingRow != null && EditingRow.Slot == CurrentSlot); - FocusEditingCell(setFocus: ContainsFocus || _focusEditingControl); + FocusEditingCell(setFocus: ContainsFocus || _focusEditingControl); // Prepare the cell for editing and raise the PreparingCellForEdit event for all columns DataGridColumn dataGridColumn = CurrentColumn; _uneditedValue = dataGridColumn.PrepareCellForEditInternal(editingElement, _editingEventArgs); OnPreparingCellForEdit(new DataGridPreparingCellForEditEventArgs(dataGridColumn, EditingRow, _editingEventArgs, editingElement)); - } + } private bool ProcessAKey(KeyEventArgs e) { - KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift, out bool alt); + KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift, out bool alt); if (ctrl && !shift && !alt && SelectionMode == DataGridSelectionMode.Extended) { @@ -4487,8 +4448,8 @@ namespace Avalonia.Controls return true; } return false; - } - + } + //TODO TabStop //TODO FlowDirection private bool ProcessDataGridKey(KeyEventArgs e) @@ -4497,55 +4458,55 @@ namespace Avalonia.Controls switch (e.Key) { case Key.Tab: - return ProcessTabKey(e); + return ProcessTabKey(e); case Key.Up: focusDataGrid = ProcessUpKey(e); - break; + break; case Key.Down: focusDataGrid = ProcessDownKey(e); - break; + break; case Key.PageDown: focusDataGrid = ProcessNextKey(e); - break; + break; case Key.PageUp: focusDataGrid = ProcessPriorKey(e); - break; + break; case Key.Left: focusDataGrid = ProcessLeftKey(e); - break; + break; case Key.Right: focusDataGrid = ProcessRightKey(e); - break; + break; case Key.F2: - return ProcessF2Key(e); + return ProcessF2Key(e); case Key.Home: focusDataGrid = ProcessHomeKey(e); - break; + break; case Key.End: focusDataGrid = ProcessEndKey(e); - break; + break; case Key.Enter: focusDataGrid = ProcessEnterKey(e); - break; + break; case Key.Escape: - return ProcessEscapeKey(); + return ProcessEscapeKey(); case Key.A: - return ProcessAKey(e); + return ProcessAKey(e); case Key.C: - return ProcessCopyKey(e.Modifiers); + return ProcessCopyKey(e.Modifiers); case Key.Insert: return ProcessCopyKey(e.Modifiers); @@ -4555,7 +4516,7 @@ namespace Avalonia.Controls Focus(); } return focusDataGrid; - } + } private bool ProcessDownKeyInternal(bool shift, bool ctrl) { @@ -4565,12 +4526,12 @@ namespace Avalonia.Controls if (firstVisibleColumnIndex == -1 || lastSlot == -1) { return false; - } + } if (WaitForLostFocus(() => ProcessDownKeyInternal(shift, ctrl))) { return true; - } + } int nextSlot = -1; if (CurrentSlot != -1) @@ -4580,7 +4541,7 @@ namespace Avalonia.Controls { nextSlot = -1; } - } + } _noSelectionChangeCount++; try @@ -4633,7 +4594,7 @@ namespace Avalonia.Controls columnIndex = CurrentColumnIndex; action = DataGridSelectionAction.SelectCurrent; } - } + } UpdateSelectionAndCurrency(columnIndex, desiredSlot, action, scrollIntoView: true); } @@ -4642,7 +4603,7 @@ namespace Avalonia.Controls NoSelectionChangeCount--; } return _successfullyUpdatedSelection; - } + } private bool ProcessEndKey(bool shift, bool ctrl) { @@ -4653,12 +4614,12 @@ namespace Avalonia.Controls if (lastVisibleColumnIndex == -1 || firstVisibleSlot == -1) { return false; - } + } if (WaitForLostFocus(() => ProcessEndKey(shift, ctrl))) { return true; - } + } _noSelectionChangeCount++; try @@ -4671,7 +4632,7 @@ namespace Avalonia.Controls { DataGridSelectionAction action = (shift && SelectionMode == DataGridSelectionMode.Extended) ? DataGridSelectionAction.SelectFromAnchorToCurrent - : DataGridSelectionAction.SelectCurrent; + : DataGridSelectionAction.SelectCurrent; UpdateSelectionAndCurrency(lastVisibleColumnIndex, lastVisibleSlot, action, scrollIntoView: true); } @@ -4681,11 +4642,11 @@ namespace Avalonia.Controls NoSelectionChangeCount--; } return _successfullyUpdatedSelection; - } + } private bool ProcessEnterKey(bool shift, bool ctrl) { - int oldCurrentSlot = CurrentSlot; + int oldCurrentSlot = CurrentSlot; if (!ctrl) { @@ -4693,12 +4654,12 @@ namespace Avalonia.Controls if (FocusManager.Instance.Current is TextBox focusedTextBox && focusedTextBox.AcceptsReturn) { return false; - } + } if (WaitForLostFocus(() => ProcessEnterKey(shift, ctrl))) { return true; - } + } // Enter behaves like down arrow - it commits the potential editing and goes down one cell. if (!ProcessDownKeyInternal(false, ctrl)) @@ -4709,7 +4670,7 @@ namespace Avalonia.Controls else if (WaitForLostFocus(() => ProcessEnterKey(shift, ctrl))) { return true; - } + } // Try to commit the potential editing if (oldCurrentSlot == CurrentSlot && @@ -4718,17 +4679,17 @@ namespace Avalonia.Controls { EndRowEdit(DataGridEditAction.Commit, exitEditingMode: true, raiseEvents: true); ScrollIntoView(CurrentItem, CurrentColumn); - } + } return true; - } + } private bool ProcessEscapeKey() { if (WaitForLostFocus(() => ProcessEscapeKey())) { return true; - } + } if (_editingColumnIndex != -1) { @@ -4743,11 +4704,11 @@ namespace Avalonia.Controls return true; } return false; - } + } private bool ProcessF2Key(KeyEventArgs e) { - KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); + KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); if (!shift && !ctrl && _editingColumnIndex == -1 && CurrentColumnIndex != -1 && GetRowSelection(CurrentSlot) && @@ -4758,10 +4719,10 @@ namespace Avalonia.Controls BeginCellEdit(e); } return true; - } + } return false; - } + } private bool ProcessHomeKey(bool shift, bool ctrl) { @@ -4771,12 +4732,12 @@ namespace Avalonia.Controls if (firstVisibleColumnIndex == -1 || firstVisibleSlot == -1) { return false; - } + } if (WaitForLostFocus(() => ProcessHomeKey(shift, ctrl))) { return true; - } + } _noSelectionChangeCount++; try @@ -4789,7 +4750,7 @@ namespace Avalonia.Controls { DataGridSelectionAction action = (shift && SelectionMode == DataGridSelectionMode.Extended) ? DataGridSelectionAction.SelectFromAnchorToCurrent - : DataGridSelectionAction.SelectCurrent; + : DataGridSelectionAction.SelectCurrent; UpdateSelectionAndCurrency(firstVisibleColumnIndex, firstVisibleSlot, action, scrollIntoView: true); } @@ -4799,7 +4760,7 @@ namespace Avalonia.Controls NoSelectionChangeCount--; } return _successfullyUpdatedSelection; - } + } private bool ProcessLeftKey(bool shift, bool ctrl) { @@ -4809,12 +4770,12 @@ namespace Avalonia.Controls if (firstVisibleColumnIndex == -1 || firstVisibleSlot == -1) { return false; - } + } if (WaitForLostFocus(() => ProcessLeftKey(shift, ctrl))) { return true; - } + } int previousVisibleColumnIndex = -1; if (CurrentColumnIndex != -1) @@ -4824,7 +4785,7 @@ namespace Avalonia.Controls { previousVisibleColumnIndex = dataGridColumn.Index; } - } + } _noSelectionChangeCount++; try @@ -4852,7 +4813,7 @@ namespace Avalonia.Controls if (previousVisibleColumnIndex == -1) { return true; - } + } UpdateSelectionAndCurrency( previousVisibleColumnIndex, @@ -4867,7 +4828,7 @@ namespace Avalonia.Controls NoSelectionChangeCount--; } return _successfullyUpdatedSelection; - } + } // Ctrl Left <==> Home private bool ProcessLeftMost(int firstVisibleColumnIndex, int firstVisibleSlot) @@ -4887,7 +4848,7 @@ namespace Avalonia.Controls { desiredSlot = CurrentSlot; action = DataGridSelectionAction.None; - } + } UpdateSelectionAndCurrency(firstVisibleColumnIndex, desiredSlot, action, scrollIntoView: true); } @@ -4896,7 +4857,7 @@ namespace Avalonia.Controls NoSelectionChangeCount--; } return _successfullyUpdatedSelection; - } + } private bool ProcessNextKey(bool shift, bool ctrl) { @@ -4905,16 +4866,16 @@ namespace Avalonia.Controls if (firstVisibleColumnIndex == -1 || DisplayData.FirstScrollingSlot == -1) { return false; - } + } if (WaitForLostFocus(() => ProcessNextKey(shift, ctrl))) { return true; - } + } int nextPageSlot = CurrentSlot == -1 ? DisplayData.FirstScrollingSlot : CurrentSlot; Debug.Assert(nextPageSlot != -1); - int slot = GetNextVisibleSlot(nextPageSlot); + int slot = GetNextVisibleSlot(nextPageSlot); int scrollCount = DisplayData.NumTotallyDisplayedScrollingElements; while (scrollCount > 0 && slot < SlotCount) @@ -4922,7 +4883,7 @@ namespace Avalonia.Controls nextPageSlot = slot; scrollCount--; slot = GetNextVisibleSlot(slot); - } + } _noSelectionChangeCount++; try @@ -4940,7 +4901,7 @@ namespace Avalonia.Controls action = (shift && SelectionMode == DataGridSelectionMode.Extended) ? action = DataGridSelectionAction.SelectFromAnchorToCurrent : action = DataGridSelectionAction.SelectCurrent; - } + } UpdateSelectionAndCurrency(columnIndex, nextPageSlot, action, scrollIntoView: true); } @@ -4949,7 +4910,7 @@ namespace Avalonia.Controls NoSelectionChangeCount--; } return _successfullyUpdatedSelection; - } + } private bool ProcessPriorKey(bool shift, bool ctrl) { @@ -4958,15 +4919,15 @@ namespace Avalonia.Controls if (firstVisibleColumnIndex == -1 || DisplayData.FirstScrollingSlot == -1) { return false; - } + } if (WaitForLostFocus(() => ProcessPriorKey(shift, ctrl))) { return true; - } + } int previousPageSlot = (CurrentSlot == -1) ? DisplayData.FirstScrollingSlot : CurrentSlot; - Debug.Assert(previousPageSlot != -1); + Debug.Assert(previousPageSlot != -1); int scrollCount = DisplayData.NumTotallyDisplayedScrollingElements; int slot = GetPreviousVisibleSlot(previousPageSlot); @@ -4976,7 +4937,7 @@ namespace Avalonia.Controls scrollCount--; slot = GetPreviousVisibleSlot(slot); } - Debug.Assert(previousPageSlot != -1); + Debug.Assert(previousPageSlot != -1); _noSelectionChangeCount++; try @@ -4994,7 +4955,7 @@ namespace Avalonia.Controls action = (shift && SelectionMode == DataGridSelectionMode.Extended) ? DataGridSelectionAction.SelectFromAnchorToCurrent : DataGridSelectionAction.SelectCurrent; - } + } UpdateSelectionAndCurrency(columnIndex, previousPageSlot, action, scrollIntoView: true); } @@ -5003,7 +4964,7 @@ namespace Avalonia.Controls NoSelectionChangeCount--; } return _successfullyUpdatedSelection; - } + } private bool ProcessRightKey(bool shift, bool ctrl) { @@ -5013,12 +4974,12 @@ namespace Avalonia.Controls if (lastVisibleColumnIndex == -1 || firstVisibleSlot == -1) { return false; - } + } if (WaitForLostFocus(delegate { ProcessRightKey(shift, ctrl); })) { return true; - } + } int nextVisibleColumnIndex = -1; if (CurrentColumnIndex != -1) @@ -5044,7 +5005,7 @@ namespace Avalonia.Controls } else if (CurrentColumnIndex == -1) { - int firstVisibleColumnIndex = ColumnsInternal.FirstVisibleColumn == null ? -1 : ColumnsInternal.FirstVisibleColumn.Index; + int firstVisibleColumnIndex = ColumnsInternal.FirstVisibleColumn == null ? -1 : ColumnsInternal.FirstVisibleColumn.Index; UpdateSelectionAndCurrency( firstVisibleColumnIndex, @@ -5057,7 +5018,7 @@ namespace Avalonia.Controls if (nextVisibleColumnIndex == -1) { return true; - } + } UpdateSelectionAndCurrency( nextVisibleColumnIndex, @@ -5072,7 +5033,7 @@ namespace Avalonia.Controls NoSelectionChangeCount--; } return _successfullyUpdatedSelection; - } + } // Ctrl Right <==> End private bool ProcessRightMost(int lastVisibleColumnIndex, int firstVisibleSlot) @@ -5091,7 +5052,7 @@ namespace Avalonia.Controls { desiredSlot = CurrentSlot; action = DataGridSelectionAction.None; - } + } UpdateSelectionAndCurrency(lastVisibleColumnIndex, desiredSlot, action, scrollIntoView: true); } @@ -5100,13 +5061,13 @@ namespace Avalonia.Controls NoSelectionChangeCount--; } return _successfullyUpdatedSelection; - } + } private bool ProcessTabKey(KeyEventArgs e) { KeyboardHelper.GetMetaKeyState(e.Modifiers, out bool ctrl, out bool shift); return ProcessTabKey(e, shift, ctrl); - } + } private bool ProcessTabKey(KeyEventArgs e, bool shift, bool ctrl) { @@ -5116,11 +5077,11 @@ namespace Avalonia.Controls // - Ctrl key is used // - Potential current cell is not edited, or the datagrid is read-only. return false; - } + } // Try to locate a writable cell before/after the current cell Debug.Assert(CurrentColumnIndex != -1); - Debug.Assert(CurrentSlot != -1); + Debug.Assert(CurrentSlot != -1); int neighborVisibleWritableColumnIndex, neighborSlot; DataGridColumn dataGridColumn; @@ -5148,20 +5109,20 @@ namespace Avalonia.Controls } } } - neighborVisibleWritableColumnIndex = (dataGridColumn == null) ? -1 : dataGridColumn.Index; + neighborVisibleWritableColumnIndex = (dataGridColumn == null) ? -1 : dataGridColumn.Index; if (neighborVisibleWritableColumnIndex == -1 && (neighborSlot == -1 || neighborSlot >= SlotCount)) { // There is no previous/next row and no previous/next writable cell on the current row return false; - } + } if (WaitForLostFocus(() => ProcessTabKey(e, shift, ctrl))) { return true; - } + } - int targetSlot = -1, targetColumnIndex = -1; + int targetSlot = -1, targetColumnIndex = -1; _noSelectionChangeCount++; try @@ -5184,7 +5145,7 @@ namespace Avalonia.Controls { targetSlot = CurrentSlot; targetColumnIndex = neighborVisibleWritableColumnIndex; - } + } DataGridSelectionAction action; if (targetSlot != CurrentSlot || (SelectionMode == DataGridSelectionMode.Extended)) @@ -5198,24 +5159,24 @@ namespace Avalonia.Controls else { action = DataGridSelectionAction.None; - } + } UpdateSelectionAndCurrency(targetColumnIndex, targetSlot, action, scrollIntoView: true); } finally { NoSelectionChangeCount--; - } + } if (_successfullyUpdatedSelection && !RowGroupHeadersTable.Contains(targetSlot)) { BeginCellEdit(e); - } + } // Return true to say we handled the key event even if the operation was unsuccessful. If we don't // say we handled this event, the framework will continue to process the tab key and change focus. return true; - } + } private bool ProcessUpKey(bool shift, bool ctrl) { @@ -5225,16 +5186,16 @@ namespace Avalonia.Controls if (firstVisibleColumnIndex == -1 || firstVisibleSlot == -1) { return false; - } + } if (WaitForLostFocus(() => ProcessUpKey(shift, ctrl))) { return true; - } + } - int previousVisibleSlot = (CurrentSlot != -1) ? GetPreviousVisibleSlot(CurrentSlot) : -1; + int previousVisibleSlot = (CurrentSlot != -1) ? GetPreviousVisibleSlot(CurrentSlot) : -1; - _noSelectionChangeCount++; + _noSelectionChangeCount++; try { @@ -5294,7 +5255,7 @@ namespace Avalonia.Controls NoSelectionChangeCount--; } return _successfullyUpdatedSelection; - } + } private void RemoveDisplayedColumnHeader(DataGridColumn dataGridColumn) { @@ -5302,7 +5263,7 @@ namespace Avalonia.Controls { _columnHeadersPresenter.Children.Remove(dataGridColumn.HeaderCell); } - } + } private void RemoveDisplayedColumnHeaders() { @@ -5311,12 +5272,12 @@ namespace Avalonia.Controls _columnHeadersPresenter.Children.Clear(); } ColumnsInternal.FillerColumn.IsRepresented = false; - } + } private bool ResetCurrentCellCore() { return (CurrentColumnIndex == -1 || SetCurrentCellCore(-1, -1)); - } + } private void ResetEditingRow() { @@ -5330,7 +5291,7 @@ namespace Avalonia.Controls DisplayData.FullyRecycleElements(); } EditingRow = null; - } + } private void ResetFocusedRow() { @@ -5344,12 +5305,12 @@ namespace Avalonia.Controls DisplayData.FullyRecycleElements(); } _focusedRow = null; - } + } private void SelectAll() { SetRowsSelection(0, SlotCount - 1); - } + } private void SetAndSelectCurrentCell(int columnIndex, int slot, @@ -5357,7 +5318,7 @@ namespace Avalonia.Controls { DataGridSelectionAction action = forceCurrentCellSelection ? DataGridSelectionAction.SelectCurrent : DataGridSelectionAction.None; UpdateSelectionAndCurrency(columnIndex, slot, action, scrollIntoView: false); - } + } // columnIndex = 2, rowIndex = -1 --> current cell belongs to the 'new row'. // columnIndex = 2, rowIndex = 2 --> current cell is an inner cell @@ -5368,7 +5329,7 @@ namespace Avalonia.Controls Debug.Assert(columnIndex < ColumnsItemsInternal.Count); Debug.Assert(slot < SlotCount); Debug.Assert(columnIndex == -1 || ColumnsItemsInternal[columnIndex].IsVisible); - Debug.Assert(!(columnIndex > -1 && slot == -1)); + Debug.Assert(!(columnIndex > -1 && slot == -1)); if (columnIndex == CurrentColumnIndex && slot == CurrentSlot) @@ -5377,10 +5338,10 @@ namespace Avalonia.Controls Debug.Assert(_editingColumnIndex == -1 || _editingColumnIndex == CurrentColumnIndex); Debug.Assert(EditingRow == null || EditingRow.Slot == CurrentSlot || DataConnection.CommittingEdit); return true; - } + } Control oldDisplayedElement = null; - DataGridCellCoordinates oldCurrentCell = new DataGridCellCoordinates(CurrentCellCoordinates); + DataGridCellCoordinates oldCurrentCell = new DataGridCellCoordinates(CurrentCellCoordinates); object newCurrentItem = null; if (!RowGroupHeadersTable.Contains(slot)) @@ -5390,18 +5351,18 @@ namespace Avalonia.Controls { newCurrentItem = DataConnection.GetDataItem(rowIndex); } - } + } if (CurrentColumnIndex > -1) { Debug.Assert(CurrentColumnIndex < ColumnsItemsInternal.Count); - Debug.Assert(CurrentSlot < SlotCount); + Debug.Assert(CurrentSlot < SlotCount); if (!IsInnerCellOutOfBounds(oldCurrentCell.ColumnIndex, oldCurrentCell.Slot) && IsSlotVisible(oldCurrentCell.Slot)) { oldDisplayedElement = DisplayData.GetDisplayedElement(oldCurrentCell.Slot); - } + } if (!RowGroupHeadersTable.Contains(oldCurrentCell.Slot) && !_temporarilyResetCurrentCell) { @@ -5417,7 +5378,7 @@ namespace Avalonia.Controls IsInnerCellOutOfSelectionBounds(oldCurrentCell.ColumnIndex, oldCurrentCell.Slot)) { return false; - } + } if (endRowEdit && !EndRowEdit(DataGridEditAction.Commit, exitEditingMode: true, raiseEvents: true)) { @@ -5430,7 +5391,7 @@ namespace Avalonia.Controls ExitEdit(keepFocus); } } - } + } if (newCurrentItem != null) { @@ -5441,8 +5402,7 @@ namespace Avalonia.Controls return false; } CurrentColumnIndex = columnIndex; - CurrentSlot = slot; - + CurrentSlot = slot; if (_temporarilyResetCurrentCell) { @@ -5454,7 +5414,7 @@ namespace Avalonia.Controls if (!_temporarilyResetCurrentCell && _editingColumnIndex != -1) { _editingColumnIndex = columnIndex; - } + } if (oldDisplayedElement != null) { @@ -5467,7 +5427,7 @@ namespace Avalonia.Controls { UpdateCurrentState(oldDisplayedElement, oldCurrentCell.ColumnIndex, applyCellState: false); } - } + } if (CurrentColumnIndex > -1) { @@ -5478,10 +5438,10 @@ namespace Avalonia.Controls { UpdateCurrentState(DisplayData.GetDisplayedElement(CurrentSlot), CurrentColumnIndex, applyCellState: true); } - } + } return true; - } + } private void SetVerticalOffset(double newVerticalOffset) { @@ -5490,7 +5450,7 @@ namespace Avalonia.Controls { _vScrollBar.Value = _verticalOffset; } - } + } private void UpdateCurrentState(Control displayedElement, int columnIndex, bool applyCellState) { @@ -5514,7 +5474,7 @@ namespace Avalonia.Controls groupHeader.ApplyHeaderStatus(); } } - } + } private void UpdateHorizontalScrollBar(bool needHorizScrollbar, bool forceHorizScrollbar, double totalVisibleWidth, double totalVisibleFrozenWidth, double cellsWidth) { @@ -5526,11 +5486,11 @@ namespace Avalonia.Controls // v---v //|<|_____|###|>| // ^ ^ - // min max + // min max // we want to make the relative size of the thumb reflect the relative size of the viewing area // viewportSize / (max + viewportSize) = cellsWidth / max - // -> viewportSize = max * cellsWidth / (max - cellsWidth) + // -> viewportSize = max * cellsWidth / (max - cellsWidth) // always zero _hScrollBar.Minimum = 0; @@ -5543,7 +5503,7 @@ namespace Avalonia.Controls { _frozenColumnScrollBarSpacer.Width = totalVisibleFrozenWidth; } - Debug.Assert(_hScrollBar.Maximum >= 0); + Debug.Assert(_hScrollBar.Maximum >= 0); // width of the scrollable viewing area double viewPortSize = Math.Max(0, cellsWidth - totalVisibleFrozenWidth); @@ -5562,7 +5522,7 @@ namespace Avalonia.Controls _hScrollBar.Maximum = 0; _hScrollBar.ViewportSize = 0; _hScrollBar.IsEnabled = false; - } + } if (!_hScrollBar.IsVisible) { @@ -5589,7 +5549,7 @@ namespace Avalonia.Controls } } } - } + } private void UpdateVerticalScrollBar(bool needVertScrollbar, bool forceVertScrollbar, double totalVisibleHeight, double cellsHeight) { @@ -5601,14 +5561,14 @@ namespace Avalonia.Controls // v---v //|<|_____|###|>| // ^ ^ - // min max + // min max // we want to make the relative size of the thumb reflect the relative size of the viewing area // viewportSize / (max + viewportSize) = cellsWidth / max // -> viewportSize = max * cellsHeight / (totalVisibleHeight - cellsHeight) // -> = max * cellsHeight / (totalVisibleHeight - cellsHeight) // -> = max * cellsHeight / max - // -> = cellsHeight + // -> = cellsHeight // always zero _vScrollBar.Minimum = 0; @@ -5616,7 +5576,7 @@ namespace Avalonia.Controls { // maximum travel distance -- not the total height _vScrollBar.Maximum = totalVisibleHeight - cellsHeight; - Debug.Assert(_vScrollBar.Maximum >= 0); + Debug.Assert(_vScrollBar.Maximum >= 0); // total height of the display area _vScrollBar.ViewportSize = cellsHeight; @@ -5627,7 +5587,7 @@ namespace Avalonia.Controls _vScrollBar.Maximum = 0; _vScrollBar.ViewportSize = 0; _vScrollBar.IsEnabled = false; - } + } if (!_vScrollBar.IsVisible) { @@ -5654,46 +5614,46 @@ namespace Avalonia.Controls } } } - } + } private void VerticalScrollBar_Scroll(object sender, ScrollEventArgs e) { ProcessVerticalScroll(e.ScrollEventType); - } + } //TODO: Ensure left button is checked for private bool UpdateStateOnMouseLeftButtonDown(PointerPressedEventArgs pointerPressedEventArgs, int columnIndex, int slot, bool allowEdit, bool shift, bool ctrl) { - bool beginEdit; + bool beginEdit; - Debug.Assert(slot >= 0); + Debug.Assert(slot >= 0); // Before changing selection, check if the current cell needs to be committed, and // check if the current row needs to be committed. If any of those two operations are required and fail, - // do not change selection, and do not change current cell. + // do not change selection, and do not change current cell. - bool wasInEdit = EditingColumnIndex != -1; + bool wasInEdit = EditingColumnIndex != -1; if (IsSlotOutOfBounds(slot)) { return true; - } + } if (wasInEdit && (columnIndex != EditingColumnIndex || slot != CurrentSlot) && WaitForLostFocus(() => UpdateStateOnMouseLeftButtonDown(pointerPressedEventArgs, columnIndex, slot, allowEdit, shift, ctrl))) { return true; - } + } try { - _noSelectionChangeCount++; + _noSelectionChangeCount++; beginEdit = allowEdit && CurrentSlot == slot && columnIndex != -1 && (wasInEdit || CurrentColumnIndex == columnIndex) && - !GetColumnEffectiveReadOnlyState(ColumnsItemsInternal[columnIndex]); + !GetColumnEffectiveReadOnlyState(ColumnsItemsInternal[columnIndex]); DataGridSelectionAction action; if (SelectionMode == DataGridSelectionMode.Extended && shift) @@ -5728,24 +5688,22 @@ namespace Avalonia.Controls { action = DataGridSelectionAction.AddCurrentToSelection; } - } + } UpdateSelectionAndCurrency(columnIndex, slot, action, scrollIntoView: false); } finally { NoSelectionChangeCount--; - } + } if (_successfullyUpdatedSelection && beginEdit && BeginCellEdit(pointerPressedEventArgs)) { FocusEditingCell(setFocus: true); - } + } return true; - } - #endregion Private Methods - + } /// /// Returns the Group at the indicated level or null if the item is not in the ItemsSource @@ -5768,7 +5726,7 @@ namespace Avalonia.Controls rowGroupInfo = RowGroupHeadersTable.GetValueAt(groupHeaderSlot); } return rowGroupInfo?.CollectionViewGroup; - } + } /// /// Raises the LoadingRowGroup event @@ -5783,7 +5741,7 @@ namespace Avalonia.Controls handler(this, e); LoadingOrUnloadingRow = false; } - } + } /// /// Raises the UnLoadingRowGroup event @@ -5798,17 +5756,17 @@ namespace Avalonia.Controls handler(this, e); LoadingOrUnloadingRow = false; } - } + } /// /// Occurs before a DataGridRowGroupHeader header is used. /// - public event EventHandler LoadingRowGroup; + public event EventHandler LoadingRowGroup; /// /// Occurs when the DataGridRowGroupHeader is available for reuse. /// - public event EventHandler UnloadingRowGroup; + public event EventHandler UnloadingRowGroup; // Recursively expands parent RowGroupHeaders from the top down private void ExpandRowGroupParentChain(int level, int slot) @@ -5841,16 +5799,14 @@ namespace Avalonia.Controls previousHeaderSlot = RowGroupHeadersTable.GetPreviousIndex(previousHeaderSlot); } } - } - - #region Clipboard + } /// /// This event is raised by OnCopyingRowClipboardContent method after the default row content is prepared. /// Event listeners can modify or add to the row clipboard content. /// - public event EventHandler CopyingRowClipboardContent; - + public event EventHandler CopyingRowClipboardContent; + /// /// This method raises the CopyingRowClipboardContent event. /// @@ -5858,8 +5814,8 @@ namespace Avalonia.Controls protected virtual void OnCopyingRowClipboardContent(DataGridRowClipboardEventArgs e) { CopyingRowClipboardContent?.Invoke(this, e); - } - + } + /// /// This method formats a row (specified by a DataGridRowClipboardEventArgs) into /// a single string to be added to the Clipboard when the DataGrid is copying its contents. @@ -5887,7 +5843,7 @@ namespace Avalonia.Controls } } return text.ToString(); - } + } /// /// Handles the case where a 'Copy' key ('C' or 'Insert') has been pressed. If pressed in combination with @@ -5897,11 +5853,11 @@ namespace Avalonia.Controls /// Whether or not the DataGrid handled the key press. private bool ProcessCopyKey(InputModifiers modifiers) { - KeyboardHelper.GetMetaKeyState(modifiers, out bool ctrl, out bool shift, out bool alt); + KeyboardHelper.GetMetaKeyState(modifiers, out bool ctrl, out bool shift, out bool alt); if (ctrl && !shift && !alt && ClipboardCopyMode != DataGridClipboardCopyMode.None && SelectedItems.Count > 0) { - StringBuilder textBuilder = new StringBuilder(); + StringBuilder textBuilder = new StringBuilder(); if (ClipboardCopyMode == DataGridClipboardCopyMode.IncludeHeader) { @@ -5912,7 +5868,7 @@ namespace Avalonia.Controls } OnCopyingRowClipboardContent(headerArgs); textBuilder.Append(FormatClipboardContent(headerArgs)); - } + } for (int index = 0; index < SelectedItems.Count; index++) { @@ -5925,9 +5881,9 @@ namespace Avalonia.Controls } OnCopyingRowClipboardContent(itemArgs); textBuilder.Append(FormatClipboardContent(itemArgs)); - } + } - string text = textBuilder.ToString(); + string text = textBuilder.ToString(); if (!string.IsNullOrEmpty(text)) { @@ -5936,13 +5892,13 @@ namespace Avalonia.Controls } } return false; - } + } private async void CopyToClipboard(string text) { var clipboard = ((IClipboard)AvaloniaLocator.Current.GetService(typeof(IClipboard))); await clipboard.SetTextAsync(text); - } + } /// /// This is an empty content control that's used during the DataGrid's copy procedure @@ -5958,12 +5914,8 @@ namespace Avalonia.Controls } return _clipboardContentControl; } - } - - #endregion + } - #region Validation - //TODO Validation UI private void ResetValidationStatus() { @@ -5984,18 +5936,11 @@ namespace Avalonia.Controls EditingRow.UpdatePseudoClasses(); } } - IsValid = true; + IsValid = true; _validationSubscription?.Dispose(); _validationSubscription = null; - } - - #region Old Validation UI - - - #endregion - - #endregion + } /// /// Raises the AutoGeneratingColumn event. @@ -6003,51 +5948,8 @@ namespace Avalonia.Controls protected virtual void OnAutoGeneratingColumn(DataGridAutoGeneratingColumnEventArgs e) { AutoGeneratingColumn?.Invoke(this, e); - } - - } - - #region Automation - - #endregion - - #region Validation - - #endregion - - #region RowGroups - - #endregion - - #region Styles - - #region CellStyle - - #endregion CellStyle - - #region ColumnHeaderStyle - - #endregion ColumnHeaderStyle - - #region RowHeaderStyle - - #endregion RowHeaderStyle - - #region RowStyle - - #endregion RowStyle - - #endregion - - #region DragDrop - - #region DragIndicatorStyle - - #endregion DragIndicatorStyle - - #region DropLocationIndicatorStyle + } - #endregion DropLocationIndicatorStyle + } - #endregion } \ No newline at end of file diff --git a/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs b/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs index 73bc392e65..d213285aff 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs @@ -1,7 +1,7 @@ // (c) Copyright Microsoft Corporation. // This source is subject to the Microsoft Public License (Ms-PL). // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. +// All other rights reserved. using Avalonia.Data; using Avalonia.Utilities; @@ -10,7 +10,7 @@ using System.Reactive.Disposables; using System.Reactive.Subjects; using Avalonia.Reactive; using System.Diagnostics; -using Avalonia.Controls.Utils; +using Avalonia.Controls.Utils; namespace Avalonia.Controls { @@ -20,8 +20,8 @@ namespace Avalonia.Controls /// public abstract class DataGridBoundColumn : DataGridColumn { - private IBinding _binding; - + private IBinding _binding; + /// /// Gets or sets the binding that associates the column with a property in the data source. /// @@ -40,10 +40,9 @@ namespace Avalonia.Controls { // Edited value couldn't be committed, so we force a CancelEdit OwningGrid.CancelEdit(DataGridEditingUnit.Row, raiseEvents: false); - } - - _binding = value; + } + _binding = value; if (_binding != null) { @@ -53,25 +52,25 @@ namespace Avalonia.Controls if (!String.IsNullOrEmpty(binding.Path)) { binding.Mode = BindingMode.TwoWay; - } + } if (binding.Converter == null) { binding.Converter = DataGridValueConverter.Instance; } - } + } // Apply the new Binding to existing rows in the DataGrid if (OwningGrid != null) { OwningGrid.OnColumnBindingChanged(this); } - } + } RemoveEditingElement(); } } - } + } /// /// The binding that will be used to get or set cell content for the clipboard. @@ -87,47 +86,47 @@ namespace Avalonia.Controls { base.ClipboardContentBinding = value; } - } + } //TODO Rename //TODO Validation protected sealed override IControl GenerateEditingElement(DataGridCell cell, object dataItem, out ICellEditBinding editBinding) { IControl element = GenerateEditingElementDirect(cell, dataItem); - editBinding = null; + editBinding = null; if (Binding != null) { editBinding = BindEditingElement(element, BindingTarget, Binding); - } + } return element; - } + } private static ICellEditBinding BindEditingElement(IAvaloniaObject target, AvaloniaProperty property, IBinding binding) { - var result = binding.Initiate(target, property, enableDataValidation: true); + var result = binding.Initiate(target, property, enableDataValidation: true); if (result != null) { if(result.Subject != null) { var bindingHelper = new CellEditBinding(result.Subject); - var instanceBinding = new InstancedBinding(bindingHelper.InternalSubject, result.Mode, result.Priority); + var instanceBinding = new InstancedBinding(bindingHelper.InternalSubject, result.Mode, result.Priority); BindingOperations.Apply(target, property, instanceBinding, null); return bindingHelper; - } + } BindingOperations.Apply(target, property, result, null); - } + } return null; - } + } - protected abstract IControl GenerateEditingElementDirect(DataGridCell cell, object dataItem); + protected abstract IControl GenerateEditingElementDirect(DataGridCell cell, object dataItem); - internal AvaloniaProperty BindingTarget { get; set; } + internal AvaloniaProperty BindingTarget { get; set; } internal void SetHeaderFromBinding() { @@ -142,13 +141,5 @@ namespace Avalonia.Controls } } } - } - - #region Binding - - #endregion - - #region Styles - - #endregion + } } diff --git a/src/Avalonia.Controls.DataGrid/DataGridCell.cs b/src/Avalonia.Controls.DataGrid/DataGridCell.cs index 7dad41136a..a21583b38e 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridCell.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridCell.cs @@ -182,7 +182,7 @@ namespace Avalonia.Controls internal void UpdatePseudoClasses() { - + } // Makes sure the right gridline has the proper stroke and visibility. If lastVisibleColumn is specified, the diff --git a/src/Avalonia.Controls.DataGrid/DataGridCheckBoxColumn.cs b/src/Avalonia.Controls.DataGrid/DataGridCheckBoxColumn.cs index 4f7189de90..f1bbea9949 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridCheckBoxColumn.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridCheckBoxColumn.cs @@ -17,15 +17,12 @@ namespace Avalonia.Controls /// public class DataGridCheckBoxColumn : DataGridBoundColumn { - #region Data private bool _beganEditWithKeyboard; private bool _isThreeState; private CheckBox _currentCheckBox; private DataGrid _owningGrid; - #endregion Data - /// /// Initializes a new instance of the class. /// @@ -34,8 +31,6 @@ namespace Avalonia.Controls BindingTarget = CheckBox.IsCheckedProperty; } - #region Public Properties - /// /// Gets or sets a value that indicates whether the hosted controls allow three states or two. /// @@ -58,10 +53,6 @@ namespace Avalonia.Controls } } - #endregion Public Properties - - #region Protected Methods - /// /// Causes the column cell being edited to revert to the specified value. /// @@ -222,10 +213,6 @@ namespace Avalonia.Controls } } - #endregion Protected Methods - - #region Private Methods - private void Columns_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Remove && e.OldItems.Contains(this) && _owningGrid != null) @@ -325,6 +312,5 @@ namespace Avalonia.Controls } } - #endregion Private Methods } } diff --git a/src/Avalonia.Controls.DataGrid/DataGridClipboard.cs b/src/Avalonia.Controls.DataGrid/DataGridClipboard.cs index 765122884a..a4bab8b304 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridClipboard.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridClipboard.cs @@ -36,16 +36,11 @@ namespace Avalonia.Controls /// public struct DataGridClipboardCellContent { - #region Data private DataGridColumn _column; private object _content; private object _item; - #endregion Data - - #region Constructors - /// /// Creates a new DataGridClipboardCellValue structure containing information about a DataGrid cell. /// @@ -59,10 +54,6 @@ namespace Avalonia.Controls this._content = content; } - #endregion Constructors - - #region Public Properties - /// /// DataGridColumn containing the cell. /// @@ -96,10 +87,6 @@ namespace Avalonia.Controls } } - #endregion Public Properties - - #region Public Methods - /// /// Field-by-field comparison to avoid reflection-based ValueType.Equals. /// @@ -152,7 +139,6 @@ namespace Avalonia.Controls return true; } - #endregion Public Methods } /// @@ -160,16 +146,11 @@ namespace Avalonia.Controls /// public class DataGridRowClipboardEventArgs : EventArgs { - #region Data private List _clipboardRowContent; private bool _isColumnHeadersRow; private object _item; - #endregion Data - - #region Constructor - /// /// Creates a DataGridRowClipboardEventArgs object and initializes the properties. /// @@ -181,10 +162,6 @@ namespace Avalonia.Controls _item = item; } - #endregion Constructor - - #region Public Properties - /// /// This list should be used to modify, add ot remove a cell content before it gets stored into the clipboard. /// @@ -222,7 +199,6 @@ namespace Avalonia.Controls } } - #endregion Public Properties } } diff --git a/src/Avalonia.Controls.DataGrid/DataGridColumn.cs b/src/Avalonia.Controls.DataGrid/DataGridColumn.cs index ce5a5c0d6d..128fbde0c1 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridColumn.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridColumn.cs @@ -198,7 +198,7 @@ namespace Avalonia.Controls } } } - + /// /// Actual visible width after Width, MinWidth, and MaxWidth setting at the Column level and DataGrid level /// have been taken into account @@ -387,7 +387,6 @@ namespace Avalonia.Controls } } - public object Header { get @@ -470,7 +469,7 @@ namespace Avalonia.Controls } } } - + public double MinWidth { get @@ -506,7 +505,7 @@ namespace Avalonia.Controls } } } - + public DataGridLength Width { get @@ -987,7 +986,7 @@ namespace Avalonia.Controls { _editingElement = GenerateEditingElement(cell, dataItem, out _editBinding); } - + return _editingElement; } @@ -1026,7 +1025,7 @@ namespace Avalonia.Controls return null; } - + internal string GetSortPropertyName() { string result = SortMemberPath; @@ -1047,12 +1046,5 @@ namespace Avalonia.Controls } } - - #region Styles - - #endregion - - #region Binding - #endregion } \ No newline at end of file diff --git a/src/Avalonia.Controls.DataGrid/DataGridColumnCollection.cs b/src/Avalonia.Controls.DataGrid/DataGridColumnCollection.cs index 4dfedd4550..922b1d9c08 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridColumnCollection.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridColumnCollection.cs @@ -23,8 +23,6 @@ namespace Avalonia.Controls DisplayIndexMap = new List(); } - #region Properties - internal int AutogeneratedColumnCount { get; @@ -156,10 +154,6 @@ namespace Avalonia.Controls private set; } - #endregion Properties - - #region Protected Methods - protected override void ClearItems() { try @@ -255,10 +249,6 @@ namespace Avalonia.Controls throw new NotSupportedException(); } - #endregion Protected Methods - - #region Internal Methods - internal bool DisplayInOrder(int columnIndex1, int columnIndex2) { int displayIndex1 = ItemsInternal[columnIndex1].DisplayIndexWithFiller; @@ -548,10 +538,6 @@ namespace Avalonia.Controls return GetDisplayedColumns(filter); } - #endregion Internal Methods - - #region Private Methods - private void RemoveItemPrivate(int columnIndex, bool isSpacer) { try @@ -596,6 +582,5 @@ namespace Avalonia.Controls } } - #endregion Private Methods } } diff --git a/src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs b/src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs index f09e3cd821..6cb0807e29 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs @@ -32,7 +32,7 @@ namespace Avalonia.Controls private const int DATAGRIDCOLUMNHEADER_resizeRegionWidth = 5; private const double DATAGRIDCOLUMNHEADER_separatorThickness = 1; - + private bool _areHandlersSuspended; private static DragMode _dragMode; private static Point? _lastMousePositionHeaders; @@ -82,10 +82,6 @@ namespace Avalonia.Controls PointerEnter += DataGridColumnHeader_PointerEnter; PointerLeave += DataGridColumnHeader_PointerLeave; } - - #region Protected Methods - - #endregion Protected Methods private void OnAreSeparatorsVisibleChanged(AvaloniaPropertyChangedEventArgs e) { @@ -103,15 +99,13 @@ namespace Avalonia.Controls } } - #region Internal Properties - internal DataGridColumn OwningColumn { get; set; } internal DataGrid OwningGrid => OwningColumn?.OwningGrid; - + internal int ColumnIndex { get @@ -130,10 +124,6 @@ namespace Avalonia.Controls private set; } - #endregion Internal Properties - - #region Private Properties - private bool IsMouseOver { get; @@ -146,8 +136,6 @@ namespace Avalonia.Controls set; } - #endregion Private Properties - private void SetValueNoCallback(AvaloniaProperty property, T value, BindingPriority priority = BindingPriority.LocalValue) { _areHandlersSuspended = true; @@ -161,8 +149,6 @@ namespace Avalonia.Controls } } - #region Internal Methods - //TODO Implement internal void ApplyState() { @@ -292,9 +278,6 @@ namespace Avalonia.Controls } } } - #endregion Internal Methods - - #region Private Methods private bool CanReorderColumn(DataGridColumn column) { @@ -335,10 +318,6 @@ namespace Avalonia.Controls return false; } - #endregion Private Methods - - #region DragDrop - //TODO DragDrop internal void OnMouseLeftButtonDown(ref bool handled, PointerEventArgs args, Point mousePosition) @@ -750,7 +729,7 @@ namespace Avalonia.Controls isFrozen: OwningColumn.IsFrozen, isReadOnly: null); targetPosition = targetColumn.HeaderCell.Translate(OwningGrid.ColumnHeaders, targetPosition); - + targetPosition = targetPosition.WithX(targetPosition.X + targetColumn.ActualWidth); } else @@ -805,7 +784,7 @@ namespace Avalonia.Controls { previousColumn = OwningGrid.ColumnsInternal.GetPreviousVisibleNonFillerColumn(currentColumn); } - + if ((distanceFromRight <= DATAGRIDCOLUMNHEADER_resizeRegionWidth && currentColumn != null && CanResizeColumn(currentColumn)) || (distanceFromLeft <= DATAGRIDCOLUMNHEADER_resizeRegionWidth && previousColumn != null && CanResizeColumn(previousColumn))) { @@ -822,12 +801,6 @@ namespace Avalonia.Controls } } - #endregion - - } - #region Style - - #endregion } diff --git a/src/Avalonia.Controls.DataGrid/DataGridColumns.cs b/src/Avalonia.Controls.DataGrid/DataGridColumns.cs index 3cc432fddf..16b63ad696 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridColumns.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridColumns.cs @@ -16,7 +16,6 @@ namespace Avalonia.Controls { public partial class DataGrid { - #region Protected Methods protected virtual void OnColumnDisplayIndexChanged(DataGridColumnEventArgs e) { @@ -34,10 +33,6 @@ namespace Avalonia.Controls ColumnReordering?.Invoke(this, e); } - #endregion Protected Methods - - #region Internal Methods - /// /// Adjusts the widths of all columns with DisplayIndex >= displayIndex such that the total /// width is adjusted by the given amount, if possible. If the total desired adjustment amount @@ -345,7 +340,7 @@ namespace Avalonia.Controls } } } - + /// /// Adjusts the specified column's width according to its new maximum value. /// @@ -770,10 +765,6 @@ namespace Avalonia.Controls } } - #endregion Internal Methods - - #region Private Methods - /// /// Adjusts the widths of all star columns with DisplayIndex >= displayIndex such that the total /// width is adjusted by the given amount, if possible. If the total desired adjustment amount @@ -901,7 +892,7 @@ namespace Avalonia.Controls return remainingAdjustment; } - + private bool ComputeDisplayedColumns() { bool invalidate = false; @@ -1137,7 +1128,7 @@ namespace Avalonia.Controls column.DisplayIndexHasChanged = true; // OnColumnDisplayIndexChanged needs to be raised later on } } - + // Now raise all the OnColumnDisplayIndexChanged events FlushDisplayIndexChanged(true /*raiseEvent*/); } @@ -1180,7 +1171,7 @@ namespace Avalonia.Controls } } ColumnsInternal.DisplayIndexMap.Insert(insertedColumn.DisplayIndexWithFiller, insertedColumn.Index); - + // Now raise all the OnColumnDisplayIndexChanged events FlushDisplayIndexChanged(true /*raiseEvent*/); } @@ -1317,7 +1308,7 @@ namespace Avalonia.Controls } } } - + private bool GetColumnEffectiveReadOnlyState(DataGridColumn dataGridColumn) { Debug.Assert(dataGridColumn != null); @@ -1346,7 +1337,7 @@ namespace Avalonia.Controls } return x; } - + private double GetNegHorizontalOffsetFromHorizontalOffset(double horizontalOffset) { foreach (DataGridColumn column in ColumnsInternal.GetVisibleScrollingColumns()) @@ -1622,10 +1613,6 @@ namespace Avalonia.Controls ComputeDisplayedColumns(); } - #endregion Private Methods - - #region AutoGenerate - private static DataGridBoundColumn GetDataGridColumnFromType(Type type) { Debug.Assert(type != null); @@ -1772,15 +1759,6 @@ namespace Avalonia.Controls } } - #endregion } - - #region DragDrop - - #endregion - - #region Styles - - #endregion } diff --git a/src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs b/src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs index 443f645eab..f5e0dbe3b3 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs @@ -20,8 +20,7 @@ namespace Avalonia.Controls { internal class DataGridDataConnection { - #region Data - + private int _backupSlotForCurrentChanged; private int _columnForCurrentChanged; private PropertyInfo[] _dataProperties; @@ -33,15 +32,11 @@ namespace Avalonia.Controls private bool _scrollForCurrentChanged; private DataGridSelectionAction _selectionActionForCurrentChanged; - #endregion Data - public DataGridDataConnection(DataGrid owner) { _owner = owner; } - #region Properties - public bool AllowEdit { get @@ -215,10 +210,6 @@ namespace Avalonia.Controls } } - #endregion Properties - - #region Public Methods - /// /// Puts the entity into editing mode if possible /// @@ -444,10 +435,6 @@ namespace Avalonia.Controls return -1; } - #endregion Public methods - - #region Internal Methods - internal void ClearDataProperties() { _dataProperties = null; @@ -552,10 +539,6 @@ namespace Avalonia.Controls EventsWired = true; } - #endregion Internal Methods - - #region Private methods - private void CollectionView_CurrentChanged(object sender, EventArgs e) { if (_expectingCurrentChanged) @@ -694,7 +677,6 @@ namespace Avalonia.Controls } } - private void UpdateDataProperties() { Type dataType = DataType; @@ -710,6 +692,5 @@ namespace Avalonia.Controls } } - #endregion Private Methods } } diff --git a/src/Avalonia.Controls.DataGrid/DataGridDisplayData.cs b/src/Avalonia.Controls.DataGrid/DataGridDisplayData.cs index 16d3bd27b3..e659438b43 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridDisplayData.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridDisplayData.cs @@ -251,7 +251,6 @@ namespace Avalonia.Controls return GetScrollingElements(element => element is DataGridRow); } - internal DataGridRow GetUsedRow() { if (_recyclableRows.Count > 0) diff --git a/src/Avalonia.Controls.DataGrid/DataGridLength.cs b/src/Avalonia.Controls.DataGrid/DataGridLength.cs index f20481cc1b..5c5499d13f 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridLength.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridLength.cs @@ -26,7 +26,6 @@ namespace Avalonia.Controls [TypeConverter(typeof(DataGridLengthConverter))] public struct DataGridLength : IEquatable { - #region Data private double _desiredValue; // desired value storage private double _displayValue; // display value storage @@ -41,10 +40,6 @@ namespace Avalonia.Controls // WPF uses 1.0 as the default value as well internal const double DATAGRIDLENGTH_DefaultValue = 1.0; - #endregion Data - - #region Constructors - /// /// Initializes a new instance of the class. /// @@ -136,10 +131,6 @@ namespace Avalonia.Controls _unitType = type; } - #endregion Constructors - - #region Properties - /// /// Gets a structure that represents the standard automatic sizing mode. /// @@ -287,10 +278,6 @@ namespace Avalonia.Controls } } - #endregion Properties - - #region Methods - /// /// Overloaded operator, compares 2 DataGridLength's. /// @@ -357,7 +344,6 @@ namespace Avalonia.Controls return ((int)_unitValue + (int)_unitType) + (int)_desiredValue + (int)_displayValue; } - #endregion Methods } /// /// DataGridLengthConverter - Converter class for converting instances of other types to and from DataGridLength instances. @@ -368,7 +354,7 @@ namespace Avalonia.Controls private static string _starSuffix = "*"; private static string[] _valueInvariantUnitStrings = { "auto", "sizetocells", "sizetoheader" }; private static DataGridLength[] _valueInvariantDataGridLengths = { DataGridLength.Auto, DataGridLength.SizeToCells, DataGridLength.SizeToHeader }; - + /// /// Checks whether or not this class can convert from a given type. /// diff --git a/src/Avalonia.Controls.DataGrid/DataGridRow.cs b/src/Avalonia.Controls.DataGrid/DataGridRow.cs index 41af4ba602..8bc76543ba 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridRow.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridRow.cs @@ -22,7 +22,6 @@ namespace Avalonia.Controls /// public class DataGridRow : TemplatedControl { - #region Constants private const byte DATAGRIDROW_defaultMinHeight = 0; internal const int DATAGRIDROW_maximumHeight = 65536; @@ -34,11 +33,6 @@ namespace Avalonia.Controls internal const string DATAGRIDROW_elementRoot = "PART_Root"; internal const string DATAGRIDROW_elementRowHeader = "PART_RowHeader"; - #endregion - - #region Fields - - private DataGridCellsPresenter _cellsElement; private DataGridCell _fillerCell; private DataGridRowHeader _headerElement; @@ -67,10 +61,6 @@ namespace Avalonia.Controls private bool? _appliedDetailsVisibility; - #endregion - - #region Avalonia Properties - /// /// Identifies the Header dependency property. /// @@ -85,7 +75,7 @@ namespace Avalonia.Controls get { return GetValue(HeaderProperty); } set { SetValue(HeaderProperty, value); } } - + public static readonly DirectProperty IsValidProperty = AvaloniaProperty.RegisterDirect( nameof(IsValid), @@ -123,8 +113,6 @@ namespace Avalonia.Controls get { return GetValue(AreDetailsVisibleProperty); } set { SetValue(AreDetailsVisibleProperty, value); } } - - #endregion static DataGridRow() { @@ -133,7 +121,7 @@ namespace Avalonia.Controls AreDetailsVisibleProperty.Changed.AddClassHandler(x => x.OnAreDetailsVisibleChanged); PointerPressedEvent.AddClassHandler(x => x.DataGridRow_PointerPressed, handledEventsToo: true); } - + /// /// Initializes a new instance of the class. /// @@ -178,7 +166,7 @@ namespace Avalonia.Controls { var oldValue = (IDataTemplate)e.OldValue; var newValue = (IDataTemplate)e.NewValue; - + if (!_areHandlersSuspended && OwningGrid != null) { IDataTemplate actualDetailsTemplate(IDataTemplate template) => (template ?? OwningGrid.RowDetailsTemplate); @@ -211,14 +199,12 @@ namespace Avalonia.Controls } } - #region Properties - internal DataGrid OwningGrid { get; set; } - + /// /// Index of the row /// @@ -227,7 +213,7 @@ namespace Avalonia.Controls get; set; } - + internal double ActualBottomGridLineHeight { get @@ -303,7 +289,7 @@ namespace Avalonia.Controls get; private set; } - + internal bool IsMouseOver { get @@ -331,7 +317,7 @@ namespace Avalonia.Controls get; private set; } - + internal bool IsRecyclable { get @@ -343,7 +329,7 @@ namespace Avalonia.Controls return true; } } - + internal bool IsSelected { get @@ -357,7 +343,7 @@ namespace Avalonia.Controls return OwningGrid.GetRowSelection(Slot); } } - + internal int? MouseOverColumnIndex { get @@ -426,12 +412,6 @@ namespace Avalonia.Controls } } - #endregion - - #region Methods - - #region Public - /// /// Returns the index of the current row. /// @@ -462,10 +442,6 @@ namespace Avalonia.Controls return row; } - #endregion - - #region Protected - /// /// Arranges the content of the . /// @@ -638,10 +614,6 @@ namespace Avalonia.Controls base.OnPointerLeave(e); } - #endregion - - #region Internal - internal void ApplyCellsState() { foreach (DataGridCell dataGridCell in Cells) @@ -668,7 +640,7 @@ namespace Avalonia.Controls ApplyHeaderStatus(); } } - + //TODO Animation internal void DetachFromDataGrid(bool recycle) { @@ -802,10 +774,6 @@ namespace Avalonia.Controls _bottomGridLine = null; } - #endregion - - #region Private - private void DataGridCellCollection_CellAdded(object sender, DataGridCellEventArgs e) { _cellsElement?.Children.Add(e.Cell); @@ -815,7 +783,7 @@ namespace Avalonia.Controls { _cellsElement?.Children.Remove(e.Cell); } - + private void DataGridRow_PointerPressed(PointerPressedEventArgs e) { if(e.MouseButton != MouseButton.Left) @@ -837,13 +805,6 @@ namespace Avalonia.Controls } } - - #endregion - - #endregion - - #region Row Details - private void OnRowDetailsChanged() { OwningGrid?.OnRowDetailsChanged(); @@ -875,7 +836,7 @@ namespace Avalonia.Controls return OwningGrid.GetRowDetailsVisibility(Index); } } - + private void UnloadDetailsTemplate(bool recycle) { if (_detailsElement != null) @@ -1027,7 +988,7 @@ namespace Avalonia.Controls { _detailsElement.ContentHeight = 0; } - + OnRowDetailsChanged(); if (raiseNotification) @@ -1087,20 +1048,9 @@ namespace Avalonia.Controls } } } - #endregion - } - - #region Constants - #endregion Constants - - #region Data - - #endregion Data - - #region HeaderStyle + } //TODO Styles - #endregion HeaderStyle } \ No newline at end of file diff --git a/src/Avalonia.Controls.DataGrid/DataGridRowGroupHeader.cs b/src/Avalonia.Controls.DataGrid/DataGridRowGroupHeader.cs index dfa0590d44..716997f62c 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridRowGroupHeader.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridRowGroupHeader.cs @@ -121,8 +121,6 @@ namespace Avalonia.Controls AddHandler(InputElement.PointerPressedEvent, (s, e) => DataGridRowGroupHeader_PointerPressed(e), handledEventsToo: true); } - #region Properties - internal DataGridRowHeader HeaderCell { get @@ -182,10 +180,6 @@ namespace Avalonia.Controls } } - #endregion Properties - - #region Methods - private IDisposable _expanderButtonSubscription; protected override void OnTemplateApplied(TemplateAppliedEventArgs e) @@ -222,7 +216,7 @@ namespace Avalonia.Controls base.OnTemplateApplied(e); } - + internal void ApplyHeaderStatus() { if (_headerElement != null && OwningGrid.AreRowHeadersVisible) @@ -391,7 +385,7 @@ namespace Avalonia.Controls base.OnPointerLeave(e); } - + private void SetIsCheckedNoCallBack(bool value) { if (_expanderButton != null && _expanderButton.IsChecked != value) @@ -447,11 +441,9 @@ namespace Avalonia.Controls else formatString = "({0} Items)"; - _itemCountElement.Text = String.Format(formatString, RowGroupInfo.CollectionViewGroup.ItemCount); } } - #endregion Methods } } \ No newline at end of file diff --git a/src/Avalonia.Controls.DataGrid/DataGridRowHeader.cs b/src/Avalonia.Controls.DataGrid/DataGridRowHeader.cs index 5ec4d83c6a..5bfe449b63 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridRowHeader.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridRowHeader.cs @@ -17,14 +17,8 @@ namespace Avalonia.Controls.Primitives private const string DATAGRIDROWHEADER_elementRootName = "Root"; private const double DATAGRIDROWHEADER_separatorThickness = 1; - #region Data - private Control _rootElement; - #endregion Data - - #region Dependency Properties - public static readonly StyledProperty SeparatorBrushProperty = AvaloniaProperty.Register(nameof(SeparatorBrush)); @@ -47,8 +41,6 @@ namespace Avalonia.Controls.Primitives set { SetValue(AreSeparatorsVisibleProperty, value); } } - #endregion - /// /// Initializes a new instance of the class. /// @@ -57,8 +49,6 @@ namespace Avalonia.Controls.Primitives AddHandler(PointerPressedEvent, DataGridRowHeader_PointerPressed, handledEventsToo: true); } - #region Properties - internal Control Owner { get; @@ -101,10 +91,6 @@ namespace Avalonia.Controls.Primitives } } - #endregion - - #region Protected Methods - /// /// Builds the visual tree for the row header when a new template is applied. /// @@ -147,23 +133,15 @@ namespace Avalonia.Controls.Primitives return measuredSize; } - #endregion Protected Methods - - #region Internal Methods - //TODO Implement internal void ApplyOwnerStatus() { if (_rootElement != null && Owner != null && Owner.IsVisible) { - + } } - #endregion Internal Methods - - #region Private Methods - protected override void OnPointerEnter(PointerEventArgs e) { if (OwningRow != null) @@ -208,16 +186,7 @@ namespace Avalonia.Controls.Primitives } } - #endregion Private Methods - } - #region Styles - - #endregion - - #region Constants - - #endregion Constants } diff --git a/src/Avalonia.Controls.DataGrid/DataGridRows.cs b/src/Avalonia.Controls.DataGrid/DataGridRows.cs index 5d035ac1dd..fda14cf5b4 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridRows.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridRows.cs @@ -18,7 +18,6 @@ namespace Avalonia.Controls { public partial class DataGrid { - #region Internal Properties internal bool AreRowBottomGridLinesRequired { @@ -59,10 +58,6 @@ namespace Avalonia.Controls } } - #endregion Internal Properties - - #region Private Properties - // Cumulated height of all known rows, including the gridlines and details section. // This property returns an approximation of the actual total row heights and also // updates the RowHeightEstimate @@ -128,10 +123,6 @@ namespace Avalonia.Controls } } - #endregion Private Properties - - #region Internal Methods - /// /// Clears the entire selection. Displayed rows are deselected explicitly to visualize /// potential transition effects @@ -602,10 +593,6 @@ namespace Avalonia.Controls return rowIndex + RowGroupHeadersTable.GetIndexCountBeforeGap(0, rowIndex); } - #endregion Internal Methods - - #region Private Methods - private void AddSlotElement(int slot, Control element) { #if DEBUG @@ -693,7 +680,7 @@ namespace Avalonia.Controls } } } - + private void ClearRows(bool recycle) { // Need to clean up recycled rows even if the RowCount is 0 @@ -2177,8 +2164,6 @@ namespace Avalonia.Controls } } - #endregion Private Methods - private void CollectionViewGroup_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { // If we receive this event when the number of GroupDescriptions is different than what we have already @@ -2779,7 +2764,7 @@ namespace Avalonia.Controls groupHeader.UpdateTitleElements(); OnLoadingRowGroup(new DataGridRowGroupHeaderEventArgs(groupHeader)); - + return groupHeader; } @@ -2804,7 +2789,6 @@ namespace Avalonia.Controls return null; } - internal void OnRowGroupHeaderToggled(DataGridRowGroupHeader groupHeader, bool newIsVisibile, bool setCurrent) { Debug.Assert(groupHeader.RowGroupInfo.CollectionViewGroup.ItemCount > 0); @@ -2919,8 +2903,6 @@ namespace Avalonia.Controls } } - #region Details - // Returns the number of rows with details visible between lowerBound and upperBound exclusive. // As of now, the caller needs to account for Collapsed slots. This method assumes everything // is visible @@ -3028,8 +3010,6 @@ namespace Avalonia.Controls RowDetailsVisibilityChanged?.Invoke(this, e); } - #endregion - #if DEBUG internal void PrintRowGroupInfo() { diff --git a/src/Avalonia.Controls.DataGrid/DataGridTextColumn.cs b/src/Avalonia.Controls.DataGrid/DataGridTextColumn.cs index c7d627187c..589cdc253c 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridTextColumn.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridTextColumn.cs @@ -17,19 +17,12 @@ namespace Avalonia.Controls /// public class DataGridTextColumn : DataGridBoundColumn { - #region Constants - - #endregion Constants - - #region Data private double? _fontSize; private FontStyle? _fontStyle; private FontWeight? _fontWeight; private IBrush _foreground; - #endregion Data - /// /// Initializes a new instance of the class. /// @@ -38,8 +31,6 @@ namespace Avalonia.Controls BindingTarget = TextBox.TextProperty; } - #region DependencyProperties - /// /// Identifies the FontFamily dependency property. /// @@ -55,10 +46,6 @@ namespace Avalonia.Controls set { SetValue(FontFamilyProperty, value); } } - #endregion DependencyProperties - - #region Public Properties - /// /// Gets or sets the font size. /// @@ -137,10 +124,6 @@ namespace Avalonia.Controls } } - #endregion Public Properties - - #region Protected Methods - /// /// Causes the column cell being edited to revert to the specified value. /// @@ -357,10 +340,6 @@ namespace Avalonia.Controls } } - #endregion Protected Methods - - #region Private Methods - private void SetTextFontSize(AvaloniaObject textElement, AvaloniaProperty fontSizeProperty) { double newFontSize = FontSize; @@ -374,6 +353,5 @@ namespace Avalonia.Controls } } - #endregion Private Methods } } diff --git a/src/Avalonia.Controls.DataGrid/EventArgs.cs b/src/Avalonia.Controls.DataGrid/EventArgs.cs index 0d370fc492..991e556efc 100644 --- a/src/Avalonia.Controls.DataGrid/EventArgs.cs +++ b/src/Avalonia.Controls.DataGrid/EventArgs.cs @@ -90,8 +90,6 @@ namespace Avalonia.Controls this.EditingEventArgs = editingEventArgs; } - #region Properties - /// /// Gets the column that contains the cell to be edited. /// @@ -119,7 +117,6 @@ namespace Avalonia.Controls private set; } - #endregion Properties } /// @@ -140,8 +137,6 @@ namespace Avalonia.Controls EditAction = editAction; } - #region Properties - /// /// The column of the cell that has just exited edit mode. /// @@ -169,7 +164,6 @@ namespace Avalonia.Controls private set; } - #endregion Properties } /// @@ -239,8 +233,6 @@ namespace Avalonia.Controls EditAction = editAction; } - #region Properties - /// /// The column of the cell that is about to exit edit mode. /// @@ -277,7 +269,6 @@ namespace Avalonia.Controls private set; } - #endregion Properties } internal class DataGridCellEventArgs : EventArgs @@ -480,8 +471,6 @@ namespace Avalonia.Controls EditingElement = editingElement; } - #region Public Properties - /// /// Gets the column that contains the cell to be edited. /// @@ -518,7 +507,6 @@ namespace Avalonia.Controls private set; } - #endregion } /// diff --git a/src/Avalonia.Controls.DataGrid/Primitives/DataGridCellsPresenter.cs b/src/Avalonia.Controls.DataGrid/Primitives/DataGridCellsPresenter.cs index f76f3d545b..b014c699bb 100644 --- a/src/Avalonia.Controls.DataGrid/Primitives/DataGridCellsPresenter.cs +++ b/src/Avalonia.Controls.DataGrid/Primitives/DataGridCellsPresenter.cs @@ -57,7 +57,7 @@ namespace Avalonia.Controls.Primitives { return base.ArrangeOverride(finalSize); } - + if (OwningGrid.AutoSizingColumns) { // When we initially load an auto-column, we have to wait for all the rows to be measured diff --git a/src/Avalonia.Controls.DataGrid/Primitives/DataGridDetailsPresenter.cs b/src/Avalonia.Controls.DataGrid/Primitives/DataGridDetailsPresenter.cs index a5fbf5b935..4e0d596d00 100644 --- a/src/Avalonia.Controls.DataGrid/Primitives/DataGridDetailsPresenter.cs +++ b/src/Avalonia.Controls.DataGrid/Primitives/DataGridDetailsPresenter.cs @@ -31,7 +31,7 @@ namespace Avalonia.Controls.Primitives get { return GetValue(ContentHeightProperty); } set { SetValue(ContentHeightProperty, value); } } - + internal DataGridRow OwningRow { get; @@ -39,7 +39,6 @@ namespace Avalonia.Controls.Primitives } private DataGrid OwningGrid => OwningRow?.OwningGrid; - public DataGridDetailsPresenter() { AffectsMeasure(ContentHeightProperty); diff --git a/src/Avalonia.Controls.DataGrid/Primitives/DataGridRowsPresenter.cs b/src/Avalonia.Controls.DataGrid/Primitives/DataGridRowsPresenter.cs index 4ce2cad737..6ad58bf250 100644 --- a/src/Avalonia.Controls.DataGrid/Primitives/DataGridRowsPresenter.cs +++ b/src/Avalonia.Controls.DataGrid/Primitives/DataGridRowsPresenter.cs @@ -161,7 +161,7 @@ namespace Avalonia.Controls.Primitives return new Size(totalCellsWidth + headerWidth, totalHeight); } - + #if DEBUG internal void PrintChildren() { diff --git a/src/Avalonia.Controls.DataGrid/Utils/ReflectionHelper.cs b/src/Avalonia.Controls.DataGrid/Utils/ReflectionHelper.cs index fd2c7b6957..31c42db076 100644 --- a/src/Avalonia.Controls.DataGrid/Utils/ReflectionHelper.cs +++ b/src/Avalonia.Controls.DataGrid/Utils/ReflectionHelper.cs @@ -149,7 +149,6 @@ namespace Avalonia.Controls.Utils return enumerableType; } - /// /// Retrieves the value and type of a property. That property can be nested and its path /// can include indexers. Each element of the path needs to be a public instance property. diff --git a/src/Avalonia.Controls.DataGrid/Utils/ValidationUtil.cs b/src/Avalonia.Controls.DataGrid/Utils/ValidationUtil.cs index c619e3cddc..e1ecb2c562 100644 --- a/src/Avalonia.Controls.DataGrid/Utils/ValidationUtil.cs +++ b/src/Avalonia.Controls.DataGrid/Utils/ValidationUtil.cs @@ -131,7 +131,6 @@ namespace Avalonia.Controls.Utils } } - /// /// Performs an action and catches any non-critical exceptions. /// @@ -151,7 +150,7 @@ namespace Avalonia.Controls.Utils // Catch any non-critical exceptions } } - + /// /// Determines if the specified exception is un-recoverable. ///