Загрузка данных


using System;
using System.Windows;
using System.Windows.Controls;

namespace ГенераторПароля
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Slider_ValueChanged(object sender,
            RoutedPropertyChangedEventArgs<double> e)
        {
            try
            {
                tb2.Text = Convert.ToString(Math.Round(sl.Value));
            }
            catch { }
        }

        private void tb2_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                sl.Value = Convert.ToDouble(tb2.Text);
                if (Convert.ToDouble(tb2.Text) >= 32)
                {
                    tb2.Text = "32";
                }
            }
            catch { }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string password = "";
            int rnd = 0;
            int rndtype = 0;
            Random random = new Random();

            string[] a = { "0","1","2","3","4","5","6","7","8","9" };
            string[] b = { "A","B","C","D","E","F","G","H","I","J",
                           "K","L","M","N","O","P","Q","R","S","T",
                           "U","V","W","X","Y","Z","a","b","c","d",
                           "e","f","g","h","i","j","k","l","m","n",
                           "o","p","q","r","s","t","u","v","w","x","y" };
            string[] c = { "!","@","#","$","%","^","&","*","(",")","_",
                           "+","-","=","[","]","{","}","|",";",":",
                           "'","\"",",",".","<",">" };

            if (rb1.IsChecked == true)
            {
                for (int i = 0; i < Math.Round(sl.Value); i++)
                {
                    rnd = random.Next(0, 9);
                    password += a[rnd];
                }
            }

            if (rb2.IsChecked == true)
            {
                for (int i = 0; i < Math.Round(sl.Value); i++)
                {
                    rndtype = random.Next(0, 9);
                    if (rndtype % 2 == 1)
                    {
                        rnd = random.Next(0, 9);
                        password += a[rnd];
                    }
                    else
                    {
                        rnd = random.Next(0, 51);
                        password += b[rnd];
                    }
                }
            }

            if (rb3.IsChecked == true)
            {
                for (int i = 0; i < Math.Round(sl.Value); i++)
                {
                    rndtype = random.Next(1, 9);
                    if (rndtype % 3 == 0)
                    {
                        rnd = random.Next(0, 9);
                        password += a[rnd];
                    }
                    if (rndtype % 3 == 1)
                    {
                        rnd = random.Next(0, 51);
                        password += b[rnd];
                    }
                    if (rndtype % 3 == 2)
                    {
                        rnd = random.Next(0, 27);
                        password += c[rnd];
                    }
                }
            }

            tb1.Text = password;
        }
    }
}