private void regbtn1_Click(object sender, EventArgs e) { string regpnr = pnrtextbox1.Text; string regfirstname = firstnametextbox1.Text; string reglastname = lastnametextbox1.Text; string regpassword = passwordtextbox1.Text; if (string.IsNullOrEmpty(regpnr) && string.IsNullOrEmpty(regfirstname) || string.IsNullOrEmpty(reglastname) || string.IsNullOrEmpty(regpassword)) { ErrorLabel.ForeColor = System.Drawing.Color.Red; ErrorLabel.Text = " Kontrollera att personnummer stämmer och att rutorna är ifyllda!"; var t1 = new Timer(); t1.Interval = 7000; t1.Tick += (s, e1) => { ErrorLabel.Hide(); t1.Stop(); }; t1.Start(); ErrorLabel.Show(); } else { if (call.AddCustomer(Convert.ToString(regpnr), regfirstname, reglastname, regpassword)) { ErrorLabel.ForeColor = System.Drawing.Color.Green; this.ErrorLabel.Text = "Konto skapat!"; //Registration reg = new Registration(); //this.Hide(); } else { ErrorLabel.ForeColor = System.Drawing.Color.Red; ErrorLabel.Text = "Personnummret finns redan, se till att det är rätt ifyllt! "; } } var t = new Timer(); t.Interval = 7000; t.Tick += (s, e1) => { ErrorLabel.Hide(); t.Stop(); }; t.Start(); ErrorLabel.Show(); pnrtextbox1.Clear(); firstnametextbox1.Clear(); lastnametextbox1.Clear(); passwordtextbox1.Clear(); }
private void ResetButton_Click(object sender, EventArgs e) { //Clear all fields and set everything back to default. CurrencyToSelector.SelectedIndex = 0; CurrencyToSelector.ForeColor = Color.Black; CurrencyFromSelector.SelectedIndex = 0; CurrencyFromSelector.ForeColor = Color.Black; ConversionInput.Text = ""; ErrorLabel.Text = ""; ErrorLabel.Hide(); ResultLabel.Text = ""; }
private void ConvertButton_Click(object sender, EventArgs e) { //Make sure we can actually convert, and set the error label if not. if (CurrencyFromSelector.SelectedIndex == 0) { //No Currency Selected in the 'From' field. CurrencyFromSelector.ForeColor = Color.Red; ErrorLabel.Text = "Error: No currency selected to convert from."; ErrorLabel.Show(); } else if (CurrencyToSelector.SelectedIndex == 0) { //No Currency Seleceted int the 'To' field. CurrencyToSelector.ForeColor = Color.Red; ErrorLabel.Text = "Error: No currency selected to convert to."; ErrorLabel.Show(); } else { //Nothing wrong with the currency combo boxes, hide any error currently showing. ErrorLabel.Hide(); //Put the input into a string so we can remove any currency symbols the user might of entered. string userInput = ConversionInput.Text; if (userInput.Contains('$')) { userInput = userInput.Replace("$", ""); } else if (userInput.Contains('£')) { userInput = userInput.Replace("£", ""); } else if (userInput.Contains("€")) { userInput = userInput.Replace("€", ""); } try { /* Attempt to convert the string to a double. If it fails, the user has entered something other than a number. * I am not producing an error for negative amounts, in case someone wants to work out their debt in another currency. ¯\_(ツ)_/¯ */ double userAmount = Double.Parse(userInput); Convert(userAmount, CurrencyFromSelector.GetItemText(CurrencyFromSelector.SelectedItem), CurrencyToSelector.GetItemText(CurrencyToSelector.SelectedItem)); } catch { //Input wasn't a number, or had extra characters in it, show an error and let the user try again. ErrorLabel.Text = "Error: Amount Entered was not a valid number"; ErrorLabel.Show(); } } }
/// <summary> /// This method makes or remakes the song by clearing all notes and adding the ones from NoteTextBox /// </summary> private void MakeSong() { try { ErrorLabel.Hide(); DisablePlayButton(); Autoplayer.ClearAllNotes(); Autoplayer.AddNotesFromString(NoteTextBox.Text); } catch (AutoplayerNoteCreationFailedException e) { ErrorLabel.Text = $"ERROR: {e.Message}"; ErrorLabel.Show(); } }
private void pnrtextbox1_KeyPress_1(object sender, KeyPressEventArgs e) { { if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.') && (e.KeyChar != ',')) { ErrorLabel.Text = "Endast siffror"; ErrorLabel.ForeColor = System.Drawing.Color.Red; e.Handled = true; var tim = new Timer(); tim.Interval = 7000; tim.Tick += (s, e1) => { ErrorLabel.Hide(); tim.Stop(); }; tim.Start(); ErrorLabel.Show(); } } }
/// <summary> /// This is the constructor for the GUI /// It is called when the GUI starts /// </summary> public GraphicalUserInterface() { InitializeComponent(); ErrorLabel.Hide(); VersionLabel.Text = Autoplayer.Version; Autoplayer.AddingNoteFinished += EnablePlayButton; Autoplayer.SongFinishedPlaying += EnableClearButton; Autoplayer.SongWasStopped += EnableClearButton; Autoplayer.SongWasStopped += SongStopped; Autoplayer.SongWasInteruptedByException += ExceptionHandler; //Subscribe the method "GKS_KeyDown" to the KeyDown event of the GlobalKeyboardHook gkh.KeyDown += new KeyEventHandler(GKS_KeyDown); //This converts the text from the keybind settings window to actual keys //Then we add them to the global hook (This is done so the keypresses will be detected when the application is not in focus) KeysConverter keysConverter = new KeysConverter(); startKey = (Keys)keysConverter.ConvertFromString(StartKeyTextBox.Text.ToString()); stopKey = (Keys)keysConverter.ConvertFromString(StopKeyTextBox.Text.ToString()); gkh.HookedKeys.Add(startKey); gkh.HookedKeys.Add(stopKey); }
private void PasswordText_TextChanged(object sender, EventArgs e) { ErrorLabel.Hide(); }
private void UsernameText_TextChanged(object sender, EventArgs e) { ErrorLabel.Hide(); }
private void UsernameText_Click(object sender, EventArgs e) { ErrorLabel.Hide(); }
private void PasswordText_Click(object sender, EventArgs e) { ErrorLabel.Hide(); }
public SaveAsForm() { InitializeComponent(); ErrorLabel.Hide(); }
private void IDTextField_MouseClick(object sender, MouseEventArgs e) { ErrorLabel.Hide(); }
public Form1() { InitializeComponent(); ErrorLabel.Hide(); Starter(); }