Example #1
0
        async System.Threading.Tasks.Task<Windows.Storage.StorageFile> CaptureAndSave(UIElement element)
        {
            // capture
            var bitmap = new Windows.UI.Xaml.Media.Imaging.RenderTargetBitmap();
            await bitmap.RenderAsync(element);
            var picker = new Windows.Storage.Pickers.FileSavePicker
            {
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary,
                FileTypeChoices = { { "JPEG", new[] { ".jpg" } } },
                SuggestedFileName = "Image",
                DefaultFileExtension = ".jpg",
                CommitButtonText = "Save",
            };

            // save
            var file = await picker.PickSaveFileAsync();
            using (var stream = await file.OpenStreamForWriteAsync())
            {

                var pixel = await bitmap.GetPixelsAsync();
                var dpi = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi;
                var random = stream.AsRandomAccessStream();
                var jpg = Windows.Graphics.Imaging.BitmapEncoder.JpegEncoderId;
                var encoder = await Windows.Graphics.Imaging.BitmapEncoder.CreateAsync(jpg, random);
                var format = Windows.Graphics.Imaging.BitmapPixelFormat.Bgra8;
                var alpha = Windows.Graphics.Imaging.BitmapAlphaMode.Ignore;
                var width = (uint)bitmap.PixelWidth;
                var height = (uint)bitmap.PixelHeight;
                encoder.SetPixelData(format, alpha, width, height, dpi, dpi, pixel.ToArray());
                await encoder.FlushAsync();
            }
            return file;
        }
Example #2
0
        async void AppBarButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            
            // We don't want to save an empty file
            if (inkCanvas.InkPresenter.StrokeContainer.GetStrokes().Count > 0)
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                savePicker.FileTypeChoices.Add("Gif with embedded ISF", new System.Collections.Generic.List<string> { ".gif" });

                Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
                if (null != file)
                {
                    try
                    {
                        using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                        {
                            
                            await inkCanvas.InkPresenter.StrokeContainer.SaveAsync(stream);
                        }
                        ShowMessage(inkCanvas.InkPresenter.StrokeContainer.GetStrokes().Count + " stroke(s) saved!");
                    }
                    catch (Exception ex)
                    {
                        ShowMessage(ex.Message);
                    }
                }
            }
            else
            {
                ShowMessage("Não tem ink para salvar.");
            }

            
        }
Example #3
0
        public ArticleViewModel(INavigationService navigationService)
        {
            this.navigationService = navigationService;
            this.dataService = SimpleIoc.Default.GetInstance<IDataService>();
            this.roamingSettings = SimpleIoc.Default.GetInstance<IRoamingSettingsService>();
     
            GetArticle();

            this.ShowComments = new RelayCommand(() =>
            {
                this.navigationService.Navigate(ViewsType.Comments);
            });

            this.BackCommand = new RelayCommand<string>((s) =>
            {
                this.navigationService.GoBack();
            });

            this.AddToFavorite = new RelayCommand(() =>
            {
               this.roamingSettings.WriteToRoamingSettings(this.Article);
            });

            this.ShowFavorite = new RelayCommand(() =>
            {
                this.navigationService.Navigate(ViewsType.Favorite);
            });

            this.SaveRanglist = new RelayCommand(async () =>
            {
                try
                {
                    var savePicker = new Windows.Storage.Pickers.FileSavePicker();

                    var plainTextFileTypes = new List<string>(new string[] { ".txt" });

                    savePicker.FileTypeChoices.Add(
                        new KeyValuePair<string, IList<string>>("Лист", plainTextFileTypes)
                        );

                    var saveFile = await savePicker.PickSaveFileAsync();

                    if (saveFile != null)
                    {
                        StringBuilder text = new StringBuilder();
                        foreach (var item in this.Article.Ranglist)
                        {
                            text.AppendLine(item.Palce);
                        }

                        await Windows.Storage.FileIO.WriteTextAsync(saveFile, text.ToString());
                        await new Windows.UI.Popups.MessageDialog("Файлът е запазен.").ShowAsync();
                    }
                }
                catch(Exception e)
                {
                    new MessageDialog("Файлът НЕ беше създаден успешно.").ShowAsync();
                }
            });
        }
Example #4
0
        public static async void SaveToFile() {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();
            savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            // Dropdown of file types the user can save the file as
            savePicker.FileTypeChoices.Add("Javascript object", new List<string>() { ".json" });
            savePicker.FileTypeChoices.Add("iCalendar", new List<string>() { ".ics" });
            // Default file name if the user does not type one in or select a file to replace
            savePicker.SuggestedFileName = "Students_Assistent-data";

            StorageFile file = await savePicker.PickSaveFileAsync();

            if (file != null) {
                CachedFileManager.DeferUpdates(file);
                // write to file
                if (file.ContentType == "text/calendar")
                    await FileIO.WriteTextAsync(file, dataStore.ExportToiCalendar());
                else if (file.FileType == ".json")
                    await FileIO.WriteTextAsync(file, dataStore.ExportToJson());

                Windows.Storage.Provider.FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);
                if (status == Windows.Storage.Provider.FileUpdateStatus.Complete) {
                    //this.textBlock.Text = "File " + file.Name + " was saved.";
                }
                else {
                    //this.textBlock.Text = "File " + file.Name + " couldn't be saved.";
                }
            }
        }
        // Create SaveLabeledImageButton_Click to handle clicking saveLabeledImageButton.
        // Allow use of "byte[] bytes = pixels.ToArray();".
        //using System.Runtime.InteropServices.WindowsRuntime;
        private async void SaveLabeledImageButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Windows.UI.Xaml.Media.Imaging.RenderTargetBitmap renderTargetBitmap = new Windows.UI.Xaml.Media.Imaging.RenderTargetBitmap();
            await renderTargetBitmap.RenderAsync(this.ImageCanvas);

            Windows.Storage.Pickers.FileSavePicker pickerToSaveLabeledImage = new Windows.Storage.Pickers.FileSavePicker();
            pickerToSaveLabeledImage.FileTypeChoices.Add("PNG Image", new string[] { ".png" });
            pickerToSaveLabeledImage.FileTypeChoices.Add("JPEG Image", new string[] { ".jpg" });
            Windows.Storage.StorageFile fileToWhichToSave = await pickerToSaveLabeledImage.PickSaveFileAsync();

            if (fileToWhichToSave != null)
            {
                Windows.Storage.Streams.IBuffer pixels = await renderTargetBitmap.GetPixelsAsync();

                using (Windows.Storage.Streams.IRandomAccessStream stream = await fileToWhichToSave.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite))
                {
                    Windows.Graphics.Imaging.BitmapEncoder encoder = await Windows.Graphics.Imaging.BitmapEncoder.CreateAsync(Windows.Graphics.Imaging.BitmapEncoder.JpegEncoderId, stream);

                    encoder.SetPixelData(
                        Windows.Graphics.Imaging.BitmapPixelFormat.Bgra8,
                        Windows.Graphics.Imaging.BitmapAlphaMode.Ignore,
                        (uint)renderTargetBitmap.PixelWidth,
                        (uint)renderTargetBitmap.PixelHeight,
                        Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi,
                        Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi,
                        pixels.ToArray());
                    await encoder.FlushAsync();
                }
            }
        }
Example #6
0
        public async void PickMedia()
        {
            var openPicker = new Windows.Storage.Pickers.FileOpenPicker();

            openPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
            openPicker.FileTypeFilter.Add(".wmv");
            openPicker.FileTypeFilter.Add(".mp4");

            StorageFile source = await openPicker.PickSingleFileAsync();

            var savePicker = new Windows.Storage.Pickers.FileSavePicker();

            savePicker.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.VideosLibrary;

            savePicker.DefaultFileExtension = ".mp3";
            savePicker.SuggestedFileName    = "New Video";

            savePicker.FileTypeChoices.Add("MPEG3", new string[] { ".mp3" });

            StorageFile destination = await savePicker.PickSaveFileAsync();

            MediaEncodingProfile profile =
                MediaEncodingProfile.CreateMp3(AudioEncodingQuality.High);

            MediaTranscoder transcoder = new MediaTranscoder();

            PrepareTranscodeResult prepareOp = await
                                               transcoder.PrepareFileTranscodeAsync(source, destination, profile);

            if (prepareOp.CanTranscode)
            {
                var transcodeOp = prepareOp.TranscodeAsync();

                transcodeOp.Progress +=
                    new AsyncActionProgressHandler <double>(TranscodeProgress);
                transcodeOp.Completed +=
                    new AsyncActionWithProgressCompletedHandler <double>(TranscodeComplete);
            }
            else
            {
                switch (prepareOp.FailureReason)
                {
                case TranscodeFailureReason.CodecNotFound:
                    System.Diagnostics.Debug.WriteLine("Codec not found.");
                    break;

                case TranscodeFailureReason.InvalidProfile:
                    System.Diagnostics.Debug.WriteLine("Invalid profile.");
                    break;

                default:
                    System.Diagnostics.Debug.WriteLine("Unknown failure.");
                    break;
                }
            }
        }
Example #7
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var fop = new Windows.Storage.Pickers.FileSavePicker();

            fop.FileTypeChoices.Add(".txt", new List <string> {
                ".txt"
            });
            txtfile = await fop.PickSaveFileAsync();
        }
Example #8
0
        private async void btnExportProfile_Click(object sender, RoutedEventArgs e)
        {
            if (listSiteProfileIds.SelectedValue == null)
            {
                return;
            }

            string siteProfileId = (listSiteProfileIds.SelectedValue as SiteProfileFolder).Name;

            var picker = new Windows.Storage.Pickers.FileSavePicker();

            picker.SuggestedFileName      = siteProfileId + ".zip";
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            picker.FileTypeChoices.Add("Zip", new List <string>()
            {
                ".zip"
            });

            StorageFile file = await picker.PickSaveFileAsync();

            if (file != null)
            {
                try
                {
                    StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
                    StorageFolder tempFolder  = await localFolder.CreateFolderAsync("Temp", CreationCollisionOption.OpenIfExists);

                    string tempFileName = siteProfileId + DateTime.Now.ToString(".yyMMddHHmmssfff") + ".zip";

                    var task = Task.Run(() =>
                    {
                        try
                        {
                            ZipFile.CreateFromDirectory(Path.Combine(localFolder.Path, SiteManager.PROFILEROOT + "\\" + siteProfileId), Path.Combine(tempFolder.Path, tempFileName));
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine("ZipFile.CreateFromDirectory Exception! " + ex.Message);
                        }
                    });
                    await       task;
                    StorageFile tempFile = await tempFolder.GetFileAsync(tempFileName);

                    if (tempFile != null)
                    {
                        await tempFile.CopyAndReplaceAsync(file);

                        await tempFile.DeleteAsync();
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("ImportProfile Exception! " + ex.Message);
                }
            }
            Splitter.IsPaneOpen = true;
        }
        private async void ExportButton_Click(object sender, RoutedEventArgs e)
        {
            if (IsAdmin())
            {
                var activeDB = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("SamplesDB.db");

                var buffer = await Windows.Storage.FileIO.ReadBufferAsync(activeDB);

                var savePicker = new Windows.Storage.Pickers.FileSavePicker
                {
                    SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.ComputerFolder
                };
                // Dropdown of file types the user can save the file as
                savePicker.FileTypeChoices.Add("SQLite Database", new List <string>()
                {
                    ".db"
                });
                // Default file name if the user does not type one in or select a file to replace
                savePicker.SuggestedFileName = "SamplesDB";

                Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();

                if (file != null)
                {
                    // Prevent updates to the remote version of the file until
                    // we finish making changes and call CompleteUpdatesAsync.
                    Windows.Storage.CachedFileManager.DeferUpdates(file);
                    // write to file
                    //await Windows.Storage.FileIO.WriteTextAsync(file, file.Name);
                    await Windows.Storage.FileIO.WriteBufferAsync(file, buffer);

                    // Let Windows know that we're finished changing the file so
                    // the other app can update the remote version of the file.
                    // Completing updates may require Windows to ask for user input.
                    Windows.Storage.Provider.FileUpdateStatus status =
                        await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);

                    if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                    {
                        ExportSuccess.Text = "File " + file.Name + " was exported.";
                    }
                    else
                    {
                        ExportSuccess.Text = "File " + file.Name + " couldn't be exported.";
                    }
                }
                else
                {
                    ExportSuccess.Text = "Operation cancelled or interrupted.";
                }
                ExportSuccess.Visibility = Visibility.Visible;
            }
            else
            {
                PrivilegeError();
            }
        }
Example #10
0
        async void SaveSnapshot(string fileName)
        {
            bool saved = this.paused;

            this.paused = true;
            this.StartStopCharts();
            Exception error = null;

            try
            {
#if DEBUG
                FrameworkElement element = RootLayout;
#else
                FrameworkElement element = ContentPanel;
#endif
                RenderTargetBitmap bitmap = new RenderTargetBitmap();
                await bitmap.RenderAsync(element);

                IBuffer pixelBuffer = await bitmap.GetPixelsAsync();

                byte[] pixels = pixelBuffer.ToArray();

                var savePicker = new Windows.Storage.Pickers.FileSavePicker();

                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                // Dropdown of file types the user can save the file as
                savePicker.FileTypeChoices.Add("PNG Images", new List <string>()
                {
                    ".png"
                });
                savePicker.SuggestedFileName = AppResources.DefaultSnapshotFileName;

                StorageFile file = await savePicker.PickSaveFileAsync();

                if (file != null)
                {
                    using (var fileStream = await file.OpenStreamForWriteAsync())
                    {
                        var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, fileStream.AsRandomAccessStream());

                        encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)bitmap.PixelWidth, (uint)bitmap.PixelHeight,
                                             96, 96, pixels);
                        await encoder.FlushAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                error = ex;
            }
            this.paused = saved;
            if (error != null)
            {
                await ShowError(error.Message, AppResources.ErrorSavingSnapshotCaption);
            }
            this.StartStopCharts();
        }
Example #11
0
        private async void Newprjbtn_Click(object sender, RoutedEventArgs e)
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();

            savePicker.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            // Dropdown of file types the user can save the file as
            savePicker.FileTypeChoices.Add("Micro_Wizard Project", new List <string>()
            {
                ".mcpr"
            });
            // Default file name if the user does not type one in or select a file to replace
            savePicker.SuggestedFileName = "Micro_prj";

            Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();

            if (file != null)
            {
                // Prevent updates to the remote version of the file until
                // we finish making changes and call CompleteUpdatesAsync.
                Windows.Storage.CachedFileManager.DeferUpdates(file);
                // write to file
                await Windows.Storage.FileIO.WriteTextAsync(file, "chip_select : " +
                                                            mcubrandcombo.SelectedItem.ToString() + " -> " +
                                                            mcumodelcombo.SelectedItem.ToString() + " -> " +
                                                            mcusubmodelcombo.SelectedItem.ToString() + "\r\n");

                // Let Windows know that we're finished changing the file so
                // the other app can update the remote version of the file.
                // Completing updates may require Windows to ask for user input.
                Windows.Storage.Provider.FileUpdateStatus status =
                    await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);

                if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                {
                    //this.textBlock.Text = "File " + file.Name + " was saved.";
                }
                else
                {
                    //this.textBlock.Text = "File " + file.Name + " couldn't be saved.";
                }
            }
            else
            {
                //this.textBlock.Text = "Operation cancelled.";
            }
            shared_var.project_line = await Windows.Storage.FileIO.ReadTextAsync(file);

            if (shared_var.project_line.Contains("chip_select : ARM -> ST -> stm32f103c8\r\n"))
            {
                mainframe.Navigate(typeof(Home_stm32f103));
            }
            else
            {
                DisplayunsopportedprjtDialog();
            }
        }
Example #12
0
        public SaveImageCommand() : base(true)
        {
            this
            .Select(e => e.EventArgs.Parameter as MemoryStreamBase64Item)
            .Where(e => e != null)
            .Subscribe(
                async e =>
            {
                try
                {
                    var fp = new Windows.Storage.Pickers.FileSavePicker();
                    fp.FileTypeChoices.Add(SaveImageCommandFileSavePickerPngFiles, new List <string> {
                        ".png"
                    });
                    fp.DefaultFileExtension = ".png";
                    var fpicked             = await fp.PickSaveFileAsync();
                    if (fpicked != null)
                    {
                        using (var saveTargetStream = await fpicked.OpenAsync(FileAccessMode.ReadWrite))
                        {
                            var bitmapSourceStream = await e.GetRandowmAccessStreamAsync();

                            await ServiceLocator
                            .Instance
                            .Resolve <IImageConvertService>()
                            .ConverterBitmapToTargetStreamAsync(bitmapSourceStream, saveTargetStream);
                        }
                        var msb             = new MessageDialog(SaveImageCommandMessageDialogFileSavedNextContent, SaveImageCommandMessageDialogMessageDialogFileSavedNextTitle);
                        var commandOpenFile = new UICommand(
                            SaveImageCommandMessageDialogUICommandOpenFile,
                            async c =>
                        {
                            await Launcher.LaunchFileAsync(fpicked);
                        });
                        // var commandOpenFold = new UICommand(
                        //  "Open Folder",
                        //async c =>
                        //{
                        //	await Launcher.LaunchFolderAsync(
                        //		await fpicked.GetParentAsync(),
                        //		new FolderLauncherOptions { DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseHalf });
                        //}
                        //  );
                        var commandCancelIt = new UICommand(SaveImageCommandMessageDialogUICommandLeave);
                        msb.Commands.Add(commandOpenFile);
                        //msb.Commands.Add(commandOpenFold);
                        msb.Commands.Add(commandCancelIt);
                        msb.CancelCommandIndex  = 1;
                        msb.DefaultCommandIndex = 0;
                        var selected            = await msb.ShowAsync();
                    }
                }
                catch (Exception ex)
                {
                }
            });
        }
Example #13
0
        private async void SaveButton(object sender, RoutedEventArgs e)
        {
            if (File == null)
            {
                Windows.Storage.Pickers.FileSavePicker savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;

                if (AppVar.FileTypeEdit == FileTypes.HtmlFile)
                {
                    savePicker.FileTypeChoices.Add("HTML file", new List <string>()
                    {
                        ".html"
                    });
                }
                else
                {
                    savePicker.FileTypeChoices.Add("Text file", new List <string>()
                    {
                        ".txt"
                    });
                }

                savePicker.SuggestedFileName = AppVar.FileNameEdit;

                Windows.Storage.StorageFile File = await savePicker.PickSaveFileAsync();

                if (File != null)
                {
                    Windows.Storage.CachedFileManager.DeferUpdates(File);

                    Windows.Storage.Streams.IRandomAccessStream randAccStream =
                        await File.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);

                    editor.Document.SaveToStream(Windows.UI.Text.TextGetOptions.None, randAccStream);

                    // Let Windows know that we're finished changing the file so the
                    // other app can update the remote version of the file.
                    Windows.Storage.Provider.FileUpdateStatus status = await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(File);

                    if (status != Windows.Storage.Provider.FileUpdateStatus.Complete)
                    {
                        Windows.UI.Popups.MessageDialog errorBox =
                            new Windows.UI.Popups.MessageDialog("File " + File.Name + " couldn't be saved.");
                        await errorBox.ShowAsync();
                    }
                    else
                    {
                        AppTitle.Text = File.Name;
                    }
                }
            }
            else
            {
                editor.Document.GetText(TextGetOptions.None, out string docText);
                await Windows.Storage.FileIO.WriteTextAsync(File, docText);
            }
        }
Example #14
0
        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            if (current_file != null)
            {
                await Windows.Storage.FileIO.WriteTextAsync(current_file, Editor.Text);

                Htto.Tools.showInformation(current_file.Name, "保存成功");
            }
            else if (current_file == null)
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation =
                    Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                // Dropdown of file types the user can save the file as
                savePicker.FileTypeChoices.Add("merdog program", new List <string>()
                {
                    ".mer"
                });
                // Default file name if the user does not type one in or select a file to replace
                savePicker.SuggestedFileName = "new";

                current_file = await savePicker.PickSaveFileAsync();

                if (current_file != null)
                {
                    // Prevent updates to the remote version of the file until
                    // we finish making changes and call CompleteUpdatesAsync.
                    Windows.Storage.CachedFileManager.DeferUpdates(current_file);
                    // write to file
                    await Windows.Storage.FileIO.WriteTextAsync(current_file, Editor.Text);

                    // Let Windows know that we're finished changing the file so
                    // the other app can update the remote version of the file.
                    // Completing updates may require Windows to ask for user input.
                    Windows.Storage.Provider.FileUpdateStatus status =
                        await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(current_file);

                    if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                    {
                        Htto.Tools.showInformation(current_file.Name, "保存文件成功");
                    }
                    else
                    {
                        Htto.Tools.showInformation(current_file.Name, "保存文件失败");
                    }
                }
                else
                {
                    Htto.Tools.showInformation("信息", "保存文件取消");
                }
            }
            if (current_file != null)
            {
                SFileName.Text = current_file.Name;
            }
        }
        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            EnableButtons(false);
            rootPage.NotifyUser("Requesting file to save to", NotifyType.StatusMessage);

            var picker = new Windows.Storage.Pickers.FileSavePicker();

            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
            picker.FileTypeChoices.Add("MP4 files", new List <string>()
            {
                ".mp4"
            });
            picker.SuggestedFileName = "TrimmedClip.mp4";

            StorageFile file = await picker.PickSaveFileAsync();

            if (file != null)
            {
                var saveOperation = composition.RenderToFileAsync(file, MediaTrimmingPreference.Precise);
                saveOperation.Progress = new AsyncOperationProgressHandler <TranscodeFailureReason, double>(async(info, progress) =>
                {
                    await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
                    {
                        rootPage.NotifyUser(string.Format("Saving file... Progress: {0:F0}%", progress), NotifyType.StatusMessage);
                    }));
                });
                saveOperation.Completed = new AsyncOperationWithProgressCompletedHandler <TranscodeFailureReason, double>(async(info, status) =>
                {
                    await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
                    {
                        try
                        {
                            var results = info.GetResults();
                            if (results != TranscodeFailureReason.None || status != AsyncStatus.Completed)
                            {
                                rootPage.NotifyUser("Saving was unsuccessful", NotifyType.ErrorMessage);
                            }
                            else
                            {
                                rootPage.NotifyUser("Trimmed clip saved to file", NotifyType.StatusMessage);
                            }
                        }
                        finally
                        {
                            // Remember to re-enable controls on both success and failure
                            EnableButtons(true);
                        }
                    }));
                });
            }
            else
            {
                rootPage.NotifyUser("User cancelled the file selection", NotifyType.StatusMessage);
                EnableButtons(true);
            }
        }
        private async void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            InkStrokeContainer container = new InkStrokeContainer();

            foreach (var item in _inkStrokes)
            {
                container.AddStrokes(from stroke in item.GetStrokes() select stroke.Clone());
            }

            if (container.GetStrokes().Count > 0)
            {
                Windows.Storage.Pickers.FileSavePicker savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                savePicker.FileTypeChoices.Add("GIF with embedded ISF", new List <string>()
                {
                    ".gif"
                });
                savePicker.DefaultFileExtension = ".gif";
                savePicker.SuggestedFileName    = "PaperPencilPen001";

                Windows.Storage.StorageFile file =
                    await savePicker.PickSaveFileAsync();

                if (file != null)
                {
                    Windows.Storage.CachedFileManager.DeferUpdates(file);
                    IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);

                    using (IOutputStream outputStream = stream.GetOutputStreamAt(0))
                    {
                        await container.SaveAsync(outputStream);

                        await outputStream.FlushAsync();
                    }

                    stream.Dispose();

                    Windows.Storage.Provider.FileUpdateStatus status =
                        await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);

                    if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                    {
                        //file saved
                    }
                    else
                    {
                        //not saved
                    }
                }

                else
                {
                    //cancelled
                }
            }
        }
Example #17
0
        private async void save_Click(object sender, RoutedEventArgs e)
        {
            if (pancakeInk.InkPresenter.StrokeContainer.GetStrokes().Count > 0)
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                savePicker.FileTypeChoices.Add("Gif with embedded ISF", new System.Collections.Generic.List <string> {
                    ".gif"
                });

                Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();

                if (null != file)
                {
                    try
                    {
                        using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                        {
                            await pancakeInk.InkPresenter.StrokeContainer.SaveAsync(stream);
                        }
                        saved    = true;
                        filePath = file.Path;
                        Button btn = sender as Button;
                        if (null == btn)
                        {
                            return;
                        }
                        var parent = VisualTreeHelper.GetParent(btn);
                        if (null != parent)
                        {
                            int count = VisualTreeHelper.GetChildrenCount(parent);
                            for (int i = 0; i < count; i++)
                            {
                                var child = VisualTreeHelper.GetChild(parent, i);
                                if (child != null && child.ToString().Equals(ELLIPSE) && ((Ellipse)child).Width == btn.Width)
                                {
                                    ((Ellipse)child).Fill = new SolidColorBrush(Color.FromArgb(255, 88, 91, 144));
                                    break;
                                }
                            }
                        }
                        ResetButtonState(btn);
                    }
                    catch (Exception ex)
                    {
#if DEBUG
                        System.Diagnostics.Debug.WriteLine(ex.Message);
#endif
                        saved = false;
                    }
                }
            }
            else
            {
            }
        }
Example #18
0
        private async void Save(object sender, RoutedEventArgs e)
        {
            var title    = Title.Text;
            var name     = Name.Text;
            var phone    = Phone.Text;
            var address  = Address.Text;
            var url      = Site.Text;
            var distance = Distance.Text;
            var city     = City.Text;
            var country  = Country.Text;

            var sb = new StringBuilder();

            sb.AppendLine(title + "; ");
            sb.AppendLine("Name: " + name + "; ");
            sb.AppendLine("Phone: " + phone + "; ");
            sb.AppendLine("Address: " + address + "; ");
            sb.AppendLine("Site: " + url + "; ");
            sb.AppendLine("Distance: " + distance + "; ");
            sb.AppendLine("City: " + city + "; ");
            sb.AppendLine("Country: " + country + "; ");

            var savePicker = new Windows.Storage.Pickers.FileSavePicker();

            var plainTextFileTypes = new List <string>(new string[] { ".txt" });

            var webPageFileTypes = new List <string>(new string[] { ".html", ".htm" });

            savePicker.FileTypeChoices.Add(
                new KeyValuePair <string, IList <string> >("Plain Text", plainTextFileTypes)
                );
            savePicker.FileTypeChoices.Add(
                new KeyValuePair <string, IList <string> >("Web Page", webPageFileTypes)
                );

            var saveFile = await savePicker.PickSaveFileAsync();

            if (saveFile != null)
            {
                if (saveFile.FileType == ".html" || saveFile.FileType == ".htm")
                {
                    var text = new StringBuilder();
                    text.Append("<html><head><title>Saved By FileSavePicker</title></head><meta charset=\"utf-8\"><body><p>" + sb + "</p></body>");
                    await Windows.Storage.FileIO.WriteTextAsync(saveFile, text.ToString());

                    await new Windows.UI.Popups.MessageDialog("File Saved!").ShowAsync();
                }
                else
                {
                    await Windows.Storage.FileIO.WriteTextAsync(saveFile, sb.ToString());

                    await new Windows.UI.Popups.MessageDialog("File Saved!").ShowAsync();
                }
            }
        }
Example #19
0
        private async void createMapping(object sender, RoutedEventArgs e)
        {
            tf.refreshLetters();
            mf = new MapFile(tf);


            textBlock3.Text = "Creating the mapping for passwords...";
            disableAllControls();

            try
            {
                await Task.Run(() => createMap());
            }
            catch (Exception)
            {
                await new MessageDialog("Increase the number of allocated entries in settings to eliminate a security threat.", "Mapping file does not contain enough characters not to create any duplicates.").ShowAsync();
                enableAllControls();
                textBlock3.Text = "";
                return;
            }

            enableAllControls();
            textBlock3.Text = "";

            var savePicker = new Windows.Storage.Pickers.FileSavePicker();

            savePicker.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            savePicker.FileTypeChoices.Add("Text File (.txt)", new List <string>()
            {
                ".txt"
            });
            savePicker.SuggestedFileName = "Not a Passwords Text File";


            Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();

            if (file != null)
            {
                Windows.Storage.CachedFileManager.DeferUpdates(file);
                await Windows.Storage.FileIO.WriteTextAsync(file, mf.getFileText());

                Windows.Storage.Provider.FileUpdateStatus status =
                    await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);

                if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                {
                    await new MessageDialog("", "File saved sucessfully.").ShowAsync();
                }
                else
                {
                    await new MessageDialog("", "Failed to save file.").ShowAsync();
                }
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Shell.Current.RegisterNewCommand("Export & Save", async(sender, args) =>
            {
                if (_infiniteCanvas != null)
                {
                    var savePicker = new Windows.Storage.Pickers.FileSavePicker
                    {
                        SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary
                    };
                    savePicker.FileTypeChoices.Add("application/json", new List <string> {
                        ".json"
                    });
                    savePicker.SuggestedFileName = "Infinite Canvas Export";

                    StorageFile file = await savePicker.PickSaveFileAsync();
                    if (file != null)
                    {
                        var json = _infiniteCanvas.ExportAsJson();
                        CachedFileManager.DeferUpdates(file);
                        await FileIO.WriteTextAsync(file, json);
                    }
                }
            });

            Shell.Current.RegisterNewCommand("Import and Load", async(sender, args) =>
            {
                if (_infiniteCanvas != null)
                {
                    var picker = new Windows.Storage.Pickers.FileOpenPicker
                    {
                        ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail,
                        SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary
                    };
                    picker.FileTypeFilter.Add(".json");
                    var file = await picker.PickSingleFileAsync();

                    if (file != null)
                    {
                        try
                        {
                            var json = await FileIO.ReadTextAsync(file);
                            _infiniteCanvas.ImportFromJson(json);
                        }
                        catch
                        {
                            var dialog = new MessageDialog("Invalid File");
                            await dialog.ShowAsync();
                        }
                    }
                }
            });
        }
Example #21
0
        private async void buttonSave_ClickAsync(object sender, RoutedEventArgs e)
        {
            //    // Get all strokes on the InkCanvas.
            IReadOnlyList <InkStroke> currentStrokes = inkCanvas.InkPresenter.StrokeContainer.GetStrokes();

            if (currentStrokes.Count > 0)
            {
                // Use a file picker to identify ink file.
                Windows.Storage.Pickers.FileSavePicker savePicker =
                    new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation =
                    Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                savePicker.FileTypeChoices.Add(
                    "GIF with embedded ISF",
                    new List <string>()
                {
                    ".gif"
                });
                savePicker.DefaultFileExtension = ".gif";
                savePicker.SuggestedFileName    = "InkSample";

                // Show the file picker.
                Windows.Storage.StorageFile file =
                    await savePicker.PickSaveFileAsync();

                // When selected, picker returns a reference to the file.
                if (file != null)
                {
                    // Prevent updates to the file until updates are
                    // finalized with call to CompleteUpdatesAsync.
                    Windows.Storage.CachedFileManager.DeferUpdates(file);
                    // Open a file stream for writing.
                    IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);

                    // Write the ink strokes to the output stream.
                    using (IOutputStream outputStream = stream.GetOutputStreamAt(0))
                    {
                        await inkCanvas.InkPresenter.StrokeContainer.SaveAsync(outputStream);

                        await outputStream.FlushAsync();
                    }
                    stream.Dispose();

                    // Finalize write so other apps can update file.
                    Windows.Storage.Provider.FileUpdateStatus status =
                        await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);

                    if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                    {
                        // File saved.
                    }
                }
            }
        }
        public static async Task <bool> SaveWritableBitmapAsync(WriteableBitmap bmp, bool isSaveAs)
        {
            string fileName          = DateTime.UtcNow.Ticks + ".png";
            Guid   BitmapEncoderGuid = BitmapEncoder.PngEncoderId;

            StorageFile   file   = null;
            StorageFolder folder = null;

            if (isSaveAs)
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                // Dropdown of file types the user can save the file as
                savePicker.FileTypeChoices.Add("PNG图片", new List <string>()
                {
                    ".png"
                });
                // Default file name if the user does not type one in or select a file to replace
                savePicker.SuggestedFileName = fileName;
                file = await savePicker.PickSaveFileAsync();

                if (file == null)
                {
                    return(false);
                }
            }
            else
            {
                folder = await GetSubFolderAsync(ApplicationData.Current.LocalFolder, "EDITOR-BriefPicture");

                file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
            }

            using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoderGuid, stream);

                Stream pixelStream = bmp.PixelBuffer.AsStream();
                byte[] pixels      = new byte[pixelStream.Length];
                await pixelStream.ReadAsync(pixels, 0, pixels.Length);

                encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore,
                                     (uint)bmp.PixelWidth,
                                     (uint)bmp.PixelHeight,
                                     96.0,
                                     96.0,
                                     pixels);
                await encoder.FlushAsync();
            }
            if (folder != null)
            {
                await Launcher.LaunchFolderAsync(folder);
            }
            return(true);
        }
Example #23
0
        private async void Download_Click(object sender, RoutedEventArgs e)
        {
            this.IsEnabled = false;
            switch (_InstagramMediaModel.InstaMediaType)
            {
            case InstaMediaType.Image:
            {
                {
                    var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                    savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                    savePicker.FileTypeChoices.Add("Picture", new List <string>()
                        {
                            ".jpg"
                        });
                    savePicker.SuggestedFileName = DateTime.Now.ToFileTime().ToString();
                    var file = await savePicker.PickSaveFileAsync();

                    if (file != null)
                    {
                        Uri source = new Uri(_InstagramMediaModel.Images[0].URI);
                        BackgroundDownloader downloader = new BackgroundDownloader();
                        DownloadOperation    download   = downloader.CreateDownload(source, file);
                        var downloadresult = await download.StartAsync();
                    }
                }
            }
            break;

            case InstaMediaType.Video:
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                savePicker.FileTypeChoices.Add("Video", new List <string>()
                    {
                        ".mp4"
                    });
                savePicker.SuggestedFileName = DateTime.Now.ToFileTime().ToString();
                var file = await savePicker.PickSaveFileAsync();

                if (file != null)
                {
                    Uri source = new Uri(_InstagramMediaModel.Videos[0].Url);
                    BackgroundDownloader downloader = new BackgroundDownloader();
                    DownloadOperation    download   = downloader.CreateDownload(source, file);
                    var downloadresult = await download.StartAsync();
                }
            }
            break;

            case InstaMediaType.Carousel:
                break;
            }
            this.IsEnabled = true;
        }
        private async void saveGIF(InkStrokeContainer strokeContainer)
        {
            var strokes = strokeContainer.GetStrokes();

            if (strokes.Count > 0)
            {
                Windows.Storage.Pickers.FileSavePicker savePicker =
                    new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation =
                    Windows.Storage.Pickers.PickerLocationId.Desktop;
                savePicker.FileTypeChoices.Add(
                    "Obrazek",
                    new List <string>()
                {
                    ".gif"
                });
                savePicker.DefaultFileExtension = ".gif";
                savePicker.SuggestedFileName    = "Nowy gif";

                Windows.Storage.StorageFile file =
                    await savePicker.PickSaveFileAsync();

                // When chosen, picker returns a reference to the selected file.
                if (file != null)
                {
                    Windows.Storage.CachedFileManager.DeferUpdates(file);
                    IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);

                    using (IOutputStream outputStream = stream.GetOutputStreamAt(0))
                    {
                        await strokeContainer.SaveAsync(outputStream);

                        await outputStream.FlushAsync();
                    }
                    stream.Dispose();

                    Windows.Storage.Provider.FileUpdateStatus status =
                        await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);

                    if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                    {
                        Debug.WriteLine("File " + file.Name + " was saved.");
                    }
                    else
                    {
                        Debug.WriteLine("File " + file.Name + " was NOT saved.");
                    }
                }
                else
                {
                    Debug.WriteLine("Cancelled");
                }
            }
        }
Example #25
0
        private async void btnGuardarComo_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();

                savePicker.FileTypeChoices.Add("JPEG-Image", new List <string>()
                {
                    ".jpg"
                });

                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                savePicker.SuggestedSaveFile      = fileFondo;
                savePicker.SuggestedFileName      = nasa.title;

                StorageFile file = await savePicker.PickSaveFileAsync();

                if (file != null)
                {
                    progressImage2.IsActive       = true;
                    textBlockWallpaper.Visibility = Visibility.Visible;
                    textBlockWallpaper.Text       = "Descargando wallpaper";

                    if (fileFondo != null)
                    {
                        await fileFondo.CopyAndReplaceAsync(file);
                    }
                    else
                    {
                        bool descarga = await DownloadImage(nasa.hdurl, nasa.title);

                        if (descarga)
                        {
                            await fileFondo.CopyAndReplaceAsync(file);
                        }
                        else
                        {
                            progressImage2.IsActive = false;
                            textBlockWallpaper.Text = "Error en la descarga";
                            btnAplicar.IsEnabled    = true;
                        }
                    }

                    progressImage2.IsActive       = false;
                    textBlockWallpaper.Visibility = Visibility.Collapsed;
                }
            }
            catch (Exception)
            {
                textBlockWallpaper.Visibility = Visibility.Visible;
                textBlockWallpaper.Text       = "Error al realizar la operacion";
            }
        }
Example #26
0
        // </SnippetPickFileAndAddClip>

        // <SnippetRenderCompositionToFile>
        private async Task RenderCompositionToFile()
        {
            var picker = new Windows.Storage.Pickers.FileSavePicker();

            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
            picker.FileTypeChoices.Add("MP4 files", new List <string>()
            {
                ".mp4"
            });
            picker.SuggestedFileName = "RenderedComposition.mp4";

            Windows.Storage.StorageFile file = await picker.PickSaveFileAsync();

            if (file != null)
            {
                // Call RenderToFileAsync
                var saveOperation = composition.RenderToFileAsync(file, MediaTrimmingPreference.Precise);

                saveOperation.Progress = new AsyncOperationProgressHandler <TranscodeFailureReason, double>(async(info, progress) =>
                {
                    await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
                    {
                        ShowErrorMessage(string.Format("Saving file... Progress: {0:F0}%", progress));
                    }));
                });
                saveOperation.Completed = new AsyncOperationWithProgressCompletedHandler <TranscodeFailureReason, double>(async(info, status) =>
                {
                    await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
                    {
                        try
                        {
                            var results = info.GetResults();
                            if (results != TranscodeFailureReason.None || status != AsyncStatus.Completed)
                            {
                                ShowErrorMessage("Saving was unsuccessful");
                            }
                            else
                            {
                                ShowErrorMessage("Trimmed clip saved to file");
                            }
                        }
                        finally
                        {
                            // Update UI whether the operation succeeded or not
                        }
                    }));
                });
            }
            else
            {
                ShowErrorMessage("User cancelled the file selection");
            }
        }
        private async void SaveMoiNewRekv_Click(object sender, RoutedEventArgs e)
        {
            var savePicker5 = new Windows.Storage.Pickers.FileSavePicker();

            savePicker5.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            // Поле выбора типа файла в диалоге
            savePicker5.FileTypeChoices.Add("Документ", new List <string>()
            {
                ".mrekv"
            });
            // Default file name if the user does not type one in or select a file to replace
            savePicker5.SuggestedFileName = "Реквизиты моей организации";
            //
            Windows.Storage.StorageFile Myfile5 = await savePicker5.PickSaveFileAsync();

            if (Myfile5 != null)
            {
                // Prevent updates to the remote version of the file until
                // we finish making changes and call CompleteUpdatesAsync.
                Windows.Storage.CachedFileManager.DeferUpdates(Myfile5);
                // write to file
                //await Windows.Storage.FileIO.WriteTextAsync(file, file.Name); //запись в файл имени
                string TShapka = "";
                if (CHeckBoxSchapka5.IsChecked == true)
                {
                    TShapka = "1";
                }

                await FileIO.WriteTextAsync(Myfile5, TextBoxMoeNaimenovaniePolnoe5.Text + ";" + TextBoxMoeNaimenovanieSokr5.Text + ";" + TextBoxMojINN5.Text + ";" + TextBoxMojKPP5.Text + ";" + TextBoxMojOGRN5.Text + ";" + TextBoxMoiBankName5.Text + ";" + TextBoxMoiBankBIK5.Text + ";" + TextBoxMoiBankKorr5.Text + ";" + TextBoxMoiRaschetnijSchet5.Text + ";" + TextBoxMojaRukDolzhnost5.Text + ";" +
                                            TextBoxMojVlice5.Text + ";" + TextBoxMojFIORuk5.Text + ";" + TextBoxMojUrAddr5.Text + ";" + TextBoxMojFackAddr5.Text + ";" + TextBoxMojPhone5.Text + ";" + TextBoxMojMobile5.Text + ";" + TextBoxMojEmail5.Text + ";" + TextBoxMojSait5.Text + ";" + TextBoxMojSlogan5.Text + ";" + TextBoxMojLogo5.Text + ";" + TextBoxMoiPechatPodpis5.Text + ";" + TShapka + ";" + TextBoxUslugiPo5.Text + ";" + Logofilename + ";" + PechatPodpisfilename + ";");


                // Let Windows know that we're finished changing the file so
                // the other app can update the remote version of the file.
                // Completing updates may require Windows to ask for user input.
                Windows.Storage.Provider.FileUpdateStatus status =
                    await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(Myfile5);

                if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                {
                    this.TextBlockStatusFile5.Text = "Файл моих реквизитов " + Myfile5.Name + " успешно сохранен.";
                }
                else
                {
                    this.TextBlockStatusFile5.Text = "Не удалось сохранить файл моих реквизитов " + Myfile5.Name + ".";
                }
            }
            else
            {
                this.TextBlockStatusFile5.Text = "Операция записи файла моих реквизитов была прервана.";
            }
        }
Example #28
0
        public static async Task <EncodeResult> EncodeGif(IFrameData frameData)
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();

            savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            savePicker.FileTypeChoices.Add("GIF", new List <string>()
            {
                ".gif"
            });
            savePicker.SuggestedFileName = "MyGif";

            var file = await savePicker.PickSaveFileAsync();

            if (file == null)
            {
                return new EncodeResult {
                           Success = false
                }
            }
            ;

            using (var memoryStream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite))
            {
                var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.GifEncoderId, memoryStream);

                var propSet = await encoder.BitmapProperties.GetPropertiesAsync(new string[] { "/grctlext/Delay" });

                var props = new BitmapPropertySet();
                props.Add("/grctlext/Delay", new BitmapTypedValue((UInt16)10, Windows.Foundation.PropertyType.UInt16));

                var count = frameData.GetFramesCount();
                for (var frameIdx = 0; frameIdx < count; frameIdx++)
                {
                    var frame = await frameData.GetFrameToEncode(frameIdx);

                    encoder.SetSoftwareBitmap(frame.ImageSource);

                    await encoder.BitmapProperties.SetPropertiesAsync(props);

                    if (frameIdx + 1 < count)
                    {
                        await encoder.GoToNextFrameAsync();
                    }
                }

                await encoder.FlushAsync();
            }

            return(new EncodeResult {
                Success = true
            });
        }
Example #29
0
        public async void  SaveImage(ZXingBarcodeImageView image)
        {
            var writer = new ZXing.Mobile.BarcodeWriter();

            if (image != null && image.BarcodeOptions != null)
            {
                writer.Options = image.BarcodeOptions;
            }
            if (image != null)
            {
                writer.Format = image.BarcodeFormat;
            }
            var value = image != null ? image.BarcodeValue : string.Empty;
            var wb    = writer.Write(value);

            //var imageData = ImagetoBytes(wb);
            var filename = System.DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg";

            if (Device.Idiom == TargetIdiom.Desktop)
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation =
                    Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                savePicker.SuggestedFileName = filename;
                savePicker.FileTypeChoices.Add("JPEG Image", new List <string>()
                {
                    ".jpg"
                });

                var file = await savePicker.PickSaveFileAsync();

                if (file != null)
                {
                    CachedFileManager.DeferUpdates(file);
                    await ConvertToJPEGFileAsync(file, wb);

                    var status = await CachedFileManager.CompleteUpdatesAsync(file);

                    if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                    {
                        ShowToastNotification();
                    }
                }
            }
            else
            {
                StorageFolder storageFolder = KnownFolders.SavedPictures;
                StorageFile   sampleFile    = await storageFolder.CreateFileAsync(
                    filename + ".jpg", CreationCollisionOption.ReplaceExisting);
                await ConvertToJPEGFileAsync(sampleFile, wb);
            }
        }
Example #30
0
        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            save.IsEnabled       = false;
            chooseFile.IsEnabled = false;
            trimClip.IsEnabled   = false;
            var picker = new Windows.Storage.Pickers.FileSavePicker();

            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
            picker.FileTypeChoices.Add("MOV files", new List <string>()
            {
                ".mov"
            });
            picker.SuggestedFileName = "TrimmedClip.mov";

            StorageFile file = await picker.PickSaveFileAsync();

            if (file != null)
            {
                var saveOperation = composition.RenderToFileAsync(file, MediaTrimmingPreference.Precise);
                saveOperation.Progress = new AsyncOperationProgressHandler <TranscodeFailureReason, double>(async(info, progress) =>
                {
                    await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
                    {
                        ResultMessage.Text = string.Format("Saving file... Progress: {0:F0}%", progress);
                    }));
                });
                saveOperation.Completed = new AsyncOperationWithProgressCompletedHandler <TranscodeFailureReason, double>(async(info, status) =>
                {
                    await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
                    {
                        try
                        {
                            var results = info.GetResults();
                            if (results != TranscodeFailureReason.None || status != AsyncStatus.Completed)
                            {
                                ResultMessage.Text = "saving error";
                            }
                            else
                            {
                                ResultMessage.Text = "saving success";
                            }
                        }
                        finally
                        {
                            save.IsEnabled       = true;
                            chooseFile.IsEnabled = true;
                            trimClip.IsEnabled   = true;
                        }
                    }));
                });
            }
        }
Example #31
0
        private async void Download()
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();

            savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Downloads;

            // Dropdown of file types the user can save the file as (MUST HAVE)
            // fileName should include the expected file format because the savePicker can't list all existing file format
            // .temp extension removed after savePicker is closed
            savePicker.FileTypeChoices.Add("Temporary format", new List <string>()
            {
                ".temp"
            });

            // Default file name if the user does not type one in or select a file to replace
            string fileName = "107.391.029_" + "bizbasz.txt";

            savePicker.SuggestedFileName = fileName;

            // Create file and rename to correct file format
            StorageFile targetFile = await savePicker.PickSaveFileAsync();

            await targetFile.RenameAsync(fileName);

            if (targetFile != null)
            {
                // Prevent updates to the remote version of the file until
                // we finish making changes and call CompleteUpdatesAsync.
                CachedFileManager.DeferUpdates(targetFile);

                // Write to file
                Azure.DownloadBlob("documents", targetFile);

                // Let Windows know that we're finished changing the file so
                // the other app can update the remote version of the file.
                // Completing updates may require Windows to ask for user input.
                Windows.Storage.Provider.FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(targetFile);

                if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                {
                    this.upload_feedback_2.Text = "File " + targetFile.Name + " was saved.";
                }
                else
                {
                    this.upload_feedback_2.Text = "File " + targetFile.Name + " couldn't be saved.";
                }
            }
            else
            {
                this.upload_feedback_2.Text = "Operation cancelled.";
            }
        }
Example #32
0
        private async void btnSave_Click(object sender, RoutedEventArgs e)
        {
            // SaveFile Picker
            Windows.Storage.Pickers.FileSavePicker savePicker = new Windows.Storage.Pickers.FileSavePicker();
            savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;

            // Dropdown of file types the user can save the file as
            savePicker.FileTypeChoices.Add("Rich Text Format", new List <string>()
            {
                ".rtf"
            });
            savePicker.FileTypeChoices.Add("Normal Text File", 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";

            Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();

            if (file != null)
            {
                // Prevent updates to the remote version of the file until we
                // finish making changes and call CompleteUpdatesAsync.
                Windows.Storage.CachedFileManager.DeferUpdates(file);
                // write to file
                Windows.Storage.Streams.IRandomAccessStream randAccStream =
                    await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);

                if (file.FileType == ".rtf")
                {
                    editor.Document.SaveToStream(Windows.UI.Text.TextGetOptions.FormatRtf, randAccStream);
                }
                else if (file.FileType == ".txt")
                {
                    editor.Document.SaveToStream(Windows.UI.Text.TextGetOptions.None, randAccStream);
                }

                // Let Windows know that we're finished changing the file so the
                // other app can update the remote version of the file.
                Windows.Storage.Provider.FileUpdateStatus status = await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);

                if (status != Windows.Storage.Provider.FileUpdateStatus.Complete)
                {
                    Windows.UI.Popups.MessageDialog errorBox =
                        new Windows.UI.Popups.MessageDialog("File " + file.Name + " couldn't be saved.");
                    await errorBox.ShowAsync();
                }
            }
        }
Example #33
0
        /// <summary>
        /// Saves file after file picker with content.ToString(), prompts afterwards.
        /// </summary>
        /// <param name="content">Content to save. Uses .ToString() method.</param>
        public async Task SaveToFile <T>(T content)
        {
            // Prepare file picker
            var savePicker = new Windows.Storage.Pickers.FileSavePicker
            {
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary,
                SuggestedFileName      = $"{DateTime.UtcNow.ToString("u")}"
            };

            _measurementsExporter.Formats
            .ForEach(ex => savePicker.FileTypeChoices.Add(ex.Description, new List <string> {
                ex.Extension
            }));

            var file = await savePicker.PickSaveFileAsync();

            if (file == null)
            {
                await InformFail();

                return;
            }

            // Get format
            var format = _measurementsExporter.Formats
                         .FirstOrDefault(msf => msf.Extension.Equals(file.FileType));

            if (format == null)
            {
                await InformFail();

                return;
            }

            // Block Windows from accessing the file
            CachedFileManager.DeferUpdates(file);

            await FileIO.WriteTextAsync(file, format.Serialize(content));

            var status = await CachedFileManager.CompleteUpdatesAsync(file);

            // Check saving status
            if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
            {
                await InformSuccess(file);
            }
            else
            {
                await InformFail();
            }
        }
        async private void SaveWithFilepickerAndDownload(object sender, RoutedEventArgs e)
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();

            savePicker.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            // Dropdown of file types the user can save the file as
            savePicker.FileTypeChoices.Add("Video", new List <string>()
            {
                ".mp4", ".mkv"
            });
            // Default file name if the user does not type one in or select a file to replace
            savePicker.SuggestedFileName = "New File";
            Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();

            if (file != null)
            {
                // Prevent updates to the remote version of the file until
                // we finish making changes and call CompleteUpdatesAsync.
                Windows.Storage.CachedFileManager.DeferUpdates(file);

                var stream = await file.OpenStreamForWriteAsync();

                getYoutubeFileProps(stream);

                // write to file
                //       await Windows.Storage.FileIO.WriteTextAsync(file, file.Name);
                // Let Windows know that we're finished changing the file so
                // the other app can update the remote version of the file.
                // Completing updates may require Windows to ask for user input.



                Windows.Storage.Provider.FileUpdateStatus status =
                    await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);

                if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                {
                    this.StatusText.Text = "File " + file.Name + " was saved.";
                    Debug.WriteLine("File created Successfully. Download started");
                }
                else
                {
                    this.StatusText.Text = "File " + file.Name + " couldn't be saved.";
                }
            }
            else
            {
                this.StatusText.Text = "Operation cancelled.";
            }
        }
Example #35
0
 public async Task<bool> BackupJson(string json) {
     var savePicker = new Windows.Storage.Pickers.FileSavePicker();
     savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
     savePicker.FileTypeChoices.Add("Json", new List<string>() { ".json" });
     savePicker.SuggestedFileName = "PlanetsBackup";
     Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
     if (file != null) {
         await Windows.Storage.FileIO.WriteTextAsync(file, json);
         return true;
     }
     else {
         return false;
     }
 }
Example #36
0
 async void OnSaveAsync(object sender, RoutedEventArgs e)
 {
     // We don't want to save an empty file 
     if (InkCanvas.InkPresenter.StrokeContainer.GetStrokes().Count > 0)
     {
         var savePicker = new Windows.Storage.Pickers.FileSavePicker();
         savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
         savePicker.FileTypeChoices.Add("Gif with embedded ISF", new System.Collections.Generic.List<string> { ".gif" });
         Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
         if (null != file)
         {
             using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
             { await InkCanvas.InkPresenter.StrokeContainer.SaveAsync(stream); }
         }
     }
 }
        public static async void ExportMeasurementData(MeasurementModel measurement)
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();
            
            StorageFolder resultFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("Evaluation");
            StorageFolder resultFolder2 = await resultFolder.GetFolderAsync("Accelerometer");
            StorageFile resultFile = await resultFolder2.GetFileAsync(measurement.Filename);

            //await resultFile.CopyAsync(Windows.Storage.KnownFolders.DocumentsLibrary, "e" + measurement.AccelerometerFilename);

            savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            // Dropdown of file types the user can save the file as
            savePicker.FileTypeChoices.Add("Binary-Datei", new List<string>() { ".bin" });
            // Default file name if the user does not type one in or select a file to replace
            savePicker.SuggestedFileName = "e" + measurement.Filename;
            savePicker.PickSaveFileAndContinue();
        }
        // Create
        private async void ExecuteCreateCommand() {
            try {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                savePicker.FileTypeChoices.Add("Json", new List<string>() { ".json" });
                savePicker.SuggestedFileName = "planets";
                Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
                if (file != null) {
                    Planets = planetRepository.ReloadPlanets();
                    var json = planetRepository.PlanetsToJson(Planets);
                    await Windows.Storage.FileIO.WriteTextAsync(file, json);
                }
                else {
                    Results = "Operation cancelled";
                }
            }
            catch (Exception x) {
                Results = x.Message;
            }

        }
Example #39
0
        private async void save_Click(object sender, RoutedEventArgs e)
        {
            if (pancakeInk.InkPresenter.StrokeContainer.GetStrokes().Count > 0)
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                savePicker.FileTypeChoices.Add("Gif with embedded ISF", new System.Collections.Generic.List<string> { ".gif" });

                Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
                if (null != file)
                {
                    try
                    {
                        using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                        {
                            await pancakeInk.InkPresenter.StrokeContainer.SaveAsync(stream);
                        }
                        saved = true;
                        filePath = file.Path;
                        Button btn = sender as Button;
                        if (null == btn)
                        {
                            return;
                        }
                        var parent = VisualTreeHelper.GetParent(btn);
                        if (null != parent)
                        {
                            int count = VisualTreeHelper.GetChildrenCount(parent);
                            for (int i = 0; i < count; i++)
                            {
                                var child = VisualTreeHelper.GetChild(parent, i);
                                if (child != null && child.ToString().Equals(ELLIPSE) && ((Ellipse)child).Width == btn.Width)
                                {
                                    ((Ellipse)child).Fill = new SolidColorBrush(Color.FromArgb(255, 88, 91, 144));
                                    break;
                                }
                            }
                        }
                        ResetButtonState(btn);
                    }
                    catch (Exception ex)
                    {
#if DEBUG
                        System.Diagnostics.Debug.WriteLine(ex.Message);
#endif
                        saved = false;
                    }
                }
            }
            else
            {
            }
        }
Example #40
0
        private async void btnSaveWritingAsImage_Click(object sender, RoutedEventArgs e)
        {
            if (MyInkManager.GetStrokes().Count > 0)
            {
                try
                {
                    Windows.Storage.Pickers.FileSavePicker SavePicker = new Windows.Storage.Pickers.FileSavePicker();
                    SavePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
                    SavePicker.DefaultFileExtension = ".png";
                    SavePicker.FileTypeChoices.Add("PNG", new string[] { ".png" });
                    SavePicker.FileTypeChoices.Add("JPG", new string[] { ".jpg" });
                    StorageFile filesave = await SavePicker.PickSaveFileAsync();
                    IOutputStream ab = await filesave.OpenAsync(FileAccessMode.ReadWrite);
                    if (ab != null)
                        await MyInkManager.SaveAsync(ab);
                }

                catch (Exception)
                {
                    var MsgDlg = new MessageDialog("Only handwriting can be saved as image.", "Error while saving");
                    MsgDlg.ShowAsync();
                }
            }
            else
            {
                var MsgDlg = new MessageDialog("Only handwriting can be saved as image.", "Error while saving");
                await MsgDlg.ShowAsync();
            }
        }
        private async void Save_Click(object sender, RoutedEventArgs e)
        {           
            EnableButtons(false);
            rootPage.NotifyUser("Requesting file to save to", NotifyType.StatusMessage);

            var picker = new Windows.Storage.Pickers.FileSavePicker();
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
            picker.FileTypeChoices.Add("MP4 files", new List<string>() { ".mp4" });
            picker.SuggestedFileName = "TrimmedClip.mp4";

            StorageFile file = await picker.PickSaveFileAsync();
            if (file != null)
            {
                var saveOperation = composition.RenderToFileAsync(file, MediaTrimmingPreference.Precise);
                saveOperation.Progress = new AsyncOperationProgressHandler<TranscodeFailureReason, double>(async (info, progress) =>
                {
                    await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
                    {
                        rootPage.NotifyUser(string.Format("Saving file... Progress: {0:F0}%", progress), NotifyType.StatusMessage);
                    }));
                });
                saveOperation.Completed = new AsyncOperationWithProgressCompletedHandler<TranscodeFailureReason, double>(async (info, status) =>
                {
                    await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
                    {
                        try
                        {
                            var results = info.GetResults();
                            if (results != TranscodeFailureReason.None || status != AsyncStatus.Completed)
                            {
                                rootPage.NotifyUser("Saving was unsuccessful", NotifyType.ErrorMessage);
                            }
                            else
                            {
                                rootPage.NotifyUser("Trimmed clip saved to file", NotifyType.StatusMessage);
                            }
                        }
                        finally
                        {
                            // Remember to re-enable controls on both success and failure
                            EnableButtons(true);
                        }
                    }));
                });
            }
            else
            {
                rootPage.NotifyUser("User cancelled the file selection", NotifyType.StatusMessage);
                EnableButtons(true);
            }
        }
Example #42
0
        public async void Button_Save_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();

            savePicker.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.Desktop;
            // Dropdown of file types the user can save the file as
            savePicker.FileTypeChoices.Add("Hypertext Markup Language (HTML)", new List<string>() { ".htm" });
            // Default file name if the user does not type one in or select a file to replace
            savePicker.SuggestedFileName = "index";

            Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
            if (file != null)
            {
                // Prevent updates to the remote version of the file until
                // we finish making changes and call CompleteUpdatesAsync.
                Windows.Storage.CachedFileManager.DeferUpdates(file);
                // write to file
                String editorContents ="";
                EditCanvas.Document.GetText(0, out editorContents);

                await Windows.Storage.FileIO.WriteTextAsync(file, editorContents);
                // Let Windows know that we're finished changing the file so
                // the other app can update the remote version of the file.
                // Completing updates may require Windows to ask for user input.
                Windows.Storage.Provider.FileUpdateStatus status =
                    await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);
                if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                {
                    
                }
                else
                {
                    this.EditCanvas.Document.SetText(0, "Sorry. Your file " + file.Name + " couldn't be saved.");
                }
            }
        }
        public SaveImageCommand() : base(true)
        {

            this
                .Select(e => e.EventArgs.Parameter as MemoryStreamBase64Item)
                .Where(e => e != null)
                .Subscribe(
                 async e =>
                   {
                       try
                       {


                           var fp = new Windows.Storage.Pickers.FileSavePicker();
                           fp.FileTypeChoices.Add(SaveImageCommandFileSavePickerPngFiles, new List<string> { ".png" });
                           fp.DefaultFileExtension = ".png";
                           var fpicked = await fp.PickSaveFileAsync();
                           if (fpicked != null)
                           {
                               using (var saveTargetStream = await fpicked.OpenAsync(FileAccessMode.ReadWrite))
                               {
                                   var bitmapSourceStream = await e.GetRandowmAccessStreamAsync();

                                   await ServiceLocator
                                            .Instance
                                            .Resolve<IImageConvertService>()
                                            .ConverterBitmapToTargetStreamAsync(bitmapSourceStream, saveTargetStream);

                               }
                               var msb = new MessageDialog(SaveImageCommandMessageDialogFileSavedNextContent, SaveImageCommandMessageDialogMessageDialogFileSavedNextTitle);
                               var commandOpenFile = new UICommand(
                                 SaveImageCommandMessageDialogUICommandOpenFile,
                                   async c =>
                                   {
                                       await Launcher.LaunchFileAsync(fpicked);
                                   });
                               // var commandOpenFold = new UICommand(
                               //  "Open Folder",
                               //async c =>
                               //{
                               //	await Launcher.LaunchFolderAsync(
                               //		await fpicked.GetParentAsync(),
                               //		new FolderLauncherOptions { DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseHalf });
                               //}
                               //  );
                               var commandCancelIt = new UICommand(SaveImageCommandMessageDialogUICommandLeave);
                               msb.Commands.Add(commandOpenFile);
                               //msb.Commands.Add(commandOpenFold);
                               msb.Commands.Add(commandCancelIt);
                               msb.CancelCommandIndex = 1;
                               msb.DefaultCommandIndex = 0;
                               var selected = await msb.ShowAsync();

                           }
                       }
                       catch (Exception ex)
                       {
                       }
                   });




        }
Example #44
0
        private async void SaveAs()
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();
            savePicker.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            // Dropdown of file types the user can save the file as
            savePicker.FileTypeChoices.Add("kerboscript", new List<string>() { ".ks" });
            // Default file name if the user does not type one in or select a file to replace
            savePicker.SuggestedFileName = docShow.FileName;

            Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
            if (file != null)
            {
                try
                {
                    // Prevent updates to the remote version of the file until
                    // we finish making changes and call CompleteUpdatesAsync.
                    Windows.Storage.CachedFileManager.DeferUpdates(file);
                    // write to file
                    string text;
                    OpenCode.Document.GetText(Windows.UI.Text.TextGetOptions.None, out text);
                    docShow.Text = text;
                    await Windows.Storage.FileIO.WriteTextAsync(file, docShow.Text);
                    // Let Windows know that we're finished changing the file so
                    // the other app can update the remote version of the file.
                    // Completing updates may require Windows to ask for user input.
                    Windows.Storage.Provider.FileUpdateStatus status =
                        await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);
                }
                catch (Exception ex)
                {
                    ContentDialog errorDialog = new ContentDialog()
                    {
                        Title = ex.ToString(),//"File save as error",
                        Content = "Sorry, I can't do that...",
                        PrimaryButtonText = "Ok"
                    };

                    await errorDialog.ShowAsync();
                }
            }
        }
Example #45
0
 private async void btnSaveRecognizedText_Click(object sender, RoutedEventArgs e)
 {
     Windows.Storage.Pickers.FileSavePicker SavePicker = new Windows.Storage.Pickers.FileSavePicker();
     SavePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
     SavePicker.DefaultFileExtension = ".txt";
     SavePicker.FileTypeChoices.Add("TXT", new string[] { ".txt" });
     SavePicker.SuggestedFileName = "untitled";
     StorageFile File = await SavePicker.PickSaveFileAsync();
     await FileIO.WriteTextAsync(File, txtRecognizedText.Text);
 }
        private async void ButtonClickSaveFile(object sender, RoutedEventArgs e)
        {
            var canvasContent = SerializeCanvas();

            var savePicker = new Windows.Storage.Pickers.FileSavePicker();
            savePicker.FileTypeChoices.Add(
                new KeyValuePair<string, IList<string>>("Painter File Format", new string[] { ".paint" })
                );

            var saveFile = await savePicker.PickSaveFileAsync();

            if (saveFile != null)
            {
                try
                {
                    await Windows.Storage.FileIO.WriteTextAsync(saveFile, canvasContent);
                }
                catch (Exception)
                {
                    new Windows.UI.Popups.MessageDialog("Could not write the selected file").ShowAsync();
                }
            }
        }
        private async void SaveDocument(IPlotModel model, String newDocument)
        {
            if (model == null)
            {
                var msg = new MessageDialog("График не создан, рассчитайте распределение", "Ошибка сохранения");
                await msg.ShowAsync();
                return;
            }

            var savePicker = new Windows.Storage.Pickers.FileSavePicker
            {
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary
            };
            savePicker.FileTypeChoices.Add("PDF Document", new List<string>() { ".pdf" });
            savePicker.SuggestedFileName = newDocument;
            StorageFile file = await savePicker.PickSaveFileAsync();
            if (file != null)
            {
                CachedFileManager.DeferUpdates(file);
                var stream = await file.OpenAsync(FileAccessMode.ReadWrite);

                using (var outputStream = stream.GetOutputStreamAt(0))
                {
                    using (var dataWriter = new Windows.Storage.Streams.DataWriter(outputStream))
                    {
                        using (var memoryStream = new MemoryStream())
                        {
                            var pdf = new PdfExporter();
                            PdfExporter.Export(model, memoryStream, 1000, 400);
                            var bt = memoryStream.ToArray();
                            dataWriter.WriteBytes(bt);
                            await dataWriter.StoreAsync();
                            await outputStream.FlushAsync();
                        }
                    }
                }
                var status = await CachedFileManager.CompleteUpdatesAsync(file);
                if (status == FileUpdateStatus.Complete)
                {
                    var msg = new MessageDialog("По пути " + file.Path, "Файл сохранен");
                    await msg.ShowAsync();
                }
                else
                {
                    var msg = new MessageDialog("Произошла ошибка сохранения");
                    await msg.ShowAsync();
                }
            }
        }
Example #48
0
        public async void SaveFile()
        {
            if (Saved)
            {
                return;
            }
            var fileBuffer = await Response.Content.ReadAsBufferAsync();
            int dotIndex = FullName.LastIndexOf('.');
            var extName = FullName.Substring(dotIndex);
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();
            savePicker.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            savePicker.FileTypeChoices.Add(new KeyValuePair<string, IList<string>>("file", new List<string> { extName }));

            savePicker.SuggestedFileName = FullName;

            LocalStorage = await savePicker.PickSaveFileAsync();
            var writeStream = await LocalStorage.OpenTransactedWriteAsync();
            await writeStream.Stream.WriteAsync(fileBuffer);
            await writeStream.CommitAsync();
            Saved = true;
        }
 public FileSavePicker()
 {
     _picker = new Windows.Storage.Pickers.FileSavePicker();
 }
        //http://stackoverflow.com/questions/6246009/inkcanvas-load-save-operations
        //https://msdn.microsoft.com/en-us/library/system.windows.controls.inkcanvas(v=vs.110).aspx
        // https://social.msdn.microsoft.com/Forums/en-US/55bd1f52-78df-45b2-b5cc-5cb6fcfc6ea9/uwp-universal-window-app-run-on-windows-10-inkcanvas-strokes-save-to-jpg-file?forum=wpdevelop

        /*
            Saves strokes as a GIF file
        */
        // https://github.com/Microsoft/Windows-universal-samples/blob/93bdfb92b3da76f2e49c959807fc5643bf0940c9/Samples/SimpleInk/cs/Scenario1.xaml.cs

        async void saveButton_Click(object sender, RoutedEventArgs e)
        {
            if (_inkPresenter.StrokeContainer.GetStrokes().Count > 0)
            {
                var save = new Windows.Storage.Pickers.FileSavePicker();
                save.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                save.FileTypeChoices.Add("Gif with embedded ISF", new System.Collections.Generic.List<String> { ".gif" });

                Windows.Storage.StorageFile file = await save.PickSaveFileAsync();

                if (null != file)
                {
                    try
                    {
                        using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                        {
                            await inkCanvas.InkPresenter.StrokeContainer.SaveAsync(stream);
                        }
                    }
                    catch (Exception ex)
                    {
                        // Figure out how to notify the user of failure  
                    }
                }
            }
        }
Example #51
0
        private async Task<PlotModel> CompareSpeedCarbon(Double step)
        {
            var sp = new PerformanceComputing.SpeedParticle(0, 1100000, Environment.ProcessorCount);
            var plotModel = new PlotModel { Title = "Общая скорость частиц углерода" };
            TextBlock item = (TextBlock)ViewSpeed.SelectedItem;
            var selectedItem = item?.Text;

            if (selectedItem != null && selectedItem.Equals("Общая"))
            {
                Stopwatch st = new Stopwatch();
                st.Start();
                await
                    sp.DecompositionSpeedCarbonsAsync(Dimensionless.IsChecked != null && (bool)Dimensionless.IsChecked);
                st.Stop();
                var speed = new List<Particle>(sp.CarbonsDecompositionSpeed);

                Compare(speed);

                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation =
                    Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                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 = "Распределение скорости карбона";

                Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
                if (file != null)
                {
                    //StringBuilder text = new StringBuilder();

                    //foreach (var particle in speed)
                    //{
                    //    text.AppendLine(particle.Vx.ToString());
                    //    text.AppendLine(particle.Vy.ToString());
                    //    text.AppendLine(particle.Vz.ToString());
                    //}

                    StringBuilder text = new StringBuilder();
                    text.AppendLine(st.ElapsedMilliseconds.ToString());
                    text.AppendLine(speed[0].x.ToString());
                    text.AppendLine(speed[0].y.ToString());
                    text.AppendLine(speed[0].z.ToString());


                    await Windows.Storage.FileIO.WriteTextAsync(file, text.ToString());

                    Windows.Storage.Provider.FileUpdateStatus status =
                        await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);
                    Windows.Storage.CachedFileManager.DeferUpdates(file);
                    // write to file

                }

                var lineSerie = new LinearBarSeries
                {
                    FillColor = OxyColor.FromArgb(69, 76, 175, 80),
                    StrokeThickness = 1,
                    StrokeColor = OxyColor.FromArgb(255, 76, 175, 80),
                    Title = "Распределение Vx"
                };

                var lineSerie2 = new LinearBarSeries
                {
                    FillColor = OxyColor.FromArgb(69, 255, 255, 0),
                    StrokeThickness = 1,
                    StrokeColor = OxyColor.FromArgb(255, 76, 175, 80),
                    Title = "Распределение Vy"
                };

                var lineSerie3 = new LinearBarSeries
                {
                    FillColor = OxyColor.FromArgb(69, 72, 118, 255),
                    StrokeThickness = 1,
                    StrokeColor = OxyColor.FromArgb(255, 76, 175, 80),
                    Title = "Распределение Vz"
                };

                Int32 k = 0;
                for (var i = 0; i < speed.Count; i += 100)
                {
                    lineSerie.Points.Add(new DataPoint(k++, speed[i].Vx));
                }
                for (var i = 0; i < speed.Count; i += 100)
                {
                    lineSerie2.Points.Add(new DataPoint(k++, speed[i].Vy));
                }
                for (var i = 0; i < speed.Count; i += 100)
                {
                    lineSerie3.Points.Add(new DataPoint(k++, speed[i].Vz));
                }

                plotModel.Series.Add(lineSerie);
                plotModel.Series.Add(lineSerie2);
                plotModel.Series.Add(lineSerie3);

            }
            return plotModel;
        }
 private void SaveReportButton_Click(object sender, RoutedEventArgs e)
 {
     var picker = new Windows.Storage.Pickers.FileSavePicker();
     picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
     picker.SuggestedFileName = this.appDataContext.Player1Name.Value + " vs " + this.appDataContext.Player2Name.Value;
     picker.DefaultFileExtension = ".html";
     picker.FileTypeChoices.Add("Web Page", new string[] { ".html" });
     string htmlString = this.appDataContext.StrategyReport.Value;
     picker.PickSaveFileAsync().AsTask().ContinueWith( (storageFile) =>
     {
         Windows.Storage.StorageFile result = storageFile.Result;
         Windows.Storage.FileIO.WriteTextAsync(result, htmlString );
     });
 }
        async void OnSave(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            // We don't want to save an empty file
            if (inkManager.GetStrokes().Count > 0)
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                savePicker.FileTypeChoices.Add("Gif with embedded ISF", new System.Collections.Generic.List<string> { ".gif" });

                Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
                if (null != file)
                {
                    using (var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite))
                    {
                        await inkManager.SaveAsync(stream);

                        rootPage.NotifyUser(inkManager.GetStrokes().Count + " strokes saved!", SDKTemplate.NotifyType.StatusMessage);
                    }
                }
            }
            else
            {
                rootPage.NotifyUser("There is no ink to save.", SDKTemplate.NotifyType.ErrorMessage);
            }
        }
        private async void AppBar_Click_Save(object sender, RoutedEventArgs e)
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();
            savePicker.FileTypeChoices.Add(
                new KeyValuePair<string, IList<string>>("Return on investment analysis file", new string[] { ".roi" }));
            var saveFile = await savePicker.PickSaveFileAsync();

            if (saveFile != null)
            {
                var currentProject = (Investment_Analysis.Models.ProjectData)App.Current.Resources["ProjectData"];
                try
                {
                    var text = await JsonConvert.SerializeObjectAsync(currentProject);
                    await Windows.Storage.FileIO.WriteTextAsync(saveFile, text);
                }
                catch (Exception)
                {
                    new Windows.UI.Popups.MessageDialog("Could not write the selected file").ShowAsync();
                } 
            }
        }
Example #55
0
        async void OnSaveAsync(object sender, RoutedEventArgs e)
        {
            // We don't want to save an empty file
            if (inkCanvas.InkPresenter.StrokeContainer.GetStrokes().Count > 0)
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                savePicker.FileTypeChoices.Add("Gif with embedded ISF", new System.Collections.Generic.List<string> { ".gif" });

                Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
                if (null != file)
                {
                    try
                    {
                        using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                        {
                            await inkCanvas.InkPresenter.StrokeContainer.SaveAsync(stream);
                        }
                        rootPage.NotifyUser(inkCanvas.InkPresenter.StrokeContainer.GetStrokes().Count + " stroke(s) saved!", NotifyType.StatusMessage);
                    }
                    catch (Exception ex)
                    {
                        rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
                    }
                }
            }
            else
            {
                rootPage.NotifyUser("There is no ink to save.", NotifyType.ErrorMessage);
            }
        }
        private async void SaveButtonPressed(ChartControlFull sender)
        {
            if (sender == chartControlOne)
            {
                string dataToSave = chartControlOne.getDataString();
                if (dataToSave == null)
                {
                    ShowErrorDialog("Chart returned no data, please try again later.", "No data to save");
                    return;
                }

                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                // 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 = "HeartBeat";

                StorageFile file = await savePicker.PickSaveFileAsync();
                if (file != null)
                {
                    CachedFileManager.DeferUpdates(file);
                    await FileIO.WriteTextAsync(file, dataToSave);

                    Windows.Storage.Provider.FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);
                    if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                    {
                        ShowErrorDialog("File " + file.Name + " was saved.", "Save to file");
                    }
                    else
                    {
                        ShowErrorDialog("File " + file.Name + " couldn't be saved.", "Save to file");
                    }
                }
            }
        }
Example #57
0
        public async System.Threading.Tasks.Task SaveKML(System.Collections.Generic.List<Windows.Devices.Geolocation.BasicGeoposition> mapdata)
        {
            #region XML generating

            XmlDocument xDoc = new XmlDocument();
            XmlDeclaration xDec = xDoc.CreateXmlDeclaration("1.0", "utf-8", null);
         
            XmlElement kml = xDoc.CreateElement("kml");
            kml.SetAttribute("xmlns", @"http://www.opengis.net/kml/2.2");
            xDoc.InsertBefore(xDec, xDoc.DocumentElement);
            xDoc.AppendChild(kml);
            XmlElement Document = xDoc.CreateElement("Document");
            kml.AppendChild(Document);

            XmlElement name = xDoc.CreateElement("name");
            XmlText nameTextMain = xDoc.CreateTextNode(DateTime.Today.ToString());
            Document.AppendChild(name);
            name.AppendChild(nameTextMain);

            XmlElement description = xDoc.CreateElement("description");
            XmlText destext = xDoc.CreateTextNode("Created by JustMeasure app.");
            Document.AppendChild(description);
            description.AppendChild(destext);

            XmlElement Style = xDoc.CreateElement("Style");
            Style.SetAttribute("id", "style1");
            Document.AppendChild(Style);

            XmlElement LineStyle = xDoc.CreateElement("LineStyle");
            Style.AppendChild(LineStyle);

            XmlElement LineStyleColor = xDoc.CreateElement("color");
            XmlText linestylecolor = xDoc.CreateTextNode("ffffffff");
            LineStyle.AppendChild(LineStyleColor);
            LineStyleColor.AppendChild(linestylecolor);

            XmlElement LineStyleWidth = xDoc.CreateElement("width");
            XmlText linestylewidth = xDoc.CreateTextNode("5");
            LineStyle.AppendChild(LineStyleWidth);
            LineStyleWidth.AppendChild(linestylewidth);

            XmlElement Polystyle = xDoc.CreateElement("PolyStyle");
            Style.AppendChild(Polystyle);

            XmlElement polystylecolor = xDoc.CreateElement("color");
            XmlText polyscolor = xDoc.CreateTextNode("330000ff");
            Polystyle.AppendChild(polystylecolor);
            polystylecolor.AppendChild(polyscolor);

            XmlElement Placemark = xDoc.CreateElement("Placemark");
            Document.AppendChild(Placemark);

            XmlElement styleUrl = xDoc.CreateElement("styleUrl");
            XmlText styleurl = xDoc.CreateTextNode("#style1");
            Placemark.AppendChild(styleUrl);
            styleUrl.AppendChild(styleurl);

            XmlElement Polygon = xDoc.CreateElement("Polygon");
            Placemark.AppendChild(Polygon);

            XmlElement extrude = xDoc.CreateElement("extrude");
            XmlText extrudetext = xDoc.CreateTextNode("1");
            Polygon.AppendChild(extrude);
            extrude.AppendChild(extrudetext);

            XmlElement altitudeMode = xDoc.CreateElement("altitudeMode");
            XmlText relativeToGround = xDoc.CreateTextNode("relativeToGround");
            Polygon.AppendChild(altitudeMode);
            altitudeMode.AppendChild(relativeToGround);

            XmlElement outerBoundaryIs = xDoc.CreateElement("outerBoundaryIs");
            Polygon.AppendChild(outerBoundaryIs);

            XmlElement LinearRing = xDoc.CreateElement("LinearRing");
            outerBoundaryIs.AppendChild(LinearRing);

            XmlElement coordinates = xDoc.CreateElement("coordinates");
            LinearRing.AppendChild(coordinates);

            for (int i = 0; i < mapdata.Count; i++)
            {
                string coord = mapdata[i].Longitude + "," + mapdata[i].Latitude + "\n";
                XmlText cord = xDoc.CreateTextNode(coord);
                coordinates.AppendChild(cord);
            }
            #endregion
            Windows.Storage.Pickers.FileSavePicker savePicker = new Windows.Storage.Pickers.FileSavePicker();
            savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            savePicker.FileTypeChoices.Add("KML file", new System.Collections.Generic.List<string>() { ".kml" });
            savePicker.SuggestedFileName = DateTime.Now.ToString();
            Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
            if (file != null)
            {
                Windows.Storage.CachedFileManager.DeferUpdates(file);
                using (Stream fileStream = await file.OpenStreamForWriteAsync())
                {
                   xDoc.Save(fileStream);
                }
                Windows.Storage.Provider.FileUpdateStatus status = await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);
                if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                {
                    SuccessOrNot("SuccessFile");
                }
                else
                {
                    SuccessOrNot("FailFile");
                }
            }
        }
        private void ExportMeasurement(MeasurementViewModel measurementViewModel)
        {
            // Show loader
            _mainPage.ShowLoader();
            //_mainPage.ExportMeasurementData(measurementViewMdel.Id);

            if (measurementViewModel.Id != null && measurementViewModel.Id.Length > 0)
            {
                MeasurementModel measurement = _mainPage.GlobalMeasurementModel.GetMeasurementById(measurementViewModel.Id);
                if (measurement != null)
                {
                    var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                    savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                    // Dropdown of file types the user can save the file as
                    savePicker.FileTypeChoices.Add("Binary-File", new List<string>() { ".bin" });
                    // Default file name if the user does not type one in or select a file to replace
                    savePicker.SuggestedFileName = String.Format("{0}_{1:yyyy-MM-dd_HH-mm-ss}", measurement.Setting.Name, measurement.StartTime);
                    // Open the file picker and call the method "ContinueFileSavePicker" when the user select a file.
                    savePicker.PickSaveFileAndContinue();
                }
            }
            // Hide loader
            _mainPage.HideLoader();
        }
Example #59
0
      private async Task SaveSettings( string authToken )
      {
         var savePicker = new Windows.Storage.Pickers.FileSavePicker();
         savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
         savePicker.FileTypeChoices.Add( "Plain Text", new List<string>() { ".txt" } );
         savePicker.SuggestedFileName = "user";

         StorageFile file = await savePicker.PickSaveFileAsync();
         if ( file != null )
         {
            // Prevent updates to the remote version of the file until
            // we finish making changes and call CompleteUpdatesAsync.
            CachedFileManager.DeferUpdates( file );
            // write to file
            await FileIO.WriteLinesAsync( file, new string[] { authToken } );
            // Let Windows know that we're finished changing the file so
            // the other app can update the remote version of the file.
            // Completing updates may require Windows to ask for user input.
            Windows.Storage.Provider.FileUpdateStatus status = await Windows.Storage.CachedFileManager.CompleteUpdatesAsync( file );
            if ( status == Windows.Storage.Provider.FileUpdateStatus.Complete )
            {
               // Nothing for now
            }
         }
      }
Example #60
0
        private async void button2_Click(object sender, RoutedEventArgs e)
        {
            if (Dump == null || Dump.Length < 0x10)
            {
                MessageDialog msg = new MessageDialog("Can't save the dump !");
                await msg.ShowAsync();
                return;
            }
            MessageDialog msg1 = new MessageDialog("The amiigo dump can be used in the amiigo PC app, automatically generates the write key and checks the uid before writing, use the binary dump only if you know what to do with it, you can also extract the binary dump from an amiigo dump with the PC app", "Save binary dump or amiigo dump ?");
            msg1.Commands.Add(new UICommand("Amiigo dump", async (command) =>
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation =
                    Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                savePicker.FileTypeChoices.Add("binary dump", new List<string>() { ".bin" });
                savePicker.SuggestedFileName = "New dump";
                Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
                if (file != null)
                {
                    Windows.Storage.CachedFileManager.DeferUpdates(file);
                    await Windows.Storage.FileIO.WriteBytesAsync(file, Dump);
                    Windows.Storage.Provider.FileUpdateStatus status =
                        await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);
                    await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);
                    if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                    {
                        textBox.Text = "Dump saved !";
                    }
                    else
                    {
                        textBox.Text = ("File " + file.Name + " couldn't be saved.");
                    }
                }
            }));

            msg1.Commands.Add(new UICommand("Binary dump", async (command) =>
            {
                var savePicker = new Windows.Storage.Pickers.FileSavePicker();
                savePicker.SuggestedStartLocation =
                    Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                savePicker.FileTypeChoices.Add("binary dump", new List<string>() { ".bin" });
                savePicker.SuggestedFileName = "New dump";
                Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
                if (file != null)
                {
                    Windows.Storage.CachedFileManager.DeferUpdates(file);
                    byte[] BinDump = new byte[540];
                    Buffer.BlockCopy(Dump, 17, BinDump, 0, 540);
                    await Windows.Storage.FileIO.WriteBytesAsync(file, BinDump);
                    Windows.Storage.Provider.FileUpdateStatus status =
                        await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);
                    await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);
                    if (status == Windows.Storage.Provider.FileUpdateStatus.Complete)
                    {
                        textBox.Text = "Dump saved !";
                    }
                    else
                    {
                        textBox.Text = ("File " + file.Name + " couldn't be saved.");
                    }
                }
            }));
            await msg1.ShowAsync();
        }