Exemplo n.º 1
0
        private void ResetZoom(ScrollViewer SV, ImageThumb ImgThumb)
        {
            void FitZoom(object NOP_0, PropertyChangedEventArgs NOP_1)
            {
                if (!ImgThumb.Equals(SV.DataContext))
                {
                    ImgThumb.PropertyChanged -= FitZoom;
                    return;
                }

                if (ImgThumb.ImgSrc != null)
                {
                    double SVRatio  = SV.ViewportWidth / SV.ViewportHeight;
                    double ImgRatio = ImgThumb.FullWidth / ImgThumb.FullHeight;
                    if (ImgRatio < SVRatio)
                    {
                        SV.ChangeView(null, null, ( float )(SV.ViewportHeight / ImgThumb.FullHeight));
                    }
                    else
                    {
                        SV.ChangeView(null, null, ( float )(SV.ViewportWidth / ImgThumb.FullWidth));
                    }
                }
            }

            if (ImgThumb.ImgSrc == null)
            {
                ImgThumb.PropertyChanged += FitZoom;
            }
            else
            {
                FitZoom(null, null);
            }
        }
Exemplo n.º 2
0
        protected override void OnNavigatedTo( NavigationEventArgs e )
        {
            base.OnNavigatedTo( e );
            Logger.Log( ID, string.Format( "OnNavigatedTo: {0}", e.SourcePageType.Name ), LogType.INFO );

            Img = e.Parameter as ImageThumb;
            SetImage();
        }
Exemplo n.º 3
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;
                }
            }
        }
Exemplo n.º 4
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();
            }
        }
Exemplo n.º 5
0
 private void SetImages(IList <ImageThumb> ImageList, ImageThumb ActiveImage)
 {
     ImagesView.ItemsSource   = ImageList;
     ImagesView.SelectedIndex = ImageList.IndexOf(ActiveImage);
 }
Exemplo n.º 6
0
 public void SaveThumb(string outFileName)
 {
     ImageThumb.Save(Dir + "\\" + outFileName, TargetFormat);
 }