Exemplo n.º 1
0
        public void startPronounSaver(List <ShortWord> shortWords)
        {
            try
            {
                switch (PreProcessData.fileFormat)
                {
                case FileFormat_en.eDOCX:
                    pronounDriver.docxManager = PreProcessData.docxManager;
                    pronounDriver.asyncChangeShortWordsDocx(shortWords);
                    PreProcessData.docxManager = shortWordDriver.docxManager;
                    HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_SUCCESS_SHORT_WORD_REPLACING);
                    break;

                case FileFormat_en.eTXT:
                    pronounDriver.txtData = PreProcessData.fullFileData;
                    pronounDriver.asyncChangeShortWordsTxt(shortWords);
                    PreProcessData.fullFileData = shortWordDriver.txtData;
                    HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_SUCCESS_SHORT_WORD_REPLACING);
                    break;
                }
            }
            catch (Exception)
            {
                HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_ERROR_SHORT_WORD_READING);
            }
        }
Exemplo n.º 2
0
        private void button_SaveChanges_Click(object sender, EventArgs e)
        {
            // Displays a SaveFileDialog so the user can save the Image
            // assigned to Button2.
            saveFileDialog_SaveAS.Filter = STR_FILE_FILTER;
            saveFileDialog_SaveAS.Title  = "Сохранить документ";
            saveFileDialog_SaveAS.ShowDialog();

            // If the file name is not an empty string open it for saving.
            if (saveFileDialog_SaveAS.FileName != "")
            {
                PreProcessData.filePath = saveFileDialog_SaveAS.FileName;
                // Saves the Image via a FileStream created by the OpenFile method.
                string newFilePath = saveFileDialog_SaveAS.FileName;
                switch (PreProcessData.savageFileFormat)
                {
                case FileFormat_en.eTXT:
                    try
                    {
                        asyncStartTxtWriting(newFilePath.Split('.')[0] + ".txt");
                        HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_SUCCESS_FILE_WRITING);
                    }
                    catch (Exception ex)
                    {
                        HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage(ex.ToString(), MessageType_en.eError));
                    }
                    break;

                case FileFormat_en.eDOCX:
                    asyncStartDocxWriting(newFilePath.Split('.')[0] + ".docx");
                    HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_SUCCESS_FILE_WRITING);
                    break;
                }
            }
        }
Exemplo n.º 3
0
        private async void startAsyncClearingStopWords()
        {
            HistoryWorker.appendLnToHistory(richTextBox_FileHistory, new HistoryMessage("Начата автоматическая обработка стоп-слов.", MessageType_en.eStandart));
            await Task.Run(() =>
            {
                StreamReader reader = new StreamReader(STR_STOP_WORDS_FILE);
                string[] stopWords;
                using (reader)
                {
                    stopWords = reader.ReadToEnd().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                }

                reader.Close();

                string[] wordsFromText = PreProcessData.getSpaceSplitWords();

                foreach (string word in wordsFromText)
                {
                    if (stopWords.Contains(word.ToLower()))
                    {
                        PreProcessData.changeTextAccordingToFormat(word, "");
                    }
                }
            });

            HistoryWorker.appendLnToHistory(richTextBox_FileHistory, new HistoryMessage("Стоп-Слова успешно удалены.", MessageType_en.eSuccess));
        }
Exemplo n.º 4
0
        private void button_DecipherShortWords_Click(object sender, EventArgs e)
        {
            button_DecipherShortWords.Enabled = false;

            HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_STARTED_SHORT_WORD_READING);
            try
            {
                HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_SUCCESS_SHORT_WORD_READING);

                shortWordDriver.asyncFindShortWordsInText(PreProcessData.getSentences());

                if (shortWordDriver.isReadyForShortWord())
                {
                    StartShortWordForm(shortWordDriver.sentencesWithShortWords);
                }
                else
                {
                    HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage("Короткие слова не найдены", MessageType_en.eStandart));
                }
            }
            catch (Exception)
            {
                HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_ERROR_SHORT_WORD_READING);
            }

            button_DecipherShortWords.Enabled = true;
        }
Exemplo n.º 5
0
        public static async void asyncRomanianNumbersToArab(Button buttonToEnable, RichTextBox richHistory, HistoryMessage message)
        {
            await Task.Run(() =>
            {
                List <string> romanianStrNumbers = new List <string>();

                string[] splitWords = fileWordsSplit == null ? docxManager.Text.Split(spaceSplitters) : fileWordsSplit;

                foreach (string word in splitWords)
                {
                    if (word.Length > 0)
                    {
                        if (isRomanian(word))
                        {
                            romanianStrNumbers.Add(word);
                        }
                    }
                }
                romanianStrNumbers.Sort();
                romanianStrNumbers.Reverse();
                foreach (string romWord in romanianStrNumbers)
                {
                    changeTextAccordingToFormat(romWord, DecodeRomanToArab(romWord).ToString());
                    //fullFileData = fullFileData.Replace(romWord, DecodeRomanToArab(romWord).ToString());
                }
            });

            buttonToEnable.Enabled = true;
            HistoryWorker.appendLnToHistory(richHistory, message);
        }
Exemplo n.º 6
0
 private void button_deleteAllTiere_Click(object sender, EventArgs e)
 {
     try
     {
         startDeletingAllTiere();
         HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage("Все переносы успешно удалены.", MessageType_en.eSuccess));
     }
     catch (Exception)
     {
         HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage("Произошла ошибка при удалении переноса", MessageType_en.eError));
     }
 }
Exemplo n.º 7
0
        private async void asyncStartDocxWriting(string filePath)
        {
            await Task.Run(() =>
            {
                startDocxWriting(filePath);
            });

            if (isSavePicturesGraphics)
            {
                HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage(String.Format("Изображения из документа '{0}' сохранены в '{1}'", PreProcessData.filePath, docxImg), MessageType_en.eSuccess));
                HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage(String.Format("Таблицы из документа '{0}' сохранены в '{1}'", PreProcessData.filePath, docxTbl), MessageType_en.eSuccess));
            }
        }
Exemplo n.º 8
0
 private void checkDLLs()
 {
     if (File.Exists(shortWordDriver.STR_DLL_FULL_NAME))
     {
         button_DecipherShortWords.Enabled = true;
     }
     else
     {
         button_DecipherShortWords.Enabled = false;
         HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_ERROR_SHORT_WORD_DLL);
         HistoryWorker.appendLnToHistory(richTextBox_FileHistory, MSG_ERROR_SHORT_WORD_DLL);
     }
 }
Exemplo n.º 9
0
        private void button_RemoveHighChrs_Click(object sender, EventArgs e)
        {
            HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage("Начат поиск слов с заглавной буквы в предложениях...", MessageType_en.eStandart));

            try
            {
                startAsyncHighChrRemoving();
                HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage("Слова успешно исправлены в предложениях.", MessageType_en.eSuccess));
            }
            catch (Exception)
            {
                HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage("Произошла ошибка при исправлении слов не с большой буквы", MessageType_en.eError));
            }
        }
Exemplo n.º 10
0
        private async void asyncStartFileReading()
        {
            string filePath = getUserFile();

            if (filePath != null)
            {
                PreProcessData.filePath = filePath;
                try
                {
                    PreProcessData.setFileFormat(filePath.Split('.')[1]);
                }
                catch (FileFormatException)
                {
                    HistoryWorker.appendLnToHistory(richTextBox_FileHistory, MSG_ERROR_FILE_READING_FORMAT);
                    Button_UploadFile.Enabled = true;
                    return;
                }
                HistoryWorker.appendLnToHistory(richTextBox_FileHistory, MSG_STARTED_FILE_LOADING);

                switch (PreProcessData.fileFormat)
                {
                case FileFormat_en.eTXT:
                    await Task.Run(() => startTxtReading(filePath));

                    break;

                case FileFormat_en.eDOCX:
                    await Task.Run(() => startDocxReading(filePath));

                    break;
                }

                HistoryWorker.appendLnToHistory(richTextBox_FileHistory, MSG_SUCCESS_FILE_LOADED);

                FileInfoWorker.setFileInfo(filePath, Label_FileName, Label_FileSize, label_QuantitySentences, label_creationTime, label_FolderName, label_LatestWriteTime);
            }

            Button_UploadFile.Enabled = true;
            setEnabledAllTabs(true);
        }
Exemplo n.º 11
0
        private void button_ChangeSimilarWords_Click(object sender, EventArgs e)
        {
            button_ChangeSimilarWords.Enabled = false;

            if (pronounDriver.readyForRead())
            {
                try
                {
                    HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage("Начат поиск местоимений в тексте...", MessageType_en.eStandart));

                    pronounDriver.asyncFindPronouns(PreProcessData.getSentences());

                    StartShortWordForm(pronounDriver.SENTENCES);

                    HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage("Новые значения местоимений успешно приняты!", MessageType_en.eSuccess));
                }
                catch (Exception)
                {
                    HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_ERROR_SHORT_WORD_READING);
                }
            }

            button_ChangeSimilarWords.Enabled = true;
        }
Exemplo n.º 12
0
 private void button_ChangeRomaniansToArab_Click(object sender, EventArgs e)
 {
     HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_STARTED_FILE_ROMAN_SEARCHING);
     button_SaveChanges.Enabled = false;
     PreProcessData.asyncRomanianNumbersToArab(button_SaveChanges, richTextBox_FileFormattingHistory, MSG_FINISHED_FILE_ROMAN_SEARCH);
 }
Exemplo n.º 13
0
 public void startNewFileUploading()
 {
     HistoryWorker.appendLnToHistory(richTextBox_FileHistory, MSG_STARTED_FILE_CHOOSING);
     Button_UploadFile.Enabled = false;
     asyncStartFileReading();
 }