public override object ProvideValue(IServiceProvider serviceProvider) { if (PresentationResourceService.InstanceAvailable) { return(PresentationResourceService.GetBitmapSource(_key)); } else { return(_key); } }
/// <summary> /// Gets an image source from a resource. /// </summary> /// <exception cref="ResourceNotFoundException">The resource with the specified name does not exist</exception> public static ImageSource GetImageSource(this IResourceService resourceService, string resourceName) { if (resourceService == null) { throw new ArgumentNullException("resourceService"); } if (resourceName == null) { throw new ArgumentNullException("resourceName"); } return(PresentationResourceService.GetBitmapSource(resourceName)); }
public IndexToImageConverter(IEnumerable <string> imageResourceNames) { _imageList = new List <ImageSource>(); foreach (var name in imageResourceNames) { if (PresentationResourceService.InstanceAvailable) { _imageList.Add(PresentationResourceService.GetBitmapSource(name)); } else { _imageList.Add(null); } } }
public override object ProvideValue(IServiceProvider serviceProvider) { if (PresentationResourceService.InstanceAvailable) { var imgSource = PresentationResourceService.GetBitmapSource(_key); return(new System.Windows.Controls.Image { Height = 16, Width = 16, Source = imgSource }); } else { return(new Image()); } }