mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-17 05:31:01 +08:00
Refactor DataGridOperationButtons
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
<ResourceInclude Source="Themes/DataGridRowExpander.axaml" />
|
||||
<ResourceInclude Source="Themes/DataGridTheme.axaml" />
|
||||
<ResourceInclude Source="Themes/DataGridTopLeftColumnHeaderTheme.axaml" />
|
||||
<ResourceInclude Source="Themes/DataGridOperationButtons.axaml" />
|
||||
<ResourceInclude Source="Themes/Filters/DataGridFilterMenuItemTheme.axaml" />
|
||||
<ResourceInclude Source="Themes/Filters/DataGridFilterTreeItemTheme.axaml" />
|
||||
<ResourceInclude Source="Themes/Filters/DataGridMenuFilterFlyoutPresenterTheme.axaml" />
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using AtomUI.Controls.Data;
|
||||
using AtomUI.Controls.DataGridLang;
|
||||
using AtomUI.Controls.DataGridLocalization;
|
||||
using AtomUI.Controls.Utils;
|
||||
using AtomUI.Theme.Data;
|
||||
using Avalonia;
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
using System.Diagnostics;
|
||||
using AtomUI.Controls.Data;
|
||||
using AtomUI.Data;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace AtomUI.Controls;
|
||||
|
||||
internal class DataGridOperationButtons : TemplatedControl
|
||||
{
|
||||
#region 公共接口
|
||||
|
||||
public static readonly StyledProperty<bool> IsMotionEnabledProperty =
|
||||
MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<DataGridOperationButtons>();
|
||||
|
||||
public static readonly StyledProperty<bool> IsEditEnabledProperty =
|
||||
AvaloniaProperty.Register<DataGridOperationButtons, bool>(nameof(IsEditEnabled));
|
||||
|
||||
public static readonly StyledProperty<bool> IsDeleteEnabledProperty =
|
||||
AvaloniaProperty.Register<DataGridOperationButtons, bool>(nameof(IsDeleteEnabled));
|
||||
|
||||
public bool IsMotionEnabled
|
||||
{
|
||||
get => GetValue(IsMotionEnabledProperty);
|
||||
@@ -23,4 +34,116 @@ internal class DataGridOperationButtons : TemplatedControl
|
||||
set => SetValue(IsEditEnabledProperty, value);
|
||||
}
|
||||
|
||||
public bool IsDeleteEnabled
|
||||
{
|
||||
get => GetValue(IsDeleteEnabledProperty);
|
||||
set => SetValue(IsDeleteEnabledProperty, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal static readonly DirectProperty<DataGridOperationButtons, bool> IsEditingProperty =
|
||||
AvaloniaProperty.RegisterDirect<DataGridOperationButtons, bool>(
|
||||
nameof(IsEditing),
|
||||
o => o.IsEditing,
|
||||
(o, v) => o.IsEditing = v);
|
||||
|
||||
internal bool IsEditing
|
||||
{
|
||||
get => _isEditing;
|
||||
set => SetAndRaise(IsEditingProperty, ref _isEditing, value);
|
||||
}
|
||||
|
||||
private bool _isEditing;
|
||||
|
||||
private HyperLinkTextBlock? _editAction;
|
||||
private PopupConfirm? _deleteAction;
|
||||
private HyperLinkTextBlock? _saveAction;
|
||||
private PopupConfirm? _cancelAction;
|
||||
private IDisposable? _disposable;
|
||||
|
||||
internal DataGrid? OwningGrid { get; set; }
|
||||
internal DataGridRow? OwningRow { get; set; }
|
||||
|
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
{
|
||||
base.OnApplyTemplate(e);
|
||||
_editAction = e.NameScope.Find<HyperLinkTextBlock>(DataGridOperationButtonsThemeConstants.EditActionPart);
|
||||
_deleteAction = e.NameScope.Find<PopupConfirm>(DataGridOperationButtonsThemeConstants.DeleteActionPart);
|
||||
_saveAction = e.NameScope.Find<HyperLinkTextBlock>(DataGridOperationButtonsThemeConstants.SaveActionPart);
|
||||
_cancelAction = e.NameScope.Find<PopupConfirm>(DataGridOperationButtonsThemeConstants.CancelActionPart);
|
||||
|
||||
if (_editAction != null)
|
||||
{
|
||||
_editAction.Click += HandleEditingRow;
|
||||
}
|
||||
|
||||
if (_deleteAction != null)
|
||||
{
|
||||
_deleteAction.Confirmed += HandleDeleteRow;
|
||||
}
|
||||
|
||||
if (_cancelAction != null)
|
||||
{
|
||||
_cancelAction.Confirmed += HandleCancelEditingRow;
|
||||
}
|
||||
|
||||
if (_saveAction != null)
|
||||
{
|
||||
_saveAction.Click += HandleSaveRow;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleDeleteRow(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (OwningGrid != null)
|
||||
{
|
||||
var dataCollectionView = OwningGrid.DataConnection.CollectionView;
|
||||
Debug.Assert(dataCollectionView != null);
|
||||
var index = OwningRow?.Index;
|
||||
if (index.HasValue)
|
||||
{
|
||||
dataCollectionView.RemoveAt(index.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleEditingRow(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (OwningRow != null && OwningGrid != null)
|
||||
{
|
||||
SetValue(IsEditingProperty, true, BindingPriority.Template);
|
||||
OwningGrid?.BeginRowEdit(OwningRow);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleSaveRow(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (OwningRow != null && OwningGrid != null)
|
||||
{
|
||||
SetValue(IsEditingProperty, false, BindingPriority.Template);
|
||||
OwningGrid?.EndRowEdit(DataGridEditAction.Commit, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void HandleCancelEditingRow(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (OwningRow != null && OwningGrid != null)
|
||||
{
|
||||
SetValue(IsEditingProperty, false, BindingPriority.Template);
|
||||
OwningGrid?.EndRowEdit(DataGridEditAction.Cancel, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
internal void NotifyLoadingRow(DataGridRow row)
|
||||
{
|
||||
OwningRow = row;
|
||||
_disposable = BindUtils.RelayBind(row, DataGridRow.IsEditingModeProperty, this, IsEditingProperty);
|
||||
}
|
||||
|
||||
internal void NotifyUnLoadingRow(DataGridRow row)
|
||||
{
|
||||
_disposable?.Dispose();
|
||||
OwningRow = null;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ public class DataGridOperationColumn : DataGridColumn
|
||||
{
|
||||
Debug.Assert(OwningGrid != null);
|
||||
var operationButtons = new DataGridOperationButtons();
|
||||
operationButtons.OwningGrid = OwningGrid;
|
||||
operationButtons[!DataGridOperationButtons.IsMotionEnabledProperty] = OwningGrid[!DataGrid.IsMotionEnabledProperty];
|
||||
return operationButtons;
|
||||
}
|
||||
@@ -72,9 +73,9 @@ public class DataGridOperationColumn : DataGridColumn
|
||||
{
|
||||
if (OwningGrid != null)
|
||||
{
|
||||
if (GetCellContent(e.Row) is DataGridRowExpander expander)
|
||||
if (GetCellContent(e.Row) is DataGridOperationButtons operationButtons)
|
||||
{
|
||||
expander.NotifyLoadingRow(e.Row);
|
||||
operationButtons.NotifyLoadingRow(e.Row);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,9 +84,9 @@ public class DataGridOperationColumn : DataGridColumn
|
||||
{
|
||||
if (OwningGrid != null)
|
||||
{
|
||||
if (GetCellContent(e.Row) is DataGridRowExpander expander)
|
||||
if (GetCellContent(e.Row) is DataGridOperationButtons operationButtons)
|
||||
{
|
||||
expander.NotifyUnLoadingRow(e.Row);
|
||||
operationButtons.NotifyUnLoadingRow(e.Row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using AtomUI.Controls.Data;
|
||||
using AtomUI.Controls.DataGridLang;
|
||||
using AtomUI.Controls.DataGridLocalization;
|
||||
using AtomUI.Data;
|
||||
using AtomUI.IconPkg.AntDesign;
|
||||
using AtomUI.Theme.Data;
|
||||
|
||||
@@ -1310,7 +1310,7 @@ public partial class DataGrid
|
||||
if (newItemsSource is IDataGridCollectionView)
|
||||
{
|
||||
setDefaultSelection = true;
|
||||
newCollectionView = (IDataGridCollectionView)newItemsSource;
|
||||
newCollectionView = (IDataGridCollectionView)newItemsSource;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1412,8 +1412,8 @@ public partial class DataGrid
|
||||
}
|
||||
else
|
||||
{
|
||||
column.HeaderCell.IsFirstVisible = false;
|
||||
column.HeaderCell.IsLastVisible = false;
|
||||
column.HeaderCell.IsFirstVisible = false;
|
||||
column.HeaderCell.IsLastVisible = false;
|
||||
column.HeaderCell.IsMiddleVisible = true;
|
||||
}
|
||||
|
||||
@@ -1494,9 +1494,9 @@ public partial class DataGrid
|
||||
dataGridCell: newCell);
|
||||
if (row.OwningGrid != null)
|
||||
{
|
||||
newCell.OwningColumn = column;
|
||||
newCell.IsVisible = column.IsVisible;
|
||||
newCell[!SizeTypeProperty] = this[!SizeTypeProperty];
|
||||
newCell.OwningColumn = column;
|
||||
newCell.IsVisible = column.IsVisible;
|
||||
newCell[!SizeTypeProperty] = this[!SizeTypeProperty];
|
||||
}
|
||||
|
||||
row.Cells.Insert(column.Index, newCell);
|
||||
@@ -1577,7 +1577,7 @@ public partial class DataGrid
|
||||
}
|
||||
|
||||
//TODO Validation
|
||||
private bool BeginRowEdit(DataGridRow dataGridRow)
|
||||
internal bool BeginRowEdit(DataGridRow dataGridRow)
|
||||
{
|
||||
Debug.Assert(EditingRow == null);
|
||||
Debug.Assert(dataGridRow != null);
|
||||
@@ -2505,7 +2505,7 @@ public partial class DataGrid
|
||||
}
|
||||
|
||||
//TODO Validation
|
||||
private bool EndRowEdit(DataGridEditAction editAction, bool exitEditingMode, bool raiseEvents)
|
||||
internal bool EndRowEdit(DataGridEditAction editAction, bool exitEditingMode, bool raiseEvents)
|
||||
{
|
||||
if (EditingRow == null || DataConnection.CommittingEdit)
|
||||
{
|
||||
@@ -2867,7 +2867,6 @@ public partial class DataGrid
|
||||
Debug.Assert(dataGridCell != null);
|
||||
|
||||
Control? element = null;
|
||||
DataGridBoundColumn? dataGridBoundColumn = dataGridColumn as DataGridBoundColumn;
|
||||
Debug.Assert(dataGridRow.DataContext != null);
|
||||
if (isCellEdited)
|
||||
{
|
||||
@@ -2878,7 +2877,7 @@ public partial class DataGrid
|
||||
dataGridCell.Content = element;
|
||||
if (element.IsInitialized)
|
||||
{
|
||||
PreparingCellForEditPrivate(element as Control);
|
||||
PreparingCellForEditPrivate(element);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4589,7 +4588,7 @@ public partial class DataGrid
|
||||
else
|
||||
{
|
||||
if (Footer == null && (GridLinesVisibility == DataGridGridLinesVisibility.All ||
|
||||
GridLinesVisibility == DataGridGridLinesVisibility.Horizontal))
|
||||
GridLinesVisibility == DataGridGridLinesVisibility.Horizontal))
|
||||
{
|
||||
SetValue(FrameBorderThicknessProperty, new Thickness(BorderThickness.Left, BorderThickness.Top, BorderThickness.Right, 0));
|
||||
}
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ namespace AtomUI.Theme
|
||||
internal static IList<AbstractLanguageProvider> GetLanguageProviders()
|
||||
{
|
||||
List<AbstractLanguageProvider> languageProviders = new List<AbstractLanguageProvider>();
|
||||
languageProviders.Add(new AtomUI.Controls.DataGridLang.en_US());
|
||||
languageProviders.Add(new AtomUI.Controls.DataGridLang.zh_CN());
|
||||
languageProviders.Add(new AtomUI.Controls.DataGridLocalization.en_US());
|
||||
languageProviders.Add(new AtomUI.Controls.DataGridLocalization.zh_CN());
|
||||
return languageProviders;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,11 +1,13 @@
|
||||
using AtomUI.Theme;
|
||||
|
||||
namespace AtomUI.Controls.DataGridLang
|
||||
namespace AtomUI.Controls.DataGridLocalization
|
||||
{
|
||||
public static class DataGridLangResourceKey
|
||||
{
|
||||
public static readonly LanguageResourceKey AscendTooltip = new LanguageResourceKey("DataGrid.AscendTooltip", "AtomUI.Lang");
|
||||
public static readonly LanguageResourceKey CancelConfirmText = new LanguageResourceKey("DataGrid.CancelConfirmText", "AtomUI.Lang");
|
||||
public static readonly LanguageResourceKey CancelTooltip = new LanguageResourceKey("DataGrid.CancelTooltip", "AtomUI.Lang");
|
||||
public static readonly LanguageResourceKey DeleteConfirmText = new LanguageResourceKey("DataGrid.DeleteConfirmText", "AtomUI.Lang");
|
||||
public static readonly LanguageResourceKey DescendTooltip = new LanguageResourceKey("DataGrid.DescendTooltip", "AtomUI.Lang");
|
||||
public static readonly LanguageResourceKey SelectAllFilterItems = new LanguageResourceKey("DataGrid.SelectAllFilterItems", "AtomUI.Lang");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using AtomUI.Theme;
|
||||
using AtomUI.Utils;
|
||||
|
||||
namespace AtomUI.Controls.DataGridLang;
|
||||
namespace AtomUI.Controls.DataGridLocalization;
|
||||
|
||||
[LanguageProvider(LanguageCode.en_US, DataGridToken.ID)]
|
||||
internal class en_US : AbstractLanguageProvider
|
||||
@@ -10,4 +10,6 @@ internal class en_US : AbstractLanguageProvider
|
||||
public const string AscendTooltip = "Click to sort ascending";
|
||||
public const string DescendTooltip = "Click to sort descending";
|
||||
public const string CancelTooltip = "Click to cancel sorting";
|
||||
public const string DeleteConfirmText = "Sure to delete?";
|
||||
public const string CancelConfirmText = "Sure to cancel?";
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using AtomUI.Theme;
|
||||
using AtomUI.Utils;
|
||||
|
||||
namespace AtomUI.Controls.DataGridLang;
|
||||
namespace AtomUI.Controls.DataGridLocalization;
|
||||
|
||||
[LanguageProvider(LanguageCode.zh_CN, DataGridToken.ID)]
|
||||
internal class zh_CN : AbstractLanguageProvider
|
||||
@@ -10,4 +10,6 @@ internal class zh_CN : AbstractLanguageProvider
|
||||
public const string AscendTooltip = "点击升序";
|
||||
public const string DescendTooltip = "点击降序";
|
||||
public const string CancelTooltip = "取消排序";
|
||||
public const string DeleteConfirmText = "确认删除?";
|
||||
public const string CancelConfirmText = "确认取消?";
|
||||
}
|
||||
@@ -36,6 +36,11 @@ public partial class DataGridRow
|
||||
internal static readonly StyledProperty<bool> IsDraggingProperty
|
||||
= AvaloniaProperty.Register<DataGridRow, bool>(nameof(IsDragging));
|
||||
|
||||
internal static readonly DirectProperty<DataGridRow, bool> IsEditingModeProperty =
|
||||
AvaloniaProperty.RegisterDirect<DataGridRow, bool>(
|
||||
nameof(IsEditingMode),
|
||||
o => o.IsEditingMode);
|
||||
|
||||
internal bool IsMotionEnabled
|
||||
{
|
||||
get => GetValue(IsMotionEnabledProperty);
|
||||
@@ -54,6 +59,13 @@ public partial class DataGridRow
|
||||
set => SetValue(IsDraggingProperty, value);
|
||||
}
|
||||
|
||||
internal bool IsEditingMode
|
||||
{
|
||||
get => _isEditingMode;
|
||||
set => SetAndRaise(IsEditingModeProperty, ref _isEditingMode, value);
|
||||
}
|
||||
private bool _isEditingMode = false;
|
||||
|
||||
internal int Slot { get; set; }
|
||||
|
||||
internal DataGridCellCollection Cells { get; private set; }
|
||||
@@ -483,6 +495,7 @@ public partial class DataGridRow
|
||||
IsSelected = isSelected;
|
||||
PseudoClasses.Set(StdPseudoClass.Editing, IsEditing);
|
||||
PseudoClasses.Set(StdPseudoClass.Invalid, !IsValid);
|
||||
IsEditingMode = IsEditing;
|
||||
ApplyHeaderStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ public partial class DataGridRow : TemplatedControl
|
||||
}
|
||||
|
||||
private bool _isSelected;
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
|
||||
@@ -1,12 +1,51 @@
|
||||
<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:DataGridOperationButtons}" TargetType="atom:DataGridOperationButtons">
|
||||
xmlns:atom="https://atomui.net"
|
||||
xmlns:dataGridLocalization="clr-namespace:AtomUI.Controls.DataGridLocalization"
|
||||
xmlns:localization="clr-namespace:AtomUI.Controls.Localization;assembly=AtomUI.Controls">
|
||||
<ControlTheme x:Key="{x:Type atom:DataGridOperationButtons}"
|
||||
TargetType="atom:DataGridOperationButtons">
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
|
||||
<Panel>
|
||||
<StackPanel Name="NormalPanel"
|
||||
Orientation="Horizontal"
|
||||
IsVisible="{TemplateBinding IsEditing, Converter={x:Static BoolConverters.Not}}">
|
||||
<atom:HyperLinkTextBlock
|
||||
Text="{DynamicResource {x:Static localization:CommonLangResourceKey.Edit}}"
|
||||
Name="{x:Static atom:DataGridOperationButtonsThemeConstants.EditActionPart}" />
|
||||
<atom:PopupConfirm
|
||||
Name="{x:Static atom:DataGridOperationButtonsThemeConstants.DeleteActionPart}"
|
||||
Title="{DynamicResource {x:Static dataGridLocalization:DataGridLangResourceKey.DeleteConfirmText}}">
|
||||
<atom:HyperLinkTextBlock
|
||||
Text="{DynamicResource {x:Static localization:CommonLangResourceKey.Delete}}"
|
||||
IsEnabled="{TemplateBinding IsEditing, Converter={x:Static BoolConverters.Not}}"/>
|
||||
</atom:PopupConfirm>
|
||||
</StackPanel>
|
||||
<StackPanel Name="EditingPanel"
|
||||
Orientation="Horizontal"
|
||||
IsVisible="{TemplateBinding IsEditing}">
|
||||
|
||||
<atom:HyperLinkTextBlock
|
||||
Text="{DynamicResource {x:Static localization:CommonLangResourceKey.Save}}"
|
||||
Name="{x:Static atom:DataGridOperationButtonsThemeConstants.SaveActionPart}" />
|
||||
|
||||
<atom:PopupConfirm
|
||||
Name="{x:Static atom:DataGridOperationButtonsThemeConstants.CancelActionPart}"
|
||||
Title="{DynamicResource {x:Static dataGridLocalization:DataGridLangResourceKey.CancelConfirmText}}">
|
||||
<atom:HyperLinkTextBlock
|
||||
Text="{DynamicResource {x:Static localization:CommonLangResourceKey.Cancel}}"
|
||||
IsEnabled="{TemplateBinding IsEditing}"/>
|
||||
</atom:PopupConfirm>
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^ /template/ StackPanel">
|
||||
<Setter Property="Spacing" Value="{DynamicResource {x:Static atom:SharedTokenKey.SpacingXS}}" />
|
||||
</Style>
|
||||
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -32,12 +32,6 @@ internal static class DataGridColumnHeaderThemeConstants
|
||||
public const string FocusVisualSecondaryPart = "PART_FocusVisualSecondary";
|
||||
}
|
||||
|
||||
internal static class DataGridFilterIndicatorThemeConstants
|
||||
{
|
||||
public const string FramePart = "PART_Frame";
|
||||
public const string IconPresenterPart = "PART_IconPresenter";
|
||||
}
|
||||
|
||||
internal static class DataGridHeaderViewItemThemeConstants
|
||||
{
|
||||
public const string ContentPresenterPart = "PART_ContentPresenter";
|
||||
@@ -106,10 +100,6 @@ internal static class DataGridThemeConstants
|
||||
public const string DraggingOverIndicatorPart = "PART_DraggingOverIndicator";
|
||||
}
|
||||
|
||||
internal static class DataGridTopLeftColumnHeaderThemeConstants
|
||||
{
|
||||
}
|
||||
|
||||
internal static class DataGridFilterFlyoutPresenterThemeConstants
|
||||
{
|
||||
public const string ButtonLayoutPart = "PART_ButtonLayout";
|
||||
@@ -128,4 +118,12 @@ internal static class DataGridRowExpanderThemeConstants
|
||||
internal static class DataGridRowReorderHandleConstants
|
||||
{
|
||||
public const string IndicatorIconButtonPart = "PART_IndicatorIconButton";
|
||||
}
|
||||
|
||||
internal static class DataGridOperationButtonsThemeConstants
|
||||
{
|
||||
public const string EditActionPart = "PART_EditAction";
|
||||
public const string DeleteActionPart = "PART_DeleteAction";
|
||||
public const string CancelActionPart = "PAR_CancelAction";
|
||||
public const string SaveActionPart = "PAR_SaveAction";
|
||||
}
|
||||
@@ -226,7 +226,7 @@
|
||||
<Style Selector="^:not(:disabled)">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorLink}}" />
|
||||
<Style Selector="^/template/ Border#PART_Frame">
|
||||
<Setter Property="Background" Value="{DynamicResource {x:Static atom:ButtonTokenKey.DefaultBg}}" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:pointerover">
|
||||
|
||||
@@ -202,7 +202,9 @@ internal class FlyoutStateHelper : AvaloniaObject
|
||||
{
|
||||
_subscriptions.Add(InputElement.IsPointerOverProperty.Changed.Subscribe(args =>
|
||||
{
|
||||
if (args.Sender == AnchorTarget)
|
||||
if (args.Sender == AnchorTarget &&
|
||||
AnchorTarget.IsEnabled &&
|
||||
AnchorTarget.IsVisible)
|
||||
{
|
||||
HandleAnchorTargetHover(args);
|
||||
}
|
||||
@@ -278,13 +280,17 @@ internal class FlyoutStateHelper : AvaloniaObject
|
||||
{
|
||||
if (args is RawPointerEventArgs pointerEventArgs)
|
||||
{
|
||||
if (AnchorTarget is not null && pointerEventArgs.Type == RawPointerEventType.LeftButtonDown)
|
||||
if (AnchorTarget is not null &&
|
||||
AnchorTarget.IsEnabled &&
|
||||
AnchorTarget.IsVisible &&
|
||||
pointerEventArgs.Type == RawPointerEventType.LeftButtonDown)
|
||||
{
|
||||
|
||||
if (Flyout is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!Flyout.IsOpen && TopLevel.GetTopLevel(AnchorTarget) == args.Root)
|
||||
{
|
||||
if (OpenFlyoutPredicate is not null)
|
||||
|
||||
+3
@@ -14,8 +14,11 @@ namespace AtomUI.Controls.Localization
|
||||
public static class CommonLangResourceKey
|
||||
{
|
||||
public static readonly LanguageResourceKey Cancel = new LanguageResourceKey("Common.Cancel", "AtomUI.Lang");
|
||||
public static readonly LanguageResourceKey Delete = new LanguageResourceKey("Common.Delete", "AtomUI.Lang");
|
||||
public static readonly LanguageResourceKey Edit = new LanguageResourceKey("Common.Edit", "AtomUI.Lang");
|
||||
public static readonly LanguageResourceKey Ok = new LanguageResourceKey("Common.Ok", "AtomUI.Lang");
|
||||
public static readonly LanguageResourceKey Reset = new LanguageResourceKey("Common.Reset", "AtomUI.Lang");
|
||||
public static readonly LanguageResourceKey Save = new LanguageResourceKey("Common.Save", "AtomUI.Lang");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,4 +11,7 @@ internal class en_US : AbstractLanguageProvider
|
||||
public const string Ok = "Ok";
|
||||
public const string Cancel = "Cancel";
|
||||
public const string Reset = "Reset";
|
||||
public const string Edit = "Edit";
|
||||
public const string Delete = "Delete";
|
||||
public const string Save = "Save";
|
||||
}
|
||||
@@ -11,4 +11,7 @@ internal class zh_CN : AbstractLanguageProvider
|
||||
public const string Ok = "确定";
|
||||
public const string Cancel = "取消";
|
||||
public const string Reset = "重置";
|
||||
public const string Edit = "编辑";
|
||||
public const string Delete = "删除";
|
||||
public const string Save = "保存";
|
||||
}
|
||||
@@ -11,6 +11,7 @@ using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Metadata;
|
||||
using Avalonia.Rendering;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
@@ -63,6 +64,7 @@ public class HyperLinkTextBlock : TemplatedControl, ICustomHitTest, IMotionAware
|
||||
/// <summary>
|
||||
/// Gets or sets the text.
|
||||
/// </summary>
|
||||
[Content]
|
||||
public string? Text
|
||||
{
|
||||
get => GetValue(TextProperty);
|
||||
|
||||
+8
@@ -219,6 +219,14 @@ namespace AtomUI.Theme.Styling
|
||||
public static readonly TokenResourceKey SizeXS = new TokenResourceKey("SizeXS");
|
||||
public static readonly TokenResourceKey SizeXXL = new TokenResourceKey("SizeXXL");
|
||||
public static readonly TokenResourceKey SizeXXS = new TokenResourceKey("SizeXXS");
|
||||
public static readonly TokenResourceKey Spacing = new TokenResourceKey("Spacing");
|
||||
public static readonly TokenResourceKey SpacingLG = new TokenResourceKey("SpacingLG");
|
||||
public static readonly TokenResourceKey SpacingMD = new TokenResourceKey("SpacingMD");
|
||||
public static readonly TokenResourceKey SpacingSM = new TokenResourceKey("SpacingSM");
|
||||
public static readonly TokenResourceKey SpacingXL = new TokenResourceKey("SpacingXL");
|
||||
public static readonly TokenResourceKey SpacingXS = new TokenResourceKey("SpacingXS");
|
||||
public static readonly TokenResourceKey SpacingXXL = new TokenResourceKey("SpacingXXL");
|
||||
public static readonly TokenResourceKey SpacingXXS = new TokenResourceKey("SpacingXXS");
|
||||
public static readonly TokenResourceKey UniformlyMargin = new TokenResourceKey("UniformlyMargin");
|
||||
public static readonly TokenResourceKey UniformlyMarginLG = new TokenResourceKey("UniformlyMarginLG");
|
||||
public static readonly TokenResourceKey UniformlyMarginMD = new TokenResourceKey("UniformlyMarginMD");
|
||||
|
||||
@@ -441,6 +441,46 @@ public partial class DesignToken
|
||||
/// 控制元素外边距,最大尺寸。
|
||||
/// </summary>
|
||||
public Thickness MarginXXL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 布局元素之间间隔,最小尺寸。
|
||||
/// </summary>
|
||||
public double SpacingXXS { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 布局元素之间间隔,小尺寸。
|
||||
/// </summary>
|
||||
public double SpacingXS { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 布局元素之间间隔,中小尺寸。
|
||||
/// </summary>
|
||||
public double SpacingSM { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 布局元素之间间隔,中等尺寸。
|
||||
/// </summary>
|
||||
public double Spacing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 布局元素之间间隔,中大尺寸。
|
||||
/// </summary>
|
||||
public double SpacingMD { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 布局元素之间间隔,大尺寸。
|
||||
/// </summary>
|
||||
public double SpacingLG { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 布局元素之间间隔,超大尺寸。
|
||||
/// </summary>
|
||||
public double SpacingXL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 布局元素之间间隔,最大尺寸。
|
||||
/// </summary>
|
||||
public double SpacingXXL { get; set; }
|
||||
|
||||
// =============== Legacy: should be remove ===============
|
||||
/// <summary>
|
||||
|
||||
@@ -165,15 +165,24 @@ public partial class DesignToken : AbstractDesignToken
|
||||
UniformlyMarginLG = SizeLG;
|
||||
UniformlyMarginXL = SizeXL;
|
||||
UniformlyMarginXXL = SizeXXL;
|
||||
|
||||
SpacingXXS = SizeXXS;
|
||||
SpacingXS = SizeXS;
|
||||
SpacingSM = SizeSM;
|
||||
Spacing = Size;
|
||||
SpacingMD = SizeMD;
|
||||
SpacingLG = SizeLG;
|
||||
SpacingXL = SizeXL;
|
||||
SpacingXXL = SizeXXL;
|
||||
|
||||
MarginXXS = new Thickness(SizeXXS);
|
||||
MarginXS = new Thickness(SizeXS);
|
||||
MarginSM = new Thickness(SizeSM);
|
||||
Margin = new Thickness(Size);
|
||||
MarginMD = new Thickness(SizeMD);
|
||||
MarginLG = new Thickness(SizeLG);
|
||||
MarginXL = new Thickness(SizeXL);
|
||||
MarginXXL = new Thickness(SizeXXL);
|
||||
MarginXXS = new Thickness(SizeXXS);
|
||||
MarginXS = new Thickness(SizeXS);
|
||||
MarginSM = new Thickness(SizeSM);
|
||||
Margin = new Thickness(Size);
|
||||
MarginMD = new Thickness(SizeMD);
|
||||
MarginLG = new Thickness(SizeLG);
|
||||
MarginXL = new Thickness(SizeXL);
|
||||
MarginXXL = new Thickness(SizeXXL);
|
||||
|
||||
ScreenXS = screenXS;
|
||||
ScreenXSMin = screenXS;
|
||||
|
||||
Reference in New Issue
Block a user