Example #1
0
        protected async void SaveAsButton_Click(object sender, RoutedEventArgs e)
        {
            FileSavePicker savePicker = new FileSavePicker();

            savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;

            // Dropdown of file types the user can save the file as
            if (CurrentFile.Language != null)
            {
                CurrentFile.Language.AddLanguageSupport(savePicker);
            }
            else
            {
                LanguageSupport.AddLanguageSupport(savePicker);
            }

            // Default file name if the user does not type one in or select a file to replace
            savePicker.SuggestedFileName = "New Document";

            StorageFile file = await savePicker.PickSaveFileAsync();

            if (file != null)
            {
                CurrentFile = await FileStorage.RegisterFile(storageFile : file);
                await SaveFile();
            }
        }
Example #2
0
        private async Task NewFile(NewFileItem item)
        {
            try
            {
                FileSavePicker savePicker = new FileSavePicker();
                savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;

                // Dropdown of file types the user can save the file as
                if (item != null)
                {
                    item.Language.AddLanguageSupport(savePicker);
                }
                else
                {
                    LanguageSupport.AddLanguageSupport(savePicker);
                }

                // Default file name if the user does not type one in or select a file to replace
                savePicker.SuggestedFileName = "New Document";

                StorageFile storageFile = await savePicker.PickSaveFileAsync();

                if (storageFile != null)
                {
                    await FileIO.WriteTextAsync(storageFile, string.Empty);

                    RecentFile file = await FileStorage.RegisterFile(storageFile : storageFile, overrideEntry : true);
                    await OpenFile(Frame, file);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Example #3
0
        private async Task PickFile()
        {
            try
            {
                FileOpenPicker openPicker = new FileOpenPicker();
                openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;

                LanguageSupport.AddLanguageSupport(openPicker);

                Windows.Storage.StorageFile storageFile = await openPicker.PickSingleFileAsync();

                if (storageFile != null)
                {
                    RecentFile file = await FileStorage.RegisterFile(storageFile : storageFile);
                    await OpenFile(Frame, file);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }