Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);
            Button button = FindViewById <Button> (Resource.Id.myButton);

            imageView = FindViewById <SmartImageView> (Resource.Id.image);
            imageView.SetImageUrl("http://cdn1.xamarin.com/webimages/images/index/icon-cross-platform.png");


            _uploader = new PhotoUploader();
            _listener = new PhotoListener();

            _listener.NewPhotosReceived += (sender, urls) =>
            {
                RunOnUiThread(() =>
                {
                    foreach (var url in urls)
                    {
                        imageView.SetImageUrl(url);
                        var toast = Toast.MakeText(BaseContext, "New Image: " + url.ToString(), ToastLength.Long);
                        toast.Show();
                    }
                });
            };

            _listener.StartListening();

            button.Click += delegate {
                UploadPicture();
            };
        }
Exemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavigationItem.RightBarButtonItem          = new UIBarButtonItem(UIBarButtonSystemItem.Add);
            NavigationItem.RightBarButtonItem.Clicked += delegate { UploadPicture(); };

            _uploader = new PhotoUploader();
            _listener = new PhotoListener();

            _listener.NewPhotosReceived += (sender, urls) =>
            {
                InvokeOnMainThread(() =>
                {
                    foreach (var url in urls)
                    {
                        _imageSection.Add(
                            new ImageStringElement(DateTime.Now.ToString(),
                                                   UIImage.LoadFromData(NSData.FromUrl(new NSUrl(url))))
                            );
                    }
                });
            };

            _listener.StartListening();
        }