Exemplo n.º 1
0
 public CommandPacket(string path, ImageLoadingOptions option, IObserver <ImageSourceContainer> observer)
 {
     this.File     = null;
     this.path     = path;
     this.Observer = observer;
     this.Option   = option;
 }
Exemplo n.º 2
0
 public CommandPacket(Record file, ImageLoadingOptions option, IObserver <ImageSourceContainer> observer)
 {
     this.File     = file;
     this.path     = null;
     this.Observer = observer;
     this.Option   = option;
 }
Exemplo n.º 3
0
 private void RequestLoadingToTask
     (Record file, string path, ImageLoadingOptions option, IObserver <ImageSourceContainer> observer,
     bool hasPriority, CancellationToken token)
 {
     if ((file != null || path != null) && !token.IsCancellationRequested)
     {
         this.RequestLoadingMain(file, path, option, observer, hasPriority, token);
     }
 }
Exemplo n.º 4
0
        private void RequestLoadingMain
            (Record file, string path, ImageLoadingOptions option, IObserver <ImageSourceContainer> observer,
            bool hasPriority, CancellationToken token)
        {
            var filePath = file?.FullPath ?? path;

            if (filePath == null)
            {
                return;
            }


            if (observer == null)
            {
                observer = emptyObserver;
            }


            if (this.TryGetImage(filePath, option.Quality, out var image))
            {
                if (image != null && image.Image != null)
                {
                    if (file != null && (file.Width <= 0 || file.Height <= 0) &&
                        image.Information != null)
                    {
                        file.Width  = image.Information.GraphicSize.Width;
                        file.Height = image.Information.GraphicSize.Height;
                    }
                    observer.OnNext(image);
                    observer.OnCompleted();
                    return;
                }
            }

            if (this.MetaImageExtention != null &&
                this.MetaImageExtention.Contains(System.IO.Path.GetExtension(filePath).ToLower()))
            {
                observer.OnCompleted();
                return;
            }

            var request = (file != null)
                ? new CommandPacket(file, option.Clone(), observer)
                : new CommandPacket(filePath, option.Clone(), observer);

            request.CancellationToken = token;


            if (option.Quality == ImageQuality.ThumbNail)
            {
                this.thumbNailLoadRequest.Enqueue(request);
            }
            else if (hasPriority)
            {
                this.currentFileLoadRequest.Enqueue(request);
            }
            else if (option.Quality == ImageQuality.LowQuality)
            {
                this.lowQualityPreLoadRequest.Enqueue(request);
            }
            else
            {
                this.highQualityPreLoadRequest.Enqueue(request);
            }
            if (this.ActionQueueSubject.HasObservers)
            {
                this.ActionQueueSubject.OnNext(Unit.Default);
            }
        }
Exemplo n.º 5
0
 public void RequestLoading
     (string path, ImageLoadingOptions option, IObserver <ImageSourceContainer> observer,
     bool hasPriority, CancellationToken token)
 => this.RequestLoadingToTask(null, path, option, observer, hasPriority, token);
Exemplo n.º 6
0
 public void RequestLoading
     (Record file, ImageLoadingOptions option, IObserver <ImageSourceContainer> observer,
     bool hasPriority, CancellationToken token)
 => this.RequestLoadingToTask(file, file?.FullPath, option, observer, hasPriority, token);