feat: add button spinner infra.
This commit is contained in:
parent
a9e1760dc5
commit
91aa3380aa
33
demo/Semi.Avalonia.Demo/Pages/ButtonSpinnerDemo.axaml
Normal file
33
demo/Semi.Avalonia.Demo/Pages/ButtonSpinnerDemo.axaml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<UserControl
|
||||||
|
x:Class="Semi.Avalonia.Demo.Pages.ButtonSpinnerDemo"
|
||||||
|
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"
|
||||||
|
d:DesignHeight="450"
|
||||||
|
d:DesignWidth="800"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<StackPanel>
|
||||||
|
<ButtonSpinner
|
||||||
|
Height="30"
|
||||||
|
AllowSpin="{Binding #allowSpinCheck.IsChecked}"
|
||||||
|
ShowButtonSpinner="{Binding #showSpinCheck.IsChecked}"
|
||||||
|
Spin="OnSpin">
|
||||||
|
<TextBlock
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="Everest" />
|
||||||
|
</ButtonSpinner>
|
||||||
|
<ButtonSpinner
|
||||||
|
Height="30"
|
||||||
|
AllowSpin="{Binding #allowSpinCheck.IsChecked}"
|
||||||
|
ButtonSpinnerLocation="Left"
|
||||||
|
ShowButtonSpinner="{Binding #showSpinCheck.IsChecked}"
|
||||||
|
Spin="OnSpin">
|
||||||
|
<TextBlock
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="Everest" />
|
||||||
|
</ButtonSpinner>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
50
demo/Semi.Avalonia.Demo/Pages/ButtonSpinnerDemo.axaml.cs
Normal file
50
demo/Semi.Avalonia.Demo/Pages/ButtonSpinnerDemo.axaml.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace Semi.Avalonia.Demo.Pages;
|
||||||
|
|
||||||
|
public partial class ButtonSpinnerDemo : UserControl
|
||||||
|
{
|
||||||
|
public ButtonSpinnerDemo()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnSpin(object sender, SpinEventArgs e)
|
||||||
|
{
|
||||||
|
var spinner = (ButtonSpinner)sender;
|
||||||
|
|
||||||
|
if (spinner.Content is TextBlock txtBox)
|
||||||
|
{
|
||||||
|
int value = Array.IndexOf(_mountains, txtBox.Text);
|
||||||
|
if (e.Direction == SpinDirection.Increase)
|
||||||
|
value++;
|
||||||
|
else
|
||||||
|
value--;
|
||||||
|
|
||||||
|
if (value < 0)
|
||||||
|
value = _mountains.Length - 1;
|
||||||
|
else if (value >= _mountains.Length)
|
||||||
|
value = 0;
|
||||||
|
|
||||||
|
txtBox.Text = _mountains[value];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly string[] _mountains = new[]
|
||||||
|
{
|
||||||
|
"Everest",
|
||||||
|
"K2 (Mount Godwin Austen)",
|
||||||
|
"Kangchenjunga",
|
||||||
|
"Lhotse",
|
||||||
|
"Makalu",
|
||||||
|
"Cho Oyu",
|
||||||
|
"Dhaulagiri",
|
||||||
|
"Manaslu",
|
||||||
|
"Nanga Parbat",
|
||||||
|
"Annapurna"
|
||||||
|
};
|
||||||
|
}
|
@ -24,6 +24,9 @@
|
|||||||
<TabItem Header="Button">
|
<TabItem Header="Button">
|
||||||
<pages:ButtonDemo />
|
<pages:ButtonDemo />
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<TabItem Header="ButtonSpinner">
|
||||||
|
<pages:ButtonSpinnerDemo />
|
||||||
|
</TabItem>
|
||||||
<TabItem Header="CheckBox">
|
<TabItem Header="CheckBox">
|
||||||
<pages:CheckBoxDemo />
|
<pages:CheckBoxDemo />
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
5
src/Semi.Avalonia/Controls/ButtonSpinner.axaml
Normal file
5
src/Semi.Avalonia/Controls/ButtonSpinner.axaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<ControlTheme x:Key="{x:Type ButtonSpinner}" TargetType="ButtonSpinner">
|
||||||
|
<!-- Add Resource -->
|
||||||
|
</ControlTheme>
|
||||||
|
</ResourceDictionary>
|
@ -4,6 +4,7 @@
|
|||||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/AutoCompleteBox.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Controls/AutoCompleteBox.axaml" />
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/Border.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Controls/Border.axaml" />
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/Button.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Controls/Button.axaml" />
|
||||||
|
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ButtonSpinner.axaml" />
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/CheckBox.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Controls/CheckBox.axaml" />
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ComboBox.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ComboBox.axaml" />
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ContentControl.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Controls/ContentControl.axaml" />
|
||||||
|
3
src/Semi.Avalonia/Themes/Light/ButtonSpinner.axaml
Normal file
3
src/Semi.Avalonia/Themes/Light/ButtonSpinner.axaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<!-- Add Resources Here -->
|
||||||
|
</ResourceDictionary>
|
@ -5,6 +5,7 @@
|
|||||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/AutoCompleteBox.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/AutoCompleteBox.axaml" />
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Border.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Border.axaml" />
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Button.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Button.axaml" />
|
||||||
|
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/ButtonSpinner.axaml" />
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/CheckBox.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/CheckBox.axaml" />
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/ComboBox.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/ComboBox.axaml" />
|
||||||
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Expander.axaml" />
|
<ResourceInclude Source="avares://Semi.Avalonia/Themes/Light/Expander.axaml" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user