InputForm.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace Steam_Desktop_Authenticator
  11. {
  12. public partial class InputForm : Form
  13. {
  14. public bool Canceled = false;
  15. private bool userClosed = true;
  16. public InputForm(string label, bool password = false)
  17. {
  18. InitializeComponent();
  19. this.labelText.Text = label;
  20. if (password)
  21. {
  22. this.txtBox.PasswordChar = '*';
  23. }
  24. }
  25. private void btnAccept_Click(object sender, EventArgs e)
  26. {
  27. if (string.IsNullOrEmpty(this.txtBox.Text))
  28. {
  29. this.Canceled = true;
  30. this.userClosed = false;
  31. this.Close();
  32. }
  33. else
  34. {
  35. this.Canceled = false;
  36. this.userClosed = false;
  37. this.Close();
  38. }
  39. }
  40. private void btnCancel_Click(object sender, EventArgs e)
  41. {
  42. this.Canceled = true;
  43. this.userClosed = false;
  44. this.Close();
  45. }
  46. private void InputForm_FormClosing(object sender, FormClosingEventArgs e)
  47. {
  48. if (this.userClosed)
  49. {
  50. // Set Canceled = true when the user hits the X button.
  51. this.Canceled = true;
  52. }
  53. }
  54. }
  55. }