/// <summary> /// Initiates saving the previously set image data to a file. /// </summary> /// <param name="filenamePrefix">The desired prefix for the filename.</param> /// <returns>True if successful, false otherwise.</returns> private async Task <bool> SaveImageFileAsync(string filenamePrefix) { bool success = false; var picker = new FileSavePicker { SuggestedStartLocation = PickerLocationId.PicturesLibrary }; picker.FileTypeChoices.Add(JpegFileTypeDescription, _supportedSaveImageFilePostfixes); picker.SuggestedFileName = filenamePrefix + FormattedCurrentDateTimeString() + _supportedSaveImageFilePostfixes[0]; System.Diagnostics.Debug.WriteLine(DebugTag + "SaveImageFileAsync(): Suggested filename is " + picker.SuggestedFileName); #if WINDOWS_PHONE_APP picker.ContinuationData[KeyOperation] = SelectDestinationOperationName; picker.PickSaveFileAndContinue(); success = true; #else StorageFile file = await picker.PickSaveFileAsync(); if (file != null) { success = await SaveImageFileAsync(file); } else { _writeableBitmapToSave = null; _imageBufferToSave = null; } #endif return(success); }
public async void SavePickerText(string fileName, string content) { this.Content = content; FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; savePicker.FileTypeChoices.Add("Feature_SavePicker", new List <string>() { ".txt" }); savePicker.SuggestedFileName = fileName; #if !WINDOWS_PHONE_APP StorageFile file = await savePicker.PickSaveFileAsync(); if (file != null) { CachedFileManager.DeferUpdates(file); await FileIO.WriteTextAsync(file, content); FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file); if (status == FileUpdateStatus.Complete) { if (this.FilePickerFinish != null) { this.FilePickerFinish("Complate", null); } } } #else savePicker.PickSaveFileAndContinue(); #endif }
public async Task SaveAsync(IStorageFile file) { var picker = new FileSavePicker { SuggestedFileName = file.Name, }; var extension = Path.GetExtension(file.Name); if (string.IsNullOrEmpty(extension)) { extension = ".unknown"; } picker.FileTypeChoices.Add("Attachment File", new List <string> { extension }); #if WINDOWS_PHONE_APP picker.ContinuationData.Add("Source", file.Path); picker.PickSaveFileAndContinue(); #else var target = await picker.PickSaveFileAsync(); await Continue(FilePickTargets.Attachments, file, target); #endif }
public async void Save() { try { XElement items = new XElement("drawing"); foreach (Ink item in list) { XElement ink = new XElement("ink"); ink.Add(new XAttribute("size", item.Size)); ink.Add(new XAttribute("colour", colourToString(item.Colour))); ink.Add(new XAttribute("point", pointToString(item.Point))); items.Add(ink); } string value = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), items).ToString(); FileSavePicker picker = new FileSavePicker(); picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; picker.FileTypeChoices.Add("Drawing", new List <string>() { ".drw" }); picker.DefaultFileExtension = ".drw"; picker.SuggestedFileName = "Drawing"; #if WINDOWS_PHONE_APP data = value; picker.PickSaveFileAndContinue(); await Task.Delay(0); #else write(await picker.PickSaveFileAsync(), value); #endif } catch { } }
/// <summary> /// /// </summary> /// <param name="imageBuffer"></param> /// <returns></returns> public async Task <bool> SaveImageFileAsync(IBuffer imageBuffer) { _imageBuffer = imageBuffer; bool success = false; var picker = new FileSavePicker { SuggestedStartLocation = PickerLocationId.PicturesLibrary }; picker.FileTypeChoices.Add(JpegFileTypeDescription, _supportedSaveImageFilePostfixes); picker.SuggestedFileName = "FE_" + FormattedDateTime() + _supportedSaveImageFilePostfixes[0]; System.Diagnostics.Debug.WriteLine(DebugTag + "SaveImageFile(): Suggested filename is " + picker.SuggestedFileName); #if WINDOWS_PHONE_APP picker.ContinuationData["Operation"] = SelectDestinationOperationName; picker.PickSaveFileAndContinue(); success = true; #else StorageFile file = await picker.PickSaveFileAsync(); if (file != null) { success = await SaveImageFileAsync(file); NameOfSavedFile = file.Name; } #endif return(success); }
private async void SaveToFileButton(object sender, RoutedEventArgs e) { FileSavePicker savePicker = new FileSavePicker() { SuggestedFileName = string.Format("TextDocument-{0}", DateTime.Now.ToString("dd-MMM-yyyy")), FileTypeChoices = { { "Plain text", new List <string> { ".txt" } }, { "Web Page", new List <string> { ".html", ".htm" } } }, SuggestedStartLocation = PickerLocationId.DocumentsLibrary, CommitButtonText = "Save my text document" }; #if WINDOWS_APP StorageFile saveFile = await savePicker.PickSaveFileAsync(); await SaveTextFile(saveFile); #elif WINDOWS_PHONE_APP savePicker.PickSaveFileAndContinue(); #endif }
public async void Save(ListBox display) { try { XElement items = new XElement("tasklist"); foreach (CheckBox item in display.Items) { items.Add(new XElement("task", item.Content, new XAttribute("value", ((bool)item.IsChecked ? "checked" : "unchecked")))); } string value = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), items).ToString(); FileSavePicker picker = new FileSavePicker(); picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; picker.FileTypeChoices.Add("Task List", new List <string>() { ".tsk" }); picker.DefaultFileExtension = ".tsk"; picker.SuggestedFileName = "Document"; #if WINDOWS_PHONE_APP data = value; picker.PickSaveFileAndContinue(); await Task.Delay(0); #else write(await picker.PickSaveFileAsync(), value); #endif } catch { } }
private void SaveTweaksButton_Click(object sender, EventArgs e) { var savePicker = new FileSavePicker() { DefaultFileExtension = ".xml", SuggestedFileName = "Tweaks.xml", }; savePicker.FileTypeChoices.Add("XML file", new List<string>() { ".xml" }); savePicker.PickSaveFileAndContinue(); }
public void SaveToChooseLocation() { FileSavePicker savePicker = new FileSavePicker(); savePicker.FileTypeChoices.Add(".jpg", new List <string>() { ".jpg" }); savePicker.SuggestedFileName = ImageArchive.GetTitle(); savePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; savePicker.PickSaveFileAndContinue(); }
private void clickSaveImage(object sender, RoutedEventArgs e) { FileSavePicker picker = new FileSavePicker(); picker.FileTypeChoices.Add("JPG File", new List <string> { ".jpg" }); picker.SuggestedFileName = string.Format("WP_{0}", DateTime.Now.ToString("yyyyMMddHHmmss")); picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; App.ContinuationEventHandler += ContinueActivation; picker.PickSaveFileAndContinue(); }
private void FileSave() { var picker = new FileSavePicker { SuggestedStartLocation = PickerLocationId.DocumentsLibrary, DefaultFileExtension = Extension, FileTypeChoices = { { "MobLang source file", new List <string> { Extension } } }, }; picker.PickSaveFileAndContinue(); }
/// <summary> /// Invoked when user clicks filename, which downloads attachment file and open. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void lblFileName_Tapped(object sender, TappedRoutedEventArgs e) { // Get note item from sender StackPanel sp = (sender as TextBlock).Parent as StackPanel; Annotation note = sp.DataContext as Annotation; // I may need to cache and try to get from cache for attachment as some are big. // At least i can let users decide if they want to download or not. // Show download message. var result = await Util.ShowConfirmMessage(loader.GetString("ConfirmDownloadAttachment"), loader.GetString("Yes"), loader.GetString("No"), 0); // If user doesn't want to download it, then do nothing. if (!result) { return; } progressRing.IsActive = true; // Delete temporary data first await DeleteTemporaryData(); // Then obtain attachment noteAttachment = await CRMHelper.RetrieveNoteAttachment((Guid)note.AnnotationId); progressRing.IsActive = false; // Show confirm message result = await Util.ShowConfirmMessage(loader.GetString("ConfirmOpenSave"), loader.GetString("Open"), loader.GetString("Save"), 0); // if user just want to open it, then open it. if (result) { await Launcher.LaunchFileAsync(noteAttachment); } else { // Save to any location. var picker = new FileSavePicker(); #if WINDOWS_PHONE_APP picker.SuggestedFileName = noteAttachment.Name; picker.FileTypeChoices.Add(noteAttachment.DisplayType.ToString(), new List <string> { noteAttachment.FileType.ToString() }); picker.SuggestedSaveFile = noteAttachment; picker.PickSaveFileAndContinue(); #endif } }
/////////////////////////////////////////////////////////////////////////// // Use the FileSavePicker to save the photo with the selected file name private void AppBarBtnSave_Click(object sender, RoutedEventArgs e) { var fsp = new FileSavePicker { DefaultFileExtension = ".jpg", SuggestedFileName = "editedPhoto.jpg", SuggestedStartLocation = PickerLocationId.PicturesLibrary, }; fsp.FileTypeChoices.Add("JPEG", new List <string> { ".jpg" }); fsp.PickSaveFileAndContinue(); }
private void TrySaveAudio(string audioFileName) { var picker = new FileSavePicker(); picker.ContinuationData.Add("OriginalFileName", audioFileName); picker.FileTypeChoices["Audio files"] = new List <string> { ".wav" }; picker.SuggestedFileName = Path.GetFileNameWithoutExtension(audioFileName); picker.DefaultFileExtension = ".wav"; picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; picker.PickSaveFileAndContinue(); }
private void SaveButton_Click(object sender, RoutedEventArgs e) { StatusTextBlock.Text = "Saving contacts..."; var savePicker = new FileSavePicker { SuggestedStartLocation = PickerLocationId.DocumentsLibrary, SuggestedFileName = "contacts.xml" }; savePicker.FileTypeChoices.Add("Contacts XML file", new List <string>() { ".xml" }); savePicker.PickSaveFileAndContinue(); }
private void ExportSaveGame(CartridgeSavegame savegame) { // Opens a save file picker. FileSavePicker picker = new FileSavePicker(); string ext = Path.GetExtension(savegame.SavegameFile); picker.DefaultFileExtension = ext; picker.FileTypeChoices.Add(String.Format("Wherigo Savegame ({0})", ext), new List <string>() { ext }); picker.SuggestedFileName = Path.GetFileNameWithoutExtension(savegame.SavegameFile); picker.ContinuationData.Add(BaseViewModel.ContinuationOperationKey, ExportSavegameOperationValue); picker.ContinuationData.Add(ExportSavegameSourceFileKey, savegame.SavegameFile); picker.PickSaveFileAndContinue(); }
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e) { StartButton.IsEnabled = false; StorageFile peekFile; try { peekFile = await Task.Run(() => ApiPeekService.PeekAndLog().AsTask()); } catch (Exception ex) { await new MessageDialog("Error in ApiPeekService: " + ex).ShowAsync(); return; } finally { StartButton.IsEnabled = true; } if (peekFile == null) { await new MessageDialog("Error when gathering Api data!").ShowAsync(); return; } FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.Desktop; savePicker.FileTypeChoices.Add("API Peek result", new List <string> { ".zip" }); savePicker.SuggestedFileName = peekFile.Name; #if WINDOWS_APP || WINDOWS_UWP StorageFile saveFile = await savePicker.PickSaveFileAsync(); if (saveFile != null) { await peekFile.CopyAndReplaceAsync(saveFile); await new MessageDialog("Done!").ShowAsync(); } #elif WINDOWS_PHONE_APP App.SavedFile = peekFile; savePicker.PickSaveFileAndContinue(); #endif }
private void SaveFileButton_Click(object sender, RoutedEventArgs e) { // Clear previous returned file name, if it exists, between iterations of this scenario OutputFileName.Text = ""; OutputFileContent.Text = ""; FileSavePicker savePicker = new FileSavePicker(); // Dropdown of file types the user can save the file as savePicker.FileTypeChoices.Add("Plain Text", new List <string>() { ".txt" }); // Default file name if the user does not type one in or select a file to replace savePicker.SuggestedFileName = "New Document"; savePicker.PickSaveFileAndContinue(); }
private void StartSavePhotoFile() { var filenameFormat = new Windows.ApplicationModel.Resources.ResourceLoader().GetString("PhotoSaveFilenameFormat"); var filename = String.Format(filenameFormat, DateTime.Now.ToString("yyyyMMddHHmmss")); var picker = new FileSavePicker(); picker.SuggestedFileName = filename; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeChoices.Add(".jpg", new List <string>() { ".jpg" }); picker.ContinuationData["Operation"] = "SavePhotoFile"; picker.PickSaveFileAndContinue(); App.ContinuationEventArgsChanged += App_ContinuationEventArgsChanged; }
private void EncodeBtn_Click(object sender, RoutedEventArgs e) { if (m_files.Count == 0) { statusText.Text = "You must select one image at least."; return; } // Create the video file via file picker. FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.VideosLibrary; savePicker.FileTypeChoices.Add("MP4 File", new List <string>() { ".mp4" }); savePicker.SuggestedFileName = "output"; savePicker.PickSaveFileAndContinue(); }
private void SaveFile( SaveFileInteraction saveFile ) { Contract.Requires( saveFile != null ); var dialog = new FileSavePicker(); dialog.ContinuationData.AddRange( saveFile.ContinuationData ); dialog.DefaultFileExtension = saveFile.DefaultFileExtension; dialog.FileTypeChoices.AddRange( saveFile.FileTypeChoices.ToDictionary() ); dialog.SuggestedStartLocation = SuggestedStartLocation; if ( !string.IsNullOrEmpty( saveFile.FileName ) ) dialog.SuggestedFileName = saveFile.FileName; if ( !string.IsNullOrEmpty( SettingsIdentifier ) ) dialog.SettingsIdentifier = SettingsIdentifier; dialog.PickSaveFileAndContinue(); }
private void BackupButton_Click(object sender, RoutedEventArgs e) { if (App.Locator.Download.ActiveDownloads.Count > 0) { CurtainPrompt.ShowError("Can't do a backup while there are active downloads."); return; } var savePicker = new FileSavePicker { SuggestedStartLocation = PickerLocationId.DocumentsLibrary }; // Dropdown of file types the user can save the file as savePicker.FileTypeChoices.Add("Audiotica Backup", new List <string> { ".autcp" }); // Default file name if the user does not type one in or select a file to replace savePicker.SuggestedFileName = string.Format("{0}-WP81", DateTime.Now.ToString("MM-dd-yy_H.mm")); savePicker.PickSaveFileAndContinue(); }
private async void OnSaveClick(object sender, RoutedEventArgs e) { var picker = new FileSavePicker(); picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.DefaultFileExtension = ".png"; picker.FileTypeChoices.Add(new KeyValuePair <string, IList <string> >("Bitmap image", new[] { ".bmp" }.ToList())); picker.FileTypeChoices.Add(new KeyValuePair <string, IList <string> >("Png image", new[] { ".png" }.ToList())); picker.FileTypeChoices.Add(new KeyValuePair <string, IList <string> >("Jpeg image", new[] { ".jpg", ".jpe", ".jpeg" }.ToList())); picker.FileTypeChoices.Add(new KeyValuePair <string, IList <string> >("Gif image", new[] { ".gif" }.ToList())); #if WINDOWS_PHONE_APP picker.ContinuationData["operation"] = MainPageOperation.Save.ToString(); picker.PickSaveFileAndContinue(); #else var file = await picker.PickSaveFileAsync(); if (file != null) { this.OnSave(file); } #endif }
private void exportButton_Click(object sender, RoutedEventArgs e) { exportDatabase = true; FileSavePicker picker = new FileSavePicker(); picker.ContinuationData["Operation"] = "ExportDatabase"; picker.FileTypeChoices.Add("TextFile", new List <string>() { ".poyo" }); String time = DateTime.Now.ToString(); time = time.Replace(' ', '_'); time = time.Replace(":", ""); time = time.Replace(".", ""); String fileName = "SenpaiExport_" + time; picker.SuggestedFileName = fileName; picker.PickSaveFileAndContinue(); }
private Task <StorageFile> SaveFileAsync(IRandomAccessStream stream) { // See http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn614994.aspx // For ContinuationManager complete implementation. // A smaller version of this is also available in the sample and in the App.xaml.cs. var tcs = new TaskCompletionSource <StorageFile>(); EventHandler <FileSavePickerContinuationEventArgs> fileSavedHandler = null; fileSavedHandler = (s, e) => { App.ContinuationManager.FilePickerSaved -= fileSavedHandler; var file = e.File; if (file == null) { tcs.TrySetCanceled(); } else { tcs.TrySetResult(file); } }; App.ContinuationManager.FilePickerSaved += fileSavedHandler; FileSavePicker filePicker = new FileSavePicker(); filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; filePicker.FileTypeChoices.Add("ZIP", new List <string>() { ".zip" }); filePicker.DefaultFileExtension = ".zip"; filePicker.SuggestedFileName = "Output"; filePicker.PickSaveFileAndContinue(); return(tcs.Task); }
public async void Save(string value) { try { FileSavePicker picker = new FileSavePicker(); picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; picker.FileTypeChoices.Add("Rich Text", new List <string>() { ".rtf" }); picker.DefaultFileExtension = ".rtf"; picker.SuggestedFileName = "Document"; #if WINDOWS_PHONE_APP data = value; picker.PickSaveFileAndContinue(); await Task.Delay(0); #else write(await picker.PickSaveFileAsync(), value); #endif } catch { } }
private async void SaveAs_Click(object sender, RoutedEventArgs e) #endif { FileSavePicker picker = new FileSavePicker(); picker.FileTypeChoices.Add("JPEG image", new string[] { ".jpg" }); picker.FileTypeChoices.Add("PNG image", new string[] { ".png" }); picker.FileTypeChoices.Add("BMP image", new string[] { ".bmp" }); picker.DefaultFileExtension = ".png"; picker.SuggestedFileName = "Output file"; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; // On Windows Phone, after the picker is launched the app is closed. #if WINDOWS_PHONE_APP picker.PickSaveFileAndContinue(); #else var file = await picker.PickSaveFileAsync(); if (file != null) { await LoadSaveFileAsync(file); } #endif }
private void SaveImage(FileSavePicker savePicker) { savePicker.PickSaveFileAndContinue(); }