private async void SaveChangesCurrentFile_Click(object sender, RoutedEventArgs e) { if (currentFormatFile.Length != 0) { switch (currentFormatFile) { case "PDF": SaveFilePdf.SaveChangesFile(dictationTextBox.Text); //SaveFilePdf.openFile = null; break; case "DOCX": SaveFileDocX.SaveChangesFile(dictationTextBox.Text); //SaveFileDocX.openFile = null; break; case "DOC": SaveFileDoc.SaveChangesFile(dictationTextBox.Text); //SaveFileDoc.openFile = null; break; } RecognizerViewModel.RecognizerSpeech.dictatedTextBuilder.Clear(); StorageFolder localFolder = Windows.Storage.ApplicationData.Current.TemporaryFolder; StorageFile stFile = await localFolder.GetFileAsync("temp.txt"); await stFile.DeleteAsync(); } else { SaveAs_Click(sender, e); } }
private async void SaveDOC_Click() { try { WordDocument doc = new WordDocument(); doc.EnsureMinimal(); doc.LastParagraph.AppendText(textFile); MemoryStream stream = new MemoryStream(); await doc.SaveAsync(stream, FormatType.Doc).ConfigureAwait(true); doc.Close(); SaveFileDoc.SaveWord(stream, nameFile.Text, pathSaveFile.Text); stream.Dispose(); } catch (ArgumentNullException) { } }
private async void Open_openFile() { dictationTextBox.SelectionChanging += dictationTextBox_SelectionChanging; switch (openFile.FileType) { case ".pdf": dictationTextBox.Text = await SaveFilePdf.Read(openFile).ConfigureAwait(true); currentFormatFile = "PDF"; break; case ".docx": dictationTextBox.Text = await SaveFileDocX.OpenFileWord(openFile).ConfigureAwait(true); currentFormatFile = "DOCX"; break; case ".doc": dictationTextBox.Text = await SaveFileDoc.OpenFileWord(openFile).ConfigureAwait(true); currentFormatFile = "DOC"; break; } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (this.mainPage.IsEnabled == false) { this.mainPage.IsEnabled = true; } try { if (e.Parameter is StorageFile) { StorageFile f = (StorageFile)e.Parameter; openFile = f; Open_openFile(); } } catch (NullReferenceException) { } try { //var entry = this.Frame.BackStack.LastOrDefault(); //if (entry.SourcePageType.Name == "recent") //{ // recentFile = (StorageFile)e.Parameter; // OpenFileDialog_Click(null, null); // //await appWindow.CloseAsync(); //} } catch (NullReferenceException) { } string textFile = ""; if (e != null) { try { this.shareOperation = (ShareOperation)e.Parameter; } catch (InvalidCastException) { } } if (this.shareOperation != null) { IEnumerable <IStorageItem> file = await shareOperation.Data.GetStorageItemsAsync(); foreach (var item in file) { StorageFile f = (StorageFile)item; switch (f.FileType) { case ".pdf": SaveFilePdf.openFile = f; openFile = f; textFile = await SaveFilePdf.Read(openFile).ConfigureAwait(true); currentFormatFile = "PDF"; break; case ".doc": SaveFileDoc.openFile = f; openFile = f; textFile = await SaveFileDoc.OpenFileWord(openFile).ConfigureAwait(true); currentFormatFile = "DOC"; break; case ".docx": SaveFileDocX.openFile = f; openFile = f; textFile = await SaveFileDocX.OpenFileWord(openFile).ConfigureAwait(true); currentFormatFile = "DOCX"; break; } } dictationTextBox.Text = textFile; } if (PrintManager.IsSupported()) { } else { //InvokePrintingButton.Visibility = Visibility.Collapsed; } printHelper = new PrintHelper(this); }