FormLogin.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using Zoo;
  5. namespace Zoo
  6. {
  7. public class FormLogin : Form
  8. {
  9. TextBox txtLogin;
  10. TextBox txtPassword;
  11. Button btnLogin;
  12. Button btnExit;
  13. public FormLogin()
  14. {
  15. InitializeComponent();
  16. }
  17. private void InitializeComponent()
  18. {
  19. Text = "Авторизация";
  20. StartPosition = FormStartPosition.CenterScreen;
  21. Size = new Size(400, 280);
  22. FormBorderStyle = FormBorderStyle.FixedSingle;
  23. MaximizeBox = false;
  24. BackColor = Color.WhiteSmoke;
  25. Font = new Font("Segoe UI", 10);
  26. Label title = new Label();
  27. title.Text = "Вход в систему";
  28. title.Font = new Font("Segoe UI", 18, FontStyle.Bold);
  29. title.AutoSize = true;
  30. title.Location = new Point(90, 20);
  31. Label lblLogin = new Label();
  32. lblLogin.Text = "Логин";
  33. lblLogin.Location = new Point(40, 80);
  34. lblLogin.AutoSize = true;
  35. txtLogin = new TextBox();
  36. txtLogin.Location = new Point(120, 76);
  37. txtLogin.Size = new Size(200, 30);
  38. txtLogin.Text = "admin";
  39. Label lblPassword = new Label();
  40. lblPassword.Text = "Пароль";
  41. lblPassword.Location = new Point(40, 125);
  42. lblPassword.AutoSize = true;
  43. txtPassword = new TextBox();
  44. txtPassword.Location = new Point(120, 121);
  45. txtPassword.Size = new Size(200, 30);
  46. txtPassword.UseSystemPasswordChar = true;
  47. txtPassword.Text = "12345";
  48. btnLogin = new Button();
  49. btnLogin.Text = "Войти";
  50. btnLogin.Location = new Point(40, 180);
  51. btnLogin.Size = new Size(130, 40);
  52. btnLogin.BackColor = Color.DodgerBlue;
  53. btnLogin.ForeColor = Color.White;
  54. btnLogin.FlatStyle = FlatStyle.Flat;
  55. btnLogin.Click += BtnLogin_Click;
  56. btnExit = new Button();
  57. btnExit.Text = "Выход";
  58. btnExit.Location = new Point(190, 180);
  59. btnExit.Size = new Size(130, 40);
  60. btnExit.BackColor = Color.IndianRed;
  61. btnExit.ForeColor = Color.White;
  62. btnExit.FlatStyle = FlatStyle.Flat;
  63. btnExit.Click += (s, e) => Application.Exit();
  64. Controls.Add(title);
  65. Controls.Add(lblLogin);
  66. Controls.Add(txtLogin);
  67. Controls.Add(lblPassword);
  68. Controls.Add(txtPassword);
  69. Controls.Add(btnLogin);
  70. Controls.Add(btnExit);
  71. }
  72. private void BtnLogin_Click(object sender, EventArgs e)
  73. {
  74. FormMain main = new FormMain();
  75. main.Show();
  76. Hide();
  77. }
  78. }
  79. }