add Pilz.UI & Pilz.UI.Gtk
This commit is contained in:
35
Pilz.UI.Gtk/Symbols/GtkSymbolFactory.cs
Normal file
35
Pilz.UI.Gtk/Symbols/GtkSymbolFactory.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user