Ejemplo n.º 1
0
        static Xwt.Drawing.Image LoadStockIcon(RuntimeAddin addin, string stockId, string resource, string imageFile, string iconId, Gtk.IconSize iconSize, string animation, bool forceWildcard)
        {
            try {
                AnimatedIcon    animatedIcon = null;
                Func <Stream[]> imageLoader  = null;

                Xwt.Drawing.Image img = null;

                if (!string.IsNullOrEmpty(resource) || !string.IsNullOrEmpty(imageFile))
                {
                    if (resource != null)
                    {
                        CustomImageLoader loader;
                        if (!imageLoaders.TryGetValue(addin, out loader))
                        {
                            loader = imageLoaders [addin] = new CustomImageLoader(addin);
                        }
                        img = Xwt.Drawing.Image.FromCustomLoader(loader, resource);
                    }
                    else
                    {
                        img = Xwt.Drawing.Image.FromFile(addin.GetFilePath(imageFile));
                    }
                }
                else if (!string.IsNullOrEmpty(iconId))
                {
                    var id = GetStockIdForImageSpec(addin, iconId, iconSize);
                    img = GetIcon(id, iconSize);
                    // This may be an animation, get it
                    animationFactory.TryGetValue(id, out animatedIcon);
                }
                else if (!string.IsNullOrEmpty(animation))
                {
                    string id = GetStockIdForImageSpec(addin, "animation:" + animation, iconSize);
                    img = GetIcon(id, iconSize);
                    // This *should* be an animation
                    animationFactory.TryGetValue(id, out animatedIcon);
                }

                if (animatedIcon != null)
                {
                    AddToAnimatedIconFactory(stockId, animatedIcon);
                }

                if (imageLoader != null)
                {
                    img.SetStreamSource(imageLoader);
                }

                return(img);
            } catch (Exception ex) {
                LoggingService.LogError(string.Format("Error loading icon '{0}'", stockId), ex);
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static Xwt.Drawing.Image GetImageResource(this RuntimeAddin addin, string resource)
        {
            var loader = new CustomImageLoader(addin);

            return(Xwt.Drawing.Image.FromCustomLoader(loader, resource));
        }
Ejemplo n.º 3
0
		public static Xwt.Drawing.Image GetImageResource (this RuntimeAddin addin, string resource)
		{
			var loader = new CustomImageLoader (addin);
			return Xwt.Drawing.Image.FromCustomLoader (loader, resource);
		}
Ejemplo n.º 4
0
		static Xwt.Drawing.Image LoadStockIcon (RuntimeAddin addin, string stockId, string resource, string imageFile, string iconId, Gtk.IconSize iconSize, string animation, bool forceWildcard)
		{
			try {
				AnimatedIcon animatedIcon = null;
				Func<Stream[]> imageLoader = null;

				Xwt.Drawing.Image img = null;

				if (!string.IsNullOrEmpty (resource) || !string.IsNullOrEmpty (imageFile)) {

					if (resource != null) {
						CustomImageLoader loader;
						if (!imageLoaders.TryGetValue (addin, out loader))
							loader = imageLoaders [addin] = new CustomImageLoader (addin);
						img = Xwt.Drawing.Image.FromCustomLoader (loader, resource);
					}
					else {
						img = Xwt.Drawing.Image.FromFile (addin.GetFilePath (imageFile));
					}
				} else if (!string.IsNullOrEmpty (iconId)) {
					var id = GetStockIdForImageSpec (addin, iconId, iconSize);
					img = GetIcon (id, iconSize);
					// This may be an animation, get it
					animationFactory.TryGetValue (id, out animatedIcon);
				} else if (!string.IsNullOrEmpty (animation)) {
					string id = GetStockIdForImageSpec (addin, "animation:" + animation, iconSize);
					img = GetIcon (id, iconSize);
					// This *should* be an animation
					animationFactory.TryGetValue (id, out animatedIcon);
				}

				if (animatedIcon != null)
					AddToAnimatedIconFactory (stockId, animatedIcon);

				if (imageLoader != null)
					img.SetStreamSource (imageLoader);

				return img;

			} catch (Exception ex) {
				LoggingService.LogError (string.Format ("Error loading icon '{0}'", stockId), ex);
				return null;
			}
		}