35 lines
877 B
C#
35 lines
877 B
C#
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);
|
|
}
|
|
} |