示例#1
0
            public MediaView(MediaPage parent, ExtendMedia media)
            {
                this.parent = parent;

                Image.Source            = media.MediaURLHttps;
                Image.DownloadProgress += Image_DownloadProgress;
                Image.Finish           += Image_Finish;

                ImageProgressBar.Progress = 0;

                Layout.Children.Add(Image);
                Layout.Children.Add(ImageProgressBar);

                AbsoluteLayout.SetLayoutBounds(Image, new Rectangle(0, 0, 1, 1));
                AbsoluteLayout.SetLayoutFlags(Image, AbsoluteLayoutFlags.All);

                AbsoluteLayout.SetLayoutBounds(ImageProgressBar, new Rectangle(0.1, 0.45, 0.8, 0.15));
                AbsoluteLayout.SetLayoutFlags(ImageProgressBar, AbsoluteLayoutFlags.All);

                var gesture = new PanGestureRecognizer();

                gesture.PanUpdated += (sender, e) =>
                {
                    switch (e.StatusType)
                    {
                    case GestureStatus.Running:
                        Image.TranslationX = e.TotalX;
                        Image.TranslationY = e.TotalY;
                        break;

                    case GestureStatus.Completed:
                        if (Math.Abs(Image.TranslationY) > (parent.Height / 8))
                        {
                            App.Navigation.RemovePage(parent);
                        }
                        Image.TranslateTo(0, 0);
                        break;
                    }
                };
                Image.GestureRecognizers.Add(gesture);
            }