public override UIView PlaceholderViewAtIndex(iCarousel carousel, uint index, UIView view)
            {
                UILabel     label     = null;
                UIImageView imageView = null;

                //create new view if no view is available for recycling
                if (null == view)
                {
                    //don't do anything specific to the index within
                    //this `if (view == nil) {...}` statement because the view will be
                    //recycled and used with other index values later
                    imageView             = new UIImageView(new RectangleF(0f, 0f, 200.0f, 200.0f));
                    imageView.Image       = UIImage.FromBundle("page.png");
                    imageView.ContentMode = UIViewContentMode.Center;
                    label = new UILabel(imageView.Bounds);
                    label.BackgroundColor = UIColor.Clear;
                    label.TextAlignment   = UITextAlignment.Center;
                    label.Font            = label.Font.WithSize(50f);
                    label.Tag             = 1;
                    imageView.AddSubview(label);
                }
                else
                {
                    label     = (UILabel)view.ViewWithTag(1);
                    imageView = (UIImageView)view;
                }
                //set item label
                //remember to always set any properties of your carousel item
                //views outside of the `if (view == nil) {...}` check otherwise
                //you'll get weird issues with carousel item content appearing
                //in the wrong place in the carousel
                label.Text = (index == 0) ? "[" : "]";

                return(imageView);
            }
Exemple #2
0
            public override UIView GetViewForItem(iCarousel carousel, nint index, UIView view)
            {
                UILabel     label     = null;
                UIImageView imageView = null;

                if (view == null)
                {
                    // create new view if no view is available for recycling
                    imageView             = new UIImageView(new CGRect(0, 0, 200.0f, 200.0f));
                    imageView.Image       = UIImage.FromBundle("page.png");
                    imageView.ContentMode = UIViewContentMode.Center;

                    label = new UILabel(imageView.Bounds);
                    label.BackgroundColor = UIColor.Clear;
                    label.TextAlignment   = UITextAlignment.Center;
                    label.Font            = label.Font.WithSize(50);
                    label.Tag             = 1;
                    imageView.AddSubview(label);
                }
                else
                {
                    // get a reference to the label in the recycled view
                    imageView = (UIImageView)view;
                    label     = (UILabel)view.ViewWithTag(1);
                }

                // set the values of the view
                label.Text = items [index].ToString();

                return(imageView);
            }
Exemple #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 = Enumerable.Range(1, 100).ToList();              // Prettier than for (int 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 iCarousel view
            carousel = new iCarousel(View.Bounds)
            {
                CarouselType = iCarouselType.Cylinder,
                DataSource   = new AutoScrollDataSource(this),
                Delegate     = new AutoScrollDelegate(this)
            };

            View.AddSubview(carousel);

            StartScrolling();
        }
Exemple #4
0
            public override UIView ViewForItem(iCarousel carousel, uint 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 RectangleF(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);
            }
            public override UIView ViewForItemAtIndex(iCarousel carousel, nint index, UIView view)
            {
                UILabel label;

                // create new view if no view is available for recycling
                if (view == null)
                {
                    var imgView = new UIImageView(new RectangleF(0, 200, 200, 200))
                    {
                        BackgroundColor = UIColor.Orange,
                        ContentMode     = UIViewContentMode.Center
                    };

                    label = new UILabel(imgView.Bounds)
                    {
                        BackgroundColor = UIColor.Clear,
                        TextAlignment   = UITextAlignment.Center,
                        Tag             = 1
                    };
                    imgView.AddSubview(label);
                    view = imgView;
                }
                else
                {
                    // get a reference to the label in the recycled view
                    label = (UILabel)view.ViewWithTag(1);
                }

                label.Text = _data[(int)index].ToString();

                return(view);
            }
        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 iCarousel view
            Carousel = new iCarousel(View.Bounds)
            {
                CarouselType = iCarouselType.CoverFlow2,
                DataSource   = new ControlsDataSource(this)
            };

            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);
        }
            public override NSView GetViewForItem(iCarousel carousel, nint index, NSView view)
            {
                NSTextField label     = null;
                NSImageView imageView = null;

                if (view == null)
                {
                    // create new view if no view is available for recycling
                    imageView                = new NSImageView(new CGRect(0, 0, 200.0f, 200.0f));
                    imageView.Image          = NSImage.ImageNamed("page");
                    imageView.ImageAlignment = NSImageAlignment.Center;

                    label = new NSTextField(imageView.Bounds);
                    label.BackgroundColor = NSColor.Clear;
                    label.Alignment       = NSTextAlignment.Center;
                    label.Font            = NSFont.LabelFontOfSize(50);
                    label.Bordered        = false;
                    label.Editable        = false;
                    label.Tag             = 1;
                    imageView.AddSubview(label);
                }
                else
                {
                    // get a reference to the label in the recycled view
                    imageView = (NSImageView)view;
                    label     = (NSTextField)view.ViewWithTag(1);
                }

                // set the values of the view
                label.StringValue = items[index].ToString();

                return(imageView);
            }
Exemple #8
0
        public override UIView ViewForItemAtIndex(iCarousel carousel, nint index, UIView view)
        {
            //throw new NotImplementedException();
            var jacketCardVC = _storyboard.InstantiateViewController("JacketCardViewController") as JacketCardViewController;

            _jacketCardViewControllers.Add(jacketCardVC);
            //jacketCardVC.JacketOwnerLabel.Text = _JacketList[(Convert.ToInt16(index))].JacketOwner;
            //jacketCardVC.JacketIDLabel.Text = _JacketList[(Convert.ToInt16(index))].JacketID;
            //jacketCardVC.LocationLabel.Text = _JacketList[(Convert.ToInt16(index))].Location;
            var jacketCardView = jacketCardVC.View;
            var outerView      = new UIView()
            {
                Frame  = new CGRect(0, 0, 270, 127),
                Bounds = new CGRect(0, 0, 270, 127)
            };

            //Implement settings for each view

            jacketCardView.Frame            = new CGRect(0, 0, 270, 127);
            outerView.ClipsToBounds         = false;
            outerView.Layer.ShadowColor     = UIColor.Black.CGColor;
            outerView.Layer.ShadowOpacity   = (float)0.5;
            outerView.Layer.ShadowOffset    = new CoreGraphics.CGSize(-2, -2);
            outerView.Layer.ShadowRadius    = (nfloat)10.0;
            outerView.Layer.ShadowPath      = UIBezierPath.FromRect(new CoreGraphics.CGRect(0, 0, 275, 132)).CGPath;
            outerView.Layer.ShouldRasterize = true;
            outerView.AddSubview(jacketCardView);

            return(outerView);
        }
        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 iCarousel view
            Carousel = new iCarousel (View.Bounds) {
                CarouselType = iCarouselType.CoverFlow2,
                DataSource = new ControlsDataSource (this)
            };

            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);
        }
        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 (int 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 iCarousel view
            carousel = new iCarousel (View.Bounds) {
                CarouselType = iCarouselType.Cylinder,
                DataSource = new AutoScrollDataSource (this),
                Delegate = new AutoScrollDelegate (this)
            };

            View.AddSubview (carousel);

            StartScrolling ();
        }
Exemple #11
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            items = Enumerable.Range(1, 3).ToList();

            // Setup iCarousel view
            carousel = new iCarousel
            {
                Bounds                 = carrosselView.Frame,
                ContentMode            = UIViewContentMode.Center,
                Type                   = iCarouselType.Rotary,
                Frame                  = carrosselView.Bounds,
                CenterItemWhenSelected = true,
                DataSource             = new SimpleDataSource(items),
                Delegate               = new SimpleDelegate(this)
            };

            //carousel.CurrentItemIndex = 2;


            carrosselView.AddSubview(carousel);
            //carousel.Frame = carrosselView.Bounds;
            carousel.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            //ViewDidLayoutSubviews();

            System.Timers.Timer timer = new System.Timers.Timer(3000);
            timer.Elapsed  += OnTimedEvent;
            timer.AutoReset = true;
            timer.Enabled   = true;
        }
Exemple #12
0
 public override float ValueForOption(iCarousel carousel, iCarouselOption option, float aValue)
 {
     if (option == iCarouselOption.Spacing)
     {
         return(aValue * 1.1f);
     }
     return(aValue);
 }
            public override void DidSelectItemAtIndex(iCarousel carousel, nint index)
            {
                var alert = UIAlertController.Create("Clicked index:", index.ToString(), UIAlertControllerStyle.Alert);

                alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null));

                _viewController.PresentViewController(alert, animated: true, completionHandler: null);
            }
 public override uint NumberOfItems(iCarousel 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);
 }
Exemple #15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            launchViewModel           = new LaunchViewModel();
            jacketCardViewControllers = new List <JacketCardViewController>();
            launchVCRef = this;

            var     soundUrl = new NSUrl("Sounds/bgmusic.mp3");
            NSError err;

            audioPlayer                  = new AVAudioPlayer(soundUrl, "Song", out err);
            audioPlayer.Volume           = 0.5f;
            audioPlayer.FinishedPlaying += AudioPlayer_FinishedPlaying;
            audioPlayer.Play();

            jacketCarouselPageControl.Pages       = 3;
            jacketCarouselPageControl.CurrentPage = 0;

            var logoVC          = Storyboard.InstantiateViewController("ConsoleLogoAnimationViewController") as ConsoleLogoAnimationViewController;
            var consoleLogoView = logoVC.View;

            logoVC.StartAnimation(ConsoleLogoAnimationViewController.loopNumber);
            consoleLogoView.Frame = new CGRect(0, 0, 309, 48);
            logoView.AddSubview(consoleLogoView);


            var carousel = new iCarousel
            {
                ContentMode            = UIViewContentMode.Left,
                Type                   = iCarouselType.Linear,
                Frame                  = new CGRect(0, 0, 300, 127),
                Bounds                 = new CGRect(0, 0, 300, 127),
                BackgroundColor        = UIColor.Clear,
                CenterItemWhenSelected = true,
                ViewpointOffset        = new CGSize((nfloat)(5), (nfloat)0),
                PagingEnabled          = true,
                DataSource             = new JacketCarouselDataSource(Storyboard, jacketCardViewControllers),
                Delegate               = new JacketCarouselDelegate(jacketCarouselPageControl)
            };

            jacketCarousel.AddSubview(carousel);

            addJacketButton.TouchUpInside += AddJacketButton_TouchUpInside;

            buyJacketButton.TouchUpInside += BuyJacketButton_TouchUpInside;

            searchJacketByIdButton.TouchUpInside += SearchJacketByIdButton_TouchUpInside;

            aboutButton.TouchUpInside += AboutButton_TouchUpInside;

            NavigationController.NavigationBar.Hidden = true;

            remainingJacketView.Layer.CornerRadius = 10;
            remainingJacketView.ClipsToBounds      = true;

            loginSignupView.Layer.CornerRadius = 10;
            loginSignupView.ClipsToBounds      = true;
        }
Exemple #16
0
        public override nfloat ValueForOption(iCarousel carousel, iCarouselOption option, nfloat defaultValue)
        {
            switch (option)
            {
            case iCarouselOption.Spacing: return(0.5f);
            }

            return(defaultValue);
        }
        public override nfloat ValueForOption(iCarousel carousel, iCarouselOption option, nfloat defaultValue)
        {
            switch (option)
            {
                case iCarouselOption.Spacing: return 0.5f;
            }

            return defaultValue;
        }
Exemple #18
0
        public nfloat ValueForOption(iCarousel carousel, iCarouselOption option, nfloat value)
        {
            switch (option)
            {
            case iCarouselOption.Spacing:
                return((nfloat)(value * 1.1));

            case iCarouselOption.Wrap:
                return((nfloat)0.0);

            default:
                return(value);
            }
        }
        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();
        }
Exemple #21
0
            public override UIView ViewForItem(iCarousel carousel, uint index, UIView reusingView)
            {
                UILabel label;

                // create new view if no view is available for recycling
                if (reusingView == null)
                {
                    // don't do anything specific to the index within
                    // this `if (view == null) {...}` statement because the view will be
                    // recycled and used with other index values later
                    var imgView = new UIImageView(new RectangleF(0, 0, 200, 200))
                    {
                        Image       = UIImage.FromBundle("page"),
                        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
                {
                    // get a reference to the label in the recycled view
                    label = (UILabel)reusingView.ViewWithTag(1);
                }

                // set item label
                // remember to always set any properties of your carousel item
                // views outside of the `if (view == null) {...}` check otherwise
                // you'll get weird issues with carousel item content appearing
                // in the wrong place in the carousel
                label.Text = vc.items[(int)index].ToString();

                return(reusingView);
            }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            items = Enumerable.Range(1, 100).ToList();

            // Setup iCarousel view
            var carousel = new iCarousel
            {
                Bounds                 = View.Bounds,
                ContentMode            = UIViewContentMode.Center,
                Type                   = iCarouselType.CoverFlow2,
                Frame                  = View.Frame,
                CenterItemWhenSelected = true,
                DataSource             = new SimpleDataSource(items),
                Delegate               = new SimpleDelegate(this)
            };

            View.AddSubview(carousel);
            ViewDidLayoutSubviews();
        }
        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 iCarousel view
            carousel = new iCarousel (View.Bounds) {
                CarouselType = iCarouselType.CoverFlow2,
                DataSource = new AsyncImageDataSource (this),
                Delegate = new AsyncImageDelegate (this)
            };

            View.AddSubview (carousel);
        }
            public override UIView ViewForItemAtIndex(iCarousel carousel, uint index, UIView view)
            {
                //create new view if no view is available for recycling
                if (view == null)
                {
                    var v = new UIImageView(new RectangleF(0f, 0f, 200.0f, 200.0f));
                    v.Image       = UIImage.FromBundle("page.png");
                    v.ContentMode = UIViewContentMode.Center;
                    var l = new UILabel(v.Bounds);
                    l.BackgroundColor = UIColor.Clear;
                    l.TextAlignment   = UITextAlignment.Center;
                    l.Font            = l.Font.WithSize(50f);
                    l.Tag             = 1;
                    l.Text            = owner.items [(int)index].ToString();
                    v.AddSubview(l);
                    return(v);
                }
                var label = (UILabel)view.ViewWithTag(1);

                label.Text = owner.items [(int)index].ToString();
                return(view);
            }
Exemple #25
0
            public override UIView ViewForItem(iCarousel carousel, uint index, UIView reusingView)
            {
                var imgView = reusingView as UIImageView;

                // create new view if no view is available for recycling
                if (imgView == null)
                {
                    // don't do anything specific to the index within
                    // this `if (view == null) {...}` statement because the view will be
                    // recycled and used with other index values later
                    imgView = new UIImageView(new RectangleF(0, 0, 200, 200))
                    {
                        ContentMode = UIViewContentMode.ScaleAspectFit
                    };
                }

                imgView.CancelCurrentImageLoad();
                imgView.SetImage(new NSUrl(vc.images[(int)index]), UIImage.FromBundle("placeholder"));

                reusingView = imgView;

                return(reusingView);
            }
        public override UIView ViewForItemAtIndex(iCarousel carousel, nint index, UIView reusingView)
        {
            UILabel label = null;

            //create new view if no view is available for recycling
            if (reusingView == null)
            {
                var imageView = new UIImageView(new CGRect(0, 0, 200.0f, 200.0f));
                imageView.Image       = UIImage.FromFile("page.png");
                imageView.ContentMode = UIViewContentMode.Center;

                var frame = new CGRect(0, imageView.Frame.Bottom, imageView.Frame.Width, 75);
                label = new UILabel(frame);
                label.BackgroundColor = UIColor.Clear;
                label.TextAlignment   = UITextAlignment.Center;
                label.Font            = label.Font.WithSize(50);
                label.Tag             = 1;
                imageView.AddSubview(label);

                reusingView = imageView;
            }
            else
            {
                //get a reference to the label in the recycled view
                label = (UILabel)reusingView.ViewWithTag(1);
            }

            //set item label
            //remember to always set any properties of your carousel item
            //views outside of the `if (view == nil) {...}` check otherwise
            //you'll get weird issues with carousel item content appearing
            //in the wrong place in the carousel
            label.Text = _items[(int)index].ToString();
            label.Font = UIFont.FromName("HelveticaNeue", 12);

            return(reusingView);
        }
Exemple #27
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 iCarousel view
            carousel = new iCarousel(View.Bounds)
            {
                CarouselType = iCarouselType.CoverFlow2,
                DataSource   = new AsyncImageDataSource(this),
                Delegate     = new AsyncImageDelegate(this)
            };

            View.AddSubview(carousel);
        }
            public override float ValueForOption(iCarousel carousel, iCarouselOption option, float value)
            {
                // customize carousel display
                switch (option)
                {
                case iCarouselOption.Wrap:
                    // normally you would hard-code this to true or false
                    return(owner.wrap ? 1.0f : 0.0f);

                case iCarouselOption.Spacing:
                    // add a bit of spacing between the item views
                    return(value * 1.05f);

                case iCarouselOption.FadeMax:
                    if (iCarouselType.Custom == carousel.Type)
                    {
                        return(0.0f);
                    }
                    return(value);

                default:
                    return(value);
                }
            }
 public override nint GetNumberOfItems(iCarousel carousel)
 {
     // return the number of items in the data
     return(items.Length);
 }
            public override UIView ViewForItem(iCarousel carousel, uint index, UIView reusingView)
            {
                if (reusingView == null)
                {
                    var itemView = new UIView(new RectangleF(0, 0, 200, 200))
                    {
                        AutoresizingMask = UIViewAutoresizing.All
                    };

                    // Creating the background
                    var imgView = new UIImageView(new RectangleF(-20, -90, 240, 380))
                    {
                        Image       = UIImage.FromBundle("page"),
                        ContentMode = UIViewContentMode.Center
                    };
                    itemView.AddSubview(imgView);

                    // We create and add some controls
                    // UIButton
                    var button = UIButton.FromType(UIButtonType.RoundedRect);
                    button.Frame = new RectangleF(20, 20, 160, 37);
                    button.SetTitle("Press me!", UIControlState.Normal);
                    button.TouchUpInside += (sender, e) => {
                        vc.Label.Text = string.Format("Button {0} tapped", vc.Carousel.IndexOfItemViewOrSubview(sender as UIView));
                    };

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

                    itemView.AddSubview(button);

                    // UISwitch
                    var switchbtn = new UISwitch(new RectangleF(62, 86, 79, 27));
                    switchbtn.ValueChanged += (sender, e) => {
                        vc.Label.Text = string.Format("Switch {0} toggled", vc.Carousel.IndexOfItemViewOrSubview(sender as UIView));
                    };

                    if (!vc.ObjCache.Contains(switchbtn))
                    {
                        vc.ObjCache.Add(switchbtn);
                    }

                    itemView.AddSubview(switchbtn);

                    // UISlider
                    var slider = new UISlider(new RectangleF(41, 146, 118, 23))
                    {
                        MinValue = 0,
                        MaxValue = 100,
                        Value    = 50
                    };
                    slider.ValueChanged += (sender, e) => {
                        vc.Label.Text = string.Format("Slider {0} changed", vc.Carousel.IndexOfItemViewOrSubview(sender as UIView));
                    };

                    if (!vc.ObjCache.Contains(slider))
                    {
                        vc.ObjCache.Add(slider);
                    }

                    itemView.AddSubview(slider);

                    reusingView = itemView;
                }
                return(reusingView);
            }
            public override UIView ViewForItem(iCarousel carousel, uint index, UIView reusingView)
            {
                var imgView = reusingView as UIImageView;

                // create new view if no view is available for recycling
                if (imgView == null)
                {
                    // don't do anything specific to the index within
                    // this `if (view == null) {...}` statement because the view will be
                    // recycled and used with other index values later
                    imgView = new UIImageView (new RectangleF (0, 0, 200, 200)) {
                        ContentMode = UIViewContentMode.ScaleAspectFit
                    };
                }

                imgView.CancelCurrentImageLoad ();
                imgView.SetImage (new NSUrl (vc.images[(int)index]), UIImage.FromBundle ("placeholder"));

                reusingView = imgView;

                return reusingView;
            }
            public override UIView ViewForItem(iCarousel carousel, uint index, UIView reusingView)
            {
                UILabel label;

                // create new view if no view is available for recycling
                if (reusingView == null)
                {
                    // don't do anything specific to the index within
                    // this `if (view == null) {...}` statement because the view will be
                    // recycled and used with other index values later
                    var imgView = new UIImageView (new RectangleF (0, 0, 200, 200)) {
                        Image = UIImage.FromBundle ("page"),
                        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
                {
                    // get a reference to the label in the recycled view
                    label = (UILabel) reusingView.ViewWithTag (1);
                }

                // set item label
                // remember to always set any properties of your carousel item
                // views outside of the `if (view == null) {...}` check otherwise
                // you'll get weird issues with carousel item content appearing
                // in the wrong place in the carousel
                label.Text = vc.items[(int)index].ToString();

                return reusingView;
            }
 public override uint NumberOfItems(iCarousel carousel)
 {
     return (uint) vc.items.Count;
 }
 public override float ValueForOption(iCarousel carousel, iCarouselOption option, float value)
 {
     // customize carousel display
     switch (option) {
     case iCarouselOption.Wrap:
         // normally you would hard-code this to true or false
         return (owner.wrap ? 1.0f : 0.0f);
     case iCarouselOption.Spacing:
         // add a bit of spacing between the item views
         return value * 1.05f;
     case iCarouselOption.FadeMax:
         if (iCarouselType.Custom == carousel.Type) {
             return 0.0f;
         }
         return value;
     default:
         return value;
     }
 }
 public override UIView ViewForItemAtIndex(iCarousel carousel, uint index, UIView view)
 {
     //create new view if no view is available for recycling
     if (view == null) {
         var v = new UIImageView (new RectangleF (0f, 0f, 200.0f, 200.0f));
         v.Image = UIImage.FromBundle ("page.png");
         v.ContentMode = UIViewContentMode.Center;
         var l = new UILabel (v.Bounds);
         l.BackgroundColor = UIColor.Clear;
         l.TextAlignment = UITextAlignment.Center;
         l.Font = l.Font.WithSize (50f);
         l.Tag = 1;
         l.Text = owner.items [(int)index].ToString ();
         v.AddSubview (l);
         return v;
     }
     var label = (UILabel)view.ViewWithTag (1);
     label.Text = owner.items [(int)index].ToString ();
     return view;
 }
 public override uint NumberOfPlaceholdersInCarousel(iCarousel carousel)
 {
     return 2;
 }
            public override UIView ViewForItem(iCarousel carousel, uint 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 RectangleF (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;
            }
 public override nint NumberOfPlaceholdersInCarousel(iCarousel carousel)
 {
     return(0);
 }
 public override UIView PlaceholderViewAtIndex(iCarousel carousel, nint index, UIView view)
 {
     return(null);
 }
            public override UIView GetViewForItem(iCarousel carousel, nint index, UIView view)
            {
                UILabel label = null;
                UIImageView imageView = null;

                if (view == null) {
                    // create new view if no view is available for recycling
                    imageView = new UIImageView (new CGRect (0, 0, 200.0f, 200.0f));
                    imageView.Image = UIImage.FromBundle ("page.png");
                    imageView.ContentMode = UIViewContentMode.Center;

                    label = new UILabel (imageView.Bounds);
                    label.BackgroundColor = UIColor.Clear;
                    label.TextAlignment = UITextAlignment.Center;
                    label.Font = label.Font.WithSize (50);
                    label.Tag = 1;
                    imageView.AddSubview (label);
                } else {
                    // get a reference to the label in the recycled view
                    imageView = (UIImageView)view;
                    label = (UILabel)view.ViewWithTag (1);
                }

                // set the values of the view
                label.Text = items [index].ToString ();

                return imageView;
            }
Exemple #41
0
 public override uint NumberOfItems(iCarousel carousel)
 {
     return((uint)vc.images.Count);
 }
 public override nint GetNumberOfItems(iCarousel carousel)
 {
     // return the number of items in the data
     return items.Length;
 }
 public override uint NumberOfItemsInCarousel(iCarousel carousel)
 {
     return (uint)owner.items.Count;
 }
 public override uint NumberOfItems(iCarousel 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;
 }
            public override UIView PlaceholderViewAtIndex(iCarousel carousel, uint index, UIView view)
            {
                UILabel label = null;
                UIImageView imageView = null;

                //create new view if no view is available for recycling
                if (null == view) {
                    //don't do anything specific to the index within
                    //this `if (view == nil) {...}` statement because the view will be
                    //recycled and used with other index values later
                    imageView = new UIImageView (new RectangleF (0f, 0f, 200.0f, 200.0f));
                    imageView.Image = UIImage.FromBundle ("page.png");
                    imageView.ContentMode = UIViewContentMode.Center;
                    label = new UILabel (imageView.Bounds);
                    label.BackgroundColor = UIColor.Clear;
                    label.TextAlignment = UITextAlignment.Center;
                    label.Font = label.Font.WithSize (50f);
                    label.Tag = 1;
                    imageView.AddSubview (label);
                } else {
                    label = (UILabel)view.ViewWithTag (1);
                    imageView = (UIImageView)view;
                }
                //set item label
                //remember to always set any properties of your carousel item
                //views outside of the `if (view == nil) {...}` check otherwise
                //you'll get weird issues with carousel item content appearing
                //in the wrong place in the carousel
                label.Text = (index == 0) ? "[" : "]";

                return imageView;
            }
 public override float ValueForOption(iCarousel carousel, iCarouselOption option, float aValue)
 {
     if (option == iCarouselOption.Spacing) {
         return aValue * 1.1f;
     }
     return aValue;
 }
 public override MonoTouch.CoreAnimation.CATransform3D ItemTransformForOffset(iCarousel carousel, float offset, MonoTouch.CoreAnimation.CATransform3D transform)
 {
     // implement 'flip3D' style carousel
     transform = CATransform3D.MakeRotation (((float)Math.PI) / 8.0f, 0.0f, 1.0f, 0.0f);
     return CATransform3D.MakeTranslation (0f, 0f, offset * carousel.ItemWidth);
 }
 public override nint NumberOfItemsInCarousel(iCarousel carousel) => _data.Count;
 public override nint NumberOfItemsInCarousel(iCarousel carousel)
 {
     return((nint)_items.Count);
 }
        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);
            });
        }
            public override UIView ViewForItem(iCarousel carousel, uint index, UIView reusingView)
            {
                if (reusingView == null) {

                    var itemView = new UIView (new RectangleF (0, 0, 200, 200)) {
                        AutoresizingMask = UIViewAutoresizing.All
                    };

                    // Creating the background
                    var imgView = new UIImageView (new RectangleF (-20, -90, 240, 380)) {
                        Image = UIImage.FromBundle ("page"),
                        ContentMode = UIViewContentMode.Center
                    };
                    itemView.AddSubview (imgView);

                    // We create and add some controls
                    // UIButton
                    var button = UIButton.FromType (UIButtonType.RoundedRect);
                    button.Frame = new RectangleF (20, 20, 160, 37);
                    button.SetTitle ("Press me!", UIControlState.Normal);
                    button.TouchUpInside += (sender, e) => {
                        vc.Label.Text = string.Format ("Button {0} tapped", vc.Carousel.IndexOfItemViewOrSubview (sender as UIView));
                    };

                    if (!vc.ObjCache.Contains (button))
                        vc.ObjCache.Add (button);

                    itemView.AddSubview (button);

                    // UISwitch
                    var switchbtn = new UISwitch (new RectangleF (62, 86, 79, 27));
                    switchbtn.ValueChanged += (sender, e) => {
                        vc.Label.Text = string.Format ("Switch {0} toggled", vc.Carousel.IndexOfItemViewOrSubview (sender as UIView));
                    };

                    if (!vc.ObjCache.Contains (switchbtn))
                        vc.ObjCache.Add (switchbtn);

                    itemView.AddSubview (switchbtn);

                    // UISlider
                    var slider = new UISlider (new RectangleF (41, 146, 118, 23)) {
                        MinValue = 0,
                        MaxValue = 100,
                        Value = 50
                    };
                    slider.ValueChanged += (sender, e) => {
                        vc.Label.Text = string.Format ("Slider {0} changed", vc.Carousel.IndexOfItemViewOrSubview (sender as UIView));
                    };

                    if (!vc.ObjCache.Contains (slider))
                        vc.ObjCache.Add (slider);

                    itemView.AddSubview (slider);

                    reusingView = itemView;
                }
                return reusingView;
            }
 public override void DidSelectItem(iCarousel carousel, int index)
 {
     Console.WriteLine ("Selected: " + ++index);
 }