private DecryptionOutput GetSelectedValuesFromGUIDecryption() { //enter values from input controls to EncryptionInput object DecryptionInput di = new DecryptionInput(InputFileTextBoxDecryption.Text, OutputFileTextBoxDecryption.Text, (User)RecipentsListBoxDecryption.SelectedItem); DecryptionOutput decryptionOutput = InputHandlers.ParseDecryptionValues(di); return(decryptionOutput); }
public static DecryptionOutput ParseDecryptionValues(DecryptionInput ei) { bool readingAllOK = true; string outDirectory = ""; string decodedFileName = ""; string errorMsg = ""; //retrieve input file and output file name string inputFilePath = ei.InputFile; if (string.IsNullOrEmpty(inputFilePath) || !File.Exists(inputFilePath)) { readingAllOK = false; errorMsg += "Błędnie wybrany plik do zaszyfrowania.\n"; } else { outDirectory = System.IO.Path.GetDirectoryName(inputFilePath); } string outputFileName = ei.OutputFileName; string outputFilePath = ""; if (string.IsNullOrEmpty(outputFileName) || (outputFileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)) { readingAllOK = false; errorMsg += "Błędna nazwa pliku wyjściowego.\n"; } else { outputFilePath = outDirectory + "\\" + outputFileName; decodedFileName = outDirectory + "\\result.txt"; } //retrieve selected recipent of encoded file from listbox User recipent = ei.Recipent; if (recipent == null) { readingAllOK = false; errorMsg += "Brak wybranego odbiorcy pliku.\n"; } //create and return an object keeping track of all read data DecryptionOutput decryptionOutput = new DecryptionOutput(readingAllOK, inputFilePath, outputFilePath, recipent, errorMsg); return(decryptionOutput); }