mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-26 03:00:28 +08:00
Add UserCanFilter fields
This commit is contained in:
@@ -29,6 +29,7 @@ public abstract partial class DataGridColumn : IDataGridColumnGroupItem
|
||||
internal bool? CanUserReorderInternal { get; set; }
|
||||
internal bool? CanUserResizeInternal { get; set; }
|
||||
internal bool? CanUserSortInternal { get; set; }
|
||||
internal bool? CanUserFilterInternal { get; set; }
|
||||
|
||||
internal bool ActualCanUserResize
|
||||
{
|
||||
|
||||
@@ -246,6 +246,21 @@ public abstract partial class DataGridColumn : AvaloniaObject
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanUserFilter
|
||||
{
|
||||
get => CanUserResizeInternal ??
|
||||
OwningGrid?.CanUserResizeColumns ??
|
||||
DataGrid.DefaultCanUserResizeColumns;
|
||||
set
|
||||
{
|
||||
CanUserFilterInternal = value;
|
||||
if (HasHeaderCell)
|
||||
{
|
||||
HeaderCell.CanUserFilter = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value that indicates whether the user can sort the column by clicking the column header.
|
||||
/// </summary>
|
||||
|
||||
@@ -94,6 +94,12 @@ internal class DataGridColumnHeader : ContentControl
|
||||
o => o.CanUserSort,
|
||||
(o, v) => o.CanUserSort = v);
|
||||
|
||||
internal static readonly DirectProperty<DataGridColumnHeader, bool> CanUserFilterProperty =
|
||||
AvaloniaProperty.RegisterDirect<DataGridColumnHeader, bool>(
|
||||
nameof(CanUserFilter),
|
||||
o => o.CanUserFilter,
|
||||
(o, v) => o.CanUserFilter = v);
|
||||
|
||||
internal static readonly DirectProperty<DataGridColumnHeader, ListSortDirection?> CurrentSortingStateProperty =
|
||||
AvaloniaProperty.RegisterDirect<DataGridColumnHeader, ListSortDirection?>(
|
||||
nameof(CurrentSortingState),
|
||||
@@ -162,6 +168,13 @@ internal class DataGridColumnHeader : ContentControl
|
||||
set => SetValue(SupportedDirectionsProperty, value);
|
||||
}
|
||||
|
||||
private bool _canUserFilter = false;
|
||||
internal bool CanUserFilter
|
||||
{
|
||||
get => _canUserFilter;
|
||||
set => SetAndRaise(CanUserFilterProperty, ref _canUserFilter, value);
|
||||
}
|
||||
|
||||
internal DataGridColumn? OwningColumn { get; set; }
|
||||
|
||||
internal DataGrid? OwningGrid => OwningColumn?.OwningGrid;
|
||||
|
||||
+1
-20
@@ -1,4 +1,3 @@
|
||||
using AtomUI.IconPkg;
|
||||
using AtomUI.IconPkg.AntDesign;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.Primitives;
|
||||
@@ -6,31 +5,13 @@ using Avalonia.Data;
|
||||
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
internal class DataGridFilterIndicator : TemplatedControl
|
||||
internal class DataGridFilterIndicator : IconButton
|
||||
{
|
||||
#region 公共属性定义
|
||||
|
||||
public static readonly StyledProperty<Icon?> IconProperty
|
||||
= AvaloniaProperty.Register<DataGridFilterIndicator, Icon?>(nameof(Icon));
|
||||
|
||||
public static readonly StyledProperty<bool> IsMotionEnabledProperty
|
||||
= MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<DataGridFilterIndicator>();
|
||||
|
||||
public static readonly StyledProperty<bool> IsFilterActivatedProperty
|
||||
= AvaloniaProperty.Register<DataGridFilterIndicator, bool>(nameof(IsFilterActivated));
|
||||
|
||||
public Icon? Icon
|
||||
{
|
||||
get => GetValue(IconProperty);
|
||||
set => SetValue(IconProperty, value);
|
||||
}
|
||||
|
||||
public bool IsMotionEnabled
|
||||
{
|
||||
get => GetValue(IsMotionEnabledProperty);
|
||||
set => SetValue(IsMotionEnabledProperty, value);
|
||||
}
|
||||
|
||||
public bool IsFilterActivated
|
||||
{
|
||||
get => GetValue(IsFilterActivatedProperty);
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
public class DataGridMenuFilterFlyout
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
public class DataGridTreeFilterFlyout
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
public class DataGridTreeFlyoutPresenter : TreeView
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1528,6 +1528,7 @@ public partial class DataGrid
|
||||
dataGridColumn.HeaderCell.IsVisible = dataGridColumn.IsVisible;
|
||||
Debug.Assert(!_columnHeadersPresenter.Children.Contains(dataGridColumn.HeaderCell));
|
||||
dataGridColumn.HeaderCell.CanUserSort = dataGridColumn.CanUserSort;
|
||||
dataGridColumn.HeaderCell.CanUserFilter = dataGridColumn.CanUserFilter;
|
||||
_columnHeadersPresenter.Children.Insert(dataGridColumn.DisplayIndexWithFiller, dataGridColumn.HeaderCell);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public partial class DataGrid
|
||||
internal const bool DefaultCanUserReorderColumns = true;
|
||||
internal const bool DefaultCanUserResizeColumns = true;
|
||||
internal const bool DefaultCanUserSortColumns = false;
|
||||
internal const bool DefaultCanUserFilterColumns = false;
|
||||
|
||||
#region 内部属性定义
|
||||
|
||||
@@ -1338,7 +1339,8 @@ public partial class DataGrid
|
||||
column.HeaderCell.IsMiddleVisible = true;
|
||||
}
|
||||
|
||||
column.HeaderCell.CanUserSort = column.CanUserSort;
|
||||
column.HeaderCell.CanUserSort = column.CanUserSort;
|
||||
column.HeaderCell.CanUserFilter = column.CanUserFilter;
|
||||
}
|
||||
PseudoClasses.Set(DataGridPseudoClass.EmptyColumns, !visibleColumns.Any());
|
||||
PseudoClasses.Set(DataGridPseudoClass.EmptyRows, !DataConnection.Any());
|
||||
|
||||
@@ -65,6 +65,12 @@ public partial class DataGrid : TemplatedControl,
|
||||
public static readonly StyledProperty<bool> CanUserSortColumnsProperty =
|
||||
AvaloniaProperty.Register<DataGrid, bool>(nameof(CanUserSortColumns), false);
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the CanUserFilterColumns dependency property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<bool> CanUserFilterColumnsProperty =
|
||||
AvaloniaProperty.Register<DataGrid, bool>(nameof(CanUserFilterColumns), false);
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the ColumnHeaderHeight dependency property.
|
||||
/// </summary>
|
||||
@@ -229,6 +235,15 @@ public partial class DataGrid : TemplatedControl,
|
||||
get => GetValue(CanUserSortColumnsProperty);
|
||||
set => SetValue(CanUserSortColumnsProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value that indicates whether the user can filter columns by clicking the column filter indicator.
|
||||
/// </summary>
|
||||
public bool CanUserFilterColumns
|
||||
{
|
||||
get => GetValue(CanUserFilterColumnsProperty);
|
||||
set => SetValue(CanUserFilterColumnsProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height of the column headers row.
|
||||
|
||||
@@ -1,48 +1,37 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:atom="https://atomui.net">
|
||||
xmlns:atom="https://atomui.net"
|
||||
xmlns:themes="using:AtomUI.Controls.Themes">
|
||||
<ControlTheme x:Key="{x:Type atom:DataGridFilterIndicator}" TargetType="atom:DataGridFilterIndicator">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Border Name="{x:Static atom:DataGridFilterIndicatorThemeConstants.FramePart}">
|
||||
<atom:IconButton Name="{x:Static atom:DataGridFilterIndicatorThemeConstants.IconPresenterPart}"
|
||||
IsEnableHoverEffect="True"
|
||||
Icon="{TemplateBinding Icon}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<ControlTheme.BasedOn>
|
||||
<themes:IconButtonTheme TargetType="atom:DataGridFilterIndicator" />
|
||||
</ControlTheme.BasedOn>
|
||||
|
||||
<Style Selector="^ /template/ atom|IconButton#PART_IconPresenter">
|
||||
<Setter Property="IconWidth" Value="{DynamicResource {x:Static atom:SharedTokenKey.IconSizeSM}}" />
|
||||
<Setter Property="IconHeight" Value="{DynamicResource {x:Static atom:SharedTokenKey.IconSizeSM}}" />
|
||||
<Setter Property="Padding"
|
||||
Value="{DynamicResource {x:Static atom:DataGridTokenKey.FilterIndicatorPadding}}" />
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource {x:Static atom:SharedTokenKey.BorderRadius}}" />
|
||||
<Setter Property="DisabledIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorTextDisabled}}" />
|
||||
</Style>
|
||||
<Setter Property="IconWidth" Value="{DynamicResource {x:Static atom:SharedTokenKey.IconSizeSM}}" />
|
||||
<Setter Property="IconHeight" Value="{DynamicResource {x:Static atom:SharedTokenKey.IconSizeSM}}" />
|
||||
<Setter Property="Padding"
|
||||
Value="{DynamicResource {x:Static atom:DataGridTokenKey.FilterIndicatorPadding}}" />
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource {x:Static atom:SharedTokenKey.BorderRadius}}" />
|
||||
<Setter Property="DisabledIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorTextDisabled}}" />
|
||||
|
||||
<Style Selector="^[IsFilterActivated=True]">
|
||||
<Style Selector="^ /template/ atom|IconButton#PART_IconPresenter">
|
||||
<Setter Property="NormalIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorPrimary}}" />
|
||||
<Setter Property="ActiveIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorPrimary}}" />
|
||||
<Setter Property="SelectedIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorPrimary}}" />
|
||||
</Style>
|
||||
<Setter Property="NormalIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorPrimary}}" />
|
||||
<Setter Property="ActiveIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorPrimary}}" />
|
||||
<Setter Property="SelectedIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorPrimary}}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^[IsFilterActivated=False]">
|
||||
<Style Selector="^ /template/ atom|IconButton#PART_IconPresenter">
|
||||
<Setter Property="NormalIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:DataGridTokenKey.HeaderIconColor}}" />
|
||||
<Setter Property="ActiveIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:DataGridTokenKey.HeaderIconHoverColor}}" />
|
||||
<Setter Property="SelectedIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:DataGridTokenKey.HeaderIconHoverColor}}" />
|
||||
</Style>
|
||||
<Setter Property="NormalIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:DataGridTokenKey.HeaderIconColor}}" />
|
||||
<Setter Property="ActiveIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:DataGridTokenKey.HeaderIconHoverColor}}" />
|
||||
<Setter Property="SelectedIconBrush"
|
||||
Value="{DynamicResource {x:Static atom:DataGridTokenKey.HeaderIconHoverColor}}" />
|
||||
</Style>
|
||||
|
||||
</ControlTheme>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:atom="https://atomui.net">
|
||||
<ControlTheme x:Key="{x:Type atom:DataGridTreeFlyoutPresenter}" TargetType="atom:DataGridTreeFlyoutPresenter">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System.Globalization;
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace AtomUI.Controls.Converters;
|
||||
|
||||
internal class DataGridFilterIndicatorVisibleConvert : IMultiValueConverter
|
||||
{
|
||||
public static readonly DataGridFilterIndicatorVisibleConvert Default = new();
|
||||
|
||||
public object Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
return values.All(v => v is bool && (bool)v);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:atom="https://atomui.net"
|
||||
xmlns:themes="using:AtomUI.Controls.Themes">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="Button/ButtonTheme.axaml"/>
|
||||
<ResourceInclude Source="DropdownButton/DropdownButtonThemes.axaml"/>
|
||||
<ResourceInclude Source="IconButtonTheme.axaml"/>
|
||||
<ResourceInclude Source="SplitButtonTheme.axaml"/>
|
||||
<ResourceInclude Source="ToggleIconButtonTheme.axaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<themes:IconButtonTheme x:Key="{x:Type atom:IconButton}" TargetType="atom:IconButton"/>
|
||||
</ResourceDictionary>
|
||||
@@ -1,36 +1,37 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:atom="https://atomui.net">
|
||||
<ControlTheme x:Key="{x:Type atom:IconButton}" TargetType="atom:IconButton">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Border
|
||||
Name="{x:Static atom:IconButtonThemeConstants.FramePart}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<atom:IconPresenter
|
||||
Name="{x:Static atom:IconButtonThemeConstants.IconContentPart}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Icon="{TemplateBinding Icon}"
|
||||
LoadingAnimation="{TemplateBinding LoadingAnimation}"
|
||||
LoadingAnimationDuration="{TemplateBinding LoadingAnimationDuration}"
|
||||
IconWidth="{TemplateBinding IconWidth}"
|
||||
IconHeight="{TemplateBinding IconHeight}"
|
||||
IconMode="{TemplateBinding atom:IconButton.IconMode}"
|
||||
NormalFilledBrush="{TemplateBinding NormalIconBrush}"
|
||||
ActiveFilledBrush="{TemplateBinding ActiveIconBrush}"
|
||||
SelectedFilledBrush="{TemplateBinding SelectedIconBrush}"
|
||||
DisabledFilledBrush="{TemplateBinding DisabledIconBrush}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<ControlTheme xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:atom="https://atomui.net"
|
||||
x:Class="AtomUI.Controls.Themes.IconButtonTheme"
|
||||
TargetType="atom:IconButton">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="atom:IconButton">
|
||||
<Border
|
||||
Name="{x:Static atom:IconButtonThemeConstants.FramePart}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<atom:IconPresenter
|
||||
Name="{x:Static atom:IconButtonThemeConstants.IconContentPart}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Icon="{TemplateBinding Icon}"
|
||||
LoadingAnimation="{TemplateBinding LoadingAnimation}"
|
||||
LoadingAnimationDuration="{TemplateBinding LoadingAnimationDuration}"
|
||||
IconWidth="{TemplateBinding IconWidth}"
|
||||
IconHeight="{TemplateBinding IconHeight}"
|
||||
IconMode="{TemplateBinding atom:IconButton.IconMode}"
|
||||
NormalFilledBrush="{TemplateBinding NormalIconBrush}"
|
||||
ActiveFilledBrush="{TemplateBinding ActiveIconBrush}"
|
||||
SelectedFilledBrush="{TemplateBinding SelectedIconBrush}"
|
||||
DisabledFilledBrush="{TemplateBinding DisabledIconBrush}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:is(atom|IconButton)">
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
|
||||
<Style Selector="^ /template/ Border#PART_Frame">
|
||||
@@ -74,6 +75,6 @@
|
||||
<Setter Property="IconMode" Value="Disabled" />
|
||||
</Style>
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
</ControlTheme>
|
||||
@@ -0,0 +1,7 @@
|
||||
using Avalonia.Styling;
|
||||
|
||||
namespace AtomUI.Controls.Themes;
|
||||
|
||||
public class IconButtonTheme : ControlTheme
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user