private void OnClientRegWndClosed(object sender, EventArgs e)
        {
            ClientRegistrationWindow window = sender as ClientRegistrationWindow;

            window.Closed -= OnClientRegWndClosed;
            if (window.DialogResult != null && window.DialogResult.Value)
            {
                UserRegistrationPropertiesViewModel vm = window.DataContext
                                                         as UserRegistrationPropertiesViewModel;
                if (vm == null)
                {
                    throw new ArgumentException("Wrong object type");
                }
                User   client   = vm.Model;
                string password = vm.Password;
                client.PasswordHash = Sha256Hash.Calculate(password);
                registeredClient    = client;
                ProcessMissingFields(client);
                UserRegistrator registrator = new UserRegistrator(client,
                                                                  OnClientRegistered, OnError);
                progressWindow         = new UserRegistrationProgressWindow(registrator);
                progressWindow.Closed += OnRegistrationWindowClosed;
                progressWindow.Show();
            }
        }
        private void RegisterUser()
        {
            User client = new User();
            UserRegistrationPropertiesViewModel vm =
                new UserRegistrationPropertiesViewModel(client);
            ClientRegistrationWindow wnd = new ClientRegistrationWindow();

            wnd.DataContext = vm;
            wnd.Closed     += OnClientRegWndClosed;
            wnd.Show();
        }