53 lines
1.2 KiB
C#
53 lines
1.2 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Media;
|
|
using Avalonia.Svg;
|
|
using Pilz.UI.Symbols;
|
|
|
|
namespace Pilz.UI.AvaloniaUI.Symbols;
|
|
|
|
public abstract class SymbolFactory<TSymbols> : BaseSymbolFactory<TSymbols>, ISymbolFactory<TSymbols>
|
|
{
|
|
public IImage? GetImageSource(TSymbols image)
|
|
{
|
|
using var stream = GetImageRessourceStream(image);
|
|
|
|
if (stream is null)
|
|
return null;
|
|
|
|
return new SvgImage
|
|
{
|
|
Source = SvgSource.Load(stream),
|
|
};
|
|
}
|
|
|
|
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)
|
|
{
|
|
return new SymbolProxy<TSymbols>(this, image);
|
|
}
|
|
}
|