chore: add avalonia Label demo.
This commit is contained in:
1 parent
528f3eaf95
commit
c78e8545b8
9 files changed
+164
-22
No files matched your search
@@ -11,12 +11,16 @@
|
|||||||
<AssemblyName>HandyControlDemo</AssemblyName>
|
<AssemblyName>HandyControlDemo</AssemblyName>
|
||||||
<RootNamespace>HandyControlDemo</RootNamespace>
|
<RootNamespace>HandyControlDemo</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Data\DemoInfo.json" />
|
<None Remove="Data\DemoInfo.json" />
|
||||||
<None Remove="Resources\Img\cloud.png" />
|
<None Remove="Resources\Img\cloud.png" />
|
||||||
<None Remove="Resources\Img\icon.ico" />
|
<None Remove="Resources\Img\icon.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Data\DemoInfo.json" />
|
||||||
|
<AvaloniaResource Include="Resources\Img\cloud.png" />
|
||||||
<AvaloniaResource Include="Resources\Img\icon.ico" />
|
<AvaloniaResource Include="Resources\Img\icon.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -31,14 +35,6 @@
|
|||||||
<ProjectReference Include="..\HandyControl_Avalonia\HandyControl_Avalonia.csproj" />
|
<ProjectReference Include="..\HandyControl_Avalonia\HandyControl_Avalonia.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<AvaloniaResource Include="Resources\Img\cloud.png" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="Data\DemoInfo.json" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Lang.Designer.cs">
|
<Compile Update="Lang.Designer.cs">
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
@@ -53,9 +49,4 @@
|
|||||||
<LastGenOutput>Lang.Designer.cs</LastGenOutput>
|
<LastGenOutput>Lang.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Remove="Resources\Themes\Basic\Geometries.xaml" />
|
|
||||||
<AvaloniaXaml Include="Resources\Themes\Basic\Geometries.xaml" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<MergeResourceInclude Source="Brushes.axaml" />
|
|
||||||
<MergeResourceInclude Source="Geometries.xaml" />
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:converter="clr-namespace:HandyControlDemo.Tools.Converter">
|
||||||
|
<converter:StringRepeatConverter x:Key="StringRepeatConverter" />
|
||||||
|
</ResourceDictionary>
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
<Geometry x:Key="NewGeometry">M512 0h1216a512 512 0 1 1 0 1024H512A512 512 0 1 1 512 0zM420.16 311.04V768h74.88V433.92h2.56l228.48 334.08h72.96V311.04h-75.52v329.6h-2.56l-225.92-329.6h-74.88z m468.48 0V768h340.48v-64h-265.6V565.76h239.36v-64h-239.36V375.04h254.72v-64h-329.6z m369.28 0l131.2 456.96h80l89.6-343.68h2.56l88.96 343.68h79.36l131.84-456.96h-84.48l-85.76 347.52h-2.56l-90.24-347.52h-77.44l-90.24 347.52h-2.56l-85.76-347.52h-84.48z</Geometry>
|
<Geometry x:Key="NewGeometry">M512 0h1216a512 512 0 1 1 0 1024H512A512 512 0 1 1 512 0zM420.16 311.04V768h74.88V433.92h2.56l228.48 334.08h72.96V311.04h-75.52v329.6h-2.56l-225.92-329.6h-74.88z m468.48 0V768h340.48v-64h-265.6V565.76h239.36v-64h-239.36V375.04h254.72v-64h-329.6z m369.28 0l131.2 456.96h80l89.6-343.68h2.56l88.96 343.68h79.36l131.84-456.96h-84.48l-85.76 347.52h-2.56l-90.24-347.52h-77.44l-90.24 347.52h-2.56l-85.76-347.52h-84.48z</Geometry>
|
||||||
@@ -3,7 +3,9 @@
|
|||||||
<Styles.Resources>
|
<Styles.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<MergeResourceInclude Source="Basic/Basic.axaml" />
|
<MergeResourceInclude Source="/Resources/Themes/Basic/Brushes.axaml" />
|
||||||
|
<MergeResourceInclude Source="/Resources/Themes/Basic/Geometries.axaml" />
|
||||||
|
<MergeResourceInclude Source="/Resources/Themes/Basic/Converters.axaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Styles.Resources>
|
</Styles.Resources>
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
|
using Avalonia.Data.Converters;
|
||||||
|
|
||||||
|
namespace HandyControlDemo.Tools.Converter;
|
||||||
|
|
||||||
|
public class StringRepeatConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (value is not string strValue)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
var builder = new StringBuilder();
|
||||||
|
int num;
|
||||||
|
|
||||||
|
switch (parameter)
|
||||||
|
{
|
||||||
|
case string numStr:
|
||||||
|
{
|
||||||
|
if (!int.TryParse(numStr, out num))
|
||||||
|
{
|
||||||
|
return strValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case int intValue:
|
||||||
|
num = intValue;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return strValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
builder.Append(strValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<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.LabelDemo">
|
||||||
|
<hc:UniformSpacingPanel Margin="32"
|
||||||
|
Spacing="32"
|
||||||
|
ChildWrapping="Wrap">
|
||||||
|
<hc:UniformSpacingPanel Spacing="5"
|
||||||
|
Orientation="Vertical">
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle" />
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"
|
||||||
|
Theme="{StaticResource LabelDanger}" />
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"
|
||||||
|
Theme="{StaticResource LabelInfo}" />
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"
|
||||||
|
Theme="{StaticResource LabelPrimary}" />
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"
|
||||||
|
Theme="{StaticResource LabelSuccess}" />
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"
|
||||||
|
Theme="{StaticResource LabelWarning}" />
|
||||||
|
</hc:UniformSpacingPanel>
|
||||||
|
<hc:UniformSpacingPanel Spacing="5"
|
||||||
|
Orientation="Vertical">
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"
|
||||||
|
Theme="{StaticResource LabelDefault.Small}" />
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"
|
||||||
|
Theme="{StaticResource LabelDanger.Small}" />
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"
|
||||||
|
Theme="{StaticResource LabelInfo.Small}" />
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"
|
||||||
|
Theme="{StaticResource LabelPrimary.Small}" />
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"
|
||||||
|
Theme="{StaticResource LabelSuccess.Small}" />
|
||||||
|
<Label Content="TitleTitleTitleTitleTitleTitleTitleTitleTitleTitle"
|
||||||
|
Theme="{StaticResource LabelWarning.Small}" />
|
||||||
|
</hc:UniformSpacingPanel>
|
||||||
|
</hc:UniformSpacingPanel>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace HandyControlDemo.UserControl;
|
||||||
|
|
||||||
|
public partial class LabelDemo : Avalonia.Controls.UserControl
|
||||||
|
{
|
||||||
|
public LabelDemo()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,6 +57,15 @@
|
|||||||
BasedOn="{StaticResource LabelDefault}"
|
BasedOn="{StaticResource LabelDefault}"
|
||||||
TargetType="Label" />
|
TargetType="Label" />
|
||||||
|
|
||||||
|
<ControlTheme x:Key="LabelDefault.Small"
|
||||||
|
BasedOn="{StaticResource LabelDefault}"
|
||||||
|
TargetType="Label">
|
||||||
|
<Setter Property="Height"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
<ControlTheme x:Key="LabelPrimary"
|
<ControlTheme x:Key="LabelPrimary"
|
||||||
BasedOn="{StaticResource LabelBaseStyle}"
|
BasedOn="{StaticResource LabelBaseStyle}"
|
||||||
TargetType="Label">
|
TargetType="Label">
|
||||||
@@ -64,6 +73,15 @@
|
|||||||
Value="{DynamicResource PrimaryBrush}" />
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="LabelPrimary.Small"
|
||||||
|
BasedOn="{StaticResource LabelPrimary}"
|
||||||
|
TargetType="Label">
|
||||||
|
<Setter Property="Height"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
<ControlTheme x:Key="LabelSuccess"
|
<ControlTheme x:Key="LabelSuccess"
|
||||||
BasedOn="{StaticResource LabelBaseStyle}"
|
BasedOn="{StaticResource LabelBaseStyle}"
|
||||||
TargetType="Label">
|
TargetType="Label">
|
||||||
@@ -71,6 +89,15 @@
|
|||||||
Value="{DynamicResource SuccessBrush}" />
|
Value="{DynamicResource SuccessBrush}" />
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="LabelSuccess.Small"
|
||||||
|
BasedOn="{StaticResource LabelSuccess}"
|
||||||
|
TargetType="Label">
|
||||||
|
<Setter Property="Height"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
<ControlTheme x:Key="LabelInfo"
|
<ControlTheme x:Key="LabelInfo"
|
||||||
BasedOn="{StaticResource LabelBaseStyle}"
|
BasedOn="{StaticResource LabelBaseStyle}"
|
||||||
TargetType="Label">
|
TargetType="Label">
|
||||||
@@ -78,6 +105,15 @@
|
|||||||
Value="{DynamicResource InfoBrush}" />
|
Value="{DynamicResource InfoBrush}" />
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="LabelInfo.Small"
|
||||||
|
BasedOn="{StaticResource LabelInfo}"
|
||||||
|
TargetType="Label">
|
||||||
|
<Setter Property="Height"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
<ControlTheme x:Key="LabelWarning"
|
<ControlTheme x:Key="LabelWarning"
|
||||||
BasedOn="{StaticResource LabelBaseStyle}"
|
BasedOn="{StaticResource LabelBaseStyle}"
|
||||||
TargetType="Label">
|
TargetType="Label">
|
||||||
@@ -85,10 +121,28 @@
|
|||||||
Value="{DynamicResource WarningBrush}" />
|
Value="{DynamicResource WarningBrush}" />
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="LabelWarning.Small"
|
||||||
|
BasedOn="{StaticResource LabelWarning}"
|
||||||
|
TargetType="Label">
|
||||||
|
<Setter Property="Height"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
<ControlTheme x:Key="LabelDanger"
|
<ControlTheme x:Key="LabelDanger"
|
||||||
BasedOn="{StaticResource LabelBaseStyle}"
|
BasedOn="{StaticResource LabelBaseStyle}"
|
||||||
TargetType="Label">
|
TargetType="Label">
|
||||||
<Setter Property="Background"
|
<Setter Property="Background"
|
||||||
Value="{DynamicResource DangerBrush}" />
|
Value="{DynamicResource DangerBrush}" />
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="LabelDanger.Small"
|
||||||
|
BasedOn="{StaticResource LabelDanger}"
|
||||||
|
TargetType="Label">
|
||||||
|
<Setter Property="Height"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
</ControlTheme>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
Reference in new issue
Block a user