public async Task LoadImage() { if (ImageFileName.Contains("ms-appx:Assets")) { BitmapImage bitmapImage = new BitmapImage(new Uri(ImageFileName, UriKind.RelativeOrAbsolute)); ImageBrush brush = new ImageBrush(); brush.AlignmentX = AlignmentX.Left; brush.AlignmentY = AlignmentY.Top; brush.Stretch = Stretch.UniformToFill; _picBrush.ImageSource = bitmapImage; return; } var folder = await StaticHelpers.GetSaveFolder(); var file = await folder.GetFileAsync(ImageFileName); using (Windows.Storage.Streams.IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read)) { // Set the image source to the selected bitmap. Windows.UI.Xaml.Media.Imaging.BitmapImage bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage(); bitmapImage.SetSource(fileStream); _picBrush.ImageSource = bitmapImage; } }
public ImageViewer(string imageFileName, Area a, Control owner) : base(owner) { this.Area = a; this.ImageFileName = imageFileName; this.InitializeComponent(); // Descriptive window title this.Text = @"Imagen: " + a.Name; if (this.Area is Estate) { this.Text += @" - " + EstateExplorer.EtqFinca + ((this.Area as Estate).IsUrban ? (@" " + EstateExplorer.EtqUrbana) : @"") ; if (ImageFileName.Contains(Database.EtqZona)) { this.Text += ' ' + ('(' + Database.EtqZona.ToLower() + ')' + ' '); } } else if (this.Area is Place) { this.Text += @" - " + Area.FormatForPresentation(Database.EtqLugar); } this.MaximumSize = new Size(this.Owner.Width, this.Owner.Height); pictureBox.LoadAsync(imageFileName); }