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);
            }
        }
Exemple #2
0
        private async void SaveDOCX_Click()
        {
            try
            {
                WordDocument docx = new WordDocument();
                docx.EnsureMinimal();
                docx.LastParagraph.AppendText(textFile);
                MemoryStream streamDocx = new MemoryStream();
                await docx.SaveAsync(streamDocx, FormatType.Docx).ConfigureAwait(true);

                docx.Close();
                //SaveFileDocX.SaveWord(streamDocx, "Result.docx");
                SaveFileDocX.SaveWord(streamDocx, nameFile.Text, pathSaveFile.Text);
                streamDocx.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);
        }