public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = UIColor.White;

            _coverFlow             = new iCarousel();
            _coverFlow.Delegate    = new CarouselDelegate();
            _coverFlow.DataSource  = new CarouselDataSource();
            _coverFlow.Type        = iCarouselType.CoverFlow;
            _coverFlow.ScrollSpeed = 0.5f;
            _coverFlow.IgnorePerpendicularSwipes = true;

            Add(_coverFlow);

            _coverFlow.ReloadData();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            View.BackgroundColor = UIColor.White;

            _coverFlow = new iCarousel();
            _coverFlow.Delegate = new CarouselDelegate();
            _coverFlow.DataSource = new CarouselDataSource();
            _coverFlow.Type = iCarouselType.CoverFlow;
            _coverFlow.ScrollSpeed = 0.5f;
            _coverFlow.IgnorePerpendicularSwipes = true;

            Add(_coverFlow);

            _coverFlow.ReloadData();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            bool wrap = false;

            // create a nice background
            background = new UIImageView (View.Bounds);
            background.Image = UIImage.FromBundle ("background.png");
            background.ContentMode = UIViewContentMode.ScaleToFill;
            background.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            View.AddSubview (background);

            // create the carousel
            carousel = new iCarousel (View.Bounds);
            carousel.Type = iCarouselType.CoverFlow2;
            carousel.DataSource = new CarouselDataSource ();
            carousel.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            View.AddSubview (carousel);

            // customize the appearance of the carousel
            carousel.GetValue = (sender, option, value) => {
                // set a nice spacing between items
                if (option == iCarouselOption.Spacing) {
                    return value * 1.1F;
                } else if (option == iCarouselOption.Wrap) {
                    return wrap ? 1 : 0;
                }

                // use the defaults for everything else
                return value;
            };

            // handle item selections
            carousel.ItemSelected += (sender, args) => {
                using (var alert = new UIAlertView ("Item Selected", string.Format ("You selected item '{0}'.", args.Index), null, "OK"))
                    alert.Show ();
            };

            NavigationItem.RightBarButtonItem = new UIBarButtonItem ("Wrap Off", UIBarButtonItemStyle.Plain, (sender, args) => {
                wrap = !wrap;
                carousel.ReloadData ();
                if (wrap)
                    NavigationItem.RightBarButtonItem.Title = "Wrap On";
                else
                    NavigationItem.RightBarButtonItem.Title = "Wrap Off";
            });
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem (carousel.Type.ToString (), UIBarButtonItemStyle.Plain, (sender, args) => {
                // create the popup
                UIActionSheet sheet = new UIActionSheet ("Select Carousel Type");
                var names = Enum.GetNames (typeof(iCarouselType));
                foreach (var type in names.Where(n => n != "Custom"))
                    sheet.AddButton (type);
                // change the type
                sheet.Dismissed += (_, e) => {
                    if (e.ButtonIndex != -1) {
                        // animate the change
                        UIView.BeginAnimations (null);
                        carousel.Type = (iCarouselType)Enum.Parse (typeof(iCarouselType), names [e.ButtonIndex]);
                        UIView.CommitAnimations ();

                        NavigationItem.LeftBarButtonItem.Title = carousel.Type.ToString ();
                    }
                };
                // show the popup
                sheet.ShowInView (View);
            });
        }
Beispiel #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            bool wrap = false;

            // create a nice background
            background                  = new UIImageView(View.Bounds);
            background.Image            = UIImage.FromBundle("background.png");
            background.ContentMode      = UIViewContentMode.ScaleToFill;
            background.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            View.AddSubview(background);

            // create the carousel
            carousel                  = new iCarousel(View.Bounds);
            carousel.Type             = iCarouselType.CoverFlow2;
            carousel.DataSource       = new CarouselDataSource();
            carousel.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            View.AddSubview(carousel);

            // customize the appearance of the carousel
            carousel.GetValue = (sender, option, value) => {
                // set a nice spacing between items
                if (option == iCarouselOption.Spacing)
                {
                    return(value * 1.1F);
                }
                else if (option == iCarouselOption.Wrap)
                {
                    return(wrap ? 1 : 0);
                }

                // use the defaults for everything else
                return(value);
            };

            // handle item selections
            carousel.ItemSelected += (sender, args) => {
                using (var alert = new UIAlertView("Item Selected", string.Format("You selected item '{0}'.", args.Index), null, "OK"))
                    alert.Show();
            };

            NavigationItem.RightBarButtonItem = new UIBarButtonItem("Wrap Off", UIBarButtonItemStyle.Plain, (sender, args) => {
                wrap = !wrap;
                carousel.ReloadData();
                if (wrap)
                {
                    NavigationItem.RightBarButtonItem.Title = "Wrap On";
                }
                else
                {
                    NavigationItem.RightBarButtonItem.Title = "Wrap Off";
                }
            });
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem(carousel.Type.ToString(), UIBarButtonItemStyle.Plain, (sender, args) => {
                // create the popup
                UIActionSheet sheet = new UIActionSheet("Select Carousel Type");
                var names           = Enum.GetNames(typeof(iCarouselType));
                foreach (var type in names.Where(n => n != "Custom"))
                {
                    sheet.AddButton(type);
                }
                // change the type
                sheet.Dismissed += (_, e) => {
                    if (e.ButtonIndex != -1)
                    {
                        // animate the change
                        UIView.BeginAnimations(null);
                        carousel.Type = (iCarouselType)Enum.Parse(typeof(iCarouselType), names [e.ButtonIndex]);
                        UIView.CommitAnimations();

                        NavigationItem.LeftBarButtonItem.Title = carousel.Type.ToString();
                    }
                };
                // show the popup
                sheet.ShowInView(View);
            });
        }
Beispiel #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            bool wrap = false;

            // create a nice background
            background                  = new UIImageView(View.Bounds);
            background.Image            = UIImage.FromBundle("background.png");
            background.ContentMode      = UIViewContentMode.ScaleToFill;
            background.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            View.AddSubview(background);

            // create the carousel
            carousel                  = new iCarousel();
            carousel.Type             = iCarouselType.CoverFlow2;
            carousel.DataSource       = new CarouselDataSource();
            carousel.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            View.AddSubview(carousel);

            // customize the appearance of the carousel
            carousel.GetValue = (sender, option, value) => {
                // set a nice spacing between items
                if (option == iCarouselOption.Spacing)
                {
                    return(value * 1.1F);
                }
                else if (option == iCarouselOption.Wrap)
                {
                    return(wrap ? 0 : 1);
                }

                // use the defaults for everything else
                return(value);
            };

            // handle item selections
            carousel.ItemSelected += (sender, args) => {
                using (var alert = new UIAlertView("Item Selected", string.Format("You selected item '{0}'.", args.Index), null, "OK"))
                    alert.Show();
            };

            toolbar = new UIToolbar();
            toolbar.SetItems(new [] {
                new UIBarButtonItem("Change Style", UIBarButtonItemStyle.Plain, (sender, args) => {
                    // create the popup
                    UIActionSheet sheet = new UIActionSheet("Select Carousel Type");
                    var names           = Enum.GetNames(typeof(iCarouselType));
                    foreach (var type in names.Where(n => n != "Custom"))
                    {
                        sheet.AddButton(type);
                    }
                    // change the type
                    sheet.Dismissed += (_, e) => {
                        if (e.ButtonIndex != -1)
                        {
                            // animate the change
                            UIView.BeginAnimations(null);
                            carousel.Type = (iCarouselType)Enum.Parse(typeof(iCarouselType), names [e.ButtonIndex]);
                            UIView.CommitAnimations();
                        }
                    };
                    // show the popup
                    sheet.ShowInView(View);
                }),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem("Toggle Wrap", UIBarButtonItemStyle.Plain, (sender, args) => {
                    wrap = !wrap;
                    carousel.ReloadData();
                })
            }, false);
            View.AddSubview(toolbar);
            toolbar.TranslatesAutoresizingMaskIntoConstraints = false;
            View.AddConstraints(new [] {
                NSLayoutConstraint.Create(toolbar, NSLayoutAttribute.Top, NSLayoutRelation.Equal, View, NSLayoutAttribute.Top, 1, 0),
                NSLayoutConstraint.Create(toolbar, NSLayoutAttribute.Left, NSLayoutRelation.Equal, View, NSLayoutAttribute.Left, 1, 0),
                NSLayoutConstraint.Create(toolbar, NSLayoutAttribute.Right, NSLayoutRelation.Equal, View, NSLayoutAttribute.Right, 1, 0),
            });
        }