예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox2.Text != String.Empty && comboBox2.GetItemText(comboBox2.SelectedItem) != String.Empty)
            {
                USBDeviceInfo selectedUsbDevice = (USBDeviceInfo)comboBox2.SelectedItem;

                var listConfig = File.ReadAllText(@"config.txt").Replace("\n", " ");

                if (listConfig.Contains(textBox2.Text + "-" + selectedUsbDevice.DeviceID))
                {
                    USBManager.Unlock(textBox2.Text);

                    MessageBox.Show(
                        "Папка успешно разблокирована",
                        "Разблокировка",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);

                    return;
                }

                MessageBox.Show(
                    "Неправильно выбрана папка либо USB-устройство",
                    "Разблокировка",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
        }
예제 #2
0
        public Form1()
        {
            InitializeComponent();

            var usbDeviceList = USBManager.GetListUsbDevicesId();

            comboBox1.DisplayMember = "Description";
            comboBox1.ValueMember   = "DeviceID";

            comboBox2.DisplayMember = "Description";
            comboBox2.ValueMember   = "DeviceID";

            foreach (var item in usbDeviceList)
            {
                comboBox1.Items.Add(item);
            }

            foreach (var item in usbDeviceList)
            {
                comboBox2.Items.Add(item);
            }
        }
예제 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != String.Empty && comboBox1.GetItemText(comboBox1.SelectedItem) != String.Empty)
            {
                USBDeviceInfo selectedUsbDevice = (USBDeviceInfo)comboBox1.SelectedItem;

                USBManager.Lock(textBox1.Text);
                File.AppendAllText("config.txt", $"{textBox1.Text}-{selectedUsbDevice.DeviceID}-");

                MessageBox.Show(
                    "Папка успешно заблокирована",
                    "Блокировка",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);

                return;
            }

            MessageBox.Show(
                "Не выбрана папка либо не выбрано USB-устройство",
                "Блокировка",
                MessageBoxButtons.OK,
                MessageBoxIcon.Information);
        }