Пример #1
0
        /// <summary>Sends the request off and defines a callback to run when the result is ready.</summary>
        /// <param name="imageReady">The callback to run when the graphic has been retrieved.
        /// Note that the callback must check if the result is <see cref="PowerUI.ImagePackage.Ok"/>.</param>
        public void Get(OnImageReady imageReady)
        {
            ImageReady += imageReady;

            if (string.IsNullOrEmpty(Url))
            {
                ImageReady(this);
                return;
            }

            // Exception - Is it an animation that has been cached?
            if (File.Filetype == "spa")
            {
                // Might already be loaded - let's check:
                SPA animation = SPA.Get(Url);
                if (animation != null)
                {
                    //It's already been loaded - use that.
                    GotGraphic(animation);
                    return;
                }
            }

            // Do we have a file protocol handler available?
            FileProtocol fileProtocol = File.Handler;

            if (fileProtocol != null)
            {
                fileProtocol.OnGetGraphic(this, File);
            }
        }
Пример #2
0
        /// <summary>Attempts to get a graphic from the given location using this protocol.</summary>
        /// <param name="package">The image request. GotGraphic must be called on this when the protocol is done.</param>
        /// <param name="path">The location of the file to retrieve using this protocol.</param>
        public override void OnGetGraphic(ImagePackage package, FilePath path)
        {
            if (path.Filetype == "spa")
            {
                // Grab a runtime SPA:
                package.GotGraphic(SPA.Get(path.Path));
                return;
            }

            package.GotGraphic(ImageCache.Get(path.Path));
        }