private void RegisterWorker_DoWork(object sender, DoWorkEventArgs e) { string Username = null, Password = null, Email = null, SerialKey = null; Dispatcher.Invoke(() => { Username = UsernameBox.Text; Password = PasswordBox.Password; Email = EmailBox.Text; SerialKey = SerialKeyBox.Text; }); WebInterface.VerifyWebsite(this); var Result = WebInterface.Register(Username, Password, Email, SerialKey); switch (Result.Result) { case WebInterface.RegisterResult.OK: { DataInterface.Save("token", Result.Token); Dispatcher.Invoke(() => { MessageBox.Show( "You have succesfully created your Synapse account!\n\nYou can now restart Synapse X to use the software.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Information); }); Environment.Exit(0); break; } case WebInterface.RegisterResult.ALPHA_NUMERIC_ONLY: { Dispatcher.Invoke(() => { MessageBox.Show( "Non-alphanumeric usernames are not supported. Please enter an alphanumeric username and try again.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Error); RegisterButton.Content = "Register"; Registering = false; }); return; } case WebInterface.RegisterResult.USERNAME_TAKEN: { Dispatcher.Invoke(() => { MessageBox.Show( "Username is taken, please enter a new one and try again.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Error); RegisterButton.Content = "Register"; Registering = false; }); return; } case WebInterface.RegisterResult.ALREADY_EXISTING_ACCOUNT: { Dispatcher.Invoke(() => { MessageBox.Show( "You already have a Synapse account, please use the account you already crated.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Error); RegisterButton.Content = "Register"; Registering = false; }); return; } case WebInterface.RegisterResult.INVALID_KEY: { Dispatcher.Invoke(() => { MessageBox.Show( "Invalid serial key.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Error); RegisterButton.Content = "Register"; Registering = false; }); return; } case WebInterface.RegisterResult.INVALID_REQUEST: case WebInterface.RegisterResult.UNKNOWN: { Dispatcher.Invoke(() => { MessageBox.Show( "Failed to create Synapse account. Please contact 3dsboy08 on Discord.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Error); RegisterButton.Content = "Register"; Registering = false; }); return; } } }