Esempio n. 1
0
        public CaptionedImage(PhotosetPhoto photoInfo)
        {
            captionLabel = new UILabel();
            captionLabel.Text = photoInfo.Title;
            //Times New Roman  TimesNewRomanPS-ItalicMT
            //Times New Roman  TimesNewRomanPS-BoldMT
            //Times New Roman  TimesNewRomanPSMT
            //Times New Roman  TimesNewRomanPS-BoldItalicMT
            captionLabel.Font = UIFont.FromName("TimesNewRomanPS-ItalicMT",
                                                (DeviceUtils.IsIPad() ? 20 : 14));

            captionLabel.LineBreakMode = UILineBreakMode.WordWrap;
            // set more lines than we need.  we resize to fit later
            captionLabel.Lines = 4;
            captionLabel.ContentMode = UIViewContentMode.Bottom;
            captionLabel.TextAlignment = UITextAlignment.Center;

            captionLabel.BackgroundColor = UIColor.Clear;
            //captionLabel.Layer.BorderColor = new CGColor (1f, 1f, 1f);
            //captionLabel.Layer.BorderWidth = 2;

            NSData data = FileCacher.LoadUrl(photoInfo.Url, false);

            if (null == data) {
                if (Reachability.RemoteHostStatus().Equals(NetworkStatus.ReachableViaWiFiNetwork)) {
                    ThreadPool.QueueUserWorkItem(delegate {
                        data = FileCacher.LoadUrl(photoInfo.Url, true);
                        if (null == data) {
                            // this is not expected
                            Debug.WriteLine("Null data after LoadUrl: {0} - {1}", photoInfo.Title, photoInfo.Url);
                        } else {
                            InvokeOnMainThread(delegate {
                                SetImage(data);
                            });
                        }
                    });
                } else {
                    // FIXME otherwise - display a different image?  can't download right now
                    // this should be somewhat uncommon, because it means we downloaded the
                    // photo info (which required a network connection), but not the photo
                    Debug.WriteLine("No image downloaded: {0} - {1}", photoInfo.Title, photoInfo.Url);
            #if DEBUG
                    var label = new UILabel();
                    label.Text = String.Format("No image downloaded: {0} - {1}", photoInfo.Title, photoInfo.Url);
                    AddSubview(label);
            #endif
                }
            } else {
                SetImage(data);
            }

            AddSubview(captionLabel);
            this.BackgroundColor = UIColor.White;
        }
Esempio n. 2
0
 public DataSource(PhotosetPhoto[] photos)
 {
     this.photos = new List<PhotosetPhoto>(photos);
     if (null != OnChanged) { OnChanged(); }
 }
Esempio n. 3
0
 public void AddPhoto(PhotosetPhoto newPhoto)
 {
     this.photos.Add(newPhoto);
     if (null != OnChanged) {
         OnChanged();
     }
 }
Esempio n. 4
0
 private void PhotoAdded(PhotosetPhoto photo)
 {
     InvokeOnMainThread (delegate {
         lblLoadingMessage.Hidden = true;
         (scrollView.DataSource as DataSource).AddPhoto(photo);
     });
 }