private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            RegisterOutput ro           = GetSelectedValuesFromGUIRegister();
            bool           correctInput = ro.IsInputCorrect;

            if (correctInput)
            {
                User newUser = UsersManagement.AddUser(ro.Email, ro.Password);
                users.Add(newUser);

                //refresh all listboxes to show also newly added user
                RecipentsListBox.ItemsSource           = null;
                RecipentsListBoxDecryption.ItemsSource = null;
                RecipentsListViewRegister.ItemsSource  = null;

                RecipentsListBox.ItemsSource           = users;
                RecipentsListBoxDecryption.ItemsSource = users;
                RecipentsListViewRegister.ItemsSource  = users;

                resultTextBlockRegister.Text = "Zostałeś zarejestrowany, dziękujemy!";
            }
            else
            {
                MessageBoxResult result =
                    MessageBox.Show(ro.ErrorMessage,
                                    "Błędne dane wejściowe", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
        private RegisterOutput GetSelectedValuesFromGUIRegister()
        {
            //enter values from input controls to EncryptionInput object
            RegisterInput ri = new RegisterInput(TextBoxRegistrationEmail.Text,
                                                 userPassword.Password);

            RegisterOutput ro = InputHandlers.ParseRegisterValues(ri);

            return(ro);
        }
        public static RegisterOutput ParseRegisterValues(RegisterInput ri)
        {
            bool   readingAllOK = true;
            string errorMsg     = "";

            //retrieve email and password
            string email = ri.Email;

            if (string.IsNullOrEmpty(email))
            {
                readingAllOK = false;
                errorMsg    += "Błędny email.\n";
            }
            else
            {
                try
                {
                    var addr = new System.Net.Mail.MailAddress(email);
                    readingAllOK = (addr.Address == email);
                }
                catch
                {
                    readingAllOK = false;
                    errorMsg    += "Błędny email.\n";
                }
            }


            string password = ri.Password;

            if (!UsersManagement.PasswordCorrect(password))
            {
                readingAllOK = false;
                errorMsg    += "Błędne hasło. \n" +
                               "Ograniczenia hasła: Minimalna długość osiem znaków; \n" +
                               "co najmniej: jedna cyfra, jedna litera, jeden znak specjalny\n";
            }

            RegisterOutput ro = new RegisterOutput(readingAllOK,
                                                   email, password, errorMsg);

            return(ro);
        }