Exemple #1
0
 /// <summary>
 /// Handles the Clicked event of the login button.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="SFML.Window.MouseButtonEventArgs"/> instance containing the event data.</param>
 void _btnLogin_Clicked(object sender, MouseButtonEventArgs e)
 {
     if (!_sockets.Connect())
     {
         SetError("Already attempting to connect or error occured while creating socket.");
     }
 }
Exemple #2
0
        /// <summary>
        /// Handles when the CreateAccount button is clicked.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="SFML.Window.MouseButtonEventArgs"/> instance containing the event data.</param>
        void ClickButton_CreateAccount(object sender, MouseButtonEventArgs e)
        {
            // Manually check for invalid values before checking with the server
            if (!GameData.AccountName.IsValid(_cNameText.Text))
            {
                SetError(GameMessageCollection.CurrentLanguage.GetMessage(GameMessage.CreateAccountInvalidName));
                return;
            }

            if (!GameData.AccountPassword.IsValid(_cPasswordText.Text))
            {
                SetError(GameMessageCollection.CurrentLanguage.GetMessage(GameMessage.CreateAccountInvalidPassword));
                return;
            }

            if (!GameData.AccountEmail.IsValid(_cEmailText.Text))
            {
                SetError(GameMessageCollection.CurrentLanguage.GetMessage(GameMessage.CreateAccountInvalidEmail));
                return;
            }

            // Disconnect if already connected
            if (_sockets.IsConnected)
            {
                _sockets.Disconnect();
            }

            // Start connecting to the server
            SetMessage("Connecting to server...");

            _sockets.Connect();
        }