Ejemplo n.º 1
0
        public PictureView(CarouselModal carouselModal)
        {
            StackLayout stkContent = new StackLayout();
            Image       img        = new Image()
            {
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Center,
                Source            = carouselModal.FilePath
            };

            StackLayout stkControls = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#80000000")
            };
            Button btnClose = new Button()
            {
                Text = "Click to close"
            };

            btnClose.Clicked += (sender, e) =>
            {
                this.Navigation.PopModalAsync();
            };
            stkControls.Children.Add(btnClose);
            stkContent.Children.Add(img);
            stkContent.Children.Add(stkControls);
            this.Content = stkContent;
        }
Ejemplo n.º 2
0
        public MediaPlayerPage(CarouselModal carouselModal)
        {
            string flag = "image";

            switch (flag)
            {
            case "image":
            {
                this.Content = new PictureView(carouselModal);
            };
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
        void CreateCarousel()
        {
            ScrollView  scrollView    = new ScrollView();
            StackLayout stkWrapper    = new StackLayout();
            StackLayout editStatusBar = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal
            };

            Image imgEdit = new Image()
            {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Source            = "tick.ico",
                HeightRequest     = WidthRequest = 50
            };

            editStatusBar.Children.Add(imgEdit);
            StackLayout actionStatusBar = new StackLayout();

            TapGestureRecognizer recognizer = new TapGestureRecognizer()
            {
                NumberOfTapsRequired = 1
            };

            recognizer.Tapped += (sender, e) =>
            {
                if (CurrentState.Equals(CarouselState.Edit))
                {
                    CurrentState = CarouselState.View;
                }
                else
                {
                    CurrentState = CarouselState.Edit;
                }
                CreateCarousel();
            };
            imgEdit.GestureRecognizers.Add(recognizer);

            editStatusBar.Children.Add(imgEdit);

            stkWrapper.Children.Add(editStatusBar);

            Grid grdMain = new Grid()
            {
                // Margin = 20,RowSpacing=5
                // HeightRequest=100
            };
            int index = 0;

            for (int i = 0; i < Source.Count; i++)
            {
                int originalivalue = i;
                ItemPerRow = ItemPerRow >= Source.Count ? Source.Count : ItemPerRow;
                for (int j = 0; j < ItemPerRow; j++)
                {
                    if (Source.Count > index)
                    {
                        grdMain.RowDefinitions.Add(new RowDefinition()
                        {
                            Height = 50
                                     //  Height=new GridLength(1,GridUnitType.Auto)
                        });
                        RelativeLayout rtlThumbnailContent = new RelativeLayout()
                        {
                            Margin          = 0,
                            VerticalOptions = HorizontalOptions = LayoutOptions.FillAndExpand
                        };
                        Image ThumbNail = new Image()
                        {
                            Source  = Source[i].FilePath,
                            Aspect  = Aspect.AspectFit,
                            ClassId = Source[i].Id
                        };


                        rtlThumbnailContent.Children.Add(ThumbNail, Constraint.RelativeToParent((parent) =>
                        {
                            return(parent.X * 0);
                        }), Constraint.RelativeToParent((parent) =>
                        {
                            return(parent.Y * 0);
                        }), Constraint.RelativeToParent((parent) =>
                        {
                            return(parent.Width);
                        }), Constraint.RelativeToParent((parent) =>
                        {
                            return(parent.Height);
                        }));

                        CustomImage imgSelect = new CustomImage()
                        {
                            ID        = System.IO.Path.GetFileName(Source[i].FilePath),
                            IsVisible = CurrentState.Equals(CarouselState.Edit)
                                        //WidthRequest= HeightRequest=10
                        };

                        rtlThumbnailContent.Children.Add(imgSelect, Constraint.RelativeToView(ThumbNail, (parent, view) =>
                        {
                            return(view.Width * .8);
                        }), Constraint.RelativeToView(ThumbNail, (parent, view) =>
                        {
                            return(view.Height * .0);
                        })
                                                         //                                 , Constraint.RelativeToView(ThumbNail, (parent, view) =>
                                                         //{
                                                         //    return view.Height * .4;
                                                         //}), Constraint.RelativeToView(ThumbNail, (parent, view) =>
                                                         //{
                                                         //    return view.Height * .4;
                                                         //})
                                                         );
                        var sdf = new StackLayout();
                        sdf.Children.Add(rtlThumbnailContent);


                        TapGestureRecognizer imgtap = new TapGestureRecognizer();

                        imgtap.Tapped += Imgtap_Tapped;

                        imgSelect.GestureRecognizers.Add(imgtap);


                        TapGestureRecognizer imgThumbNailtap = new TapGestureRecognizer()
                        {
                            NumberOfTapsRequired = 1
                        };
                        imgThumbNailtap.Tapped += async(sender, e) => {
                            if (CurrentState.Equals(CarouselState.View))
                            {
                                Image         img   = sender as Image;
                                CarouselModal modal = Source.FirstOrDefault(ec => ec.Id == img.ClassId);
                                await Navigation.PushModalAsync(new MediaPlayerPage(modal));
                            }
                            else
                            {
                                Imgtap_Tapped(imgSelect, e);
                            }
                        };
                        ThumbNail.GestureRecognizers.Add(imgThumbNailtap);

                        i++;
                        grdMain.Children.Add(rtlThumbnailContent, j, originalivalue);
                    }
                }
            }

            StackLayout stkStatusbar = new StackLayout()
            {
                BackgroundColor = Color.Gray
            };

            lblStatus.Text = $"{SelectedItems?.Count} item(s) selected.";
            stkStatusbar.Children.Add(lblStatus);

            stkWrapper.Children.Add(grdMain);
            stkWrapper.Children.Add(stkStatusbar);
            scrollView.Content = stkWrapper;
            this.Content       = scrollView;
        }