private EncryptionOutput GetSelectedValuesFromGUIEncryption()
        {
            //enter values from input controls to EncryptionInput object
            EncryptionInput ei = new EncryptionInput(InputFileTextBox.Text,
                                                     OutputFileTextBox.Text, cipherModeComboBox.Text,
                                                     RecipentsListBox.SelectedItems);

            EncryptionOutput eo = InputHandlers.ParseEncryptionValues(ei);

            return(eo);
        }
        public static EncryptionOutput ParseEncryptionValues(EncryptionInput ei)
        {
            bool   readingAllOK = true;
            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";
            }

            //get input file extension
            string fileExtension = "";

            try
            {
                fileExtension = System.IO.Path.GetExtension(inputFilePath);
            }catch (ArgumentException e)
            {
                readingAllOK = false;
                errorMsg    += "Błędne rozszerzenie pliku wejściowego.\n";
            }

            //get output file name
            string outputFileName = ei.OutputFile;

            if (string.IsNullOrEmpty(outputFileName) ||
                (outputFileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0))
            {
                readingAllOK = false;
                errorMsg    += "Błędna nazwa pliku wyjściowego.\n";
            }

            string outputFilePath = "";

            try
            {
                string outDirectory = System.IO.Path.GetDirectoryName(inputFilePath);
                outputFilePath = outDirectory + "\\" + outputFileName;
            }
            catch (Exception e)
            {
                readingAllOK = false;
                errorMsg    += "Błędny katalog pliku wejściowego.\n";
            }

            //retrieve cipher mode
            string cipherMode = ei.CipherMode;


            //retrieve selected recipents from listbox
            System.Collections.IList items = ei.ListItems;
            List <User> recipents          = items.Cast <User>().ToList();

            if (recipents == null || recipents.Count == 0)
            {
                readingAllOK = false;
                errorMsg    += "Brak wybranych odbiorców pliku.\n";
            }

            //create and return an object keeping track of all read data
            EncryptionOutput eo = new EncryptionOutput(readingAllOK,
                                                       inputFilePath, outputFilePath, cipherMode, fileExtension,
                                                       recipents, errorMsg);

            return(eo);
        }