Beispiel #1
0
        private async void TryUseImage(string Url)
        {
            WBackgroundTransfer Transfer = new WBackgroundTransfer();
            Guid id = Guid.Empty;

            Transfer.OnThreadComplete += ( DTheradCompleteArgs DArgs ) =>
            {
                if (DArgs.Id.Equals(id))
                {
                    ApplyImage(DArgs.FileLocation);
                }
            };

            string fileName      = Url.Substring(Url.LastIndexOf('/') + 1);
            string imageLocation = FileLinks.ROOT_IMAGE + fileName;

            if (Shared.Storage.FileExists(imageLocation))
            {
                ApplyImage(imageLocation);
            }
            else
            {
                id = await Transfer.RegisterImage(Url, imageLocation);
            }
        }
Beispiel #2
0
        public async void RegisterImage(IIllusUpdate Item)
        {
            lock ( ImgThumbs )
            {
                if (ImgThumbs.Contains(Item))
                {
                    return;
                }
                ImgThumbs.Add(Item);
            }

            ImageThumb Thumb;

            if (Item.ImgThumb == null)
            {
                string url = Item.SrcUrl;

                // Use filename as <id>.<format> since format maybe <id>.png or <id>.jpg
                string fileName      = url.Substring(url.LastIndexOf('/') + 1);
                string imageLocation = FileLinks.ROOT_IMAGE + fileName;

                Thumb           = new ImageThumb(imageLocation, 200, null);
                Thumb.Reference = url;

                Item.ImgThumb = Thumb;
            }
            else
            {
                Thumb = Item.ImgThumb;
            }

            await Thumb.Set();

            if (Thumb.IsDownloadNeeded)
            {
                Guid G = await Transfer.RegisterImage(Thumb.Reference, Thumb.Location);

                Thumb.Id = G;
            }
            else
            {
                lock (ImgThumbs) ImgThumbs.Remove(Item);
                Item.Update();
            }
        }
Beispiel #3
0
            private async void TryUseImage( string Url )
            {
                WBackgroundTransfer Transfer = new WBackgroundTransfer();
                Guid id = Guid.Empty;

                Transfer.OnThreadComplete += ( DTheradCompleteArgs DArgs ) =>
                {
                    if ( DArgs.Id.Equals( id ) )
                    {
                        ApplyImage( DArgs.FileLocation );
                    }
                };

                string fileName = Url.Substring( Url.LastIndexOf( '/' ) + 1 );
                string imageLocation = FileLinks.ROOT_IMAGE + fileName;

                if ( Shared.Storage.FileExists( imageLocation ) )
                {
                    ApplyImage( imageLocation );
                }
                else
                {
                    id = await Transfer.RegisterImage( Url, imageLocation );
                }
            }
Beispiel #4
0
        private async void SetTemplate()
        {
            Chapter C = ReaderPage.CurrentChapter;
            if ( !C.HasIllustrations )
            {
                AsyncTryOut<Chapter> ASC;
                if ( ASC = await TryFoundIllustration() )
                {
                    C = ASC.Out;
                }
                else
                {
                    ChapterList.Visibility = Visibility.Collapsed;
                    return;
                }
            }

            ChapterList.Visibility = Visibility.Collapsed;

            string[] ImagePaths = Shared.Storage.GetString( C.IllustrationPath )
                .Split( new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries );

            int l = ImagePaths.Length;

            WBackgroundTransfer Transfer = new WBackgroundTransfer();

            List<ImageThumb> ImgThumbs = new List<ImageThumb>();

            Transfer.OnThreadComplete += Transfer_OnThreadComplete;
            for ( int i = 0; i < l; i++ )
            {
                // Retrive URL
                string url = ImagePaths[ i ];

                // Use filename as <id>.<format> since format maybe <id>.png or <id>.jpg
                string fileName = url.Substring( url.LastIndexOf( '/' ) + 1 );
                string imageLocation = FileLinks.ROOT_IMAGE + fileName;

                ImageThumb Img = new ImageThumb( imageLocation, 200, null );
                Img.Reference = url;
                ImgThumbs.Add( Img );
            }

            MainView.ItemsSource = ImgThumbs;

            foreach( ImageThumb Thumb in ImgThumbs )
            {
                await Thumb.Set();
                if( Thumb.IsDownloadNeeded )
                {
                    Guid G = await Transfer.RegisterImage( Thumb.Reference, Thumb.Location );
                    Thumb.Id = G;
                }
            }
        }