示例#1
0
        public static void LoadIcon(this Gtk.Image image, string iconId, Gtk.IconSize size)
        {
            AnimatedImageInfo ainfo = animatedImages.Select(a => (AnimatedImageInfo)a.Target).FirstOrDefault(a => a != null && a.Image == image);

            if (ainfo != null)
            {
                if (ainfo.AnimatedIcon.AnimationSpec == iconId)
                {
                    return;
                }
                UnregisterImageAnimation(ainfo);
            }
            if (IsAnimation(iconId, size))
            {
                var anim = GetAnimatedIcon(iconId);
                ainfo           = new AnimatedImageInfo(image, anim);
                ainfo.Animation = anim.StartAnimation(delegate(Xwt.Drawing.Image pix) {
                    image.Pixbuf = pix.ToPixbuf();
                });
                animatedImages.Add(new WeakReference(ainfo));
            }
            else
            {
                image.SetFromStock(iconId, size);
            }
        }