Example #1
0
        /// <summary>
        ///		Gathers all images under the given resource directory and plays them over the given duration.
        ///		Assumes that images are named on the form Foo-1.png, Foo-2.png, ...., Foo-n.png
        ///		<todo>Probably need some more error handling. </todo>
        /// </summary>
        /// <param name="resourceDirectoryName">Where to look for images</param>
        /// <param name="assembly">Assembly to find the embeded images resources</param>
        /// <param name="duration">How long one loop lasts</param>
        /// <param name="overlayColor">Tint all images with the provided color.</param>
        /// <returns></returns>
        public static IControl Animation(string resourceDirectoryName, Assembly assembly, TimeSpan duration, IObservable <Color> overlayColor = null)
        {
            var resourceCache = _resourceCaches.GetOrAdd(assembly, a => a.GetManifestResourceNames().ToImmutableHashSet());
            var resources     = resourceCache
                                .Where(k => k.Contains(resourceDirectoryName))
                                .ToImmutableSortedSet(new AnimationImageNameComparer())
                                .Select(resource => new ImageStream(scaleFactor: 1, create: () => assembly.GetManifestResourceStream(resource)))
                                .ToList();

            return(Implementation.Animate(resources, duration, overlayColor));
        }