コード例 #1
1
		public override UIView ViewForItem(CarouselView carousel, uint index, UIView reusingView)
		{

			UILabel label;

			if (reusingView == null)
			{
				var imgView = new UIImageView(new RectangleF(0, 0, 200, 200))
				{

					Image = FromUrl( index > 1 ? product[0].ImageForSize(250) : product[(int)index].ImageForSize(250) ),
					ContentMode = UIViewContentMode.Center
				};


				label = new UILabel(imgView.Bounds)
				{
					BackgroundColor = UIColor.Clear,
					TextAlignment = UITextAlignment.Center,
					Tag = 1
				};
				label.Font = label.Font.WithSize(50);
				imgView.AddSubview(label);
				reusingView = imgView;
			}
			else
			{
				label = (UILabel)reusingView.ViewWithTag(1);
			}
				

			return reusingView;
		}
コード例 #2
0
        public static void AutoPlayBindingPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            if ((bool)newValue == true)
            {
                CarouselView cv = bindable as CarouselView;
                _cv = cv;
                //var period = (double?)cv.GetValue(PeriodProperty);
                //if (period == null)
                //{
                //    period = 2000;
                //}
                double period = 3000;
                Device.StartTimer(System.TimeSpan.FromMilliseconds(period), () =>
                {
                    IList list  = _cv.ItemsSource as IList;
                    _itemsCount = list.Count;
                    if (_itemsCount == 0)
                    {
                        return(false);
                    }
                    _cv.Position = (_cv.Position + 1) % _itemsCount;

                    var re = (bool)_cv.GetValue(AutoPlayProperty);
                    return(re);
                });
            }
        }
コード例 #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Setup the item list we will display
            // your carousel should always be driven by an array/list of
            // data of some kind - don't store data in your item views
            // or the recycling mechanism will destroy your data once
            // your item views move off-screen
            items = new List <int>();

            // Setup Background image
            var imgView = new UIImageView(UIImage.FromBundle("background"))
            {
                ContentMode      = UIViewContentMode.ScaleToFill,
                AutoresizingMask = UIViewAutoresizing.All,
                Frame            = View.Bounds
            };

            View.AddSubview(imgView);

            // Setup CarouselView view
            carousel              = new CarouselView(View.Bounds);
            carousel.DataSource   = new ZeroItemLinearDataSource(this);
            carousel.Delegate     = new ZeroItemLinearDelegate(this);
            carousel.CarouselType = CarouselType.Linear;
            carousel.ConfigureView();

            View.AddSubview(carousel);
        }
コード例 #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            items = Enumerable.Range(1, 100).ToList();
            BigTed.BTProgressHUD.Show("Loading Image");
            View.DownloadImageAsync(item.images [0]).ContinueWith((task) => InvokeOnMainThread(() => {
                var imgView = new UIImageView(task.Result)
                {
                    ContentMode      = UIViewContentMode.ScaleToFill,
                    AutoresizingMask = UIViewAutoresizing.All,
                    Frame            = View.Bounds
                };
                View.AddSubview(imgView);

                carousel              = new CarouselView(new RectangleF(0, 400, View.Bounds.Width, 50));
                carousel.DataSource   = new LinearDataSource(item);
                carousel.Delegate     = new LinearDelegate();
                carousel.CarouselType = CarouselType.Linear;
                carousel.ConfigureView();
                View.AddSubview(carousel);
                carousel.Autoscroll = 1.0f;
                BigTed.BTProgressHUD.Dismiss();
            }
                                                                                               ));
        }
コード例 #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Setup Background image
            var imgView = new UIImageView(UIImage.FromBundle("background"))
            {
                ContentMode      = UIViewContentMode.ScaleToFill,
                AutoresizingMask = UIViewAutoresizing.All,
                Frame            = View.Bounds
            };

            View.AddSubview(imgView);

            // Setup CarouselView view
            Carousel = new CarouselView(View.Bounds)
            {
                DataSource = new ControlsDataSource(this),
                Delegate   = new CarouselViewDelegate()
            };
            Carousel.CarouselType = CarouselType.CoverFlow2;
            Carousel.ConfigureView();

            View.AddSubview(Carousel);

            // Setup info label
            Label = new UILabel(new RectangleF(20, 362, 280, 21))
            {
                BackgroundColor = UIColor.Clear,
                Text            = string.Empty,
                TextAlignment   = UITextAlignment.Center
            };

            View.AddSubview(Label);
        }
コード例 #6
0
        //        private UInt16 counter(IList<GalleryObject> list){
        //            UInt16 x = 0;
        //            foreach (GalleryObject o in list) {
        //                x++;
        //            }
        //            return x;
        //        }
        public override UIView ViewForItem(CarouselView carousel, uint index, UIView reusingView)
        {
            //			if (!Empty) {
            Console.WriteLine ("viewForItem()index:" + index);
            var imgView = reusingView as UIImageView;

            var documentsDirectory = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            var gallerydirectory = Path.Combine (documentsDirectory, "gallery");

            string thumbfilename = vc.items [(int)index].thumbFileName;
            string path = Path.Combine (gallerydirectory, thumbfilename);
            Console.WriteLine ("path:" + path);
            UIImage currentImage = UIImage.FromFile (path);
            SizeF dim = currentImage.Size;

            //create new view if none is availble fr recycling
            if (imgView == null) {
                imgView = new UIImageView (new RectangleF (0, 0, dim.Width, dim.Height)) {
                    ContentMode = UIViewContentMode.ScaleAspectFit
                };
            }

            imgView.Image = currentImage;

            reusingView = imgView;

            return reusingView;
            //			} else {
            //				if (reusingView == null) {
            //					reusingView = new UIImageView (new RectangleF(0, 0, 10, 10));
            //				}
            //
            //				return reusingView;
            //			}
        }
コード例 #7
0
        public App()
        {
            var assemblyName = new AssemblyName("Xamarin.Forms.CarouselView");
            var assembly     = Assembly.Load(assemblyName);
            var versionLabel = new Label
            {
                Text = $"AssemblyVersion {assembly.GetName().Version}"
            };

            var carouselView = new CarouselView
            {
                BackgroundColor = Color.Purple,
                ItemTemplate    = new DataTemplate(typeof(MyView)),
                ItemsSource     = new[]
                {
                    new MyModel("Foo"),
                    new MyModel("Bar"),
                    new MyModel("Baz"),
                }
            };

            // The root page of your application
            MainPage = new ContentPage
            {
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Children        =
                    {
                        versionLabel,
                        carouselView
                    }
                }
            };
        }
コード例 #8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Setup the item list we will display
            // your carousel should always be driven by an array/list of
            // data of some kind - don't store data in your item views
            // or the recycling mechanism will destroy your data once
            // your item views move off-screen
            items = Enumerable.Range(1, 100).ToList(); // Prettier than for (nint i = 0; i < 100; i++)

            // Setup Background image
            var imgView = new UIImageView(UIImage.FromBundle("background"))
            {
                ContentMode      = UIViewContentMode.ScaleToFill,
                AutoresizingMask = UIViewAutoresizing.All,
                Frame            = View.Bounds
            };

            View.AddSubview(imgView);

            // Setup CarouselView view
            carousel = new CarouselView(View.Bounds)
            {
                DataSource = new ButtonsDataSource(this),
                Delegate   = new CarouselViewDelegate()
            };
            carousel.CarouselType = CarouselType.CoverFlow2;
            carousel.ConfigureView();

            View.AddSubview(carousel);
        }
コード例 #9
0
        protected override void Init()
        {
            var layout = new StackLayout();

            var instructions = new Label
            {
                Margin = new Thickness(6),
                Text   = "The CarouselView below should render 5 items."
            };

            var itemsLayout =
                new LinearItemsLayout(ItemsLayoutOrientation.Horizontal)
            {
                SnapPointsType      = SnapPointsType.MandatorySingle,
                SnapPointsAlignment = SnapPointsAlignment.Center
            };

            var carouselView = new CarouselView
            {
                ItemsLayout  = itemsLayout,
                ItemTemplate = GetCarouselTemplate()
            };

            carouselView.SetBinding(ItemsView.ItemsSourceProperty, "Items");

            layout.Children.Add(instructions);
            layout.Children.Add(carouselView);

            Content = layout;
        }
コード例 #10
0
            public override UIView ViewForItem(CarouselView carousel, nint index, UIView reusingView)
            {
                var button = reusingView as UIButton;

                if (button == null)
                {
                    //no button available to recycle, so create new one
                    var image = UIImage.FromBundle("page.png");
                    button       = UIButton.FromType(UIButtonType.Custom);
                    button.Frame = new CGRect(0, 0, image.Size.Width, image.Size.Height);
                    button.SetTitleColor(UIColor.Black, UIControlState.Normal);
                    button.SetBackgroundImage(image, UIControlState.Normal);
                    button.TitleLabel.Font = button.TitleLabel.Font.WithSize(50);
                    button.TouchUpInside  += (sender, e) =>
                    {
                        var idx = vc.carousel.IndexOfItemViewOrSubview(sender as UIView);
                        new UIAlertView("Hello", "You tapped button number " + idx, null, "Ok", null).Show();
                    };
                }

                // set button label
                button.SetTitle(index.ToString(), UIControlState.Normal);

                if (!vc.objCache.Contains(button))
                {
                    vc.objCache.Add(button);
                }

                return(button);
            }
コード例 #11
0
        public CarouselSampleSrollView()
        {
            _carouselView = new CarouselView
            {
                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.ItemsProperty, nameof(CarouselSampleScrollViewModel.Items));

            Title = "CarouselView scroll";

            Content        = _carouselView;
            BindingContext = new CarouselSampleScrollViewModel();
        }
コード例 #12
0
        public NodeListView()
        {
            var c = new CarouselView();

            InitializeComponent();
            BindingContext = MyViewModel;
        }
コード例 #13
0
ファイル: Issue10234.cs プロジェクト: hevey/maui
            public PhotosPage()
            {
                //InitializeComponent();
                Photos = new CarouselView
                {
                    AutomationId = "carouselView",
                    ItemTemplate = new DataTemplate(
                        () =>
                    {
                        var image = new Image();
                        image.SetBinding(Image.SourceProperty, new Binding("."));
                        return(image);
                    }
                        )
                };

                var grid = new Grid();

                grid.RowDefinitions.Add(new RowDefinition());
                grid.RowDefinitions.Add(new RowDefinition());
                var btn = new Button
                {
                    Text         = "Go back",
                    AutomationId = "goToBack",
                    Command      = new Command(async() => await Shell.Current.GoToAsync("//main"))
                };

                Grid.SetRow(Photos, 0);
                Grid.SetRow(btn, 1);
                grid.Children.Add(Photos);
                grid.Children.Add(btn);
                Content = grid;
            }
コード例 #14
0
ファイル: Issue8964.cs プロジェクト: terrajobst/maui
        protected override void Init()
        {
            ItemSourceUnderTest = new ObservableCollection <ModelIssue8964>(GetCarouselItems());
            var lbl = new Label
            {
                Text = "Scroll to the previous item until see the Item with counter 6, since we are inserting items on the start of the collection the position should be  the same"
            };

            CarouselViewUnderTest = new CarouselView
            {
                HeightRequest  = 250,
                IsSwipeEnabled = true,
                ItemsSource    = ItemSourceUnderTest,
                ItemTemplate   = GetCarouselTemplate(),
                CurrentItem    = _currentItem,
                AutomationId   = "carouseView",
                Loop           = false
            };
            CarouselViewUnderTest.CurrentItemChanged += CarouselViewUnderTestCurrentItemChanged;
            CarouselViewUnderTest.PositionChanged    += CarouselViewUnderTest_PositionChanged;

            _lbl = new Label
            {
                Text = $"Item Position - {CarouselViewUnderTest.Position}"
            };

            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children        = { lbl, CarouselViewUnderTest, _lbl, }
            };
        }
コード例 #15
0
#pragma warning disable CS0435 // Namespace conflicts with imported type
        CarouselView LoadCarouselView()
#pragma warning restore CS0435 // Namespace conflicts with imported type
        {
            if (_carouselView != null)
            {
                return(_carouselView);
            }

            DependencyObject     parent   = VisualTreeHelper.GetParent(this);
            CarouselViewRenderer renderer = default(CarouselViewRenderer);

            do
            {
                if (parent == null)
                {
                    return(null);
                }

                renderer = parent as CarouselViewRenderer;
                if (renderer != null)
                {
                    break;
                }

                parent = VisualTreeHelper.GetParent(parent);
            } while (true);

            _carouselView = renderer.Element;
            return(_carouselView);
        }
コード例 #16
0
        public DotsCarouselView()
        {
            sourceList   = new List <View>();
            carouselView = new CarouselView()
            {
                ItemTemplate = new DataTemplate(() =>
                {
                    Image image = new Image();
                    image.SetBinding(Image.SourceProperty, "Source");
                    return(image);
                }),
                WidthRequest  = 600,
                HeightRequest = 200,
                Margin        = 0
            };
            //carouselView.ItemSelected += ScrollCarousel;
            carouselView.ItemsSource = sourceList;

            HorizontalOptions = LayoutOptions.Center;
            VerticalOptions   = LayoutOptions.Center;
            Margin            = 0;
            Padding           = 0;

            sliderDots = new SliderDots(0);

            Children.Add(carouselView);
            Children.Add(sliderDots);
        }
コード例 #17
0
 void TapGestureRecognizer_Tapped(System.Object sender, System.EventArgs e)
 {
     if (sender is StackLayout stackLayout)
     {
         var index = Footer.Children.IndexOf(stackLayout);
         CarouselView.ScrollTo(index);
     }
 }
コード例 #18
0
		public override void DidSelectItem(CarouselView carousel, int index)
		{
			//Console.WriteLine("Selected: " + ++index);

			ProductSelected (Products [index]);


		}
コード例 #19
0
 public override float ValueForOption(CarouselView carousel, CarouselOption option, float aValue)
 {
     if (option == CarouselOption.Spacing)
     {
         return(aValue * 1.1f);
     }
     return(aValue);
 }
コード例 #20
0
 public override uint NumberOfItems(CarouselView carousel)
 {
     // generate 100 item views
     // normally we'd use a backing array/List
     // as shown in the basic iOS example
     // but for this example we haven't bothered
     return(100);
 }
コード例 #21
0
		public override float ValueForOption(CarouselView carousel, CarouselOption option, float aValue)
		{
			if (option == CarouselOption.Spacing)
			{
				return aValue * 1.1f;
			}
			return aValue;
		}
コード例 #22
0
 public CarouselViewController(CarouselView itemsView, ItemsViewLayout layout) : base(itemsView, layout)
 {
     _carouselView = itemsView;
     _layout       = layout;
     Delegator.CarouselViewController       = this;
     CollectionView.AllowsSelection         = false;
     CollectionView.AllowsMultipleSelection = false;
 }
コード例 #23
0
ファイル: Issue12574.cs プロジェクト: tytok/maui
        protected override void Init()
        {
            _btn = new Button
            {
                Text         = "Remove Last",
                AutomationId = btnRemoveAutomationId
            };
            _btn.SetBinding(Button.CommandProperty, "RemoveLastItemCommand");

            _btn2 = new Button
            {
                Text         = "Remove All",
                AutomationId = btnRemoveAllAutomationId
            };
            _btn2.SetBinding(Button.CommandProperty, "RemoveAllItemsCommand");

            _carouselView = new CarouselView
            {
                AutomationId    = carouselAutomationId,
                Margin          = new Thickness(30),
                BackgroundColor = Color.Yellow,
                ItemTemplate    = new DataTemplate(() =>
                {
                    var stacklayout      = new StackLayout();
                    var labelId          = new Label();
                    var labelText        = new Label();
                    var labelDescription = new Label();
                    labelId.SetBinding(Label.TextProperty, "Id");
                    labelText.SetBinding(Label.TextProperty, "Text");
                    labelDescription.SetBinding(Label.TextProperty, "Description");

                    stacklayout.Children.Add(labelId);
                    stacklayout.Children.Add(labelText);
                    stacklayout.Children.Add(labelDescription);
                    return(stacklayout);
                })
            };
            _carouselView.SetBinding(CarouselView.ItemsSourceProperty, "Items");
            this.SetBinding(Page.TitleProperty, "Title");

            var layout = new Grid();

            layout.RowDefinitions.Add(new RowDefinition {
                Height = 100
            });
            layout.RowDefinitions.Add(new RowDefinition {
                Height = 100
            });
            layout.RowDefinitions.Add(new RowDefinition());
            Grid.SetRow(_btn2, 1);
            Grid.SetRow(_carouselView, 2);
            layout.Children.Add(_btn);
            layout.Children.Add(_btn2);
            layout.Children.Add(_carouselView);

            BindingContext = viewModel = new ViewModelIssue12574();
            Content        = layout;
        }
コード例 #24
0
        public void TestConstructorAndDefaults()
        {
            var carouselView = new CarouselView();

            Assert.IsNull(carouselView.ItemsSource);
            Assert.IsNull(carouselView.ItemTemplate);
            Assert.IsNotNull(carouselView.ItemsLayout);
            Assert.IsTrue(carouselView.Position == 0);
        }
コード例 #25
0
ファイル: Issue7780.cs プロジェクト: zhamppx97/maui
        protected override void Init()
        {
            var layout = new StackLayout();

            var instructions = new Label
            {
                Margin = new Thickness(6),
                Text   = "Change the CarouselView FlowDirection and verify that it works correctly."
            };

            var itemsLayout =
                new LinearItemsLayout(ItemsLayoutOrientation.Horizontal)
            {
                SnapPointsType      = SnapPointsType.MandatorySingle,
                SnapPointsAlignment = SnapPointsAlignment.Center
            };

            var carouselView = new CarouselView
            {
                FlowDirection = FlowDirection.RightToLeft,
                ItemsLayout   = itemsLayout,
                ItemTemplate  = GetCarouselTemplate()
            };

            carouselView.SetBinding(ItemsView.ItemsSourceProperty, "Items");

            var flowDirectionButton = new Button
            {
                Text = "Change FlowDirection"
            };

            var flowDirectionLabel = new Label
            {
                Text = carouselView.FlowDirection.ToString()
            };

            layout.Children.Add(instructions);
            layout.Children.Add(carouselView);
            layout.Children.Add(flowDirectionButton);
            layout.Children.Add(flowDirectionLabel);

            flowDirectionButton.Clicked += (sender, args) =>
            {
                if (carouselView.FlowDirection == FlowDirection.RightToLeft)
                {
                    carouselView.FlowDirection = FlowDirection.LeftToRight;
                    flowDirectionLabel.Text    = "LeftToRight";
                }
                else
                {
                    carouselView.FlowDirection = FlowDirection.RightToLeft;
                    flowDirectionLabel.Text    = "RightToLeft";
                }
            };

            Content = layout;
        }
コード例 #26
0
ファイル: Issue8693.cs プロジェクト: zhamppx97/maui
        protected override void Init()
        {
            var layout = new StackLayout();

            var instructions = new Label
            {
                Margin          = new Thickness(6),
                BackgroundColor = Color.Black,
                TextColor       = Color.White,
                Text            = "Press the Button to update the ItemsSource of the CarouselView below. After updating, verify that the IndicatorView is still visible. If it is visible, the test has passed."
            };

            var updateButton = new Button
            {
                Text = "Update ItemsSource"
            };

            var itemsLayout =
                new LinearItemsLayout(ItemsLayoutOrientation.Horizontal)
            {
                SnapPointsType      = SnapPointsType.MandatorySingle,
                SnapPointsAlignment = SnapPointsAlignment.Center
            };

            var carouselView = new CarouselView
            {
                ItemsLayout  = itemsLayout,
                ItemTemplate = GetCarouselTemplate()
            };

            carouselView.SetBinding(ItemsView.ItemsSourceProperty, "Items");

            var indicatorView = new IndicatorView
            {
                IndicatorColor         = Color.Red,
                SelectedIndicatorColor = Color.Green,
                IndicatorTemplate      = GetIndicatorTemplate(),
                HorizontalOptions      = LayoutOptions.Center,
                Margin = new Thickness(0, 0, 0, 24)
            };

            carouselView.IndicatorView = indicatorView;

            layout.Children.Add(instructions);
            layout.Children.Add(updateButton);
            layout.Children.Add(carouselView);
            layout.Children.Add(indicatorView);

            Content = layout;

            updateButton.Clicked += (sender, args) =>
            {
                var vm = (Issue8693ViewModel)BindingContext;
                vm.LoadItems();
            };
        }
コード例 #27
0
ファイル: Issue10708.cs プロジェクト: gywerd/CPUI
        public Issue10708SecondView()
        {
            Title = "Issue 10708";

            _carouselView = new CarouselView();

            _carouselView.SetBinding(ItemsView.ItemsSourceProperty, "Items");
            _carouselView.SetBinding(CarouselView.CurrentItemProperty, "SelectedItem");

            Content = _carouselView;
        }
コード例 #28
0
ファイル: SOSPage.cs プロジェクト: patel-pragnesh/Appyfleet
        void CreateUI()
        {
            var list = ViewModel.GetSOSListModel;

            foreach (var l in list)
            {
                l.Image = l.Image.CorrectedImageSource();
            }

            var carousel = new CarouselView
            {
                ItemsSource   = list,
                HeightRequest = App.ScreenSize.Height * .7,
                IsEnabled     = true,
                ItemTemplate  = new DataTemplate(typeof(SOSViewCell))
            };

            carousel.PositionSelected += Carousel_PositionSelected;

            BoxGrid = ProgressBars.GenerateProgressBars(ViewModel.CurrentViewPage);

            Content = new StackLayout
            {
                WidthRequest      = App.ScreenSize.Width,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                Children          =
                {
                    new TopBar(true,                   "",          this,              1, "back_arrow", "icon_user").CreateTopBar(),
                    new TitleBar("SOS - What to do?"),
                    new StackLayout
                    {
                        HeightRequest   = App.ScreenSize.Height * .15,
                        VerticalOptions = LayoutOptions.Center,
                        Children        =
                        {
                            new Label {
                                Text = ViewModel.GetSOSMainTitle,TextColor = Color.White, FontSize = 24, FontFamily = Helper.RegFont, HorizontalTextAlignment = TextAlignment.Center
                            }
                        }
                    },
                    new BoxView {
                        WidthRequest = App.ScreenSize.Width,HeightRequest = 1, BackgroundColor = Color.White
                    },
                    new StackLayout
                    {
                        Padding  = new Thickness(0,            24),
                        Children = { carousel,         BoxGrid }
                    }
                }
            };
        }
コード例 #29
0
        public CarouselCodeGallery(ItemsLayoutOrientation orientation)
        {
            Title = $"CarouselView (Code, {orientation})";

            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    }
                }
            };

            var itemsLayout =
                new ListItemsLayout(orientation)
            {
                SnapPointsType      = SnapPointsType.MandatorySingle,
                SnapPointsAlignment = SnapPointsAlignment.Center
            };

            var itemTemplate = ExampleTemplates.CarouselTemplate();

            var carouselView = new CarouselView
            {
                ItemsLayout  = itemsLayout,
                ItemTemplate = itemTemplate,
            };

            var generator = new ItemsSourceGenerator(carouselView, initialItems: 50);

            layout.Children.Add(generator);

            var scrollToControl = new ScrollToIndexControl(carouselView, false);

            layout.Children.Add(scrollToControl);

            layout.Children.Add(carouselView);

            Grid.SetRow(scrollToControl, 1);
            Grid.SetRow(carouselView, 2);

            Content = layout;

            generator.GenerateItems();
        }
コード例 #30
0
        public CarouselSampleListView()
        {
            BindingContext = new CarouselSampleListViewModel();

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

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

            Content = carousel;
        }
コード例 #31
0
 public static void SetItemsSourceBy(this IndicatorView indicatorView, CarouselView carouselView)
 {
     indicatorView.SetBinding(PositionProperty, new Binding
     {
         Path   = nameof(CarouselView.Position),
         Source = carouselView
     });
     indicatorView.SetBinding(ItemsSourceProperty, new Binding
     {
         Path   = nameof(ItemsView.ItemsSource),
         Source = carouselView
     });
 }
コード例 #32
0
        public MainPageViewModel(INavigation myNavigation)
        {
            Models           = new ObservableCollection <TestModel>();
            MyCarouselViewVM = new CarouselView();
            NavigateTo       = new Command((e) => ShowView((string)e));


            List <Label> myLabels = new List <Label>();

            for (int i = 0; i < 5; i++)
            {
                Label label = new Label();
                label.Text = "View " + i;

                myLabels.Add(label);
            }


            StackLayout stackL = getNewStackLayout(Color.Red);

            stackL.Children.Add(myLabels[0]);
            Models.Add(new TestModel(stackL));


            stackL = getNewStackLayout(Color.Blue);
            Button bt1 = new Button();

            bt1.Text = "Navigation";
            INavigation myNav = myNavigation;

            bt1.Clicked += (sender, args) =>
            {
                myNav.PushAsync(new NavPage());
            };
            stackL.Children.Add(bt1);
            stackL.Children.Add(myLabels[1]);
            Models.Add(new TestModel(stackL));

            stackL = getNewStackLayout(Color.Green);
            stackL.Children.Add(myLabels[2]);
            Models.Add(new TestModel(stackL));

            stackL = getNewStackLayout(Color.Yellow);
            stackL.Children.Add(myLabels[3]);
            Models.Add(new TestModel(stackL));

            stackL = getNewStackLayout(Color.Purple);
            stackL.Children.Add(myLabels[4]);
            Models.Add(new TestModel(stackL));
        }
コード例 #33
0
        protected override void SetUpNewElement(ItemsView newElement)
        {
            Carousel = newElement as CarouselView;

            base.SetUpNewElement(newElement);

            if (newElement == null)
            {
                return;
            }

            UpdateIsSwipeEnabled();
            UpdateInitialPosition();
            UpdateItemSpacing();
        }
コード例 #34
0
        public CarouselSampleDoubleView()
        {
            var cardsView = new CarouselView
            {
                ItemTemplate = new DataTemplate(GetCardItem)
            };

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


            Title = "CarouselView Double Carousel";

            Content        = cardsView;
            BindingContext = new CarouselSampleDoubleViewModel();
        }
コード例 #35
0
        public override uint NumberOfItems(CarouselView carousel)
        {
            //			Empty = false;
            int x = vc.items.Count;
            //			if (x == 0) {
            //				x = 2;
            //				Empty = true;
            //			}
            return (uint)x;

            //			Console.WriteLine ("x=" + x);
            //			if (x == 0) {
            //				Empty = true;
            //				x = 2;
            //				Console.WriteLine ("x override: " + x);
            //				return 0;
            //			} else {
            //				Empty = false;
            //			}
            //			return x;
        }
コード例 #36
0
 public override float ValueForOption(CarouselView carousel, CarouselOption option, float aValue)
 {
     //			if (option == CarouselOption.Spacing)
     //			{
     //				return aValue * 1.1f;
     //			}
     //
     //
     //			if (option == CarouselOption.Count) {
     //				return vc.items.Count;
     //			}
     //
     return aValue;
 }
コード例 #37
0
		public void setOptionsGrid(Grid buttonGrid, List<string> buttonText, List<VisualElement> grids, List<Action> actions, CarouselView carousel)
		{
			List<Button> buttons = new List<Button>();
			List<Action> clickButtonAction = new List<Action>();
			if (buttonText != null)
			{
				foreach (String s in buttonText)
				{
					Button b = new Button { Text = s, BackgroundColor = Color.Transparent, HorizontalOptions = LayoutOptions.Fill, TextColor = App.PlaceHolderColor, FontSize = 12 };
					buttons.Add(b);
					clickButtonAction.Add(() => selectButton(buttons, b));
				}
			}

			if (grids != null && grids[0] != null) grids[0].IsVisible = true;
			//if (actions != null && actions[0] != null) { actions[0].Invoke(); }
			selectButton(buttons, buttons[0]);

			int bNumber = 0;
			buttonGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(28, GridUnitType.Absolute) });
			buttonGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(2, GridUnitType.Absolute) });
			buttonGrid.RowSpacing = 0;

			StackLayout selectedBar = new StackLayout() { BackgroundColor = App.HowlOut };
			buttonGrid.Children.Add(selectedBar, 0, 1);

			for (int i = 0; i < (buttons.Count * 2 - 1); i++)
			{
				if (i % 2 == 0)
				{
					buttonGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
				}
				else {
					buttonGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = 1 });
				}

				if (i == (buttons.Count * 2 - 1) - 1)
				{
					buttonGrid.Children.Add(new Button() { BorderColor = App.LineColor, BorderWidth = 0.0, BorderRadius = 0, BackgroundColor = Color.White }, 0, i + 1, 0, 1);
				}
			}

			for (int i = 0; i < (buttons.Count * 2 - 1); i++)
			{
				if (i % 2 == 0)
				{
					buttonGrid.Children.Add(buttons[bNumber], i, 0);
					bNumber++;
				}
				else {
					//buttonGrid.Children.Add(new StackLayout() { WidthRequest = 1, BackgroundColor = App.LineColor }, i, 0);
				}
			}

			if (carousel != null)
			{
				carousel.PositionSelected += (sender, e) =>
				{
					if (clickButtonAction[carousel.Position] != null) { 
						clickButtonAction[carousel.Position].Invoke(); 
					}
					buttonGrid.Children.Add(selectedBar, carousel.Position * 2, 1);
				};
			}

			foreach (Button b in buttons)
			{
				b.Clicked += (sender, e) =>
				{
					//selectButton(buttons, b);
					if (grids != null)
					{
						foreach (VisualElement g in grids)
						{
							if (g != null) { g.IsVisible = false; }
						}
					}
					if (clickButtonAction[buttons.IndexOf(b)] != null) { clickButtonAction[buttons.IndexOf(b)].Invoke(); }
					if (grids != null && grids[buttons.IndexOf(b)] != null) { grids[buttons.IndexOf(b)].IsVisible = true; }
					if (actions != null && actions[buttons.IndexOf(b)] != null) { actions[buttons.IndexOf(b)].Invoke(); }
					//scrollTo(b);
				};
			}

		}
コード例 #38
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            var imgView = new UIImageView(BlueSea.MakeBlueSea()){
                ContentMode = UIViewContentMode.ScaleToFill,
                AutoresizingMask = UIViewAutoresizing.All,
                Frame = View.Bounds
            };

            View.Add (imgView);
            View.SendSubviewToBack (imgView);

            Photos = AppDelegate.dao.GetInsurancePhotosByTypeAndID (isLargeObject, currentID);

            carousel = new CarouselView(View.Bounds);
            carousel.DataSource = new InsurancePhotoDataSource(this);
            carousel.Delegate = new InsurancePhotoDelegate(this);
            carousel.CarouselType = CarouselType.CoverFlow;
            carousel.ConfigureView();
            View.AddSubview(carousel);

            View.AddSubview (carousel);
            CreateAddBarButton ();
            CreateDeleteBarButton ();

            //carousel.CurrentItemIndex
        }
コード例 #39
0
		public override uint NumberOfItems(CarouselView carousel)
		{
			return (uint)product.Count;
		}
コード例 #40
0
 public override uint NumberOfItems(CarouselView carousel)
 {
     if (vc.Photos != null) {
         return (uint)vc.Photos.Count;
     } else {
         return 0;
     }
 }
コード例 #41
0
        public override UIView ViewForItem(CarouselView carousel, uint index, UIView reusingView)
        {
            var imgView = reusingView as UIImageView;

            var documentsDirectory = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            var gallerydirectory = Path.Combine (documentsDirectory, "insurancePhotos");

            InsurancePhoto photo = vc.Photos[(int)index];
            string thumbfilename = photo.ThumbFileName;
            string path = Path.Combine (gallerydirectory, thumbfilename);
            Console.WriteLine ("path:" + path);
            UIImage currentImage = UIImage.FromFile (path);
            SizeF dim = currentImage.Size;

            //create new view if none is availble fr recycling
            if (imgView == null) {
                imgView = new UIImageView(new RectangleF(0,0, dim.Width,dim.Height)){
                    ContentMode = UIViewContentMode.ScaleAspectFit
                };
            }

            if (currentImage == null) {
                Console.WriteLine ("Fubar image");
            }

            //imgView.CancelCurrentImageLoad (); //?????
            imgView.Image = currentImage;

            reusingView = imgView;

            return reusingView;
        }
コード例 #42
0
		async void GetData ()
		{
			//source.Products

			List<Product> PP = await WebService.Shared.GetProducts ();
			//Kicking off a task no need to await
			#pragma warning disable 4014
			WebService.Shared.PreloadImages (320 * UIScreen.MainScreen.Scale);
			#pragma warning restore 4014

			carousel = new CarouselView(new RectangleF(0,64,  View.Bounds.Width, View.Bounds.Height - 94));
			carousel.BackgroundColor = UIColor.White;
			carousel.DataSource = new LinearDataSource(this, PP);
			carousel.Delegate = new LinearDelegate(this, 
				PP,  (products => { ProductTapped(products); }));
			carousel.CarouselType = CarouselType.Rotary;
			carousel.ConfigureView();
			View.AddSubview(carousel);

		}
コード例 #43
0
        public override void DidSelectItem(CarouselView carousel, int index)
        {
            photo = vc.Photos [index];

            vip = new ViewInsurancePhoto (photo);
            vc.NavigationController.PushViewController (vip, false);
        }
コード例 #44
0
 public override void DidSelectItem(CarouselView carousel, int index)
 {
     vc.Open (index);
 }
コード例 #45
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            InitActiveField ();

            items = GetActiveGalleryItems ();

            Console.WriteLine (items.Count);

            var imgView = new UIImageView (BlueSea.MakeBlueSea ()) {
                ContentMode = UIViewContentMode.ScaleToFill,
                AutoresizingMask = UIViewAutoresizing.All,
                Frame = View.Bounds
            };
            View.AddSubview (imgView);
            View.SendSubviewToBack (imgView);

            carousel = new CarouselView (UIScreen.MainScreen.Bounds);
            //carousel. = images.Count;
            carousel.DataSource = new GalleryDataSource (this);
            gd = new GalleryDelegate (this);
            carousel.Delegate = gd;
            carousel.CarouselType = CarouselType.CoverFlow;
            carousel.ConfigureView ();
            View.AddSubview (carousel);

            //
            //			tap = new UITapGestureRecognizer (Tapped);
            //			tap.NumberOfTapsRequired = 1;
            //			carousel.AddGestureRecognizer (tap);

            View.AddSubview (carousel);
            //CreateAddBarButton ();
            //CreateDeleteBarButton ();

            //carousel.CurrentItemIndex

            //InitSateliteMenu ();

            menu = new IndexerSateliteMenu ("Gallery", this);
            View.Add (menu.View);

            CreateOptions ();

            View.BringSubviewToFront (ActiveText);
        }