static void AddToIconFactory(string stockId, Gdk.Pixbuf pixbuf, Gdk.Pixbuf pixbuf2x, Gtk.IconSize iconSize)
        {
            Gtk.IconSet iconSet = iconFactory.Lookup(stockId);
            if (iconSet == null)
            {
                iconSet = new Gtk.IconSet();
                iconFactory.Add(stockId, iconSet);
            }

            Gtk.IconSource source   = new Gtk.IconSource();
            Gtk.IconSource source2x = null;

            if (Platform.IsWindows)
            {
                var pixel_scale = GtkWorkarounds.GetPixelScale();
                source.Pixbuf = pixbuf.ScaleSimple((int)(pixbuf.Width * pixel_scale), (int)(pixbuf.Height * pixel_scale), Gdk.InterpType.Bilinear);
            }
            else
            {
                source.Pixbuf = pixbuf;
            }

            source.Size           = iconSize;
            source.SizeWildcarded = iconSize == Gtk.IconSize.Invalid;

            if (pixbuf2x != null)
            {
                if (GtkWorkarounds.SetSourceScale(source, 1))
                {
                    GtkWorkarounds.SetSourceScaleWildcarded(source, false);
                    source2x                = new Gtk.IconSource();
                    source2x.Pixbuf         = pixbuf2x;
                    source2x.Size           = iconSize;
                    source2x.SizeWildcarded = iconSize == Gtk.IconSize.Invalid;
                    GtkWorkarounds.SetSourceScale(source2x, 2);
                    GtkWorkarounds.SetSourceScaleWildcarded(source2x, false);
                }
            }
            else
            {
                GtkWorkarounds.SetSourceScaleWildcarded(source, true);
            }

            iconSet.AddSource(source);
            if (source2x != null)
            {
                iconSet.AddSource(source2x);
            }
        }
Пример #2
0
        static void AddIcon(string stockid, string resource)
        {
            Gtk.IconSet iconset = stock.Lookup(stockid);

            if (iconset == null)
            {
                iconset = new Gtk.IconSet();
                Gdk.Pixbuf img    = Gdk.Pixbuf.LoadFromResource(resource);
                IconSource source = new IconSource();
                source.Size           = Gtk.IconSize.Menu;
                source.SizeWildcarded = false;
                source.Pixbuf         = img;
                iconset.AddSource(source);
                stock.Add(stockid, iconset);
            }
        }
Пример #3
0
    static void AddIcon(string stockid, Gtk.IconSize iconSize, string resource)
    {
        Gtk.IconSet iconset = stock.Lookup(stockid);

        if (iconset == null)
        {
            iconset = new Gtk.IconSet();
            Gdk.Pixbuf img = Gdk.Pixbuf.LoadFromResource(resource);
            //no scaling in the given size, ...
            IconSource source = new IconSource();
            source.Size           = iconSize;
            source.SizeWildcarded = false;
            source.Pixbuf         = img;
            iconset.AddSource(source);
            //... but allow to use the image for all other sizes, too.
            source = new IconSource();
            source.SizeWildcarded = true;
            source.Pixbuf         = img;
            iconset.AddSource(source);

            stock.Add(stockid, iconset);
        }
    }
Пример #4
0
        static void AddIcon(IconFactory stock, string stockid, string resource)
        {
            Gtk.IconSet iconset = stock.Lookup (stockid);

            if (iconset != null)
                return;

            iconset = new Gtk.IconSet ();
            Gdk.Pixbuf img = Gdk.Pixbuf.LoadFromResource (resource);
            IconSource source = new IconSource ();
            source.Pixbuf = img;
            iconset.AddSource (source);
            stock.Add (stockid, iconset);
        }