public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     UriImageSource img = new UriImageSource();
     var fileName = ((string)value).Replace(' ', '_').ToLower();
     img.Uri = new Uri("ms-appx:///Images/Posters/" + fileName + ".jpg");
     return img;
 }
		public LoadingPlaceholder ()
		{
			Padding = new Thickness (20);
			Title = "Image Loading Gallery";

			var source = new UriImageSource {
				Uri = new Uri ("http://www.nasa.gov/sites/default/files/styles/1600x1200_autoletterbox/public/images/298773main_EC02-0282-3_full.jpg"),
				CachingEnabled = false
			};

			var image = new Image {
				Source = source,
				WidthRequest = 200,
				HeightRequest = 200,
			};

			var indicator = new ActivityIndicator {Color = new Color (.5),};
			indicator.SetBinding (ActivityIndicator.IsRunningProperty, "IsLoading");
			indicator.BindingContext = image;

			var grid = new Grid();
			grid.RowDefinitions.Add (new RowDefinition());


			grid.Children.Add (image);
			grid.Children.Add (indicator);


			Content = grid;
		}
        void OnTapped(object sender, EventArgs args)
        {
            Image theImage = ((Image)sender);

            Xamarin.Forms.UriImageSource source = ((Xamarin.Forms.UriImageSource)theImage.Source);

            ((App)Application.Current).pageChange2(new ImageShow(source));
        }
 public async Task<IControl> GetImage(UriImageSource source, ImageFormat format)
 {
     using (var stream = await Forms.UpdateContext.Wait(source.GetStreamAsync()))
     {
         if (stream == null)
             throw new ArgumentException("Resource not found", "source");
         return await ImageFactory.CreateFromStream(stream, format, CancellationToken.None);
     }
 }
        public PeopleViewModel()
        {
            _peopleService = new PeopleService();
            this.ChoosePersonCommand = new Command(FindPerson);

            _sourceForImage = new UriImageSource();

            _pathToPhoto = "https://randomuser.me/api/portraits/women/19.jpg";
            _sourceForImage.Uri = new Uri(_pathToPhoto);
            SourcePhoto = _sourceForImage;
        }
		const int ImageSize = 88*2; //176

		void GetImage () {
			var p = (PersonViewModel)BindingContext;
			var person = p.Person;

			if (person.HasEmail) {
				var imageUrl = Gravatar.GetImageUrl (person.Email, ImageSize);

				var loader = new UriImageSource ();
				loader.Uri = imageUrl;
				PersonImage.Source = loader;
			}
		}
Beispiel #7
0
        public ZoomVM()
        {
            _indexGenerator = new Random();
            _imageUrls = new List<ImageResource>
            {
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "http://yeahsoup.s3-us-west-2.amazonaws.com/wp-content/uploads/2015/05/img1114.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Stream, ImageSourceText = "http://i.telegraph.co.uk/multimedia/archive/02262/A124CE_2262003b.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "http://i.telegraph.co.uk/multimedia/archive/01476/chimp_1476818c.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Stream, ImageSourceText = "http://i.huffpost.com/gen/1490756/images/o-CHIMPANZEE-facebook.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "http://static1.squarespace.com/static/523b539be4b0a75330f9c8ce/55a55614e4b01d30adbfe144/55a557ace4b0632463d49108/1436909257139/babyowl.jpg?format=1000w"},
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "http://www.rantlifestyle.com/wp-content/uploads/2014/06/schattigebabydier11.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Stream, ImageSourceText = "http://ww2.valdosta.edu/~kaletour/bb1.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "https://36.media.tumblr.com/5c493da746cc1c1f438ae304591244c4/tumblr_n9a78n99Ea1tvs3v3o1_500.jpg"},
                new ImageResource{ ImageFrom = ImageOrigin.Uri, ImageSourceText = "http://streetloop.com/wp-content/uploads/2014/07/Baby-animals-looking-like-their-parents25.jpg"}
            };

            ToggleZoomCommand = new Command((_) =>
            {
                EnableZoom = !EnableZoom;
            });
            ChangeImageCommand = new Command(async (_) =>
            {
                var index = _indexGenerator.Next(0, _imageUrls.Count - 1);
                var resource = _imageUrls[index];
                ImageComesFrom = Enum.GetName(typeof(ImageOrigin), resource.ImageFrom);
                if (resource.ImageFrom == ImageOrigin.Uri)
                    Image = new UriImageSource() { Uri = new Uri(resource.ImageSourceText)};
                else if (resource.ImageFrom == ImageOrigin.Stream)
                {
                    // this would normally be something off the device, but any stream will do so we'll just manually get a stream to the online image
                    var client = new HttpClient(new NativeMessageHandler());
                    var stream = await client.GetStreamAsync(resource.ImageSourceText);
                    Image = ImageSource.FromStream(() => stream);
                }
                else
                    throw new NotSupportedException($"Unable to load image of type {ImageComesFrom} with value {resource.ImageSourceText}.");
            });

            // enable zoom should initially be false
            EnableZoom = false;

            // initialize the image
            ChangeImageCommand.Execute(null);
        }
Beispiel #8
0
			public CustomCell()
			{
				var image = new Image
				{
					HorizontalOptions = LayoutOptions.Start,
					Aspect = Aspect.AspectFill
				};

				var source = new UriImageSource {
					CachingEnabled = false,
				};

				source.SetBinding(UriImageSource.UriProperty, new Binding("Image", converter: new UriConverter()));

				image.Source = source;


				View = image;
			}
		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			if (value == null)
				return null;
			var url = value.ToString();
			try
			{
				var source = new UriImageSource()
					{
						Uri = new Uri(url),
						CachingEnabled = true,
						CacheValidity = Constants.ImageCacheTimespan
					};
				return source;
			}
			catch
			{
				return null;
			}
		}
        private void FetchPhoto()
        {
            //Prepare for new image.
            image.Source = null;
            string url = imageList.Photos[imageListIndex];

            //Set the filename.
            filenameLabel.Text = url.Substring(url.LastIndexOf('/') + 1);

            //Create the UriImageSource.
            UriImageSource imageSource = new UriImageSource
            {
                Uri = new Uri(url + "?Width=1080"),
                CacheValidity = TimeSpan.FromDays(30)
            };

            //Set the Image source
            image.Source = imageSource;

            //Enable or Disable buttons.
            prevButton.IsEnabled = imageListIndex > 0;
            nextButton.IsEnabled = imageListIndex < imageList.Photos.Count - 1;
        }
Beispiel #11
0
		public User (string name, string message, string picture)
		{
			Name = name;
			Picture = new UriImageSource { Uri = new Uri(picture)};
		}
 public ImageSource GetSource(string filePath)
 {
     ImageSource source;
     if (filePath.StartsWith ("http")) {
         source = new UriImageSource {
             Uri = new Uri (filePath),
             CachingEnabled = true,
             CacheValidity = new TimeSpan (5, 0, 0, 0)
         };
     } else {
         source = ImageSource.FromFile (Path.Combine (GlobalVariables.DownloadPath, filePath));
     }
     return source;
 }
		public ImagePage()
		{
			// Layout controls
			quitButton = new Button
			{
				Text = "Quit"
			};
			quitButton.Clicked += quitButton_Clicked;

			noTargetButton = new Button
			{
				Text = "No Target"
			};
			noTargetButton.Clicked += noTargetButton_Clicked;

			doneButton = new Button
			{
				Text = "Done"
			};
			doneButton.Clicked += doneButton_Clicked;

			resetLabelsButton = new Button
			{
				Text = "Reset"
			};
			resetLabelsButton.Clicked += resetLabelsButton_Clicked;

			tapcounter = new Label
			{
				Text = "TAPPED 0 TIMES"
			};

			ImageSource mImageSource = new UriImageSource
			{
				Uri = new Uri(ServerConnection.imageResource + "1")
			};

			mImage = new Image
			{
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.Center,
				BackgroundColor = Color.Yellow,
				HeightRequest = 200,
				Aspect = Xamarin.Forms.Aspect.AspectFit,
				//Source = "http://developer.xamarin.com/demo/IMG_1415.JPG"
				//Source = ImageSource.FromResource("ResourceBitmapCode.Images.img.jpg")
				Source = mImageSource
			};


			AbsoluteLayout.SetLayoutFlags(mImage, AbsoluteLayoutFlags.None);

			tapPointsLayout = new MR.Gestures.AbsoluteLayout
			{
				VerticalOptions = LayoutOptions.Center,
				HorizontalOptions = LayoutOptions.Center,
				BackgroundColor = Color.Teal
			};
			tapPointsLayout.Tapped += absoluteLayout_Tapped;

			ResetLabels();

			LayoutPage();
		}
        public RatingDetailView(CheeseAndRating theRating)
        {
            _viewModel = new RatingDetailViewModel (theRating, this);
            BindingContext = _viewModel;

            this.SetBinding (ContentPage.TitleProperty, "Title");

            AbsoluteLayout cheeseInfoLayout = new AbsoluteLayout {
                HeightRequest = 250,
                BackgroundColor = CheeseColors.PURPLE
            };

            var cheeseName = new Label {
                FontSize = 30,
                FontFamily = "AvenirNext-DemiBold",
                TextColor = Color.White
            };
            cheeseName.SetBinding (Label.TextProperty, "CheeseName");

            var dairyName = new Label {
                TextColor = Color.FromHex ("#ddd"),
                FontFamily = "AvenirNextCondensed-Medium"
            };
            dairyName.SetBinding (Label.TextProperty, "DairyName");

            UriImageSource uriImgSource = new UriImageSource ();
            uriImgSource.SetBinding (UriImageSource.UriProperty, "CheesePhotoUri");

            _backgroundImage = new Image () {
                Source = uriImgSource,
                Aspect = Aspect.AspectFill,
            };

            var overlay = new BoxView () {
                Color = Color.Black.MultiplyAlpha (.7f)
            };

            var notesLabel = new Label () {
                FontSize = 14,
                TextColor = Color.FromHex ("#ddd")
            };

            notesLabel.SetBinding (Label.TextProperty, "RatingDescription");

            var description = new Frame () {
                Padding = new Thickness (10, 5),
                HasShadow = false,
                BackgroundColor = Color.Transparent,
                Content = notesLabel
            };

            AbsoluteLayout.SetLayoutFlags (overlay, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds (overlay, new Rectangle (0, 1, 1, 0.3));

            AbsoluteLayout.SetLayoutFlags (_backgroundImage, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds (_backgroundImage, new Rectangle (0f, 0f, 1f, 1f));

            AbsoluteLayout.SetLayoutFlags (cheeseName, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds (cheeseName,
                new Rectangle (0.1, 0.85, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)
            );

            AbsoluteLayout.SetLayoutFlags (dairyName, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds (dairyName,
                new Rectangle (0.1, 0.95, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)
            );

            cheeseInfoLayout.Children.Add (_backgroundImage);
            cheeseInfoLayout.Children.Add (overlay);
            cheeseInfoLayout.Children.Add (cheeseName);
            cheeseInfoLayout.Children.Add (dairyName);

            Content = new StackLayout () {
                BackgroundColor = Color.FromHex ("#333"),
                Children = {
                    cheeseInfoLayout, description
                }
            };
        }
Beispiel #15
0
		public Message (string name, string message, string picture)
		{
			Name = name;
			Body = message;
			Picture = new UriImageSource { Uri = new Uri(picture)};
		}