Ejemplo n.º 1
0
        // установить драйвер на устройство
        private void installDriverOnDevice_Click(object sender, EventArgs e)
        {
            int i = listOfDrivers.SelectedIndex;
            int j = listOfDevices.SelectedIndex;

            if (i == -1 || j == -1)
            {
                return;
            }
            else
            {
                string str   = listOfDrivers.SelectedItem.ToString();
                string value = listOfDevices.SelectedItem.ToString();

                string[] separators = { ",", " " };
                string[] words      = value.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                string   name       = words[0];
                string   typeDevice = words[1]; // тип устройства


                string[] separators1 = { ",", " " };
                string[] words1      = str.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                string   typeDriver  = words1[5]; // тип драйвера


                if (typeDevice == typeDriver)
                {
                    Regex           r      = new Regex(@"-{0,1}\d+");
                    MatchCollection m      = r.Matches(str);
                    int             index2 = int.Parse(m[0].Value); // версия драйвера

                    int index1 = listOfDevices.SelectedIndex;

                    controller.AddDriverForDevice(index1, index2, name, typeDevice);

                    if (controller.ready())
                    {
                        label3.Text = "Готовность к работе: готово";
                    }
                }
                else
                {
                    MessageBox.Show("Типы железок не совпадают");
                }
            }
        }