ImageButton & ImageSplitButton

This commit is contained in:
Pilzinsel64
2025-11-07 10:48:36 +01:00
parent 0e11a0f9c4
commit 1ab775aa3e
11 changed files with 235 additions and 6 deletions

View File

@@ -0,0 +1,25 @@
<Button 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="Pilz.UI.AvaloniaUI.Controls.ImageButton">
<StackPanel
Orientation="Horizontal"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="6"
>
<Image
VerticalAlignment="Center"
Width="16"
Height="16"
x:Name="ButtonImage"
/>
<TextBlock
VerticalAlignment="Center"
x:Name="ButtonText"
/>
</StackPanel>
</Button>

View File

@@ -0,0 +1,55 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
namespace Pilz.UI.AvaloniaUI.Controls;
public partial class ImageButton : Button
{
protected override Type StyleKeyOverride => typeof(Button);
public ImageButton()
{
InitializeComponent();
}
public string? Text
{
get => ButtonText.Text;
set => ButtonText.Text = value;
}
public IImage? ImageSource
{
get => ButtonImage.Source;
set => ButtonImage.Source = value;
}
public double ImageWidth
{
get => ButtonImage.Width;
set => ButtonImage.Width = value;
}
public double ImageHeight
{
get => ButtonImage.Height;
set => ButtonImage.Height = value;
}
public double ImageQuadSize
{
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

@@ -0,0 +1,25 @@
<SplitButton 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="Pilz.UI.AvaloniaUI.Controls.ImageSplitButton">
<StackPanel
Orientation="Horizontal"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="6"
>
<Image
VerticalAlignment="Center"
Width="16"
Height="16"
x:Name="ButtonImage"
/>
<TextBlock
VerticalAlignment="Center"
x:Name="ButtonText"
/>
</StackPanel>
</SplitButton>

View File

@@ -0,0 +1,55 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
namespace Pilz.UI.AvaloniaUI.Controls;
public partial class ImageSplitButton : SplitButton
{
protected override Type StyleKeyOverride => typeof(SplitButton);
public ImageSplitButton()
{
InitializeComponent();
}
public string? Text
{
get => ButtonText.Text;
set => ButtonText.Text = value;
}
public IImage? ImageSource
{
get => ButtonImage.Source;
set => ButtonImage.Source = value;
}
public double ImageWidth
{
get => ButtonImage.Width;
set => ButtonImage.Width = value;
}
public double ImageHeight
{
get => ButtonImage.Height;
set => ButtonImage.Height = value;
}
public double ImageQuadSize
{
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

@@ -0,0 +1,3 @@
using Avalonia.Metadata;
[assembly: XmlnsDefinition("https://git.pilzinsel64.de/pilz-framework/pilz", "Pilz.UI.AvaloniaUI.Controls")]