add Pilz.UI & Pilz.UI.Gtk

This commit is contained in:
2025-06-16 12:19:28 +02:00
parent 299867a910
commit 6f7bb5d92c
14 changed files with 175 additions and 32 deletions

View File

@@ -0,0 +1,35 @@
using Gdk;
using Gtk;
using Pilz.UI.Symbols;
using Size = System.Drawing.Size;
namespace Pilz.UI.Gtk.Symbols;
public abstract class GtkSymbolFactory<TSymbols> : BaseSymbolFactory<TSymbols>, IGtkSymbolFactory<TSymbols>
{
public virtual Image? GetImage(TSymbols svgImage, SymbolSize size)
{
return GetImage(svgImage, ResolveCommonSize(size));
}
public virtual Image? GetImage(TSymbols svgImage, Size size)
{
using var stream = GetImageRessourceStream(svgImage);
if (stream is null)
return null;
Pixbuf pixbuf;
if (size.IsEmpty)
pixbuf = new(stream);
else
pixbuf = new(stream, size.Width, size.Height);
return GetImageFromPixbuf(pixbuf);
}
public virtual Image GetImageFromPixbuf(Pixbuf pixbuf)
{
return new Image(pixbuf);
}
}