protected override void OnNavigatedTo(NavigationEventArgs e) { imageDetails.Text = ""; IDictionary<string, string> queryStrings = NavigationContext.QueryString; string token = null; string source = null; if (queryStrings.ContainsKey("token")) { token = queryStrings["token"]; source = "Photos_Extra_Viewer"; } else if (queryStrings.ContainsKey("FileId")) { token = queryStrings["FileId"]; source = "Photos_Extra_Share"; } if (!string.IsNullOrEmpty(token)) { MediaLibrary mediaLib = new MediaLibrary(); Picture picture = mediaLib.GetPictureFromToken(token); currentImage = ImageUtil.GetBitmap(picture.GetImage()); photoContainer.Fill = new ImageBrush { ImageSource = currentImage }; imageDetails.Text = string.Format("Image from {0}.\nPicture name:\n{1}\nMedia library token:\n{2}", source, picture.Name, token); } imageDetails.Text += "\nUri: " + e.Uri.ToString(); }
// Sample code for building a localized ApplicationBar //private void BuildLocalizedApplicationBar() //{ // // Set the page's ApplicationBar to a new instance of ApplicationBar. // ApplicationBar = new ApplicationBar(); // // Create a new button and set the text value to the localized string from AppResources. // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative)); // appBarButton.Text = AppResources.AppBarButtonText; // ApplicationBar.Buttons.Add(appBarButton); // // Create a new menu item with the localized string from AppResources. // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText); // ApplicationBar.MenuItems.Add(appBarMenuItem); //} protected override void OnNavigatedTo(NavigationEventArgs e) { if (State.ContainsKey("customCamera")) { State.Remove("customCamera"); InitializeCamera(); } IDictionary<string, string> queryStrings = NavigationContext.QueryString; string action = null; if (queryStrings.ContainsKey("Action")) action = queryStrings["Action"]; string token = null; if (queryStrings.ContainsKey("FileId")) token = queryStrings["FileId"]; if (!string.IsNullOrEmpty(token)) { MediaLibrary mediaLib = new MediaLibrary(); Picture picture = mediaLib.GetPictureFromToken(token); currentImage = PictureDecoder.DecodeJpeg(picture.GetImage()); photoContainer.Fill = new ImageBrush { ImageSource = currentImage }; imageDetails.Text = string.Format("Image from {0} action.\nPicture name:\n{1}\nMedia library token:\n{2}", action, picture.GetPath(), token); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { // Get a dictionary of query string keys and values. IDictionary<string, string> queryStrings = this.NavigationContext.QueryString; // Check whether the app has been started by the photo edit picker of the Windows Phone System // More information about the photo edit picker here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202966(v=vs.105).aspx if (queryStrings.ContainsKey("FileId") && imageAlreadyLoaded == false) { imageAlreadyLoaded = true; // Retrieve the photo from the media library using the FileID passed to the app. MediaLibrary library = new MediaLibrary(); Picture photoFromLibrary = library.GetPictureFromToken(queryStrings["FileId"]); // Create a BitmapImage object and add set it as the PreviewImage BitmapImage bitmapFromPhoto = new BitmapImage(); bitmapFromPhoto.SetSource(photoFromLibrary.GetPreviewImage()); SetPreviewImage(bitmapFromPhoto); } // Every time we navigate to the MainPage we check if a filter has been selected on the FilterView page // If so, we apply this filter to the PreviewImage if (FilterSelectorView.SelectedFilter != null) { await ApplyFilter(FilterSelectorView.SelectedFilter, PreviewPicture); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { // Get a dictionary of query string keys and values. IDictionary<string, string> queryStrings = this.NavigationContext.QueryString; // Ensure that there is at least one key in the query string, and check whether the "FileId" key is present. if (queryStrings.ContainsKey("FileId")) { // Retrieve the photo from the media library using the FileID passed to the app. MediaLibrary library = new MediaLibrary(); Picture photoFromLibrary = library.GetPictureFromToken(queryStrings["FileId"]); // Create a BitmapImage object and add set it as the image control source. // To retrieve a full-resolution image, use the GetImage() method instead. BitmapImage bitmapFromPhoto = new BitmapImage(); bitmapFromPhoto.SetSource(photoFromLibrary.GetPreviewImage()); image1.Source = bitmapFromPhoto; } }
/// <summary> /// Called when this MainPage becomes the active page in a frame. /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { if (!bmp.IsLoaded) { Stream stream; var query = this.NavigationContext.QueryString; if (query.ContainsKey("token")) { MediaLibrary lib = new MediaLibrary(); Picture pic = lib.GetPictureFromToken(query["token"]); stream = pic.GetImage(); } else { Uri uri = new Uri("Images/lenna.jpg", UriKind.Relative); stream = Application.GetResourceStream(uri).Stream; } bmp.Load(stream); } base.OnNavigatedTo(e); }
protected override void OnActivate() { var library = new MediaLibrary(); var photoFromLibrary = library.GetPictureFromToken(FileId); var image = photoFromLibrary.GetImage(); var buffer = LerTudo(image); dadosDaMulta.ExibirImagem(image, true); fileInfo = new HttpUpload.FileInfo { FileName = photoFromLibrary.Name, ContentType = "image/jpeg", Buffer = buffer, ParamName = "multa[foto]" }; dadosDaMulta.PropertyChanged += (sender, e) => { if (e.PropertyName == "IsValid") NotifyOfPropertyChange("CanShare"); }; base.OnActivate(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { // Get a dictionary of query string keys and values. IDictionary<string, string> queryStrings = this.NavigationContext.QueryString; // Ensure that there is at least one key in the query string, and check whether the "token" key is present. if (queryStrings.ContainsKey("token")) { // Retrieve the picture from the media library using the token passed to the application. MediaLibrary library = new MediaLibrary(); Picture picture = library.GetPictureFromToken(queryStrings["token"]); // Create a WriteableBitmap object and add it to the Image control Source property. BitmapImage bitmap = new BitmapImage(); bitmap.CreateOptions = BitmapCreateOptions.None; bitmap.SetSource(picture.GetImage()); // WriteableBitmap picLibraryImage = new WriteableBitmap(bitmap); Image_ToBeUploaded.Source = bitmap; } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { if (NavigationContext.QueryString.ContainsKey("token")) { var library = new MediaLibrary(); Picture picture = library.GetPictureFromToken(NavigationContext.QueryString["token"]); BitmapImage img = new BitmapImage() { CreateOptions = BitmapCreateOptions.None}; img.SetSource(picture.GetImage()); image.Source = img; NavigationContext.QueryString.Remove("token"); } else if (NavigationContext.QueryString.ContainsKey("Photo")) { if (bool.Parse(NavigationContext.QueryString["Photo"])) image.Source = new BitmapImage(new Uri(instance.CurrentImage, UriKind.RelativeOrAbsolute)); else { task.Show(); NavigationContext.QueryString.Remove("Photo"); } } base.OnNavigatedTo(e); }
private void TryInitPhoto() { // Get a dictionary of query string keys and values. IDictionary<string, string> queryStrings = Page.NavigationContext.QueryString; // Ensure that there is at least one key in the query string, and check whether the "FileId" key is present. if (queryStrings.ContainsKey(FileId)) { string fileId = queryStrings[FileId]; MediaLibrary library = new MediaLibrary(); Picture photoFromLibrary = library.GetPictureFromToken(fileId); InitImaging(null, fileId); } }
public void FromLibraryImage(string token) { System.Diagnostics.Debug.Assert(token != null); using (var library = new MediaLibrary()) { using (var picture = library.GetPictureFromToken(token)) { var libraryPath = picture.GetPath(); if (LibraryPath != libraryPath) { LibraryPath = libraryPath; LocalPath = Mapping.MatchLibraryPathWithLocalPath(libraryPath); if (LocalPath != null) { using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { Image = store.OpenFile(LocalPath, FileMode.Open); } } else { Image = picture.GetImage(); } OriginalPath = Mapping.MatchPathWithOriginalPath(libraryPath); if (OriginalPath != null) { using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { Original = store.OpenFile(OriginalPath, FileMode.Open); } } else { Original = null; } OriginalLibraryPath = null; } } } }
// Sample code for building a localized ApplicationBar //private void BuildLocalizedApplicationBar() //{ // // Set the page's ApplicationBar to a new instance of ApplicationBar. // ApplicationBar = new ApplicationBar(); // // Create a new button and set the text value to the localized string from AppResources. // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative)); // appBarButton.Text = AppResources.AppBarButtonText; // ApplicationBar.Buttons.Add(appBarButton); // // Create a new menu item with the localized string from AppResources. // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText); // ApplicationBar.MenuItems.Add(appBarMenuItem); //} protected override void OnNavigatedTo(NavigationEventArgs e) { if (State.ContainsKey("customCamera")) { State.Remove("customCamera"); InitializeCamera(); } IDictionary<string, string> queryStrings = NavigationContext.QueryString; string fileId = null; string source = null; // Photos_Extra_Viewer is deprecated //if (queryStrings.ContainsKey("token")) //{ // token = queryStrings["token"]; // source = "Photos_Extra_Viewer"; //} //else if (queryStrings.ContainsKey("Action") && queryStrings.ContainsKey("FileId")) { fileId = queryStrings["FileId"]; source = queryStrings["Action"]; } if (!string.IsNullOrEmpty(fileId)) { MediaLibrary mediaLib = new MediaLibrary(); Picture picture = mediaLib.GetPictureFromToken(fileId); currentImage = PictureDecoder.DecodeJpeg(picture.GetImage()); photoContainer.Fill = new ImageBrush { ImageSource = currentImage }; imageDetails.Text = string.Format("Image from {0}.\nPicture name:\n{1}\nMedia library token:\n{2}", source, picture.Name, fileId); } }
public async Task FromToken(string token) { using (var library = new MediaLibrary()) { using (var picture = library.GetPictureFromToken(token)) { await FromLibraryPath(picture.GetPath()); } } }
public static Picture GetPictureByToken(string token) { var library = new MediaLibrary(); var photoFromLibrary = library.GetPictureFromToken(token); return photoFromLibrary; }
public ImageManipulator(string token, Image helper, int bsize) { // Retrieve the picture from the media library using the token passed to the application. MediaLibrary library = new MediaLibrary(); Picture picture = library.GetPictureFromToken(token); InitFromStream(picture.GetImage(), helper); this.Radius = (int)((finalImage.PixelWidth * bsize) / helper.Width); }
protected override void OnNavigatedTo(NavigationEventArgs e) { // Get a dictionary of query string keys and values. IDictionary<string, string> queryStrings = this.NavigationContext.QueryString; // Ensure that there is at least one key in the query string, and check whether the "token" key is present. if (queryStrings.ContainsKey("token")) { // Retrieve the picture from the media library using the token passed to the application. MediaLibrary library = new MediaLibrary(); Picture picture = library.GetPictureFromToken(queryStrings["token"]); StartLoadingImage(picture.GetImage()); } }
/// <summary> /// Locates a Post object and specifies the result as the page's DataContext /// </summary> private void LoadBlog() { Blog currentBlog = App.MasterViewModel.CurrentBlog; BlogName.Text = string.IsNullOrEmpty(currentBlog.BlogNameUpper) ? "" : currentBlog.BlogNameUpper; bool isSharingPhoto = (App.MasterViewModel.SharingPhotoToken != null); if (null != App.MasterViewModel.CurrentPostListItem && !isSharingPhoto) { string postId = App.MasterViewModel.CurrentPostListItem.PostId; if (App.MasterViewModel.CurrentPostListItem.DraftIndex > -1) { // Post is a local draft this.isEditingLocalDraft = true; DataContext = App.MasterViewModel.CurrentBlog.LocalPostDrafts[App.MasterViewModel.CurrentPostListItem.DraftIndex]; App.MasterViewModel.CurrentPost = App.MasterViewModel.CurrentBlog.LocalPostDrafts[App.MasterViewModel.CurrentPostListItem.DraftIndex]; setStatus(); initPostFormatUI(App.MasterViewModel.CurrentPost.PostFormat); //update the Media UI List<Media> unavaiblePictures = new List<Media>(); foreach (Media currentMedia in App.MasterViewModel.CurrentPost.Media) { using (Stream stream = currentMedia.getImageStream()) { if (stream == null) { unavaiblePictures.Add(currentMedia); continue; } try { BitmapImage image = new BitmapImage(); image.SetSource(stream); imageWrapPanel.Children.Add(BuildTappableImageElement(image, currentMedia)); } catch (Exception) { } } } if (unavaiblePictures.Count > 0 ) { MessageBoxResult result = MessageBox.Show("Can't read a picture attached to this draft, please try to load the draft later.", "Error", MessageBoxButton.OK); foreach (Media m in unavaiblePictures) { App.MasterViewModel.CurrentPost.Media.Remove(m); } } } else { Post post = App.MasterViewModel.CurrentPost; DataContext = post; setStatus(); initPostFormatUI(post.PostFormat); if (!string.IsNullOrWhiteSpace(post.MtKeyWords)) { tagsTextBox.Text = post.MtKeyWords; } } } else { //New post Post post = new Post(); App.MasterViewModel.CurrentPost = post; post.DateCreated = DateTime.Now; post.DateCreatedGMT = DateTime.Now.ToUniversalTime(); DataContext = post; initPostFormatUI("standard"); post.PostStatus = "publish"; setStatus(); /*postTimePicker.Value = post.DateCreated; postDatePicker.Value = post.DateCreated;*/ if (isSharingPhoto) { MediaLibrary library = new MediaLibrary(); Picture picture = library.GetPictureFromToken(App.MasterViewModel.SharingPhotoToken); using (Stream pictureStream = picture.GetImage()) AddNewMediaStream(pictureStream, picture.Name);; // clear the photo token so we don't try to add it to another post App.MasterViewModel.SharingPhotoToken = null; // blog selection page will be in the backstack, but if the user hits Back they should leave the app // and return to the photo that they were sharing (e.g., so they can share it on another service) NavigationService.RemoveBackEntry(); } } this.ToggleGalleryControlsVisibility(); }
private async void SetPhotoFromEditedPage(string FiledID) { MediaLibrary library = new MediaLibrary(); Picture photoFromLibrary = library.GetPictureFromToken(FiledID); using (MemoryStream stream = new MemoryStream()) { photoFromLibrary.GetImage().CopyTo(stream); App.PhotoModel = new PhotoModel() { Buffer = stream.GetWindowsRuntimeBuffer() }; App.PhotoModel.Captured = true; App.PhotoModel.Dirty = true; Setup(); pgrAddress.Visibility = System.Windows.Visibility.Visible; await RenderAsync(); pgrAddress.Visibility = System.Windows.Visibility.Collapsed; } }
/// <summary> /// Load Image from library /// </summary> /// <returns></returns> private WriteableBitmap LoadImage() { Stream source = null; if (!string.IsNullOrEmpty(_fileId)) { MediaLibrary library = new MediaLibrary(); Picture photoFromLibrary = library.GetPictureFromToken(_fileId); source = photoFromLibrary.GetImage(); } else { source = _stream; } BitmapImage image = new BitmapImage(); image.SetSource(source); return new WriteableBitmap(image); }