This commit is contained in:
2025-11-16 08:42:15 +01:00
parent 14d8e83a64
commit f0057ccad2
12 changed files with 146 additions and 50 deletions

View File

@@ -1,30 +1,29 @@
<Button xmlns="https://github.com/avaloniaui" <Button
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
HorizontalContentAlignment="Center" xmlns:symbols="clr-namespace:Pilz.UI.Symbols;assembly=Pilz.UI"
VerticalContentAlignment="Center" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Pilz.UI.AvaloniaUI.Controls.ImageButton"> HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
x:Class="Pilz.UI.AvaloniaUI.Controls.ImageButton">
<StackPanel <StackPanel
Orientation="Horizontal" Orientation="Horizontal"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
> Spacing="6">
<Image <Image
x:Name="ButtonImage" x:Name="ButtonImage"
Margin="0, 0, 0, 6"
VerticalAlignment="Center" VerticalAlignment="Center"
Width="16" Width="{x:Static symbols:SymbolGlobals.DefaultImageSmallSize}"
Height="16" Height="{x:Static symbols:SymbolGlobals.DefaultImageSmallSize}"
IsVisible="False" IsVisible="False"/>
/>
<TextBlock <TextBlock
x:Name="ButtonText" x:Name="ButtonText"
VerticalAlignment="Center" VerticalAlignment="Center"/>
/>
</StackPanel> </StackPanel>
</Button> </Button>

View File

@@ -41,7 +41,7 @@ public partial class ImageButton : Button
set => ButtonImage.Height = value; set => ButtonImage.Height = value;
} }
public double ImageQuadSize public double ImageWeight
{ {
get => ButtonImage.Width; get => ButtonImage.Width;
set => ButtonImage.Width = ButtonImage.Height = value; set => ButtonImage.Width = ButtonImage.Height = value;

View File

@@ -0,0 +1,29 @@
<DropDownButton
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:symbols="clr-namespace:Pilz.UI.Symbols;assembly=Pilz.UI"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
x:Class="Pilz.UI.AvaloniaUI.Controls.ImageDropDownButton">
<StackPanel
Orientation="Horizontal"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="6">
<Image
x:Name="ButtonImage"
VerticalAlignment="Center"
Width="{x:Static symbols:SymbolGlobals.DefaultImageSmallSize}"
Height="{x:Static symbols:SymbolGlobals.DefaultImageSmallSize}"
IsVisible="False"/>
<TextBlock
x:Name="ButtonText"
VerticalAlignment="Center"/>
</StackPanel>
</DropDownButton>

View File

@@ -0,0 +1,59 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
namespace Pilz.UI.AvaloniaUI.Controls;
public partial class ImageDropDownButton : DropDownButton
{
protected override Type StyleKeyOverride => typeof(SplitButton);
public ImageDropDownButton()
{
InitializeComponent();
}
public string? Text
{
get => ButtonText.Text;
set => ButtonText.Text = value;
}
public IImage? ImageSource
{
get => ButtonImage.Source;
set
{
ButtonImage.Source = value;
ButtonImage.IsVisible = value != null;
}
}
public double ImageWidth
{
get => ButtonImage.Width;
set => ButtonImage.Width = value;
}
public double ImageHeight
{
get => ButtonImage.Height;
set => ButtonImage.Height = value;
}
public double ImageWeight
{
get => ButtonImage.Width;
set => ButtonImage.Width = ButtonImage.Height = value;
}
public Size ImageSize
{
get => new(ButtonImage.Width, ButtonImage.Height);
set
{
ButtonImage.Width = value.Width;
ButtonImage.Height = value.Height;
}
}
}

View File

@@ -1,30 +1,29 @@
<SplitButton xmlns="https://github.com/avaloniaui" <SplitButton
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
HorizontalContentAlignment="Center" xmlns:symbols="clr-namespace:Pilz.UI.Symbols;assembly=Pilz.UI"
VerticalContentAlignment="Center" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Pilz.UI.AvaloniaUI.Controls.ImageSplitButton"> HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
x:Class="Pilz.UI.AvaloniaUI.Controls.ImageSplitButton">
<StackPanel <StackPanel
Orientation="Horizontal" Orientation="Horizontal"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
> Spacing="6">
<Image <Image
x:Name="ButtonImage" x:Name="ButtonImage"
Margin="0, 0, 0, 6"
VerticalAlignment="Center" VerticalAlignment="Center"
Width="16" Width="{x:Static symbols:SymbolGlobals.DefaultImageSmallSize}"
Height="16" Height="{x:Static symbols:SymbolGlobals.DefaultImageSmallSize}"
IsVisible="False" IsVisible="False"/>
/>
<TextBlock <TextBlock
x:Name="ButtonText" x:Name="ButtonText"
VerticalAlignment="Center" VerticalAlignment="Center"/>
/>
</StackPanel> </StackPanel>
</SplitButton> </SplitButton>

View File

@@ -41,7 +41,7 @@ public partial class ImageSplitButton : SplitButton
set => ButtonImage.Height = value; set => ButtonImage.Height = value;
} }
public double ImageQuadSize public double ImageWeight
{ {
get => ButtonImage.Width; get => ButtonImage.Width;
set => ButtonImage.Width = ButtonImage.Height = value; set => ButtonImage.Width = ButtonImage.Height = value;

View File

@@ -28,6 +28,7 @@
x:Name="ImageTitle" x:Name="ImageTitle"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
Width="16"
/> />
<TextBlock <TextBlock

View File

@@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<Version>1.2.8</Version> <Version>1.2.9</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -24,6 +24,10 @@
<Compile Update="Controls\ImageSplitButton.axaml.cs"> <Compile Update="Controls\ImageSplitButton.axaml.cs">
<DependentUpon>ImageSplitButton.axaml</DependentUpon> <DependentUpon>ImageSplitButton.axaml</DependentUpon>
</Compile> </Compile>
<Compile Update="Controls\ImageDropDownButton.axaml.cs">
<DependentUpon>ImageDropDownButton.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -8,7 +8,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<Version>3.1.1</Version> <Version>3.1.2</Version>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@@ -13,9 +13,9 @@ public abstract class BaseSymbolFactory<TSymbols> : IBaseSymbolFactory<TSymbols>
return size switch return size switch
{ {
SymbolSize.Default => Size.Empty, SymbolSize.Default => Size.Empty,
SymbolSize.Small => new Size(16, 16), SymbolSize.Small => new Size(SymbolGlobals.DefaultImageSmallSize, SymbolGlobals.DefaultImageSmallSize),
SymbolSize.Medium => new Size(20, 20), SymbolSize.Medium => new Size(SymbolGlobals.DefaultImageMediumSize, SymbolGlobals.DefaultImageMediumSize),
SymbolSize.Large => new Size(32, 32), SymbolSize.Large => new Size(SymbolGlobals.DefaultImageLargeSize, SymbolGlobals.DefaultImageLargeSize),
_ => new Size((int)size, (int)size), _ => new Size((int)size, (int)size),
}; };
} }

View File

@@ -0,0 +1,8 @@
namespace Pilz.UI.Symbols;
public static class SymbolGlobals
{
public static int DefaultImageSmallSize { get;} = 16;
public static int DefaultImageMediumSize { get;} = 20;
public static int DefaultImageLargeSize { get;} = 32;
}

View File

@@ -8,17 +8,14 @@ public enum SymbolSize
Default, Default,
/// <summary> /// <summary>
/// Resizes the symbol to 16 x 16 pixels. /// Resizes the symbol to 16 x 16 pixels.
/// <br/><b>Deprecated!</b> This is just present due legacy reasons. Use <see cref="x16"/> instead.
/// </summary> /// </summary>
Small, Small,
/// <summary> /// <summary>
/// Resizes the symbol to 20 x 20 pixels. /// Resizes the symbol to 20 x 20 pixels.
/// <br/><b>Deprecated!</b> This is just present due legacy reasons. Use <see cref="x20"/> instead.
/// </summary> /// </summary>
Medium, Medium,
/// <summary> /// <summary>
/// Resizes the symbol to 32 x 32 pixels. /// Resizes the symbol to 32 x 32 pixels.
/// <br/><b>Deprecated!</b> This is just present due legacy reasons. Use <see cref="x32"/> instead.
/// </summary> /// </summary>
Large, Large,
/// <summary> /// <summary>