private void ButtonLogin_Click(object sender, EventArgs e) { // Checks if the specified username is the correct length. if (TextBoxUsername.TextLength < 4 || TextBoxUsername.TextLength > 12 || TextBoxUsername.Text == "Username") { ThemeContainer.SetStatus("Username must be 4-12 characters.", 1); return; } // Checks if the specified username is valid. if (!Regex.Match(TextBoxUsername.Text, "^[a-zA-Z0-9]+$").Success) { ThemeContainer.SetStatus("Username can only contain letters/numbers.", 1); return; } // Disables the form controls to prevent spamming. SetControls(false); ThemeContainer.SetStatus("Logging in, please wait...", 3); // Attempts to log the user in with the specified credentials on a seperate thread. Thread threadLogin = new Thread(ThreadedLogin); threadLogin.Start(); }
private void DownloadAvatar(object imageLocation) { ThemeContainer.SetStatus("Downloading profile image...", 3); if (Methods.DownloadAvatar(_username, imageLocation.ToString())) { try { Invoke((MethodInvoker) delegate { PictureBoxProfileImage.ImageLocation = imageLocation.ToString(); }); } catch { // If control is disposed, catches any errors. } ThemeContainer.SetStatus("Send the user a message or add to their reputation.", 3); } else { ThemeContainer.SetStatus("There was an error downloading the profile avatar.", 1); } }
private void ViewProfile_Load(object sender, EventArgs e) { ThemeContainer.SetStatus("Loading profile, please wait...", 3); Thread loadProfileThread = new Thread(LoadProfile); loadProfileThread.Start(); }
// Use this for initialization void Start() { DontDestroyOnLoad(this); Debug.Log(Application.dataPath + "/StreamingAssets/ThemeOptions.xml HI"); // Load XML themeContainer = ThemeContainer.Load(Application.dataPath + "/StreamingAssets/ThemeOptions.xml"); }
private void Login_Load(object sender, EventArgs e) { // Sets the status bar text. if (_accountCreatedSuccessfully) { ThemeContainer.SetStatus("Account created successfully.", 4); } else { ThemeContainer.SetStatus("Please sign in or create an account.", 3); } // If stored, gets the stored username. Also creates installation directories if not already created. PreLoginProcessing(); }
private void LoadProfile() { NameValueCollection dataValues = new NameValueCollection { { "u", _username } }; if (Network.SubmitData("getprofile", dataValues)) { ProcessResponse(); } else { ThemeContainer.SetStatus("Failed to load profile.", 1); } }
private void RedeemLicense_Load(object sender, EventArgs e) { ActiveControl = ThemeContainer; // Changes the value label depending on if it is a point/duration license. DropDownLicenseType.Text = (_byteguardLicense.LicenseType == 0 ? "Duration" : "Points"); LabelValue.Text = (_byteguardLicense.LicenseType == 0 ? "Days (0 = Unlimited):" : "Value"); // Sets the numeric textbox to the licenses' value. TextBoxValue.Value = Convert.ToDecimal(_byteguardLicense.LicenseValue); // Sets the tracking description textbox to the licenses' tracking description. TextBoxTrackingDescription.Text = _byteguardLicense.TrackingDescription; // Displays the license code in the status bar. ThemeContainer.SetStatus(String.Format("Code: {0}", _byteguardLicense.LicenseCode), 3); }
private void ProcessResponse() { string webResponse = Variables.WebResponse; if (webResponse.Split('[', ']')[1] == "SUCCESS") { ThemeContainer.SetStatus(webResponse.Replace("[SUCCESS]", String.Empty), 4); SetControls(true); Tasks.Licensing.Variables.GetVariables( Variables.MyProgramsSelected.Programid); } else { ThemeContainer.SetStatus(webResponse.Replace("[ERROR]", String.Empty), 1); SetControls(true); } }
private void ButtonAddVariable_Click(object sender, EventArgs e) { if (TextBoxKey.TextLength <= 0 || TextBoxKey.TextLength > 25) { ThemeContainer.SetStatus("Invalid key length.", 1); return; } if (TextBoxValue.TextLength <= 0 || TextBoxValue.TextLength > 255) { ThemeContainer.SetStatus("Invalid value length.", 1); return; } SetControls(false); Thread addVariableThread = new Thread(AddVariableThreaded); addVariableThread.Start(); }
/// <summary> /// Processes the web response and acts accordingly. /// </summary> private void ProcessResponse() { // Retrieves the web response. string webResponse = Variables.WebResponse; if (webResponse.Split('[', ']')[1] == "SUCCESS") { Thread storeUserInformationThread = new Thread(StoreUserInformation); storeUserInformationThread.Start(); // Logged in successfully, saves username/shows EULA. PostLoginProcessing(); MainForm m = new MainForm(); Form parentForm = ParentForm; // When the MainForm is closed, the whole application will exit. if (parentForm != null) { m.FormClosed += (closedSender, closedE) => parentForm.Close(); } // Hides the current form and shows the MainForm. Invoke((MethodInvoker) delegate { if (parentForm != null) { parentForm.Hide(); } m.Show(); }); } else { // Failed to create account, display error. ThemeContainer.SetStatus(webResponse.Replace("[ERROR] ", String.Empty), 1); // Resets/Enables the controls after an incorrect login. SetControls(true); } }
private void ButtonRedeem_Click(object sender, EventArgs e) { // Check the username textbox has been changed, and that the text is between 4-12 characters. if (TextBoxRedeemTo.Text == "Username" || TextBoxRedeemTo.TextLength > 12 || TextBoxRedeemTo.TextLength < 4) { ThemeContainer.SetStatus("Enter a valid username.", 1); return; } // Asks the user to confirm they have entered the correct username. if ( MessageBox.Show(String.Format("Have you entered the correct username? ({0})", TextBoxRedeemTo.Text), "Redeem License", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { // Disables the form controls. SetControls(false); // Attempts to redeem the license to the specified username on a seperate thread. Thread redeemLicenseThread = new Thread(RedeemLicenseThreaded); redeemLicenseThread.Start(TextBoxRedeemTo.Text); } }
/// <summary> /// Processes the server response and acts accordingly. /// </summary> private void ProcessResponse() { // Converts the response bytes into a string. string webResponse = Variables.WebResponse; // Checks if the request completed successfully. if (webResponse.Split('[', ']')[1] == "SUCCESS") { // Displays the success message in the status strip. ThemeContainer.SetStatus(webResponse.Replace("[SUCCESS] ", String.Empty), 4); // Gets and displays the licenses for the current Programid. Thread getLicensesThread = new Thread(GetLicenses); getLicensesThread.Start(Variables.MyProgramsSelected.Programid); } else { // Displays the error message in the status strip and re-enables the controls. ThemeContainer.SetStatus(webResponse.Replace("[ERROR] ", String.Empty), 1); SetControls(true); } }
private void ButtonCreateAccount_Click(object sender, EventArgs e) { Form parentForm = ParentForm; // Changes from Login controls to CreateAccount controls. var conCreateAccount = new CreateAccount(); // Changes the form size to fit the CreateAccount user control. if (parentForm != null) { int x = (parentForm.Size.Width - Width); int y = (parentForm.Size.Height - Height); parentForm.Size = new Size(conCreateAccount.Width + x, conCreateAccount.Height + y); } Parent.Controls.Add(conCreateAccount); Parent.Controls.Remove(this); // Forces the theme to refresh to adjust to the new dimensions. ThemeContainer.ForceRedraw(); }
/// <summary> /// Processes the web response and acts accordingly. /// </summary> private void ProcessResponse() { string webResponse = Variables.WebResponse; if (webResponse.Split('[', ']')[1] == "SUCCESS") { // Account created successfully. Invoke((MethodInvoker) delegate { Form parentForm = ParentForm; // Changes from Login controls to CreateAccount controls. Parent.Controls.Add(new Login(true)); // Changes the form size to fit the CreateAccount user control. if (parentForm != null) { parentForm.Size = new Size(296, 289); } // Removes the Login user control. Parent.Controls.Remove(this); // Forces the theme to refresh to adjust to the new dimensions. ThemeContainer.ForceRedraw(); }); ThemeContainer.SetStatus(webResponse.Replace("[SUCCESS] ", String.Empty), 4); } else { // Failed to create account, display error. ThemeContainer.SetStatus(webResponse.Replace("[ERROR] ", String.Empty), 1); // Enables the CreateAccountForm controls after a failed login. SetControls(true); } }
private void ButtonCreateAccount_Click(object sender, EventArgs e) { // Check they have accepted the terms and conditions. if (!chkTerms.Checked) { ThemeContainer.SetStatus("You must accept the terms and conditions.", 1); return; } // Checks if the specified email is valid. if (!Regex.Match(TextBoxEmail.Text, "^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?$", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture).Success) { ThemeContainer.SetStatus("Please enter a valid e-mail address.", 1); return; } // Checks if the specified username is the correct length. if (TextBoxUsername.TextLength < 4 || TextBoxUsername.TextLength > 12 || TextBoxUsername.Text == "Username") { ThemeContainer.SetStatus("Username must be 4-12 characters.", 1); return; } // Checks if the specified username is valid. if (!Regex.Match(TextBoxUsername.Text, "^[a-zA-Z0-9]+$").Success) { ThemeContainer.SetStatus("Username can only contain letters/numbers.", 1); return; } // Checks if the specified username and passwords are not the same, to prevent account theft. if (TextBoxUsername.Text == TextBoxPassword.Text) { ThemeContainer.SetStatus("Username/password must not be the same.", 1); return; } // Checks if the specified passwords match. if (TextBoxPassword.Text != TextBoxConfirmPassword.Text) { ThemeContainer.SetStatus("Your passwords do not match.", 1); TextBoxPassword.ForeColor = Color.DimGray; TextBoxConfirmPassword.ForeColor = Color.DimGray; TextBoxPassword.UseSystemPasswordChar = false; TextBoxConfirmPassword.UseSystemPasswordChar = false; TextBoxPassword.Text = "Password"; TextBoxConfirmPassword.Text = "Confirm Password"; return; } // Disables the CreateAccountForm controls to prevent spamming. SetControls(false); // Attempts to create a new user account. Thread createAccountThread = new Thread(ThreadedCreateAccount); createAccountThread.Start(); }
private void CreateAccount_Load(object sender, EventArgs e) { ActiveControl = ButtonBack; ThemeContainer.SetStatus("Please sign in or create an account.", 3); }
private void load(ThemeContainer themeContainer) => this.RegisterTo <UITheme>(themeContainer);
private void ProcessResponse() { string webResponse = Variables.WebResponse; bool hasAvatar = false; if (webResponse.Split('[', ']')[1] == "SUCCESS") { Form parentForm = ParentForm; // Loads the XML file ready to be parsed. XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(webResponse.Replace("[SUCCESS]", "")); // Iterates through each program node. foreach (XmlNode xmlInformationNode in xmlDocument.Cast <XmlNode>().SelectMany(xmlNode => xmlNode.Cast <XmlNode>().SelectMany(xmlUserNode => xmlUserNode.Cast <XmlNode>()))) { XmlNode node = xmlInformationNode; try { Invoke((MethodInvoker) delegate { switch (node.Name) { case "email": LabelEmailAddress.Text = node.InnerText; break; case "username": LabelUsername.Text = node.InnerText; if (parentForm != null) { parentForm.Text = String.Format("ByteGuard - {0}'s profile", node.InnerText); } break; case "registeredtime": LabelRegistrationDate.Text = Methods.TimeStampToDate(Convert.ToInt32(node.InnerText)); break; case "lastaction": LabelLastOnline.Text = Methods.TimeStampToDate(Convert.ToInt32(node.InnerText)); break; // TODO: Show the user is verified/activated. case "isactivated": break; case "description": TextBoxUserDescription.Text = node.InnerText; break; // TODO: Do something! case "hasavatar": hasAvatar = (Convert.ToInt32(node.InnerText) == 1); break; } }); } catch { // Catches error if controls are disposed. } } if (hasAvatar) { Thread downloadAvatarThreaded = new Thread(DownloadAvatar); downloadAvatarThreaded.Start(_avatarPath); } Invoke((MethodInvoker) delegate { ButtonAddReputation.Enabled = true; ButtonSendMessage.Enabled = true; }); ThemeContainer.SetStatus("Send the user a message or add to their reputation.", 3); } else { // Failed to create account, display error. ThemeContainer.SetStatus(webResponse.Replace("[ERROR] ", String.Empty), 1); } }