Exemplo n.º 1
0
        /// <summary>
        /// Loads the image into given ImageViewAsync using defined parameters.
        /// </summary>
        /// <param name="parameters">Parameters for loading the image.</param>
        /// <param name="imageView">Image view that should receive the image.</param>
        public static IScheduledWork Into(this TaskParameter parameters, EvasImageContainer imageView)
        {
            var target = new EvasImageTarget(imageView);

            if (parameters.Source != ImageSource.Stream && string.IsNullOrWhiteSpace(parameters.Path))
            {
                target.SetAsEmpty(null);
                parameters.TryDispose();
                return(null);
            }

            var task = ImageService.CreateTask(parameters, target);

            ImageService.Instance.LoadImage(task);
            return(task);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the image into given imageView using defined parameters.
        /// IMPORTANT: It throws image loading exceptions - you should handle them
        /// </summary>
        /// <returns>An awaitable Task.</returns>
        /// <param name="parameters">Parameters for loading the image.</param>
        /// <param name="imageView">Image view that should receive the image.</param>
        public static Task <IScheduledWork> IntoAsync(this TaskParameter parameters, EvasImageContainer imageView)
        {
            var userErrorCallback = parameters.OnError;
            var finishCallback    = parameters.OnFinish;
            var tcs = new TaskCompletionSource <IScheduledWork>();

            parameters
            .Error(ex =>
            {
                tcs.TrySetException(ex);
                userErrorCallback?.Invoke(ex);
            })
            .Finish(scheduledWork =>
            {
                finishCallback?.Invoke(scheduledWork);
                tcs.TrySetResult(scheduledWork);
            })
            .Into(imageView);

            return(tcs.Task);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Loads the image into given imageView using defined parameters.
 /// IMPORTANT: It throws image loading exceptions - you should handle them
 /// </summary>
 /// <returns>An awaitable Task.</returns>
 /// <param name="parameters">Parameters for loading the image.</param>
 /// <param name="imageView">Image view that should receive the image.</param>
 public static Task <IScheduledWork> IntoAsync(this TaskParameter parameters, EvasImageContainer imageView)
 {
     return(parameters.IntoAsync(param => param.Into(imageView)));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Loads the image into given ImageViewAsync using defined parameters.
        /// </summary>
        /// <param name="parameters">Parameters for loading the image.</param>
        /// <param name="imageView">Image view that should receive the image.</param>
        public static IScheduledWork Into(this TaskParameter parameters, EvasImageContainer imageView)
        {
            var target = new EvasImageTarget(imageView);

            return(parameters.Into(target));
        }