public CarouselSampleSrollView()
        {
            _carouselView = new CardCarouselView
            {
                ItemTemplate = new DataTemplate(GetCardItem),
                Children     =
                {
                    new IndicatorsControl
                    {
                        SelectedIndicatorStyle = new Style(typeof(Frame))
                        {
                            BasedOn = DefaultIndicatorItemStyles.DefaultSelectedIndicatorItemStyle,
                            Setters =
                            {
                                new Setter {
                                    Property = BackgroundColorProperty, Value = Color.Red
                                }
                            }
                        }
                    }
                }
            };
            _carouselView.SetBinding(CardsView.ItemsSourceProperty, nameof(CarouselSampleScrollViewModel.Items));

            Title = "CarouselView scroll";

            Content        = _carouselView;
            BindingContext = new CarouselSampleScrollViewModel();
        }
Пример #2
0
        private Grid OnboardingGrid(PanCardView.CarouselView carouselView)
        {
            Grid grid = new Grid();
            OnboardingTemplate template = new OnboardingTemplate();

            template.signUpEmailButton.Pressed += SignUpEmailButton_Pressed;

            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(352, GridUnitType.Absolute)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(32, GridUnitType.Absolute)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength((App.Current.MainPage.Height / 11.83333), GridUnitType.Absolute)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(8, GridUnitType.Absolute)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength((App.Current.MainPage.Height / 11.83333), GridUnitType.Absolute)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(8, GridUnitType.Absolute)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength((App.Current.MainPage.Height / 11.83333), GridUnitType.Absolute)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(8, GridUnitType.Absolute)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            grid.BackgroundColor = Color.White;

            grid.RowSpacing    = 0;
            grid.ColumnSpacing = 0;

            // must use baseclass Grid to SetColumnSpan, cannot use instantiated object
            grid.Children.Add(carouselView, 0, 0);
            Grid.SetColumnSpan(carouselView, 3);
            grid.Children.Add(template.signInButton, 0, 6);
            Grid.SetColumnSpan(template.signInButton, 3);
            grid.Children.Add(template.signUpEmailButton, 0, 4);
            Grid.SetColumnSpan(template.signUpEmailButton, 3);
            grid.Children.Add(template.signUpFacebookButton, 0, 2);
            grid.Children.Add(template.signUpGoogleButton, 2, 2);

            return(grid);
        }
Пример #3
0
 public static void Preserve()
 {
     CardsView.Preserve();
     CarouselView.Preserve();
     CoverFlowView.Preserve();
     ArrowControl.Preserve();
     LeftArrowControl.Preserve();
     RightArrowControl.Preserve();
     CircleFrame.Preserve();
     IndicatorItemView.Preserve();
     IndicatorsControl.Preserve();
     ParentScrollView.Preserve();
 }
Пример #4
0
        public CarouselSampleListView()
        {
            BindingContext = new CarouselSampleListViewModel();

            var carousel = new CardCarouselView
            {
                ItemTemplate = new ListTemplateSelector()
            };

            carousel.SetBinding(CardsView.ItemsSourceProperty, nameof(CarouselSampleListViewModel.Cards));

            Content = carousel;
        }
Пример #5
0
        public CarouselSampleListView()
        {
            BindingContext = new CarouselSampleListViewModel();

            var carousel = new CardCarouselView
            {
                OppositePanDirectionDisablingThreshold = 1,
                ItemTemplate = new ListTemplateSelector()
            };

            carousel.SetBinding(CardsView.ItemsSourceProperty, nameof(CarouselSampleListViewModel.Cards));

            Content = carousel;
        }
        public CarouselSampleDoubleView()
        {
            var cardsView = new CardCarouselView
            {
                ItemTemplate = new DataTemplate(GetCardItem)
            };

            cardsView.SetBinding(CardsView.ItemsSourceProperty, "Items");
            cardsView.SetBinding(CardsView.SelectedIndexProperty, "CurrentIndex");


            Title = "CarouselView Double Carousel";

            Content        = cardsView;
            BindingContext = new CarouselSampleDoubleViewModel();
        }
        private void InitLayout()
        {
            if (Content == null)
            {
                _headerContainerGrid = new Grid
                {
                    HorizontalOptions    = LayoutOptions.FillAndExpand,
                    VerticalOptions      = LayoutOptions.Start,
                    BackgroundColor      = HeaderBackgroundColor,
                    MinimumHeightRequest = 50,
                    ColumnSpacing        = 0
                };

                _horizontalScroll = new ScrollView
                {
                    HorizontalOptions             = LayoutOptions.FillAndExpand,
                    VerticalOptions               = LayoutOptions.Fill,
                    BackgroundColor               = Color.Transparent,
                    VerticalScrollBarVisibility   = ScrollBarVisibility.Never,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Never,
                    Orientation = ScrollOrientation.Horizontal,
                    Content     = _headerContainerGrid
                };

                _carouselView = new CardCarouselView
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    BackgroundColor   = BodyBackgroundColor,
                    HeightRequest     = ContentHeight,
                    BindingContext    = this,
                    IsCyclical        = false
                };

                _carouselView.ItemAppearing += _carouselView_PositionSelected;

                _mainContainerSL = new StackLayout
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    Children          = { _horizontalScroll, _carouselView },
                    Spacing           = 0
                };

                Content = _mainContainerSL;
            }
        }
        public CarouselSampleViewNoTemplate()
        {
            Title = "CarouselSampleViewNoTemplate";

            var carousel = new CardCarouselView
            {
                HeightRequest = 200,
                ItemsSource   = new[] {
                    new BoxView {
                        Color = Color.Red
                    },
                    new BoxView {
                        Color = Color.Blue
                    },
                    new BoxView {
                        Color = Color.Yellow
                    }
                },
                IsCyclical = false
            };

            var button = new Button {
                Text = "Select last"
            };

            button.Clicked += (sender, args) => { carousel.SelectedIndex = 2; };

            Content = new ParentScrollView
            {
                Content = new StackLayout
                {
                    Children =
                    {
                        new StackLayout
                        {
                            Children =
                            {
                                carousel
                            }
                        },
                        button
                    }
                }
            };
        }
Пример #9
0
        public Onboarding()
        {
            Padding       = new Thickness(0);
            _carouselView = new PanCardView.CarouselView
            {
                ItemTemplate = new DataTemplate(GetCardItem),
                Children     =
                {
                    new IndicatorsControl
                    {
                        SelectedIndicatorStyle = new Style(typeof(Frame))
                        {
                            BasedOn = DefaultIndicatorItemStyles.DefaultSelectedIndicatorItemStyle,
                            Setters =
                            {
                                new Setter {
                                    Property = BackgroundColorProperty, Value = Color.FromRgb(70, 120, 200)
                                }
                            }
                        },

                        UnselectedIndicatorStyle = new Style(typeof(Frame))
                        {
                            BasedOn = DefaultIndicatorItemStyles.DefaultUnselectedIndicatorItemStyle,
                            Setters =
                            {
                                new Setter {
                                    Property = BackgroundColorProperty, Value = Color.FromRgb(70, 120, 200)
                                },
                                new Setter {
                                    Property = OpacityProperty, Value = 0.5
                                }
                            }
                        }
                    }
                }
            };
            _carouselView.SetBinding(CardsView.ItemsSourceProperty, nameof(OnboardingItemsSource.AllItems));
            Title = "Onboarding";

            Content = OnboardingGrid(_carouselView);

            BindingContext = new OnboardingItemsSource();
        }
        private View GetCardItem()
        {
            var label = new Label
            {
                TextColor = Color.White,
                FontSize  = 50,
                HorizontalTextAlignment = TextAlignment.Center,
                FontAttributes          = FontAttributes.Bold
            };

            label.SetBinding(Label.TextProperty, "Number");
            AbsoluteLayout.SetLayoutFlags(label, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(label, new Rectangle(.5, 1, 1, .5));

            var cardsView = new CardCarouselView
            {
                ItemTemplate = new DataTemplate(() =>
                {
                    var subCard = new ContentView();
                    subCard.SetBinding(BackgroundColorProperty, "Color");
                    return(subCard);
                })
            };

            cardsView.SetBinding(CardsView.ItemsSourceProperty, "Items");
            cardsView.SetBinding(CardsView.SelectedIndexProperty, "CurrentIndex");

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

            return(new AbsoluteLayout
            {
                BackgroundColor = Color.Black,
                Children =
                {
                    cardsView,
                    label
                }
            });
        }
Пример #11
0
        public PolicyPage GetPolicy()
        {
            _carouselView = new PanCardView.CarouselView
            {
                ItemTemplate = new DataTemplate(GetPolicyCard)
            };

            // instantiate account to access policies
            DemoAccount   demoAccount = new DemoAccount();
            Account       account     = demoAccount.GetAccount();
            List <Policy> source      = new List <Policy>();

            source = account.GetPolicies();
            _carouselView.ItemsSource   = source;
            _carouselView.SelectedIndex = TappedIndex;
            Content = _carouselView;

            // topToolbar replaces NavigationBar
            NavigationPage.SetTitleView(this, new PolicyView().TopToolbar);

            return(this);
        }
Пример #12
0
        public SavedPage()
        {
            BookInfo.fromrec = false;

            Label Saved = new Label
            {
                Text              = "My Books",
                FontSize          = Device.GetNamedSize(NamedSize.Title, typeof(Label)),
                TextColor         = Color.Blue,
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Margin            = new Thickness(0, 60, 0, 0)
            };

            Label NoBooks = new Label
            {
                Text              = "No books saved!",
                FontSize          = Device.GetNamedSize(NamedSize.Title, typeof(Label)),
                TextColor         = Color.Blue,
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Margin            = new Thickness(0, 60, 0, 0)
            };
            Label booktitle = new Label
            {
                Text      = "",
                FontSize  = Device.GetNamedSize(NamedSize.Title, typeof(Label)),
                TextColor = Color.DarkBlue,
                Margin    = new Thickness(125, 100, 0, 0),
            };

            Label author = new Label
            {
                Margin    = new Thickness(125, 20, 0, 0),
                Text      = "",
                FontSize  = Device.GetNamedSize(NamedSize.Title, typeof(Label)),
                TextColor = Color.DarkSlateBlue,
            };


            ImageButton backarrow = new ImageButton
            {
                Source = ImageSource.FromFile("FlippedArrow.png"),
                Scale  = 0.2,
                Margin = new Thickness(-275, -105, 0, 0),
            };

            CarouselView savedbookimages = new CarouselView
            {
                Scale  = 4,
                Margin = new Thickness(20, 40, 0, 0)
            };

            Button ReadMore = new Button
            {
                Margin            = new Thickness(55, 0, 60, 20),
                Text              = "Read More",
                Font              = Font.SystemFontOfSize(NamedSize.Title),
                HorizontalOptions = LayoutOptions.Center,
                BackgroundColor   = Color.LightBlue,
                TextColor         = Color.Black,
                IsVisible         = false,
            };

            ReadMore.Clicked += OnButtonClicked;


            savedbookimages.ItemsSource = savedBooks;



            backarrow.Clicked += backarrow_Clicked;

            if (!Reccomendation.prodevice)
            {
                savedbookimages.Scale = 4;
            }

            else if (Reccomendation.prodevice)
            {
                ReadMore.Margin        = new Thickness(30, 40, 60, 20);
                savedbookimages.Margin = new Thickness(20, 90, 0, 0);
                booktitle.Margin       = new Thickness(110, 100, 0, 0);
                author.Margin          = new Thickness(105, 20, 0, 0);
                backarrow.Scale        = .4;
                backarrow.Margin       = new Thickness(-265, -95, 0, 0);
            }

            if (savedBooks.Count > 0)
            {
                NoBooks.Text       = "";
                ReadMore.IsVisible = true;
            }

            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,

                Children =
                {
                    Saved,
                    backarrow,
                    savedbookimages,
                    NoBooks,
                    booktitle,
                    author,
                    ReadMore,
                }
            };

            savedbookimages.ItemDisappearing += (sender, args) =>
            {
                if (savedBooks.Count > 0)
                {
                    disappearingbook = (BookCover)savedbookimages.SelectedItem;
                    booktitle.Text   = disappearingbook.thisbook.booktitle;
                    author.Text      = disappearingbook.thisbook.authorname;
                }
            };
        }
Пример #13
0
        public ImageViewer(FoodItem food)
        {
            NavigationPage.SetHasNavigationBar(this, false);
            int index = 0;

            CurrentIndex = index;
            bool            indexSet  = false;
            List <FoodItem> FoodItems = GlobalVariables.getFoodItems();

            list = new Dictionary <int, byte[]>();
            foreach (var i in FoodItems)
            {
                list.Add(i.ID, GlobalVariables.DeserializeStringToByteArray(i.IMGBYTES));
                if (i == food && !indexSet)
                {
                    index    = list.Count - 1;
                    indexSet = true;
                }
            }

            InitializeComponent();
            PanCardView.CarouselView carouselView = new PanCardView.CarouselView
            {
                ItemTemplate    = new DataTemplate(() => CardFactory.Creator.Invoke()),
                BackgroundColor = Color.Black
            };

            carouselView.SetBinding(CardsView.CurrentContextProperty, nameof(ImageViewerModel.CurrentContext));
            carouselView.SetBinding(CardsView.NextContextProperty, nameof(ImageViewerModel.NextContext));
            carouselView.SetBinding(CardsView.PrevContextProperty, nameof(ImageViewerModel.PrevContext));
            this.SetBinding(ImageViewer.CurrentIndexProperty, nameof(ImageViewerModel.CurrentIndex));
            carouselView.SetBinding(CardsView.PanStartedCommandProperty, nameof(ImageViewerModel.PanStartedCommand));
            carouselView.SetBinding(CardsView.PositionChangedCommandProperty, nameof(ImageViewerModel.PanPositionChangedCommand));

            //ToolbarItem deleteOption = new ToolbarItem("Delete", "", new Action(() => { DeleteSelectedImage(); }), ToolbarItemOrder.Primary, 0);
            ToolbarItem editOption = new ToolbarItem("Edit", "", new Action(() => { Navigation.PushAsync(new EditDetailsPage(getCurrentID(), GlobalVariables.EntryType.UPDATE_ENTRY)); }), ToolbarItemOrder.Primary, 0);

            AbsoluteLayout UserPrefs = new AbsoluteLayout
            {
                Margin = 10
            };

            AbsoluteLayout.SetLayoutFlags(UserPrefs, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(UserPrefs, new Rectangle(1, 1, 1, 0.11));
            StackLayout prefsView = new StackLayout();

            AbsoluteLayout.SetLayoutFlags(prefsView, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(prefsView, new Rectangle(1, 1, 1, 1));
            Grid grid = new Grid
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Start,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(25, GridUnitType.Absolute)
                    },
                    new RowDefinition {
                        Height = new GridLength(25, GridUnitType.Absolute)
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Auto)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Auto)
                    }
                }
            };

            Image healthIcon = new Image
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Start,
                WidthRequest      = 25,
                HeightRequest     = 25,
                Source            = ImageSource.FromResource("SelfControl.Resources.health_icon.png")
            };
            Image frequencyIcon = new Image
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Start,
                WidthRequest      = 25,
                HeightRequest     = 25,
                Source            = ImageSource.FromResource("SelfControl.Resources.frequency_icon.png")
            };

            healthRating = new Label
            {
                Text     = "",
                FontSize = 15,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor             = Color.White
            };
            frequencyRating = new Label
            {
                Text     = "",
                FontSize = 15,
                VerticalTextAlignment = TextAlignment.Center,
                TextColor             = Color.White
            };
            grid.Children.Add(healthIcon, 0, 0);
            grid.Children.Add(healthRating, 1, 0);
            grid.Children.Add(frequencyIcon, 0, 1);
            grid.Children.Add(frequencyRating, 1, 1);

            prefsView.Children.Add(grid);
            UserPrefs.Children.Add(prefsView);
            carouselView.Children.Add(UserPrefs);

            Content = carouselView;
            ToolbarItems.Add(editOption);
            //ToolbarItems.Add(deleteOption);
            BindingContext = new ImageViewerModel(list, index);
        }
        public CarouselSampleViewNoTemplate()
        {
            Title = "CarouselSampleViewNoTemplate";

            var carousel = new CardCarouselView
            {
                HeightRequest = 200,
                WidthRequest  = 400,
                //ItemsSource = new[] {
                ItemsSource = new ObservableCollection <object> {
                    new { Source = "happyClass1.png", Color = Color.Red },
                    new { Source = "happyClass2.png", Color = Color.Green },
                    new { Source = "happyClass3.png", Color = Color.Gold },
                    new { Source = "happyClass4.png", Color = Color.Silver },
                    new { Source = "happyClass5.png", Color = Color.Blue },
                    new { Source = "happyClass6.png", Color = Color.Red },
                    new { Source = "happyClass7.png", Color = Color.Green },
                    new { Source = "happyClass8.png", Color = Color.Gold },
                    new { Source = "happyClass9.png", Color = Color.Silver },
                    new { Source = "happyClass10.png", Color = Color.White },
                    new { Source = "happyClass11.png", Color = Color.AliceBlue },
                    new { Source = "happyClass12.png", Color = Color.WhiteSmoke },
                    new { Source = "happyClass13.png", Color = Color.Black },
                    new { Source = "happyClass14.png", Color = Color.Black },
                    new { Source = "happyClass15.png", Color = Color.Black },
                    new { Source = "happyClass16.png", Color = Color.Black },
                    new { Source = "happyClass17.png", Color = Color.Black },
                    new { Source = "happyClass18.png", Color = Color.Black },
                    new { Source = "happyClass19.png", Color = Color.Black },
                    new { Source = "happyClass20.png", Color = Color.Black },
                    new { Source = "happyClass21.png", Color = Color.Black },
                    new { Source = "happyClass22.png", Color = Color.Black },
                    new { Source = "happyClass23.png", Color = Color.White },
                    new { Source = "happyClass24.png", Color = Color.LightYellow },
                    new { Source = "happyClass25.png", Color = Color.OliveDrab },
                    new { Source = "happyClass26.png", Color = Color.Black },
                    new { Source = "happyClass27.png", Color = Color.Black },
                    new { Source = "happyClass28.png", Color = Color.Black },
                    new { Source = "happyClass29.png", Color = Color.Black },
                    new { Source = "happyClass30.png", Color = Color.Black },
                    new { Source = "happyClass31.png", Color = Color.Black }
                    //new BoxView { Color = Color.Red },
                    //new BoxView { Color = Color.Blue},
                    //new BoxView { Color = Color.Yellow}

                    //    new BoxView { source = "happyClass1.png", Color = Color.Red },
                    //new BoxView { Source = "happyClass2.png", Color = Color.Green },
                    //new BoxView { Source = "happyClass3.png" , Color = Color.Gold },
                    //new BoxView { Source = "happyClass4.png" , Color = Color.Silver },
                    //new BoxView { Source = "happyClass5.png", Color = Color.Blue },
                    //new BoxView { Source = "happyClass6.png", Color = Color.Red },
                    //new BoxView { Source = "happyClass7.png", Color = Color.Green },
                    //new BoxView { Source = "happyClass8.png" , Color = Color.Gold },
                    //new BoxView { Source = "happyClass9.png" , Color = Color.Silver },
                    //new BoxView { Source = "happyClass10.png", Color = Color.White },
                    //new BoxView { Source = "happyClass11.png", Color = Color.AliceBlue },
                    //new BoxView { Source = "happyClass12.png", Color = Color.WhiteSmoke },
                    //new BoxView { Source = "happyClass13.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass14.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass15.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass16.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass17.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass18.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass19.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass20.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass21.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass22.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass23.png", Color = Color.White },
                    //new BoxView { Source = "happyClass24.png", Color = Color.LightYellow },
                    //new BoxView { Source = "happyClass25.png", Color = Color.OliveDrab },
                    //new BoxView { Source = "happyClass26.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass27.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass28.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass29.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass30.png", Color = Color.Black },
                    //new BoxView { Source = "happyClass31.png", Color = Color.Black }
                },
                IsCyclical = false
            };

            var button = new Button {
                Text = "Select last"
            };

            button.Clicked += (sender, args) => { carousel.SelectedIndex = 2; };

            Content = new ParentScrollView
            {
                Content = new StackLayout
                {
                    Children =
                    {
                        new StackLayout
                        {
                            Children =
                            {
                                carousel
                            }
                        },
                        button
                    }
                }
            };
        }