chore: add avalonia button and brush demo.
This commit is contained in:
1 parent
63bf5c6aa7
commit
40bb60164e
23 files changed
+1027
-300
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Avalonia;
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Data.Core.Plugins;
|
||||
using Avalonia.Markup.Xaml;
|
||||
@@ -6,7 +7,7 @@ using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace HandyControlDemo;
|
||||
|
||||
public partial class App : Application
|
||||
public class App : Application
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -15,6 +16,7 @@ public partial class App : Application
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
Properties.Langs.Lang.Culture = new CultureInfo("en");
|
||||
BindingPlugins.DataValidators.RemoveAt(0);
|
||||
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[
|
||||
{
|
||||
"title": "Styles",
|
||||
"selectedIndex": 0,
|
||||
"selectedIndex": -1,
|
||||
"group": false,
|
||||
"demoItemList": [
|
||||
[ "Brush", "BrushDemoCtl", "Brush.Brush", "", "" ],
|
||||
|
||||
@@ -57,6 +57,10 @@
|
||||
<Compile Update="Views\Styles\ButtonDemoCtrl.axaml.cs">
|
||||
<DependentUpon>ButtonDemoCtrl.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="UserControl\Styles\BrushDemoCtl.axaml.cs">
|
||||
<DependentUpon>BoderDemoCtl.axaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -6,46 +6,55 @@
|
||||
Margin="16,16,0,16"
|
||||
CornerRadius="10"
|
||||
Effect="{StaticResource EffectShadow4}">
|
||||
<TabControl BorderThickness="0 1 0 0"
|
||||
SelectionChanged="TabControl_OnSelectionChanged"
|
||||
ItemsSource="{Binding DemoInfoCollection}"
|
||||
Background="Transparent"
|
||||
SelectedIndex="0">
|
||||
<TabControl.ItemTemplate>
|
||||
<DataTemplate DataType="data:DemoInfoModel">
|
||||
<TextBlock Text="{Binding Title}" />
|
||||
</DataTemplate>
|
||||
</TabControl.ItemTemplate>
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate DataType="data:DemoInfoModel">
|
||||
<Panel Margin="10">
|
||||
<ListBox SelectionMode="Single"
|
||||
Padding="0"
|
||||
BorderThickness="0"
|
||||
SelectedIndex="{Binding SelectedIndex}"
|
||||
ItemsSource="{Binding DemoItemList}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="data:DemoItemModel">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Rectangle Width="16"
|
||||
Height="16"
|
||||
Fill="{Binding ImageBrush}" />
|
||||
<TextBlock Margin="6,0,0,0"
|
||||
Text="{Binding Name}" />
|
||||
<Path IsVisible="{Binding IsNew}"
|
||||
VerticalAlignment="Center"
|
||||
Data="{StaticResource NewGeometry}"
|
||||
Stretch="Uniform"
|
||||
Margin="10,0,0,0"
|
||||
Width="30"
|
||||
Height="14"
|
||||
Fill="{DynamicResource AccentBrush}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Panel>
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</TabControl>
|
||||
<DockPanel>
|
||||
<Button Content="Practical demos"
|
||||
DockPanel.Dock="Top"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="10,10,10,4"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource SecondaryRegionBrush}" />
|
||||
<TabControl BorderThickness="0 1 0 0"
|
||||
Classes="inline"
|
||||
SelectionChanged="TabControl_OnSelectionChanged"
|
||||
ItemsSource="{Binding DemoInfoCollection}"
|
||||
Background="Transparent"
|
||||
SelectedIndex="0">
|
||||
<TabControl.ItemTemplate>
|
||||
<DataTemplate DataType="data:DemoInfoModel">
|
||||
<TextBlock Text="{Binding Title}" />
|
||||
</DataTemplate>
|
||||
</TabControl.ItemTemplate>
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate DataType="data:DemoInfoModel">
|
||||
<Panel Margin="10">
|
||||
<ListBox SelectionMode="Single"
|
||||
Padding="0"
|
||||
BorderThickness="0"
|
||||
SelectedIndex="{Binding SelectedIndex}"
|
||||
ItemsSource="{Binding DemoItemList}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="data:DemoItemModel">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Rectangle Width="16"
|
||||
Height="16"
|
||||
Fill="{Binding ImageBrush}" />
|
||||
<TextBlock Margin="6,0,0,0"
|
||||
Text="{Binding Name}" />
|
||||
<Path IsVisible="{Binding IsNew}"
|
||||
VerticalAlignment="Center"
|
||||
Data="{StaticResource NewGeometry}"
|
||||
Stretch="Uniform"
|
||||
Margin="10,0,0,0"
|
||||
Width="30"
|
||||
Height="14"
|
||||
Fill="{DynamicResource AccentBrush}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Panel>
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</TabControl>
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,117 @@
|
||||
<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.BrushDemoCtl"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<ScrollViewer>
|
||||
<hc:UniformSpacingPanel ChildWrapping="Wrap"
|
||||
ItemWidth="200"
|
||||
Margin="32"
|
||||
Spacing="16"
|
||||
VerticalAlignment="Center"
|
||||
MaxWidth="632">
|
||||
<Label Content="PrimaryBrush"
|
||||
Theme="{StaticResource LabelPrimary}" />
|
||||
<Label Content="DarkPrimaryBrush"
|
||||
Background="{DynamicResource DarkPrimaryBrush}"
|
||||
Foreground="White"
|
||||
BorderThickness="0" />
|
||||
|
||||
<Label Content="DangerBrush"
|
||||
Theme="{StaticResource LabelDanger}" />
|
||||
<Label Content="DarkDangerBrush"
|
||||
Background="{DynamicResource DarkDangerBrush}"
|
||||
Foreground="White"
|
||||
BorderThickness="0" />
|
||||
|
||||
<Label Content="WarningBrush"
|
||||
Theme="{StaticResource LabelWarning}" />
|
||||
<Label Content="DarkWarningBrush"
|
||||
Background="{DynamicResource DarkWarningBrush}"
|
||||
Foreground="White"
|
||||
BorderThickness="0" />
|
||||
|
||||
<Label Content="InfoBrush"
|
||||
Theme="{StaticResource LabelInfo}" />
|
||||
<Label Content="DarkInfoBrush"
|
||||
Background="{DynamicResource DarkInfoBrush}"
|
||||
Foreground="White"
|
||||
BorderThickness="0" />
|
||||
|
||||
<Label Content="SuccessBrush"
|
||||
Theme="{StaticResource LabelSuccess}" />
|
||||
<Label Content="DarkSuccessBrush"
|
||||
Background="{DynamicResource DarkSuccessBrush}"
|
||||
Foreground="White"
|
||||
BorderThickness="0" />
|
||||
|
||||
<Label Content="AccentBrush"
|
||||
Background="{DynamicResource AccentBrush}"
|
||||
Foreground="White"
|
||||
BorderThickness="0" />
|
||||
<Label Content="DarkAccentBrush"
|
||||
Background="{DynamicResource DarkAccentBrush}"
|
||||
Foreground="White"
|
||||
BorderThickness="0" />
|
||||
<Label Content="PrimaryTextBrush"
|
||||
Background="{DynamicResource PrimaryTextBrush}"
|
||||
Foreground="{DynamicResource ThirdlyTextBrush}" />
|
||||
<Label Content="SecondaryTextBrush"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource SecondaryTextBrush}"
|
||||
Foreground="White" />
|
||||
<Label Content="ThirdlyTextBrush"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource ThirdlyTextBrush}"
|
||||
Foreground="White" />
|
||||
<Label Content="ReverseTextBrush"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource ReverseTextBrush}"
|
||||
Foreground="White" />
|
||||
<Label Content="TextIconBrush"
|
||||
Background="{DynamicResource TextIconBrush}"
|
||||
Foreground="{DynamicResource ReverseTextBrush}" />
|
||||
<Label Content="BorderBrush"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource BorderBrush}"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}" />
|
||||
<Label Content="SecondaryBorderBrush"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource SecondaryBorderBrush}"
|
||||
Foreground="White" />
|
||||
<Label Content="BackgroundBrush"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource BackgroundBrush}"
|
||||
Foreground="{DynamicResource ReverseTextBrush}" />
|
||||
<Label Content="RegionBrush"
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}" />
|
||||
<Label Content="SecondaryRegionBrush"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource SecondaryRegionBrush}"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}" />
|
||||
<Label Content="ThirdlyRegionBrush"
|
||||
Background="{DynamicResource ThirdlyRegionBrush}"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}" />
|
||||
<Label Content="TitleBrush"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource TitleBrush}"
|
||||
Foreground="White" />
|
||||
<Label Content="DefaultBrush"
|
||||
Background="{DynamicResource DefaultBrush}"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}" />
|
||||
<Label Content="DarkDefaultBrush"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource DarkDefaultBrush}"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}" />
|
||||
<Label Content="DarkMaskBrush"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource DarkMaskBrush}"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}" />
|
||||
<Label Content="DarkOpacityBrush"
|
||||
BorderThickness="0"
|
||||
Background="{DynamicResource DarkOpacityBrush}"
|
||||
Foreground="White" />
|
||||
</hc:UniformSpacingPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace HandyControlDemo.UserControl;
|
||||
|
||||
public partial class BrushDemoCtl : Avalonia.Controls.UserControl
|
||||
{
|
||||
public BrushDemoCtl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,69 @@
|
||||
<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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="800"
|
||||
d:DesignHeight="450"
|
||||
x:Class="HandyControlDemo.UserControl.ButtonDemoCtl"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<ScrollViewer>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
VerticalAlignment="Top"
|
||||
Spacing="4"
|
||||
Margin="32">
|
||||
<Button Content="default" />
|
||||
<Button Content="primary"
|
||||
Classes="primary" />
|
||||
<Button Content="success"
|
||||
Classes="success" />
|
||||
<Button Content="info"
|
||||
Classes="info" />
|
||||
<Button Content="warning"
|
||||
Classes="warning" />
|
||||
<Button Content="danger"
|
||||
Classes="danger" />
|
||||
</StackPanel>
|
||||
<hc:UniformSpacingPanel ChildWrapping="Wrap"
|
||||
Spacing="32"
|
||||
Margin="32">
|
||||
<hc:UniformSpacingPanel Orientation="Vertical"
|
||||
Spacing="32">
|
||||
<WrapPanel>
|
||||
<StackPanel>
|
||||
<Button Content="default"
|
||||
Margin="5" />
|
||||
<Button IsEnabled="False"
|
||||
Content="default"
|
||||
Margin="5" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Content="primary"
|
||||
Margin="5"
|
||||
Theme="{StaticResource ButtonPrimary}" />
|
||||
<Button IsEnabled="False"
|
||||
Content="primary"
|
||||
Margin="5"
|
||||
Theme="{StaticResource ButtonPrimary}" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Content="success"
|
||||
Margin="5"
|
||||
Theme="{StaticResource ButtonSuccess}" />
|
||||
<Button IsEnabled="False"
|
||||
Content="success"
|
||||
Margin="5"
|
||||
Theme="{StaticResource ButtonSuccess}" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Content="info"
|
||||
Margin="5"
|
||||
Theme="{StaticResource ButtonInfo}" />
|
||||
<Button IsEnabled="False"
|
||||
Content="info"
|
||||
Margin="5"
|
||||
Theme="{StaticResource ButtonInfo}" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Content="warning"
|
||||
Margin="5"
|
||||
Theme="{StaticResource ButtonWarning}" />
|
||||
<Button IsEnabled="False"
|
||||
Content="warning"
|
||||
Margin="5"
|
||||
Theme="{StaticResource ButtonWarning}" />
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Content="danger"
|
||||
Margin="5"
|
||||
Theme="{StaticResource ButtonDanger}" />
|
||||
<Button IsEnabled="False"
|
||||
Content="danger"
|
||||
Margin="5"
|
||||
Theme="{StaticResource ButtonDanger}" />
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
</hc:UniformSpacingPanel>
|
||||
</hc:UniformSpacingPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@@ -69,7 +69,7 @@ public class MainViewModel : DemoViewModelBase<DemoDataModel>
|
||||
return;
|
||||
}
|
||||
|
||||
ContentTitle = Lang.ResourceManager.GetString(DemoItemCurrent.Name);
|
||||
ContentTitle = Lang.ResourceManager.GetString(DemoItemCurrent.Name, Lang.Culture);
|
||||
});
|
||||
|
||||
//load items
|
||||
@@ -91,7 +91,7 @@ public class MainViewModel : DemoViewModelBase<DemoDataModel>
|
||||
}
|
||||
|
||||
DemoItemCurrent = item;
|
||||
ContentTitle = Lang.ResourceManager.GetString(item.Name);
|
||||
ContentTitle = Lang.ResourceManager.GetString(item.Name, Lang.Culture);
|
||||
object? demoControl = AssemblyHelper.ResolveByKey(item.TargetCtlName) ?? AssemblyHelper.CreateInternalInstance($"UserControl.{item.TargetCtlName}");
|
||||
SubContent = demoControl;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user