feat: improve icon and theme.
This commit is contained in:
@@ -10,31 +10,43 @@
|
|||||||
x:Class="Ursa.Demo.Pages.PopConfirmDemo">
|
x:Class="Ursa.Demo.Pages.PopConfirmDemo">
|
||||||
<StackPanel HorizontalAlignment="Left">
|
<StackPanel HorizontalAlignment="Left">
|
||||||
<TextBlock Text="Default PopConfirm" Margin="0 16" />
|
<TextBlock Text="Default PopConfirm" Margin="0 16" />
|
||||||
<u:PopConfirm PopupHeader="Header" PopupContent="Content"
|
<u:PopConfirm PopupHeader="确定是否要保存此修改?" PopupContent="此修改将不可逆"
|
||||||
ConfirmCommand="{Binding ConfirmCommand}"
|
ConfirmCommand="{Binding ConfirmCommand}"
|
||||||
CancelCommand="{Binding Path=CancelCommand}" >
|
CancelCommand="{Binding Path=CancelCommand}" >
|
||||||
<Button Content="Hello World"></Button>
|
<Button Content="Hello World"></Button>
|
||||||
</u:PopConfirm>
|
</u:PopConfirm>
|
||||||
<TextBlock Text="Hover to trigger" Margin="0 16" />
|
<TextBlock Text="Hover to trigger" Margin="0 16" />
|
||||||
<u:PopConfirm PopupHeader="Header" PopupContent="Content"
|
<u:PopConfirm PopupHeader="确定是否要保存此修改?" PopupContent="此修改将不可逆"
|
||||||
TriggerMode="Focus"
|
TriggerMode="Focus"
|
||||||
|
u:ControlClassesInput.Source="{Binding #classInput}"
|
||||||
ConfirmCommand="{Binding ConfirmCommand}"
|
ConfirmCommand="{Binding ConfirmCommand}"
|
||||||
CancelCommand="{Binding Path=CancelCommand}" >
|
CancelCommand="{Binding Path=CancelCommand}" >
|
||||||
<Button Content="Hello World"></Button>
|
<Button Content="Hello World"></Button>
|
||||||
</u:PopConfirm>
|
</u:PopConfirm>
|
||||||
<TextBlock Text="Non-button control as main element" Margin="0 16" />
|
<TextBlock Text="Non-button control as main element" Margin="0 16" />
|
||||||
<u:PopConfirm PopupHeader="Header" PopupContent="Content"
|
<u:PopConfirm PopupHeader="确定是否要保存此修改?" PopupContent="此修改将不可逆"
|
||||||
TriggerMode="Click"
|
TriggerMode="Click"
|
||||||
|
u:ControlClassesInput.Source="{Binding #classInput}"
|
||||||
Placement="BottomEdgeAlignedLeft"
|
Placement="BottomEdgeAlignedLeft"
|
||||||
ConfirmCommand="{Binding ConfirmCommand}"
|
ConfirmCommand="{Binding ConfirmCommand}"
|
||||||
CancelCommand="{Binding Path=CancelCommand}" >
|
CancelCommand="{Binding Path=CancelCommand}" >
|
||||||
<TextBlock Text="Hello World" />
|
<TextBlock Text="Hello World" />
|
||||||
</u:PopConfirm>
|
</u:PopConfirm>
|
||||||
<TextBlock Text="Asynchronized command support" Margin="0 16" />
|
<TextBlock Text="Asynchronized command support" Margin="0 16" />
|
||||||
<u:PopConfirm PopupHeader="Header" PopupContent="Content"
|
<u:PopConfirm PopupHeader="确定是否要保存此修改?"
|
||||||
|
PopupContent="此修改将不可逆"
|
||||||
|
u:ControlClassesInput.Source="{Binding #classInput}"
|
||||||
ConfirmCommand="{Binding AsyncConfirmCommand}"
|
ConfirmCommand="{Binding AsyncConfirmCommand}"
|
||||||
CancelCommand="{Binding Path=AsyncCancelCommand}" >
|
CancelCommand="{Binding Path=AsyncCancelCommand}" >
|
||||||
<Button Content="Hello World"></Button>
|
<Button Content="Hello World"></Button>
|
||||||
</u:PopConfirm>
|
</u:PopConfirm>
|
||||||
|
|
||||||
|
<u:ControlClassesInput Name="classInput" Width="320" >
|
||||||
|
<u:ControlClassesInput.Styles>
|
||||||
|
<Style Selector="TextBox">
|
||||||
|
<Setter Property="Watermark" Value="Change Classes"></Setter>
|
||||||
|
</Style>
|
||||||
|
</u:ControlClassesInput.Styles>
|
||||||
|
</u:ControlClassesInput>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
<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:u="https://irihi.tech/ursa">
|
xmlns:u="https://irihi.tech/ursa"
|
||||||
|
xmlns:helpers="clr-namespace:Irihi.Avalonia.Shared.Helpers;assembly=Irihi.Avalonia.Shared">
|
||||||
<!-- Add Resources Here -->
|
<!-- Add Resources Here -->
|
||||||
<ControlTheme x:Key="{x:Type u:PopConfirm}" TargetType="u:PopConfirm">
|
<ControlTheme x:Key="{x:Type u:PopConfirm}"
|
||||||
|
TargetType="u:PopConfirm">
|
||||||
|
<Setter Property="Placement" Value="TopEdgeAlignedLeft" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate TargetType="u:PopConfirm">
|
<ControlTemplate TargetType="u:PopConfirm">
|
||||||
<Panel>
|
<Panel>
|
||||||
@@ -16,15 +19,49 @@
|
|||||||
OverlayInputPassThroughElement="{Binding #PART_ContentPresenter}"
|
OverlayInputPassThroughElement="{Binding #PART_ContentPresenter}"
|
||||||
Name="{x:Static u:PopConfirm.PART_Popup}"
|
Name="{x:Static u:PopConfirm.PART_Popup}"
|
||||||
Placement="{TemplateBinding Placement}">
|
Placement="{TemplateBinding Placement}">
|
||||||
<Border Theme="{DynamicResource CardBorder}">
|
<Border
|
||||||
<StackPanel>
|
Theme="{DynamicResource CardBorder}"
|
||||||
|
MinHeight="160"
|
||||||
|
MinWidth="280">
|
||||||
|
<Grid
|
||||||
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
RowDefinitions="*, Auto"
|
||||||
|
ColumnDefinitions="Auto, *">
|
||||||
|
<!-- Icon Area -->
|
||||||
|
<Panel
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="{DynamicResource BannerIconMargin}"
|
||||||
|
VerticalAlignment="Top">
|
||||||
|
<ContentPresenter
|
||||||
|
Content="{TemplateBinding Icon}" />
|
||||||
|
<PathIcon
|
||||||
|
Name="PART_BuildInIcon"
|
||||||
|
Theme="{DynamicResource InnerPathIcon}"
|
||||||
|
Data="{DynamicResource BannerWarningIconGeometry}"
|
||||||
|
Foreground="{DynamicResource BannerWarningBorderBrush}"
|
||||||
|
Classes="Large"
|
||||||
|
IsVisible="{TemplateBinding Icon, Converter={x:Static ObjectConverters.IsNull}}" />
|
||||||
|
</Panel>
|
||||||
|
<StackPanel Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Spacing="2">
|
||||||
<ContentPresenter
|
<ContentPresenter
|
||||||
Content="{TemplateBinding PopupHeader}"
|
Content="{TemplateBinding PopupHeader}"
|
||||||
ContentTemplate="{TemplateBinding PopupHeaderTemplate}"/>
|
ContentTemplate="{TemplateBinding PopupHeaderTemplate}"
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
TextElement.FontSize="{DynamicResource BannerTitleFontSize}"
|
||||||
|
TextElement.FontWeight="{DynamicResource TextBlockTitleFontWeight}" />
|
||||||
<ContentPresenter
|
<ContentPresenter
|
||||||
Content="{TemplateBinding PopupContent}"
|
Content="{TemplateBinding PopupContent}"
|
||||||
ContentTemplate="{TemplateBinding PopupContentTemplate}"/>
|
ContentTemplate="{TemplateBinding PopupContentTemplate}"
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
TextWrapping="Wrap" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="0 8 0 0"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
HorizontalAlignment="Right">
|
||||||
<Button
|
<Button
|
||||||
Name="{x:Static u:PopConfirm.PART_CancelButton}"
|
Name="{x:Static u:PopConfirm.PART_CancelButton}"
|
||||||
Margin="0 0 8 0"
|
Margin="0 0 8 0"
|
||||||
@@ -39,11 +76,56 @@
|
|||||||
CommandParameter="{TemplateBinding ConfirmCommandParameter}" />
|
CommandParameter="{TemplateBinding ConfirmCommandParameter}" />
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</Popup>
|
</Popup>
|
||||||
</Panel>
|
</Panel>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter>
|
</Setter>
|
||||||
|
|
||||||
|
<Style Selector="^ /template/ Button#PART_CancelButton">
|
||||||
|
<Setter Property="helpers:ClassHelper.Classes" Value="Tertiary" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^ /template/ Button#PART_ConfirmButton">
|
||||||
|
<Setter Property="helpers:ClassHelper.Classes" Value="Primary" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^.Information">
|
||||||
|
<Style
|
||||||
|
Selector="^ /template/ PathIcon#PART_BuildInIcon">
|
||||||
|
<Setter Property="Data"
|
||||||
|
Value="{DynamicResource BannerInformationIconGeometry}" />
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{DynamicResource BannerInformationBorderBrush}" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^.Success">
|
||||||
|
<Style
|
||||||
|
Selector="^ /template/ PathIcon#PART_BuildInIcon">
|
||||||
|
<Setter Property="Data"
|
||||||
|
Value="{DynamicResource BannerSuccessIconGeometry}" />
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{DynamicResource BannerSuccessBorderBrush}" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^.Warning">
|
||||||
|
<Style
|
||||||
|
Selector="^ /template/ PathIcon#PART_BuildInIcon">
|
||||||
|
<Setter Property="Data"
|
||||||
|
Value="{DynamicResource BannerWarningIconGeometry}" />
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{DynamicResource BannerWarningBorderBrush}" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^.Error">
|
||||||
|
<Style
|
||||||
|
Selector="^ /template/ PathIcon#PART_BuildInIcon">
|
||||||
|
<Setter Property="Data"
|
||||||
|
Value="{DynamicResource BannerErrorIconGeometry}" />
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{DynamicResource BannerErrorBorderBrush}" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
@@ -13,13 +14,14 @@ using Irihi.Avalonia.Shared.Helpers;
|
|||||||
|
|
||||||
namespace Ursa.Controls;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
[PseudoClasses(PC_DropdownOpen)]
|
[PseudoClasses(PC_DropdownOpen, PC_Icon)]
|
||||||
public class PopConfirm : ContentControl
|
public class PopConfirm : ContentControl
|
||||||
{
|
{
|
||||||
public const string PART_ConfirmButton = "PART_ConfirmButton";
|
public const string PART_ConfirmButton = "PART_ConfirmButton";
|
||||||
public const string PART_CancelButton = "PART_CancelButton";
|
public const string PART_CancelButton = "PART_CancelButton";
|
||||||
public const string PART_Popup = "PART_Popup";
|
public const string PART_Popup = "PART_Popup";
|
||||||
public const string PC_DropdownOpen = ":dropdownopen";
|
public const string PC_DropdownOpen = ":dropdownopen";
|
||||||
|
public const string PC_Icon = ":icon";
|
||||||
|
|
||||||
public static readonly StyledProperty<object?> PopupHeaderProperty = AvaloniaProperty.Register<PopConfirm, object?>(
|
public static readonly StyledProperty<object?> PopupHeaderProperty = AvaloniaProperty.Register<PopConfirm, object?>(
|
||||||
nameof(PopupHeader));
|
nameof(PopupHeader));
|
||||||
@@ -64,7 +66,15 @@ public class PopConfirm : ContentControl
|
|||||||
nameof(IsDropdownOpen));
|
nameof(IsDropdownOpen));
|
||||||
|
|
||||||
public static readonly StyledProperty<PlacementMode> PlacementProperty =
|
public static readonly StyledProperty<PlacementMode> PlacementProperty =
|
||||||
Popup.PlacementProperty.AddOwner<PopConfirm>();
|
Popup.PlacementProperty.AddOwner<PopConfirm>(new StyledPropertyMetadata<PlacementMode>());
|
||||||
|
|
||||||
|
public static readonly StyledProperty<object?> IconProperty = Banner.IconProperty.AddOwner<PopConfirm>();
|
||||||
|
|
||||||
|
public object? Icon
|
||||||
|
{
|
||||||
|
get => GetValue(IconProperty);
|
||||||
|
set => SetValue(IconProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
private Button? _cancelButton;
|
private Button? _cancelButton;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user