ImageButton & ImageSplitButton
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Pilz.UI.Avalonia\Pilz.UI.AvaloniaUI.csproj" />
|
<ProjectReference Include="..\Pilz.UI.AvaloniaUI\Pilz.UI.AvaloniaUI.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
25
Pilz.UI.AvaloniaUI/Controls/ImageButton.axaml
Normal file
25
Pilz.UI.AvaloniaUI/Controls/ImageButton.axaml
Normal 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>
|
||||||
55
Pilz.UI.AvaloniaUI/Controls/ImageButton.axaml.cs
Normal file
55
Pilz.UI.AvaloniaUI/Controls/ImageButton.axaml.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Pilz.UI.AvaloniaUI/Controls/ImageSplitButton.axaml
Normal file
25
Pilz.UI.AvaloniaUI/Controls/ImageSplitButton.axaml
Normal 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>
|
||||||
55
Pilz.UI.AvaloniaUI/Controls/ImageSplitButton.axaml.cs
Normal file
55
Pilz.UI.AvaloniaUI/Controls/ImageSplitButton.axaml.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Pilz.UI.AvaloniaUI/Controls/_XmlnsDefinitions.cs
Normal file
3
Pilz.UI.AvaloniaUI/Controls/_XmlnsDefinitions.cs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
using Avalonia.Metadata;
|
||||||
|
|
||||||
|
[assembly: XmlnsDefinition("https://git.pilzinsel64.de/pilz-framework/pilz", "Pilz.UI.AvaloniaUI.Controls")]
|
||||||
@@ -7,10 +7,11 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.1.3</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Avalonia" Version="11.3.8" />
|
||||||
<PackageReference Include="Avalonia.Svg" Version="11.3.0" />
|
<PackageReference Include="Avalonia.Svg" Version="11.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -18,4 +19,10 @@
|
|||||||
<ProjectReference Include="..\Pilz.UI\Pilz.UI.csproj" />
|
<ProjectReference Include="..\Pilz.UI\Pilz.UI.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Controls\ImageSplitButton.axaml.cs">
|
||||||
|
<DependentUpon>ImageSplitButton.axaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Avalonia.Media;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Media;
|
||||||
using Pilz.UI.Symbols;
|
using Pilz.UI.Symbols;
|
||||||
|
|
||||||
namespace Pilz.UI.AvaloniaUI.Symbols;
|
namespace Pilz.UI.AvaloniaUI.Symbols;
|
||||||
@@ -6,5 +7,9 @@ namespace Pilz.UI.AvaloniaUI.Symbols;
|
|||||||
public interface ISymbolFactory<TSymbols> : IBaseSymbolFactory<TSymbols>
|
public interface ISymbolFactory<TSymbols> : IBaseSymbolFactory<TSymbols>
|
||||||
{
|
{
|
||||||
IImage? GetImageSource(TSymbols image);
|
IImage? GetImageSource(TSymbols image);
|
||||||
|
Image? GetImage(TSymbols image, double width, double height);
|
||||||
|
Image? GetImage(TSymbols image, Avalonia.Size size);
|
||||||
|
Image? GetImage(TSymbols image, System.Drawing.Size size);
|
||||||
|
Image? GetImage(TSymbols image, SymbolSize size);
|
||||||
ISymbolProxy GetImage(TSymbols image);
|
ISymbolProxy GetImage(TSymbols image);
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,14 @@
|
|||||||
using Avalonia.Media;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using Pilz.UI.Symbols;
|
||||||
|
|
||||||
namespace Pilz.UI.AvaloniaUI.Symbols;
|
namespace Pilz.UI.AvaloniaUI.Symbols;
|
||||||
|
|
||||||
public interface ISymbolProxy
|
public interface ISymbolProxy
|
||||||
{
|
{
|
||||||
IImage? GetImageSource();
|
IImage? GetImageSource();
|
||||||
|
Image? GetImage(double width, double height);
|
||||||
|
Image? GetImage(Avalonia.Size size);
|
||||||
|
Image? GetImage(System.Drawing.Size size);
|
||||||
|
Image? GetImage(SymbolSize size);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Avalonia.Media;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Media;
|
||||||
using Avalonia.Svg;
|
using Avalonia.Svg;
|
||||||
using Pilz.UI.Symbols;
|
using Pilz.UI.Symbols;
|
||||||
|
|
||||||
@@ -19,6 +20,31 @@ public abstract class SymbolFactory<TSymbols> : BaseSymbolFactory<TSymbols>, ISy
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Image? GetImage(TSymbols image, double width, double height)
|
||||||
|
{
|
||||||
|
return new Image
|
||||||
|
{
|
||||||
|
Source = GetImageSource(image),
|
||||||
|
Width = width,
|
||||||
|
Height = height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image? GetImage(TSymbols image, Avalonia.Size size)
|
||||||
|
{
|
||||||
|
return GetImage(image, size.Width, size.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image? GetImage(TSymbols image, System.Drawing.Size size)
|
||||||
|
{
|
||||||
|
return GetImage(image, size.Width, size.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image? GetImage(TSymbols image, SymbolSize size)
|
||||||
|
{
|
||||||
|
return GetImage(image, ResolveCommonSize(size));
|
||||||
|
}
|
||||||
|
|
||||||
public ISymbolProxy GetImage(TSymbols image)
|
public ISymbolProxy GetImage(TSymbols image)
|
||||||
{
|
{
|
||||||
return new SymbolProxy<TSymbols>(this, image);
|
return new SymbolProxy<TSymbols>(this, image);
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Avalonia.Media;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using Pilz.UI.Symbols;
|
||||||
|
|
||||||
namespace Pilz.UI.AvaloniaUI.Symbols;
|
namespace Pilz.UI.AvaloniaUI.Symbols;
|
||||||
|
|
||||||
@@ -8,4 +10,24 @@ public class SymbolProxy<TSymbols>(SymbolFactory<TSymbols> factory, TSymbols ima
|
|||||||
{
|
{
|
||||||
return factory.GetImageSource(image);
|
return factory.GetImageSource(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Image? GetImage(double width, double height)
|
||||||
|
{
|
||||||
|
return factory.GetImage(image, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image? GetImage(Avalonia.Size size)
|
||||||
|
{
|
||||||
|
return factory.GetImage(image, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image? GetImage(System.Drawing.Size size)
|
||||||
|
{
|
||||||
|
return factory.GetImage(image, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image? GetImage(SymbolSize size)
|
||||||
|
{
|
||||||
|
return factory.GetImage(image, size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user