protected override BrowserViewController CreateBrowserViewController()
        {
            var photos = new List<Photo>(_images.Count);
            foreach (var img in _images)
            {
                var photo = new Photo(UIImage.FromFile(img.Path)) { Icon = img.Icon };
                if (img.Icon)
                    photo.CornerRadius = 80f;
                if (img.Category != null)
                    photo.Caption = img.Category;
                photos.Add(photo);
            }

            return new LocalBrowserViewController(photos, _images);
        }
Exemplo n.º 2
0
        private void LoadImages()
        {
            if (_state != State.Waiting)
                return;

            _state = State.Loading;
            var hud = new RedPlum.MBProgressHUD(View.Frame)
            {
                Mode = RedPlum.MBProgressHUDMode.Indeterminate,
                TitleText = "Loading...",
                TitleFont = UIFont.BoldSystemFontOfSize(14f)
            };

            this.View.AddSubview(hud);
            hud.Show(false);

            //Do the loading
            ThreadPool.QueueUserWorkItem(delegate {
                try
                {
                    _icons = RequestFactory.GetIcons();
                    _loadedImages = new List<Photo>();
                    _icons.ForEach(x => {
                        var photo = new Photo(new NSUrl(x.FullUrl)) { Caption = x.App, Icon = true, CornerRadius = 512f * (10f / 57f) };
                        _loadedImages.Add(photo);
                    });

                    BeginInvokeOnMainThread(() => {
                        _state = State.Loaded;
                        hud.Hide(true);
                        hud.RemoveFromSuperview();
                        CollectionView.ReloadData();
                    });
                }
                catch (Exception e)
                {
                    BeginInvokeOnMainThread(() =>  {
                        _state = State.Waiting;
                        hud.Hide(true);
                        hud.RemoveFromSuperview();
                        var alert = new UIAlertView {Message = e.Message, Title = "Error"};
                        alert.CancelButtonIndex = alert.AddButton("Ok");
                        alert.Show();
                    });
                }
            });
        }