Beispiel #1
0
 internal ScrollViewDelegate(PagingScrollView view)
 {
     this.view = view;
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            Debug.WriteLine("Image controller view did load");

            scrollView = new PagingScrollView(View.Bounds);
            // set our scroll view to automatically resize on rotation
            scrollView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;

            View.BackgroundColor = UIColor.White;
            scrollView.BackgroundColor = UIColor.Clear;
            View.AddSubview(scrollView);

            dataSource.Added += PhotoAdded;
            dataSource.ImagesChanged += NoticeImagesChanged;
            dataSource.Messages += NoticeMessages;

            var scrollViewDataSource = new DataSource(dataSource.Photos);
            scrollView.DataSource = scrollViewDataSource;
            if (dataSource.Photos.Length == 0) {
                CheckConnectionAndDisplayMessage();
            } else {
                lblLoadingMessage.Hidden = true;
            }

            scrollView.OnScroll += delegate {
                // clear the icon badge number.  In the future we might want to update it as cartoons are viewed
                UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;

                SetToolbarHidden(true);
                // we have to do this on another thread because the scroll hasn't finished yet
                ThreadPool.QueueUserWorkItem(delegate {
                    GlobalUserSettings.Get().LastViewedCartoonId = scrollViewDataSource.GetPhoto(scrollView.GetCurrentViewIndex()).Id;
                });
            };

            scrollView.AddGestureRecognizer(new UITapGestureRecognizer(this, new MonoTouch.ObjCRuntime.Selector("tapToggleToolbar")));
            var spacerButton = new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace);
            spacerButton.Width = 5;
            toolbar.SetItems(new UIBarButtonItem[] {
            //                spacerButton,
                GetFirstImageButton(),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                GetLastImageButton(),
                spacerButton}, false);
            View.BringSubviewToFront(toolbar);

            (UIApplication.SharedApplication.Delegate as AppDelegate).FetchCartoonsIfConnected();
        }