Exemplo n.º 1
0
        //swipe action
        private void OnMediaPan(object sender, PanUpdatedEventArgs e)
        {
            switch (e.StatusType)
            {
            case GestureStatus.Started:
                break;

            case GestureStatus.Running:

                UIMediaContent.TranslationX = e.TotalX;
                break;

            case GestureStatus.Completed:

                double x = UIMediaContent.TranslationX;

                double Threshhold = (Booru.ScreenWidth / 3);     //aka 1/3 of the screen
                if (Threshhold < Math.Abs(x))
                {
                    //A new Image Will Load, Clear the Current one
                    UIMediaContent.Children.Clear();

                    //place on oppsite side (so the next one slides in)
                    //[last] <- [current] <- [next]
                    //   ^----------------------^

                    bool Direction = (x < 0) ? true : false;

                    switch (Direction)
                    {
                    case true:        // swipe right ->
                        UIMediaContent.TranslationX = Booru.ScreenWidth;
                        OnSwipeLeft();
                        break;

                    case false:        //swipe left <-
                        UIMediaContent.TranslationX = -Booru.ScreenWidth;
                        OnSwipeRight();
                        break;
                    }
                }
                UIMediaContent.TranslateTo(0, 0);
                break;
            }
        }
Exemplo n.º 2
0
        //templates
        public void UpdateMediaLayer()
        {
            UIMediaContent.Children.Clear();

            dynamic media;

            switch (Post.FileExt)
            {
            case "gif":
                media = WebVeiwTemplate(Post.FileUrl.AbsoluteUri);
                //UpdateNotification("this is a gif", Color.LightGreen, 2);
                break;

            case "webm":    //Webm's used to work but dont anymore, hmm
                media = new VideoPlayer
                {
                    Source       = VideoSource.FromUri(Post.FileUrl),
                    AutoPlay     = true,
                    Volume       = 0,//Default Mute
                    WidthRequest = Booru.ScreenWidth,
                    //height causes streaching
                };
                Task.Run(async() =>
                {
                    Indicate();
                    while (((VideoPlayer)media).IsLoading)
                    {
                        if ((((VideoPlayer)media).IsLoading == false))
                        {
                            Indicate(false);
                            return;
                        }
                        await Task.Delay(100);
                    }
                    ;
                });

                UpdateNotification("Webm's Muted. (volume control not implemented)", Color.LightGreen, 2);
                break;

            case "png":
            case "jpg":
            case "bmp":
                media = new Image
                {
                    Source          = ImageSource.FromUri(Post.SampleUrl),
                    HeightRequest   = Booru.ScreenHeight / 2,
                    WidthRequest    = Booru.ScreenWidth,
                    VerticalOptions = LayoutOptions.Center,
                };
                break;

            default:
                media = new Label
                {
                    Text = $"Media format not implemented: {Post.FileExt}",
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    TextColor = Color.Chartreuse,
                };
                break;
            }

            var result = new StackLayout
            {
                //known bug: gif/webView doesn't inherit this background color...
                BackgroundColor = Color.FromHex("#648F8F8F"),
                Children        = { media },
            };

            UIMediaContent.Children.Add(result);
            UIMediaContent.LowerChild(result);//image should be under the menu's
        }