Merge branch 'main' into tests

This commit is contained in:
Dong Bin
2025-01-10 22:10:28 +08:00
committed by GitHub
19 changed files with 392 additions and 389 deletions

View File

@@ -36,6 +36,7 @@ jobs:
- name: Commit wwwroot to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: ${{ env.OUTPUT_PATH }}
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: ${{ env.OUTPUT_PATH }}
single-commit: true

View File

@@ -4,54 +4,65 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:Ursa.Demo.Pages"
xmlns:u="https://irihi.tech/ursa"
x:DataType="pages:BannerDemoViewModel"
xmlns:vm="clr-namespace:Ursa.Demo.ViewModels"
x:DataType="vm:BannerDemoViewModel"
mc:Ignorable="d">
<Design.DataContext>
<pages:BannerDemoViewModel />
<vm:BannerDemoViewModel />
</Design.DataContext>
<StackPanel Spacing="20">
<Grid ColumnDefinitions="*, 300">
<Grid Grid.Column="0">
<Border Margin="20">
<u:Banner
Classes.Bordered="{Binding Bordered}"
Content="This is the Demo of Ursa Banner. "
Header="Welcome to Ursa"
Width="300"
Height="100"
HorizontalAlignment="Left"
VerticalAlignment="Top"
CanClose="True"
Type="{Binding SelectedType}" />
</Border>
</Grid>
<Border Grid.Column="1" VerticalAlignment="Top">
<Grid ColumnDefinitions="*, Auto" RowDefinitions="*, *">
<Label
Grid.Row="0"
Grid.Column="0"
VerticalAlignment="Center"
Content="Type" />
<ComboBox
Grid.Row="0"
Grid.Column="1"
MinWidth="200"
ItemsSource="{Binding Types}"
SelectedItem="{Binding SelectedType}" />
<Label
Grid.Row="1"
Grid.Column="0"
VerticalAlignment="Center"
Content="Bordered" />
<ToggleSwitch
Grid.Row="1"
Grid.Column="1"
VerticalAlignment="Center"
IsChecked="{Binding Bordered}" />
</Grid>
</Border>
</Grid>
</StackPanel>
<ScrollViewer>
<StackPanel Spacing="20">
<u:Banner
Name="banner"
Classes.Bordered="{Binding Bordered}"
Header="{Binding Title}"
Content="{Binding Content}" />
<u:Form Width="500">
<TextBox
Classes="ClearButton"
IsEnabled="{Binding SetTitleNull}"
Text="{Binding Title}">
<u:FormItem.Label>
<StackPanel Orientation="Horizontal">
<CheckBox Content="Title" IsChecked="{Binding SetTitleNull}" />
</StackPanel>
</u:FormItem.Label>
</TextBox>
<TextBox
Classes="ClearButton TextArea"
IsEnabled="{Binding SetContentNull}"
Text="{Binding Content}"
TextWrapping="Wrap">
<u:FormItem.Label>
<CheckBox Content="Content" IsChecked="{Binding SetContentNull}" />
</u:FormItem.Label>
</TextBox>
<u:EnumSelector
u:FormItem.Label="NotificationType"
EnumType="NotificationType"
Value="{Binding #banner.Type}" />
<u:EnumSelector
u:FormItem.Label="HorizontalContentAlignment"
EnumType="HorizontalAlignment"
Value="{Binding #banner.HorizontalContentAlignment}" />
<ToggleSwitch
Theme="{StaticResource SimpleToggleSwitch}"
u:FormItem.Label="Bordered"
IsChecked="{Binding Bordered}" />
<ToggleSwitch
Theme="{StaticResource SimpleToggleSwitch}"
u:FormItem.Label="ShowIcon"
IsChecked="{Binding #banner.ShowIcon}" />
<ToggleSwitch
Theme="{StaticResource SimpleToggleSwitch}"
u:FormItem.Label="CanClose"
IsChecked="{Binding #banner.CanClose}" />
<ToggleSwitch
Theme="{StaticResource SimpleToggleSwitch}"
u:FormItem.Label="IsVisible"
IsChecked="{Binding #banner.IsVisible}" />
</u:Form>
</StackPanel>
</ScrollViewer>
</UserControl>

View File

@@ -1,7 +1,4 @@
using System.Collections.ObjectModel;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using Avalonia.Markup.Xaml;
using Ursa.Demo.ViewModels;
namespace Ursa.Demo.Pages;
@@ -13,44 +10,4 @@ public partial class BannerDemo : UserControl
InitializeComponent();
this.DataContext = new BannerDemoViewModel();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
public class BannerDemoViewModel : ViewModelBase
{
private ObservableCollection<NotificationType>? _types;
public ObservableCollection<NotificationType>? Types
{
get => _types;
set => SetProperty(ref _types, value);
}
private NotificationType _selectedType;
public NotificationType SelectedType
{
get => _selectedType;
set => SetProperty(ref _selectedType, value);
}
private bool _bordered;
public bool Bordered
{
get => _bordered;
set => SetProperty(ref _bordered, value);
}
public BannerDemoViewModel()
{
Types = new ObservableCollection<NotificationType>()
{
NotificationType.Information, NotificationType.Success, NotificationType.Warning, NotificationType.Error
};
}
}

View File

@@ -13,14 +13,14 @@
<UserControl.Styles>
<Style Selector="Button">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Margin" Value="8"></Setter>
<Setter Property="Margin" Value="8" />
</Style>
</UserControl.Styles>
<StackPanel HorizontalAlignment="Left">
<ComboBox ItemsSource="{Binding Icons}" SelectedItem="{Binding SelectedIcon}" />
<ToggleSwitch Content="Try Long Message" IsChecked="{Binding UseLong}"></ToggleSwitch>
<ToggleSwitch Content="Show Title" IsChecked="{Binding UseTitle}"></ToggleSwitch>
<ToggleSwitch Content="Overlay" IsChecked="{Binding UseOverlay}"></ToggleSwitch>
<ToggleSwitch Content="Try Long Message" IsChecked="{Binding UseLong}" />
<ToggleSwitch Content="Show Title" IsChecked="{Binding UseTitle}" />
<ToggleSwitch Content="Overlay" IsChecked="{Binding UseOverlay}" />
<Button Command="{Binding DefaultMessageBoxCommand}" Content="Default" />
<Button Command="{Binding OkCommand}" Content="OK" />
<Button Command="{Binding OkCancelCommand}" Content="OKCancel" />
@@ -28,8 +28,8 @@
<Button Command="{Binding YesNoCancelCommand}" Content="YesNoCancel" />
<TextBlock>
<Run Text="Last Clicked Result: "></Run>
<Run Text="{Binding Result}"></Run>
<Run Text="Last Clicked Result: " />
<Run Text="{Binding Result}" />
</TextBlock>
</StackPanel>
</UserControl>

View File

@@ -1,6 +1,41 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace Ursa.Demo.ViewModels;
public class BannerDemoViewModel: ViewModelBase
public partial class BannerDemoViewModel : ViewModelBase
{
private string? _oldTitle = string.Empty;
private string? _oldContent = string.Empty;
[ObservableProperty] private string? _title = "Welcome to Ursa";
[ObservableProperty] private string? _content = "This is the Demo of Ursa Banner.";
[ObservableProperty] private bool _bordered;
[ObservableProperty] private bool _setTitleNull = true;
[ObservableProperty] private bool _setContentNull = true;
partial void OnSetTitleNullChanged(bool value)
{
if (value)
{
Title = _oldTitle;
}
else
{
_oldTitle = Title;
Title = null;
}
}
partial void OnSetContentNullChanged(bool value)
{
if (value)
{
Content = _oldContent;
}
else
{
_oldContent = Content;
Content = null;
}
}
}

View File

@@ -0,0 +1,45 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StaticResource x:Key="NotificationCloseButton" ResourceKey="OverlayCloseButton" />
<StaticResource x:Key="ToastCloseButton" ResourceKey="OverlayCloseButton" />
<ControlTheme x:Key="InnerPathIcon" TargetType="PathIcon">
<Setter Property="Height" Value="16" />
<Setter Property="Width" Value="16" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<ControlTemplate TargetType="PathIcon">
<Border Background="{TemplateBinding Background}">
<Viewbox
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}">
<Path
Name="PART_Path"
Width="24"
Height="24"
Data="{TemplateBinding Data}"
Fill="{TemplateBinding Foreground}" />
</Viewbox>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^.Active /template/ Path#PART_Path">
<Setter Property="Fill" Value="{Binding BorderBrush,RelativeSource={RelativeSource TemplatedParent}}" />
</Style>
<Style Selector="^.ExtraSmall">
<Setter Property="Height" Value="8" />
<Setter Property="Width" Value="8" />
</Style>
<Style Selector="^.Small">
<Setter Property="Height" Value="12" />
<Setter Property="Width" Value="12" />
</Style>
<Style Selector="^.Large">
<Setter Property="Height" Value="20" />
<Setter Property="Width" Value="20" />
</Style>
<Style Selector="^.ExtraLarge">
<Setter Property="Height" Value="24" />
<Setter Property="Width" Value="24" />
</Style>
</ControlTheme>
</ResourceDictionary>

View File

@@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="/Compatibles/Icon.axaml" />
<ResourceInclude Source="/Compatibles/Theme.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

View File

@@ -2,8 +2,18 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
<!-- Add Resources Here -->
<Design.PreviewWith>
<HeaderedContentControl Theme="{StaticResource GroupBox}" Width="500">
<u:Banner
Classes="Bordered"
Header="Title"
Content="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat"
Type="Warning"
CanClose="True" />
</HeaderedContentControl>
</Design.PreviewWith>
<ControlTheme x:Key="{x:Type u:Banner}" TargetType="u:Banner">
<Setter Property="Padding" Value="{DynamicResource BannerBorderPadding}" />
<Setter Property="BorderThickness" Value="{DynamicResource BannerBorderThickness}" />
<Setter Property="BorderBrush" Value="{DynamicResource BannerBorderBrush}" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
@@ -11,19 +21,16 @@
<ControlTemplate TargetType="u:Banner">
<Border
Name="PART_Container"
Padding="12"
Padding="{TemplateBinding Padding}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid ColumnDefinitions="*, Auto">
<Grid
Grid.Column="0"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
ColumnDefinitions="Auto, *"
RowDefinitions="Auto, *">
ColumnDefinitions="Auto, *">
<!-- Icon Area -->
<Panel
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="0"
Margin="{DynamicResource BannerIconMargin}"
VerticalAlignment="Top"
@@ -31,38 +38,31 @@
<ContentPresenter Content="{TemplateBinding Icon}" />
<PathIcon
Name="PART_BuildInIcon"
Width="16"
Height="16"
IsVisible="{TemplateBinding Icon,
Converter={x:Static ObjectConverters.IsNull}}" />
Theme="{DynamicResource InnerPathIcon}"
Classes="Large"
IsVisible="{TemplateBinding Icon, Converter={x:Static ObjectConverters.IsNull}}" />
</Panel>
<ContentPresenter
Grid.Row="0"
Grid.Column="1"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
IsVisible="{TemplateBinding Header,
Converter={x:Static ObjectConverters.IsNotNull}}"
TextElement.FontWeight="{DynamicResource TextBlockTitleFontWeight}" />
<ContentPresenter
Grid.Row="1"
Grid.Column="1"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
<StackPanel Grid.Column="1" Spacing="2">
<ContentPresenter
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
TextTrimming="CharacterEllipsis"
TextElement.FontSize="{DynamicResource BannerTitleFontSize}"
TextElement.FontWeight="{DynamicResource TextBlockTitleFontWeight}" />
<ContentPresenter
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
TextWrapping="Wrap" />
</StackPanel>
</Grid>
<Button
Name="{x:Static u:Banner.PART_CloseButton}"
Grid.Column="1"
Padding="4"
Cursor="Hand"
IsVisible="{TemplateBinding CanClose}"
Theme="{DynamicResource BorderlessButton}">
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource BannerCloseIconGeometry}"
Foreground="{DynamicResource BannerCloseButtonForeground}" />
</Button>
Margin="{DynamicResource BannerCloseButtonMargin}"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Theme="{DynamicResource OverlayCloseButton}"
IsVisible="{TemplateBinding CanClose}" />
</Grid>
</Border>
</ControlTemplate>

View File

@@ -76,9 +76,8 @@
<MenuItem Command="{Binding $parent[u:DialogControlBase].Close}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource WindowCloseIconGlyph}" />
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource SemiIconClose}" />
</MenuItem.Icon>
</MenuItem>
</MenuFlyout>
@@ -93,8 +92,7 @@
Header="{DynamicResource STRING_MENU_BRING_FORWARD}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource DialogArrangeBringForwardGlyph}" />
</MenuItem.Icon>
</MenuItem>
@@ -104,8 +102,7 @@
Header="{DynamicResource STRING_MENU_BRING_TO_FRONT}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource DialogArrangeBringToFrontGlyph}" />
</MenuItem.Icon>
</MenuItem>
@@ -115,8 +112,7 @@
Header="{DynamicResource STRING_MENU_SEND_BACKWARD}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource DialogArrangeSendBackwardGlyph}" />
</MenuItem.Icon>
</MenuItem>
@@ -126,17 +122,15 @@
Header="{DynamicResource STRING_MENU_SEND_TO_BACK}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource DialogArrangeSendToBackGlyph}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="{Binding $parent[u:DialogControlBase].Close}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource WindowCloseIconGlyph}" />
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource SemiIconClose}" />
</MenuItem.Icon>
</MenuItem>
</MenuFlyout>
@@ -186,8 +180,8 @@
<PathIcon
Name="PART_Icon"
Grid.Column="0"
Width="16"
Height="16"
Theme="{StaticResource InnerPathIcon}"
Classes="ExtraLarge"
Margin="24,24,8,0"
VerticalAlignment="Center" />
<TextBlock
@@ -392,9 +386,8 @@
<MenuItem Command="{Binding $parent[u:DialogControlBase].Close}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource WindowCloseIconGlyph}" />
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource SemiIconClose}" />
</MenuItem.Icon>
</MenuItem>
</MenuFlyout>
@@ -409,8 +402,7 @@
Header="{DynamicResource STRING_MENU_BRING_FORWARD}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource DialogArrangeBringForwardGlyph}" />
</MenuItem.Icon>
</MenuItem>
@@ -420,8 +412,7 @@
Header="{DynamicResource STRING_MENU_BRING_TO_FRONT}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource DialogArrangeBringToFrontGlyph}" />
</MenuItem.Icon>
</MenuItem>
@@ -431,8 +422,7 @@
Header="{DynamicResource STRING_MENU_SEND_BACKWARD}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource DialogArrangeSendBackwardGlyph}" />
</MenuItem.Icon>
</MenuItem>
@@ -442,8 +432,7 @@
Header="{DynamicResource STRING_MENU_SEND_TO_BACK}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource DialogArrangeSendToBackGlyph}" />
</MenuItem.Icon>
</MenuItem>
@@ -453,9 +442,8 @@
Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource WindowCloseIconGlyph}" />
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource SemiIconClose}" />
</MenuItem.Icon>
</MenuItem>
</MenuFlyout>
@@ -588,8 +576,8 @@
<PathIcon
Name="PART_Icon"
Grid.Column="0"
Width="16"
Height="16"
Theme="{StaticResource InnerPathIcon}"
Classes="ExtraLarge"
Margin="24,24,8,0"
VerticalAlignment="Center" />
<TextBlock

View File

@@ -1,28 +1,44 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<ControlTheme x:Key="CloseButton" TargetType="Button">
<Design.PreviewWith>
<StackPanel Orientation="Horizontal" Margin="20">
<Button Theme="{DynamicResource CloseButton}" />
<Button Theme="{DynamicResource OverlayCloseButton}" />
<Button Theme="{DynamicResource NotificationCloseButton}" />
<Button Theme="{DynamicResource ToastCloseButton}" />
</StackPanel>
</Design.PreviewWith>
<ControlTheme x:Key="OverlayCloseButton" TargetType="Button">
<Setter Property="CornerRadius" Value="6" />
<Setter Property="Margin" Value="0, 4" />
<Setter Property="Height" Value="24" />
<Setter Property="Width" Value="24" />
<Setter Property="Padding" Value="4" />
<Setter Property="Height" Value="28" />
<Setter Property="Width" Value="28" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Template">
<ControlTemplate TargetType="Button">
<Border
Name="PART_Border"
Padding="{TemplateBinding Padding}"
Background="Transparent"
CornerRadius="{TemplateBinding CornerRadius}">
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource WindowCloseIconGlyph}"/>
Foreground="{DynamicResource SemiColorText1}"
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource SemiIconClose}" />
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ Border">
<Setter Property="Background" Value="{DynamicResource SemiColorFill1}" />
</Style>
<Style Selector="^:pressed /template/ Border">
<Setter Property="Background" Value="{DynamicResource SemiColorFill2}" />
</Style>
</ControlTheme>
<ControlTheme
x:Key="CloseButton"
BasedOn="{StaticResource OverlayCloseButton}"
TargetType="Button">
<Style Selector="^:pointerover /template/ Border">
<Setter Property="Background" Value="{DynamicResource CaptionButtonClosePointeroverBackground}" />
</Style>
@@ -38,34 +54,4 @@
</Style>
</ControlTheme>
<ControlTheme x:Key="OverlayCloseButton" TargetType="Button">
<Setter Property="CornerRadius" Value="6" />
<Setter Property="Margin" Value="0, 4" />
<Setter Property="Padding" Value="4" />
<Setter Property="Height" Value="28" />
<Setter Property="Width" Value="28" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Template">
<ControlTemplate TargetType="Button">
<Border
Name="PART_Border"
Padding="{TemplateBinding Padding}"
Background="Transparent"
CornerRadius="{TemplateBinding CornerRadius}">
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource WindowCloseIconGlyph}"/>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ Border">
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPointeroverBackground}" />
</Style>
<Style Selector="^:pressed /template/ Border">
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPressedBackground}" />
</Style>
</ControlTheme>
</ResourceDictionary>

View File

@@ -3,10 +3,35 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa"
xmlns:helpers="clr-namespace:Irihi.Avalonia.Shared.Helpers;assembly=Irihi.Avalonia.Shared">
<!-- Add Resources Here -->
<Design.PreviewWith>
<StackPanel Margin="20">
<u:MessageBoxControl
Content="此修改将不可逆"
MessageIcon="None"
Buttons="OK" />
<u:MessageBoxControl
Content="此修改将不可逆"
MessageIcon="Warning"
Buttons="OKCancel" />
<u:MessageBoxControl
Title="确定是否要保存此修改?"
MessageIcon="Warning"
Buttons="OKCancel" />
<u:MessageBoxControl
Title="确定是否要保存此修改?"
Content="此修改将不可逆"
MessageIcon="Warning"
Buttons="OKCancel" />
<u:MessageBoxControl
Title="确定是否要保存此修改?"
Content="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
MessageIcon="Warning"
Buttons="OKCancel" />
</StackPanel>
</Design.PreviewWith>
<ControlTheme x:Key="{x:Type u:MessageBoxWindow}" TargetType="u:MessageBoxWindow">
<Setter Property="Title" Value="{x:Null}" />
<Setter Property="Background" Value="{DynamicResource SemiColorBackground2}" />
<Setter Property="Background" Value="{DynamicResource SemiColorBackground3}" />
<Setter Property="TransparencyBackgroundFallback" Value="{DynamicResource WindowDefaultBackground}" />
<Setter Property="Foreground" Value="{DynamicResource WindowDefaultForeground}" />
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
@@ -36,99 +61,93 @@
BackgroundSizing="InnerBorderEdge"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
IsHitTestVisible="False" />
IsHitTestVisible="False" />
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
<VisualLayerManager>
<Grid RowDefinitions="Auto, *, Auto">
<Grid
Grid.Row="0"
Margin="24,24,24,0"
ColumnDefinitions="Auto, *, Auto">
<PathIcon
Name="PART_Icon"
Grid.Column="0"
Width="24"
Height="24"
Margin="0,0,8,0"
VerticalAlignment="Center"
IsHitTestVisible="False" />
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontSize="16"
FontWeight="{DynamicResource TextBlockTitleFontWeight}"
IsHitTestVisible="False"
Text="{TemplateBinding Title}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap" />
<Button
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
Grid.Column="2"
Theme="{DynamicResource CloseButton}" />
</Grid>
<Grid
Grid.Row="1"
MaxWidth="{DynamicResource MessageBoxWindowContentMaxWidth}"
Margin="{TemplateBinding Padding}"
ColumnDefinitions="Auto, *">
<ScrollViewer
Grid.Column="1"
MaxHeight="300"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<ContentPresenter
Name="PART_ContentPresenter"
Grid.Row="0"
Margin="24,24,24,0"
ColumnDefinitions="Auto, *, Auto">
<PathIcon
Name="PART_Icon"
Grid.Column="0"
Theme="{StaticResource InnerPathIcon}"
Classes="ExtraLarge"
Margin="0,0,8,0"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
TextAlignment="Left"
TextWrapping="Wrap" />
</ScrollViewer>
</Grid>
IsHitTestVisible="False" />
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontSize="16"
FontWeight="{DynamicResource TextBlockTitleFontWeight}"
IsHitTestVisible="False"
Text="{TemplateBinding Title}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap" />
<Button
Name="{x:Static u:MessageBoxWindow.PART_CloseButton}"
Grid.Column="2"
Theme="{DynamicResource CloseButton}" />
</Grid>
<Grid
Grid.Row="1"
MaxWidth="{DynamicResource MessageBoxWindowContentMaxWidth}"
Margin="{TemplateBinding Padding}"
ColumnDefinitions="Auto, *">
<ScrollViewer
Grid.Column="1"
MaxHeight="300"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<ContentPresenter
Name="PART_ContentPresenter"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
TextAlignment="Left"
TextWrapping="Wrap" />
</ScrollViewer>
</Grid>
<StackPanel
Grid.Row="2"
Margin="24,0,24,24"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button
Name="{x:Static u:MessageBoxWindow.PART_CancelButton}"
Margin="8,0,0,0" />
<Button
Name="{x:Static u:MessageBoxWindow.PART_NoButton}"
Margin="8,0,0,0" />
<Button
Name="{x:Static u:MessageBoxWindow.PART_YesButton}"
Margin="8,0,0,0" />
<Button
Name="{x:Static u:MessageBoxWindow.PART_OKButton}"
Margin="8,0,0,0" />
</StackPanel>
</Grid>
Grid.Row="2"
Margin="24,0,24,24"
Spacing="8"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button Name="{x:Static u:MessageBoxControl.PART_CancelButton}" />
<Button Name="{x:Static u:MessageBoxControl.PART_NoButton}" />
<Button Name="{x:Static u:MessageBoxControl.PART_YesButton}" />
<Button Name="{x:Static u:MessageBoxControl.PART_OKButton}" />
</StackPanel>
</Grid>
</VisualLayerManager>
</Panel>
</ControlTemplate>
</Setter>
<Style Selector="^ /template/ Button#PART_CancelButton">
<Setter Property="Grid.Column" Value="0"/>
<Setter Property="helpers:ClassHelper.Classes" Value="Tertiary"/>
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_CANCEL}"/>
<Setter Property="Grid.Column" Value="0" />
<Setter Property="helpers:ClassHelper.Classes" Value="Tertiary" />
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_CANCEL}" />
</Style>
<Style Selector="^ /template/ Button#PART_NoButton">
<Setter Property="Grid.Column" Value="1"></Setter>
<Setter Property="helpers:ClassHelper.Classes" Value="Danger"/>
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_NO}"/>
<Setter Property="Theme" Value="{DynamicResource SolidButton}"/>
<Setter Property="Grid.Column" Value="1" />
<Setter Property="helpers:ClassHelper.Classes" Value="Danger" />
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_NO}" />
<Setter Property="Theme" Value="{DynamicResource SolidButton}" />
</Style>
<Style Selector="^ /template/ Button#PART_YesButton">
<Setter Property="Grid.Column" Value="2"></Setter>
<Setter Property="helpers:ClassHelper.Classes" Value="Primary"/>
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_YES}"/>
<Setter Property="Theme" Value="{DynamicResource SolidButton}"/>
<Setter Property="Grid.Column" Value="2" />
<Setter Property="helpers:ClassHelper.Classes" Value="Primary" />
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_YES}" />
<Setter Property="Theme" Value="{DynamicResource SolidButton}" />
</Style>
<Style Selector="^ /template/ Button#PART_OKButton">
<Setter Property="Grid.Column" Value="3"></Setter>
<Setter Property="helpers:ClassHelper.Classes" Value="Primary"/>
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_OK}"/>
<Setter Property="Theme" Value="{DynamicResource SolidButton}"/>
<Setter Property="Grid.Column" Value="3" />
<Setter Property="helpers:ClassHelper.Classes" Value="Primary" />
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_OK}" />
<Setter Property="Theme" Value="{DynamicResource SolidButton}" />
</Style>
<Style Selector="^[MessageIcon=None] /template/ PathIcon#PART_Icon">
<Setter Property="IsVisible" Value="False" />
@@ -166,7 +185,7 @@
</ControlTheme>
<ControlTheme x:Key="{x:Type u:MessageBoxControl}" TargetType="u:MessageBoxControl">
<Setter Property="CornerRadius" Value="12" />
<Setter Property="CornerRadius" Value="6" />
<Setter Property="Padding" Value="48 24" />
<Setter Property="u:DialogControlBase.CanDragMove" Value="True" />
<Setter Property="Template">
@@ -178,7 +197,7 @@
VerticalAlignment="Center"
Classes="Shadow"
ClipToBounds="False"
Background="{DynamicResource SemiColorBackground2}"
Background="{DynamicResource SemiColorBackground3}"
CornerRadius="{TemplateBinding CornerRadius}"
IsHitTestVisible="True"
Theme="{DynamicResource CardBorder}">
@@ -193,8 +212,8 @@
<PathIcon
Name="PART_Icon"
Grid.Column="0"
Width="24"
Height="24"
Theme="{StaticResource InnerPathIcon}"
Classes="ExtraLarge"
Margin="24,24,8,0"
VerticalAlignment="Center"
IsHitTestVisible="False" />
@@ -227,6 +246,7 @@
Name="PART_ContentPresenter"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
TextAlignment="Left"
TextWrapping="Wrap" />
</ScrollViewer>
@@ -234,20 +254,13 @@
<StackPanel
Grid.Row="2"
Margin="24,0,24,24"
Spacing="8"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button
Name="{x:Static u:MessageBoxControl.PART_CancelButton}"
Margin="8,0,0,0" />
<Button
Name="{x:Static u:MessageBoxControl.PART_NoButton}"
Margin="8,0,0,0" />
<Button
Name="{x:Static u:MessageBoxControl.PART_YesButton}"
Margin="8,0,0,0" />
<Button
Name="{x:Static u:MessageBoxControl.PART_OKButton}"
Margin="8,0,0,0" />
<Button Name="{x:Static u:MessageBoxControl.PART_CancelButton}" />
<Button Name="{x:Static u:MessageBoxControl.PART_NoButton}" />
<Button Name="{x:Static u:MessageBoxControl.PART_YesButton}" />
<Button Name="{x:Static u:MessageBoxControl.PART_OKButton}" />
</StackPanel>
</Grid>
</Border>
@@ -257,39 +270,38 @@
<Style Selector="^ /template/ Panel#PART_TitleArea">
<Setter Property="ContextFlyout">
<MenuFlyout>
<MenuItem Command="{Binding $parent[u:CustomDialogControl].Close}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem Command="{Binding $parent[u:MessageBoxControl].Close}" Header="{DynamicResource STRING_MENU_DIALOG_CLOSE}">
<MenuItem.Icon>
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource WindowCloseIconGlyph}" />
Theme="{StaticResource InnerPathIcon}"
Data="{DynamicResource SemiIconClose}" />
</MenuItem.Icon>
</MenuItem>
</MenuFlyout>
</Setter>
</Style>
<Style Selector="^ /template/ Button#PART_CancelButton">
<Setter Property="Grid.Column" Value="0"/>
<Setter Property="helpers:ClassHelper.Classes" Value="Tertiary"/>
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_CANCEL}"/>
<Setter Property="Grid.Column" Value="0" />
<Setter Property="helpers:ClassHelper.Classes" Value="Tertiary" />
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_CANCEL}" />
</Style>
<Style Selector="^ /template/ Button#PART_NoButton">
<Setter Property="Grid.Column" Value="1"></Setter>
<Setter Property="helpers:ClassHelper.Classes" Value="Danger"/>
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_NO}"/>
<Setter Property="Theme" Value="{DynamicResource SolidButton}"/>
<Setter Property="Grid.Column" Value="1" />
<Setter Property="helpers:ClassHelper.Classes" Value="Danger" />
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_NO}" />
<Setter Property="Theme" Value="{DynamicResource SolidButton}" />
</Style>
<Style Selector="^ /template/ Button#PART_YesButton">
<Setter Property="Grid.Column" Value="2"></Setter>
<Setter Property="helpers:ClassHelper.Classes" Value="Primary"/>
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_YES}"/>
<Setter Property="Theme" Value="{DynamicResource SolidButton}"/>
<Setter Property="Grid.Column" Value="2" />
<Setter Property="helpers:ClassHelper.Classes" Value="Primary" />
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_YES}" />
<Setter Property="Theme" Value="{DynamicResource SolidButton}" />
</Style>
<Style Selector="^ /template/ Button#PART_OKButton">
<Setter Property="Grid.Column" Value="3"></Setter>
<Setter Property="helpers:ClassHelper.Classes" Value="Primary"/>
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_OK}"/>
<Setter Property="Theme" Value="{DynamicResource SolidButton}"/>
<Setter Property="Grid.Column" Value="3" />
<Setter Property="helpers:ClassHelper.Classes" Value="Primary" />
<Setter Property="Content" Value="{DynamicResource STRING_MENU_DIALOG_OK}" />
<Setter Property="Theme" Value="{DynamicResource SolidButton}" />
</Style>
<Style Selector="^[MessageIcon=None] /template/ PathIcon#PART_Icon">
<Setter Property="IsVisible" Value="False" />

View File

@@ -84,8 +84,8 @@
<DockPanel MinWidth="{DynamicResource NotificationCardMinWidth}">
<PathIcon
x:Name="NotificationIcon"
Width="{DynamicResource NotificationCardIconWidth}"
Height="{DynamicResource NotificationCardIconHeight}"
Theme="{StaticResource InnerPathIcon}"
Classes="Large"
Margin="{DynamicResource NotificationCardIconMargin}"
VerticalAlignment="Top"
IsVisible="{TemplateBinding ShowIcon}"
@@ -126,7 +126,7 @@
x:Name="PART_CloseButton"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Theme="{StaticResource NotificationCloseButton}"
Theme="{StaticResource OverlayCloseButton}"
IsVisible="{TemplateBinding ShowClose}"
u:MessageCard.CloseOnClick="True" />
</DockPanel>
@@ -432,32 +432,4 @@
</Style>
</Style>
</ControlTheme>
<ControlTheme x:Key="NotificationCloseButton" TargetType="Button">
<Setter Property="CornerRadius" Value="6" />
<Setter Property="Height" Value="24" />
<Setter Property="Width" Value="24" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Foreground" Value="{DynamicResource NotificationCardCloseButtonForeground}" />
<Setter Property="Template">
<ControlTemplate TargetType="Button">
<Border
Name="PART_Border"
Padding="{TemplateBinding Padding}"
Background="Transparent"
CornerRadius="{TemplateBinding CornerRadius}">
<PathIcon
Width="10"
Height="10"
Data="{DynamicResource WindowCloseIconGlyph}" />
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ Border">
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPointeroverBackground}" />
</Style>
<Style Selector="^:pressed /template/ Border">
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPressedBackground}" />
</Style>
</ControlTheme>
</ResourceDictionary>

View File

@@ -56,8 +56,8 @@
<DockPanel>
<PathIcon
x:Name="ToastIcon"
Width="{DynamicResource ToastCardIconWidth}"
Height="{DynamicResource ToastCardIconHeight}"
Theme="{StaticResource InnerPathIcon}"
Classes="Large"
Margin="{DynamicResource ToastCardIconMargin}"
VerticalAlignment="Top"
IsVisible="{TemplateBinding ShowIcon}"
@@ -87,7 +87,7 @@
</ContentControl>
<Button
x:Name="PART_CloseButton"
Theme="{StaticResource ToastCloseButton}"
Theme="{StaticResource OverlayCloseButton}"
VerticalAlignment="Top"
IsVisible="{TemplateBinding ShowClose}"
u:MessageCard.CloseOnClick="True" />
@@ -220,31 +220,4 @@
</Style>
</Style>
</ControlTheme>
<ControlTheme x:Key="ToastCloseButton" TargetType="Button">
<Setter Property="CornerRadius" Value="6" />
<Setter Property="Height" Value="24" />
<Setter Property="Width" Value="24" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<ControlTemplate TargetType="Button">
<Border
Name="PART_Border"
Padding="{TemplateBinding Padding}"
Background="Transparent"
CornerRadius="{TemplateBinding CornerRadius}">
<PathIcon
Width="10"
Height="10"
Data="{DynamicResource WindowCloseIconGlyph}" />
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ Border">
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPointeroverBackground}" />
</Style>
<Style Selector="^:pressed /template/ Border">
<Setter Property="Background" Value="{DynamicResource ButtonDefaultPressedBackground}" />
</Style>
</ControlTheme>
</ResourceDictionary>

View File

@@ -6,7 +6,7 @@
<x:String x:Key="STRING_MENU_BRING_FORWARD">上移一层</x:String>
<x:String x:Key="STRING_MENU_SEND_BACKWARD">下移一层</x:String>
<x:String x:Key="STRING_MENU_SEND_TO_BACK">置于底层</x:String>
<x:String x:Key="STRING_MENU_DIALOG_OK">确</x:String>
<x:String x:Key="STRING_MENU_DIALOG_OK">确</x:String>
<x:String x:Key="STRING_MENU_DIALOG_CANCEL">取消</x:String>
<x:String x:Key="STRING_MENU_DIALOG_YES">是</x:String>
<x:String x:Key="STRING_MENU_DIALOG_NO">否</x:String>
@@ -16,7 +16,7 @@
<x:String x:Key="STRING_THEME_TOGGLE_DARK">暗色</x:String>
<x:String x:Key="STRING_THEME_TOGGLE_LIGHT">亮色</x:String>
<x:String x:Key="STRING_THEME_TOGGLE_SYSTEM">跟随系统</x:String>
<x:String x:Key="STRING_DATE_TIME_CONFIRM">确</x:String>
<x:String x:Key="STRING_DATE_TIME_CONFIRM">确</x:String>
<x:String x:Key="STRING_DATE_TIME_START_TIME">开始时间</x:String>
<x:String x:Key="STRING_DATE_TIME_END_TIME">结束时间</x:String>
</ResourceDictionary>

View File

@@ -0,0 +1,18 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
<Design.PreviewWith>
<Border Padding="20">
<!-- Add Controls for Previewer Here -->
</Border>
</Design.PreviewWith>
<Style Selector=":is(u|UrsaWindow)[ExtendClientAreaToDecorationsHint=True] u|WindowNotificationManager">
<Style Selector="^:topright">
<Setter Property="Margin" Value="0 36 0 0"></Setter>
</Style>
</Style>
<Style Selector=":is(u|UrsaWindow)[ExtendClientAreaToDecorationsHint=True] u|WindowToastManager">
<Setter Property="Margin" Value="0 36 0 0"></Setter>
</Style>
</Styles>

View File

@@ -11,5 +11,6 @@
<StyleInclude Source="ToolBar.axaml"/>
<StyleInclude Source="TimeBox.axaml"/>
<StyleInclude Source="UrsaView.axaml" />
<StyleInclude Source="UrsaWindow.axaml" />
<!-- Add Styles Here -->
</Styles>

View File

@@ -6,6 +6,9 @@
<StaticResource x:Key="BannerCloseIconGeometry" ResourceKey="SemiIconClose" />
<CornerRadius x:Key="BannerCornerRadius">3</CornerRadius>
<Thickness x:Key="BannerBorderPadding">12</Thickness>
<Thickness x:Key="BannerBorderThickness">1</Thickness>
<Thickness x:Key="BannerIconMargin">0 0 12 0</Thickness>
<Thickness x:Key="BannerCloseButtonMargin">12 0 0 0</Thickness>
<x:Double x:Key="BannerTitleFontSize">18</x:Double>
</ResourceDictionary>

View File

@@ -1,3 +1,3 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<x:Double x:Key="MessageBoxWindowContentMaxWidth">300</x:Double>
<x:Double x:Key="MessageBoxWindowContentMaxWidth">320</x:Double>
</ResourceDictionary>

View File

@@ -76,7 +76,7 @@ public class StyleClassTests
Assert.DoesNotContain("Custom", dialog.Classes);
var okButton = dialog.GetVisualDescendants().OfType<Button>().SingleOrDefault(a=>a.Name == DefaultDialogControl.PART_OKButton);
Assert.NotNull(okButton);
Assert.Equal("确", okButton.Content);
Assert.Equal("确", okButton.Content);
var cancelButton = dialog.GetVisualDescendants().OfType<Button>().SingleOrDefault(a=>a.Name == DefaultDialogControl.PART_CancelButton);
Assert.NotNull(cancelButton);
Assert.Equal("取消", cancelButton.Content);