feat: Add PinBox control, styles and demo.

This commit is contained in:
NaBian committed 2026-06-20 17:55:51 +08:00
1 parent c48a634220
commit aa32f72563
6 files changed
+551

No files matched your search

@@ -46,6 +46,7 @@
[ "ButtonGroup", "ButtonGroupDemo", "Brush.ButtonGroup", "", "Button" ],
[ "ProgressButton", "ProgressButtonDemo", "Brush.ProgressBarStatusBar8", "", "Button" ],
[ "Card", "CardDemo", "Brush.ContactCard", "", "DataDisplay" ],
[ "PinBox", "PinBoxDemo", "Brush.Ellipsis", "", "DataEntry" ],
[ "ElementGroup", "ElementGroupDemo", "Brush.ButtonGroup", "", "Layout" ],
[ "CirclePanel", "CirclePanelDemo", "Brush.ColorWheel", "", "Layout" ],
[ "Grid", "GridDemo", "Brush.GridPane", "", "Layout" ],
@@ -0,0 +1,26 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
x:Class="HandyControlDemo.UserControl.PinBoxDemo"
Background="{DynamicResource RegionBrush}">
<TransitioningContentControl>
<hc:UniformSpacingPanel Spacing="16"
Orientation="Vertical"
Margin="32"
VerticalAlignment="Center">
<hc:PinBox Length="4"
Password="1234"
Completed="PinBox_OnCompleted" />
<hc:PinBox x:Name="PinBoxUnsafe"
Length="4"
Password="1234"
IsSafeEnabled="False"
Completed="PinBox_OnCompleted" />
<TextBox Text="{Binding #PinBoxUnsafe.UnsafePassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<hc:PinBox Length="6"
Password="123456"
PasswordChar="❤"
Completed="PinBox_OnCompleted" />
</hc:UniformSpacingPanel>
</TransitioningContentControl>
</UserControl>
@@ -0,0 +1,29 @@
using Avalonia.Interactivity;
using HandyControl.Controls;
using System;
using System.Reflection;
namespace HandyControlDemo.UserControl;
public partial class PinBoxDemo : Avalonia.Controls.UserControl
{
public PinBoxDemo()
{
InitializeComponent();
}
private void PinBox_OnCompleted(object? sender, RoutedEventArgs e)
{
if (e.Source is PinBox pinBox)
{
TryShowGrowl(pinBox.Password);
}
}
private static void TryShowGrowl(string message)
{
var growlType = Type.GetType("HandyControl.Controls.Growl, HandyControl");
var infoMethod = growlType?.GetMethod("Info", BindingFlags.Public | BindingFlags.Static, [typeof(string), typeof(string)]);
infoMethod?.Invoke(null, [message, string.Empty]);
}
}