예제 #1
0
        private void refreshDeviceSelectionView()
        {
            DEIFlags flags = DEIFlags.DICFG_AllClasses;

            bool driverLessOnly = deviceSelection_DriverlessOnlyCheckBox.Checked;
            bool connnectedOnly = deviceSelection_ConnectedOnlyCheckBox.Checked;

            if (connnectedOnly)
            {
                flags = flags | DEIFlags.DICFG_Present;
            }

            if (driverLessOnly)
            {
                flags |= DEIFlags.Driverless;
            }

#if DEBUG
            flags |= DEIFlags.IncludeWindowsServices;
#endif
            cmdRemoveDevice.Enabled = false;
            gridDeviceSelection.Rows.Clear();

            if (deviceSelection_CreateNewRadio.Checked)
            {
                mCurrentDeviceItem  = new DeviceItem();
                wizMain.NextEnabled = true;
                deviceSelection_RefreshButton.Enabled = false;
                return;
            }
            deviceSelection_RefreshButton.Enabled = true;

            DeviceEnumeratorInfo deInfo = new DeviceEnumeratorInfo(flags, Handle);
            mDeviceList = deInfo.DeviceList;
            DeviceSelectionHelper.EnumerateDevices(deInfo);

            foreach (DeviceItem deviceItem in mDeviceList)
            {
                int iRow =
                    gridDeviceSelection.Rows.Add(new object[]
                {
                    "0x" + deviceItem.VendorID, "0x" + deviceItem.ProductID, deviceItem.DeviceDescription,
                    deviceItem.Manufacturer, deviceItem.mDriverless, deviceItem.mDeviceId
                });
                gridDeviceSelection.Rows[iRow].Tag = deviceItem;
                deviceItem.ResetDirty();
            }

            wizMain.NextEnabled = (gridDeviceSelection.Rows.Count > 0);
            if (wizMain.NextEnabled && mCurrentDeviceItem == null)
            {
                mCurrentDeviceItem = (DeviceItem)gridDeviceSelection.SelectedRows[0].Tag;
            }
        }
예제 #2
0
        private void writeSetupPackageFn(object state)
        {
            mFoundLikeDevices = new List <DeviceItem>();

            rtfFinishedSatus.LoggingEnabled = true;
            mSetupPackageWritten            = mCurrentInfWriter.Write();
            rtfFinishedSatus.LoggingEnabled = false;

            if (!mSetupPackageWritten)
            {
                return;
            }

            if (mSettings.UserDeviceManufacturers == null)
            {
                mSettings.UserDeviceManufacturers = new StringCollection();
            }
            if (!mSettings.UserDeviceManufacturers.Contains(mCurrentDeviceItem.Manufacturer))
            {
                mSettings.UserDeviceManufacturers.Add(mCurrentDeviceItem.Manufacturer);
            }
            while (mSettings.UserDeviceManufacturers.Count > 5)
            {
                mSettings.UserDeviceManufacturers.RemoveAt(0);
            }

            mCurrentDeviceItem.SaveUserSettings(mSettings);
            mSettings.Last_DriverName = mCurrentDriverResource.DisplayName;
            mSettings.Save();

            // Check (by hardware ID) if connected? driverless?
            DeviceEnumeratorInfo deCheck = new DeviceEnumeratorInfo(DEIFlags.DICFG_AllClasses | DEIFlags.IncludeWindowsServices, IntPtr.Zero);

            DeviceSelectionHelper.EnumerateDevices(deCheck);


            string currentHardwareID = mCurrentDeviceItem.BuildInfHardwareID();

            foreach (DeviceItem deviceItem in deCheck.DeviceList)
            {
                if (currentHardwareID != deviceItem.BuildInfHardwareID())
                {
                    continue;
                }
                mFoundLikeDevices.Add(deviceItem);
            }
            Invoke(new GenericStateDelegate(writeSetupPackageCompletedFn), new object[] { null });
        }
예제 #3
0
        private void Remove()
        {
            DEIFlags flags = DEIFlags.DICFG_AllClasses | DEIFlags.IncludeWindowsServices;

            Cursor = Cursors.WaitCursor;

            rtfRemoveDeviceStatus.StatusFilter = RemoveStatusFilter;
            removeDeviceOptionGrid.Enabled     = false;
            removeCommand.Enabled = false;

            if (DefaultRemoveOptions.OnlyConnectedDevices)
            {
                flags = flags | DEIFlags.DICFG_Present;
            }

            try
            {
                mRemoveDialogResult = DialogResult.OK;
                rtfRemoveDeviceStatus.LoggingEnabled = true;
                InfWizardStatus.Log(CategoryType.RemoveDevice, StatusType.Info, "enumerating devices..");
                DeviceSelectionHelper.RemoveDevice(DefaultRemoveOptions, Handle, flags);

                if (DefaultRemoveOptions.DeepClean)
                {
                    DeepClean();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "Device Removal", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                rtfRemoveDeviceStatus.LoggingEnabled = false;
                Cursor = Cursors.Default;
                removeDeviceOptionGrid.Enabled = true;
            }
        }