Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Windows.Forms;
- namespace Password_Generator
- {
- public partial class Form1 : Form
- {
- public const int WM_NCLBUTTONDOWN = 0xA1;
- public const int HT_CAPTION = 0x2;
- [DllImportAttribute("user32.dll")]
- public static extern int SendMessage(IntPtr hWnd,
- int Msg, int wParam, int lParam);
- [DllImportAttribute("user32.dll")]
- public static extern bool ReleaseCapture();
- public Form1()
- {
- InitializeComponent();
- }
- Random rand = new Random();
- private void button1_Click(object sender, EventArgs e)
- {
- string b = "";
- string a = "";
- if (checkBox1.Checked == true)
- {
- if (!a.Contains("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"))
- a += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- }
- if(checkBox1.Checked==false)
- if(a.Contains("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ)"))
- a.Replace("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ","");
- if (checkBox2.Checked == true)
- {
- if (!a.Contains("123456789"))
- a += "123456789";
- }
- if (checkBox2.Checked == false)
- if (a.Contains("123456789)"))
- a.Replace("123456789", "");
- if (checkBox3.Checked == true)
- {
- if (!a.Contains("~!@#$%^&*()_+=-[]}{;':/.,?><"))
- a += "~!@#$%^&*()_+=-[]}{;':/.,?><";
- }
- if (checkBox3.Checked == false)
- if (a.Contains("~!@#$%^&*()_+=-[]}{;':/.,?><"))
- a.Replace("~!@#$%^&*()_+=-[]}{;':/.,?><", "");
- if (textBox1.Text == "" || (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == false))
- {
- if (textBox1.Text == "" && (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == false))
- MessageBox.Show("Nu ai introdus numărul de caractere şi nu ai ales tipul caracterelor!");
- else
- {
- if (textBox1.Text == "")
- MessageBox.Show("Nu ai ales numărul de caractere!");
- if (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == false)
- MessageBox.Show("Nu ai selectat niciun fel de caracter!");
- }
- }
- else
- {
- b = "";
- int c = Convert.ToInt32(textBox1.Text);
- for (int i = 1; i <= c; i++)
- {
- b += a[rand.Next(0, a.Length)];
- }
- richTextBox1.Text = b;
- }
- }
- private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!char.IsControl(e.KeyChar)
- && !char.IsDigit(e.KeyChar)
- && e.KeyChar != '.')
- {
- e.Handled = true;
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (richTextBox1.Text != "")
- Clipboard.SetText(richTextBox1.Text);
- }
- private void label4_Click(object sender, EventArgs e)
- {
- Close();
- }
- private void label4_MouseEnter(object sender, EventArgs e)
- {
- label4.BackColor = Color.White;
- }
- private void label4_MouseLeave(object sender, EventArgs e)
- {
- label4.BackColor = Color.DarkGray;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void label1_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- ReleaseCapture();
- SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment