private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            callback = new ClientCallback();
            client   = new MineSweeperServiceClient(
                new InstanceContext(callback));
            RegisterWindow wind = new RegisterWindow();

            wind.client   = client;
            wind.callback = callback;
            wind.ShowDialog();
        }
        private void ConnectToServer()
        {
            ClientCallback callback = new ClientCallback();

            username = UsernameTextBox.Text.Trim();
            MineSweeperServiceClient client = new MineSweeperServiceClient(
                new InstanceContext(callback));

            if (!client.IsLegalUser(UsernameTextBox.Text.Trim(), PasswordTextBox.Text.Trim()))
            {
                MessageBox.Show("Invalid user name or password");
            }
            else
            {
                try
                {
                    client.ClientConnected(username);
                    GameLobbyWindow mainWindow = new GameLobbyWindow();
                    MainWindow.client   = client;
                    MainWindow.callback = callback;
                    mainWindow.Username = username;
                    mainWindow.Title    = username;
                    this.Close();
                    mainWindow.Show();
                }
                catch (FaultException <UserExistsFault> fe)
                {
                    MessageBox.Show(fe.Message);
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }