feat: initialize.
This commit is contained in:
9
demo/Ursa.Demo/Pages/AvatarDemo.axaml
Normal file
9
demo/Ursa.Demo/Pages/AvatarDemo.axaml
Normal file
@@ -0,0 +1,9 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
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:u="https://irihi.tech/ursa"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Ursa.Demo.Pages.AvatarDemo">
|
||||
<u:Avatar />
|
||||
</UserControl>
|
||||
13
demo/Ursa.Demo/Pages/AvatarDemo.axaml.cs
Normal file
13
demo/Ursa.Demo/Pages/AvatarDemo.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Ursa.Demo.Pages;
|
||||
|
||||
public partial class AvatarDemo : UserControl
|
||||
{
|
||||
public AvatarDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
6
demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs
Normal file
6
demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public class AvatarDemoViewModel: ViewModelBase
|
||||
{
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ public class MainViewViewModel : ViewModelBase
|
||||
Content = s switch
|
||||
{
|
||||
MenuKeys.MenuKeyIntroduction => new IntroductionDemoViewModel(),
|
||||
MenuKeys.MenuKeyAvatar => new AvatarDemoViewModel(),
|
||||
MenuKeys.MenuKeyBadge => new BadgeDemoViewModel(),
|
||||
MenuKeys.MenuKeyBanner => new BannerDemoViewModel(),
|
||||
MenuKeys.MenuKeyButtonGroup => new ButtonGroupDemoViewModel(),
|
||||
|
||||
@@ -12,6 +12,7 @@ public class MenuViewModel: ViewModelBase
|
||||
{
|
||||
new() { MenuHeader = "Introduction", Key = MenuKeys.MenuKeyIntroduction, IsSeparator = false },
|
||||
new() { MenuHeader = "Controls", IsSeparator = true },
|
||||
new() { MenuHeader = "Avatar", Key = MenuKeys.MenuKeyAvatar, Status = "WIP"},
|
||||
new() { MenuHeader = "Badge", Key = MenuKeys.MenuKeyBadge },
|
||||
new() { MenuHeader = "Banner", Key = MenuKeys.MenuKeyBanner },
|
||||
new() { MenuHeader = "Breadcrumb", Key = MenuKeys.MenuKeyBreadcrumb },
|
||||
@@ -59,6 +60,7 @@ public class MenuViewModel: ViewModelBase
|
||||
public static class MenuKeys
|
||||
{
|
||||
public const string MenuKeyIntroduction = "Introduction";
|
||||
public const string MenuKeyAvatar = "Avatar";
|
||||
public const string MenuKeyBadge = "Badge";
|
||||
public const string MenuKeyBanner = "Banner";
|
||||
public const string MenuKeyButtonGroup = "ButtonGroup";
|
||||
|
||||
7
src/Ursa.Themes.Semi/Controls/Avatar.axaml
Normal file
7
src/Ursa.Themes.Semi/Controls/Avatar.axaml
Normal file
@@ -0,0 +1,7 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="https://irihi.tech/ursa">
|
||||
<ControlTheme x:Key="{x:Type u:Avatar}" TargetType="{x:Type u:Avatar}" />
|
||||
<ControlTheme x:Key="{x:Type u:AvatarGroup}" TargetType="{x:Type u:AvatarGroup}" />
|
||||
</ResourceDictionary>
|
||||
@@ -1,6 +1,7 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="Avatar.axaml" />
|
||||
<ResourceInclude Source="Badge.axaml" />
|
||||
<ResourceInclude Source="Banner.axaml" />
|
||||
<ResourceInclude Source="ButtonGroup.axaml" />
|
||||
|
||||
2
src/Ursa.Themes.Semi/Themes/Dark/Avatar.axaml
Normal file
2
src/Ursa.Themes.Semi/Themes/Dark/Avatar.axaml
Normal file
@@ -0,0 +1,2 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
</ResourceDictionary>
|
||||
@@ -1,6 +1,7 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<MergeResourceInclude Source="Avatar.axaml" />
|
||||
<MergeResourceInclude Source="Badge.axaml" />
|
||||
<MergeResourceInclude Source="Banner.axaml" />
|
||||
<MergeResourceInclude Source="ButtonGroup.axaml" />
|
||||
|
||||
2
src/Ursa.Themes.Semi/Themes/Light/Avatar.axaml
Normal file
2
src/Ursa.Themes.Semi/Themes/Light/Avatar.axaml
Normal file
@@ -0,0 +1,2 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
</ResourceDictionary>
|
||||
@@ -1,6 +1,7 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<MergeResourceInclude Source="Avatar.axaml" />
|
||||
<MergeResourceInclude Source="Badge.axaml" />
|
||||
<MergeResourceInclude Source="Banner.axaml" />
|
||||
<MergeResourceInclude Source="ButtonGroup.axaml" />
|
||||
|
||||
2
src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml
Normal file
2
src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml
Normal file
@@ -0,0 +1,2 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
</ResourceDictionary>
|
||||
@@ -1,6 +1,7 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<MergeResourceInclude Source="Avatar.axaml" />
|
||||
<MergeResourceInclude Source="Badge.axaml" />
|
||||
<MergeResourceInclude Source="Banner.axaml" />
|
||||
<MergeResourceInclude Source="ButtonGroup.axaml" />
|
||||
|
||||
38
src/Ursa/Controls/Avatar/Avatar.cs
Normal file
38
src/Ursa/Controls/Avatar/Avatar.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
public class Avatar : Button
|
||||
{
|
||||
public const string PART_TopPresenter = "PART_TopPresenter";
|
||||
public const string PART_BottomPresenter = "PART_BottomPresenter";
|
||||
public const string PART_HoverMask = "PART_HoverMask";
|
||||
|
||||
public static readonly StyledProperty<bool> ContentMotionProperty = AvaloniaProperty.Register<Avatar, bool>(
|
||||
nameof(ContentMotion));
|
||||
|
||||
public static readonly StyledProperty<double> GapProperty = AvaloniaProperty.Register<Avatar, double>(
|
||||
nameof(Gap));
|
||||
|
||||
public static readonly StyledProperty<string> SourceProperty = AvaloniaProperty.Register<Avatar, string>(
|
||||
nameof(Source));
|
||||
|
||||
public bool ContentMotion
|
||||
{
|
||||
get => GetValue(ContentMotionProperty);
|
||||
set => SetValue(ContentMotionProperty, value);
|
||||
}
|
||||
|
||||
public double Gap
|
||||
{
|
||||
get => GetValue(GapProperty);
|
||||
set => SetValue(GapProperty, value);
|
||||
}
|
||||
|
||||
public string Source
|
||||
{
|
||||
get => GetValue(SourceProperty);
|
||||
set => SetValue(SourceProperty, value);
|
||||
}
|
||||
}
|
||||
33
src/Ursa/Controls/Avatar/AvatarGroup.cs
Normal file
33
src/Ursa/Controls/Avatar/AvatarGroup.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
public class AvatarGroup : ItemsControl
|
||||
{
|
||||
public const string PART_RenderMore = "PART_RenderMore";
|
||||
|
||||
public static readonly StyledProperty<int> MaxCountProperty = AvaloniaProperty.Register<AvatarGroup, int>(
|
||||
nameof(MaxCount));
|
||||
|
||||
public static readonly StyledProperty<OverlapFromType> OverlapFromProperty = AvaloniaProperty.Register<AvatarGroup, OverlapFromType>(
|
||||
nameof(OverlapFrom));
|
||||
|
||||
public int MaxCount
|
||||
{
|
||||
get => GetValue(MaxCountProperty);
|
||||
set => SetValue(MaxCountProperty, value);
|
||||
}
|
||||
|
||||
public OverlapFromType OverlapFrom
|
||||
{
|
||||
get => GetValue(OverlapFromProperty);
|
||||
set => SetValue(OverlapFromProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
public enum OverlapFromType
|
||||
{
|
||||
Start,
|
||||
End
|
||||
}
|
||||
Reference in New Issue
Block a user