Esempio n. 1
0
 public void SearchDevice(ref DeviceEnumerator.Device[] devices)
 {
     try
     {
         deviceTable.Clear();
         List <DeviceEnumerator.Device> deviceList = new List <DeviceEnumerator.Device>();
         deviceList = DeviceEnumerator.EnumerateDevices();
         deviceList.Sort((x, y) => { return(x.Name.CompareTo(y.Name)); });
         foreach (DeviceEnumerator.Device item in deviceList)
         {
             deviceTable.Rows.Add(
                 deviceTable.Rows.Count + 1,
                 item.Index,
                 item.FullName,
                 item.Name,
                 item.Tooltip);
         }
         devices = deviceList.ToArray();
     }
     catch (Exception ex)
     {
         StackFrame[] stackFrames = new StackTrace(true).GetFrames();
         clsLogFile.LogTryCatch(stackFrames, ex.Message, true, true);
     }
 }
Esempio n. 2
0
        private void UpdateDeviceList()
        {
            try
            {
                /* 向設備列舉器詢問設備列表。 */
                List <DeviceEnumerator.Device> list = DeviceEnumerator.EnumerateDevices();

                /* 將每個新設備添加到列表中。 */
                foreach (DeviceEnumerator.Device device in list)
                {
                    ListViewItem item = new ListViewItem(device.Name);
                    if (device.Tooltip.Length > 0)
                    {
                        item.ToolTipText = device.Tooltip;
                    }
                    item.Tag = device;

                    //******//
                    try
                    {
                        // 使用設備數據中的索引打開圖像提供者。
                        m_imageProvider.Open(device.Index);
                    }
                    catch (Exception e)
                    {
                        ShowException(e, m_imageProvider.GetLastErrorMessage());
                    }
                    //*******//
                }
            }
            catch (Exception e)
            {
                ShowException(e, m_imageProvider.GetLastErrorMessage());
            }
        }
Esempio n. 3
0
        public SystemTrayViewModel()
        {
            ActiveIcon = "Resources/octopode_icon.ico";
            device     = new KrakenDevice(DeviceEnumerator.EnumerateKrakenX62Devices().First());
            Task.Run(() => RefreshControllerState());
            device.StartReading();


            var key = Registry.CurrentUser.OpenSubKey("Software", true);

            if (key == null)
            {
                Console.Error.WriteLine("Could not open Registry Key");
                return;
            }

            appKey = key.OpenSubKey("Octopode", true);
            if (appKey == null)
            {
                appKey = key.CreateSubKey("Octopode", true, RegistryOptions.None);
            }

            LoadProfile();

            logoManager = new LightningManager(LightChannel.Logo);
            rimManager  = new LightningManager(LightChannel.Rim);

            logoManager.OnNewLightSetting += LightingManagerCallback;
            rimManager.OnNewLightSetting  += LightingManagerCallback;

            commander = new CommandController(device.usbDevice);
        }
Esempio n. 4
0
        private void OnThreadProc()
        {
            var token = _tokenSource.Token;

            var device = DeviceEnumerator.GetWaveInDeviceById(Options.DeviceId);

            if (device == null)
            {
                throw new InvalidOperationException($"Device '{Options.DeviceId}' is not found");
            }

            var waveFormat = new WaveFormat(44100, 16, 2);

            using (var input = new WaveInput(device, waveFormat))
            {
                input.OnDataReady += OnDataReady;
                input.Start();

                Console.WriteLine($"Wave input is started ({waveFormat})");

                while (!token.IsCancellationRequested)
                {
                    Thread.Sleep(10);
                }

                input.Stop();
            }
        }
Esempio n. 5
0
        public WaveInput(WaveInputDevice device, WaveFormat format)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }
            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            var devices = DeviceEnumerator.GetWaveInDevices();

            if (devices.All(d => d.DeviceId != device.DeviceId))
            {
                throw new ArgumentException("Cannot find specified device");
            }

            Debug.WriteLine(device.ToString());

            _locker = new object();
            _device = device;
            _format = format;

            _isStarted = false;
        }
Esempio n. 6
0
        protected void Initialize()
        {
            RawInputParser = new RawInputParser();
            WindowCreator  = new WindowCreator(RawInputParser);
            var windowHandle = WindowCreator.CreateWindow();

            Devices = new DeviceEnumerator(RawInputParser, windowHandle);
        }
Esempio n. 7
0
 static void Main(string[] args)
 {
     using (var enumerator = new DeviceEnumerator(DeviceType.Any))
     {
         enumerator.DeviceListChanged += Enumerator_DeviceListChanged;
         Console.ReadLine();
     }
 }
Esempio n. 8
0
 private void BindTypeList()
 {
     cbxType.Items.Clear();
     foreach (var bdd in DeviceEnumerator.SelectByType <IUlaDevice>())
     {
         cbxType.Items.Add(bdd);
     }
     cbxType.Sorted = true;
 }
Esempio n. 9
0
        public static async Task Main(string[] args)
        {
            DeviceEnumerator en = new DeviceEnumerator();
            var arr             = await en.FindAll <ISerialDevice <SerialDeviceName> >().ToArrayAsync();

            ISerialDevice <SerialDeviceName> device = arr[0];

            device.Start();
            await device.Send(new byte[] { 0, 1, 2 });
        }
Esempio n. 10
0
        // Lists all devices, and for each device all processes that are currently playing sound using that device
        public static List <SoundInfoDevice> getSoundInfo()
        {
            List <SoundInfoDevice> soundInfoDevices = new List <SoundInfoDevice>();

            DeviceEnumerator    enumerator       = new DeviceEnumerator();
            IMMDeviceEnumerator deviceEnumerator = (IMMDeviceEnumerator)enumerator;
            IMMDeviceCollection deviceCollection = deviceEnumerator.EnumAudioEndpoints(EDataFlow.eRender, DeviceStatemask.DEVICE_STATE_ACTIVE);
            uint deviceCount = deviceCollection.GetCount();

            for (uint i = 0; i < deviceCount; i++)
            {
                SoundInfoDevice soundInfoDevice = new SoundInfoDevice();
                soundInfoDevices.Add(soundInfoDevice);

                IMMDevice device   = deviceCollection.Item(i);
                string    deviceId = device.GetId();
                soundInfoDevice.ID = deviceId;
                IMMPropertyStore propertyStore         = device.OpenPropertyStore(ProperyStoreMode.STGM_READ);
                PropertyKey      propertyKeyDeviceDesc = new PropertyKey();
                propertyKeyDeviceDesc.fmtid = new Guid(0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0);
                propertyKeyDeviceDesc.pid   = 2;
                PropVariant deviceNamePtr = propertyStore.GetValue(ref propertyKeyDeviceDesc);
                string      deviceName    = Marshal.PtrToStringUni(deviceNamePtr.pszVal);
                soundInfoDevice.name = deviceName;

                Guid guidAudioSessionManager2             = new Guid("77AA99A0-1BD6-484F-8BC7-2C654C9A9B6F");
                IAudioSessionManager2 audioSessionManager = (IAudioSessionManager2)device.Activate(ref guidAudioSessionManager2, (int)ClsCtx.CLSCTX_ALL, IntPtr.Zero);


                IAudioSessionEnumerator sessionEnumerator = audioSessionManager.GetSessionEnumerator();

                int sessionCount = sessionEnumerator.GetCount();
                for (int j = 0; j < sessionCount; j++)
                {
                    IAudioSessionControl  audioSessionControl  = sessionEnumerator.GetSession(j);
                    IAudioSessionControl2 audioSessionControl2 = (IAudioSessionControl2)audioSessionControl;
                    AudioSessionState     state = audioSessionControl.GetState();
                    if (state == AudioSessionState.AudioSessionStateActive)
                    {
                        SoundInfoSession soundInfoSession = new SoundInfoSession();
                        soundInfoDevice.sessions.Add(soundInfoSession);

                        string displayName = audioSessionControl.GetDisplayName();
                        string iconPath    = audioSessionControl.GetIconPath();
                        int    processId   = audioSessionControl2.GetProcessId();
                        string processName = Process.GetProcessById(processId).MainWindowTitle;

                        soundInfoSession.pid        = processId;
                        soundInfoSession.windowName = processName;
                    }
                }
            }

            return(soundInfoDevices);
        }
Esempio n. 11
0
        public static Dictionary <string, CameraProperty> Read(PYLON_DEVICE_HANDLE deviceHandle, string fullName)
        {
            Dictionary <string, CameraProperty> properties = new Dictionary <string, CameraProperty>();

            // Enumerate devices again to make sure we have the correct device index and find the device class.
            DeviceEnumerator.Device        device  = null;
            List <DeviceEnumerator.Device> devices = DeviceEnumerator.EnumerateDevices();

            foreach (DeviceEnumerator.Device candidate in devices)
            {
                if (candidate.FullName != fullName)
                {
                    continue;
                }

                device = candidate;
                break;
            }

            if (device == null)
            {
                return(properties);
            }

            string deviceClass = "BaslerGigE";

            try
            {
                deviceClass = Pylon.DeviceInfoGetPropertyValueByName(device.DeviceInfoHandle, Pylon.cPylonDeviceInfoDeviceClassKey);
            }
            catch
            {
                log.ErrorFormat("Could not read Basler device class. Assuming BaslerGigE.");
            }

            properties.Add("width", ReadIntegerProperty(deviceHandle, "Width"));
            properties.Add("height", ReadIntegerProperty(deviceHandle, "Height"));
            properties.Add("enableFramerate", ReadBooleanProperty(deviceHandle, "AcquisitionFrameRateEnable"));

            if (deviceClass == "BaslerUsb")
            {
                properties.Add("framerate", ReadFloatProperty(deviceHandle, "AcquisitionFrameRate"));
                properties.Add("exposure", ReadFloatProperty(deviceHandle, "ExposureTime"));
                properties.Add("gain", ReadFloatProperty(deviceHandle, "Gain"));
            }
            else
            {
                properties.Add("framerate", ReadFloatProperty(deviceHandle, "AcquisitionFrameRateAbs"));
                properties.Add("exposure", ReadFloatProperty(deviceHandle, "ExposureTimeAbs"));
                properties.Add("gain", ReadIntegerProperty(deviceHandle, "GainRaw"));
            }

            return(properties);
        }
Esempio n. 12
0
        protected override int OnRun(GetDevicesOptions options)
        {
            var devices = DeviceEnumerator.GetWaveInDevices();

            foreach (var device in devices)
            {
                Console.WriteLine(device.ToString());
            }

            return(0);
        }
Esempio n. 13
0
        public JoystickConfigViewModel()
        {
            using (var enumerator = new DeviceEnumerator())
            {
                Devices = new ReadOnlyObservableCollection <DeviceInformation>(
                    new ObservableCollection <DeviceInformation>(
                        enumerator.GetDevices(new[]
                {
                    VjdStat.VJD_STAT_BUSY,
                    VjdStat.VJD_STAT_FREE,
                    VjdStat.VJD_STAT_OWN,
                }).OrderBy(ob => ob.Id)));

                this.SelectedDeviceItem = Devices.FirstOrDefault();
            }

            //using (var input = new DirectInput())
            //{
            //  var inputDevices = input.GetDevices().Where(w => w.ProductGuid.Equals(DeviceEnumerator.VJoyProductGuid)).ToArray();
            //  foreach (var deviceInstance in inputDevices)
            //  {
            //    var device = new Joystick(input, deviceInstance.ProductGuid);

            //    device.Properties.BufferSize = 128;

            //    device.Acquire();
            //    JoystickState joystickState = new JoystickState();
            //    device.GetCurrentState(ref joystickState);
            //    //Debug.WriteLine(joystickState.Y);
            //    var x = device.GetObjects(DeviceObjectTypeFlags.All).FirstOrDefault(fd => !fd.ReportId.Equals(0));



            //    Debug.WriteLine(device.Properties.JoystickId);
            //    Debug.WriteLine(device.Properties.ProductName);
            //    Debug.WriteLine(device.Properties.ProductId);
            //    //Debug.WriteLine(device.Properties.UserName);
            //    Debug.WriteLine(device.Properties.InstanceName);
            //    Debug.WriteLine(device.Properties.InterfacePath);
            //    //Debug.WriteLine(device.Properties.PortDisplayName);
            //  }

            //  using (var helper = new JoystickHelper())
            //  {
            //    helper.StartCapture(inputDevices[0].ProductGuid);
            //  }


            //}
        }
Esempio n. 14
0
        public void CanGetValidDevices()
        {
            DeviceEnumerator e = new DeviceEnumerator(new Context());

            Assert.True(e.ValidDevices.Count > 0);
            DeviceConfig d = e.ValidDevices[0];

            Assert.True(d.Id.IsNotNullOrEmpty());
            Assert.True(d.Config.IsNotNullOrEmpty());
            Assert.True(d.Description.IsNotNullOrEmpty());
            Assert.True(d.Details.IsNotNullOrEmpty());
            Assert.True(e.GetConfigSource().IsNotNullOrEmpty());
            e.Free();
        }
Esempio n. 15
0
        private Device FindDevice()
        {
            DeviceEnumerator enumerator = new DeviceEnumerator("pwrdaq://");

            while (enumerator.MoveNext())
            {
                Device current = (Device)enumerator.Current;
                if (current.GetDeviceName().Substring(4, 2) == "AO")
                {
                    this.m_Logger.DebugFormat("{0} > {1}", base.GetType().Name, "Analog out device found");
                    return(current);
                }
            }
            return(null);
        }
Esempio n. 16
0
        /// <summary>
        /// Refreshes the Device-list.
        /// </summary>
        public void RefreshDevices()
        {
            logger.Info("Refreshing devices list...");


            try {
                rawDevices = DeviceEnumerator.EnumerateDevices();
            }
            catch (Exception ex) {
                logger.Fatal("ERROR Refreshing devices list: " + ex.ToString() + ".");
            }
            finally {
                logger.Info("Successfully refreshed the device list.");
            }
        }
Esempio n. 17
0
        private void BindTypeList()
        {
            cbxType.Items.Clear();
            foreach (var bdd in DeviceEnumerator.SelectByType <IMemoryDevice>())
            {
                cbxType.Items.Add(bdd);
            }
            cbxType.Sorted = true;

            cbxRomSet.Items.Clear();
            foreach (var name in RomPack.GetRomSetNames())
            {
                cbxRomSet.Items.Add(name);
            }
            cbxRomSet.Sorted = true;
        }
        /// <summary>
        /// Finds nearby devices that are running the Internet Protocol Support
        /// Service (IPSS) and the IPv6ToBle packet processing service.
        /// </summary>
        private async Task EnumerateNearbySupportedDevices()
        {
            // Start the supported device enumerator and subscribe to the
            // EnumerationCompleted event
            enumerator = new DeviceEnumerator();

            Debug.WriteLine("Looking for nearby supported devices...");

            enumerator.EnumerationCompleted += WatchForEnumerationCompletion;
            enumerator.StartSupportedDeviceEnumerator();

            // Spin while enumeration is in progress
            while (!enumerationCompleted)
            {
                ;
            }

            Debug.WriteLine("Enumeration of nearby supported devices" +
                            " complete."
                            );

            // Stop the device watcher
            enumerator.StopSupportedDeviceEnumerator();

            // Filter found devices for supported ones
            Debug.WriteLine("Filtering devices for supported services...");

            await enumerator.PopulateSupportedDevices();

            Debug.WriteLine("Filtering for supported devices complete.");

            if (enumerator.SupportedBleDevices != null)
            {
                supportedBleDevices = enumerator.SupportedBleDevices;
                Debug.WriteLine($"Found {supportedBleDevices.Count} devices");
            }
            else
            {
                Debug.WriteLine("No nearby supported devices found.");
            }

            if (enumerator != null)
            {
                enumerator.EnumerationCompleted -= WatchForEnumerationCompletion;
                enumerator = null;
            }
        }
Esempio n. 19
0
        public static Dictionary <string, CameraProperty> Read(PYLON_DEVICE_HANDLE deviceHandle, string fullName)
        {
            Dictionary <string, CameraProperty> properties = new Dictionary <string, CameraProperty>();

            // Enumerate devices again to make sure we have the correct device index and find the device class.
            DeviceEnumerator.Device        device  = null;
            List <DeviceEnumerator.Device> devices = DeviceEnumerator.EnumerateDevices();

            foreach (DeviceEnumerator.Device candidate in devices)
            {
                if (candidate.FullName != fullName)
                {
                    continue;
                }

                device = candidate;
                break;
            }

            if (device == null)
            {
                return(properties);
            }

            string deviceClass = "BaslerGigE";

            try
            {
                deviceClass = Pylon.DeviceInfoGetPropertyValueByName(device.DeviceInfoHandle, Pylon.cPylonDeviceInfoDeviceClassKey);
            }
            catch
            {
                log.ErrorFormat("Could not read Basler device class. Assuming BaslerGigE.");
            }

            properties.Add("width", ReadIntegerProperty(deviceHandle, "Width"));
            properties.Add("height", ReadIntegerProperty(deviceHandle, "Height"));

            // Camera properties in Kinovea combine the value and the "auto" flag.
            // We potentially need to read several Basler camera properties to create one Kinovea camera property.
            // Furthermore, some properties name or type depends on whether the camera is USB or GigE.
            ReadFramerate(deviceHandle, deviceClass, properties);
            ReadExposure(deviceHandle, deviceClass, properties);
            ReadGain(deviceHandle, deviceClass, properties);

            return(properties);
        }
Esempio n. 20
0
 public DeviceSearchForm()
 {
     InitializeComponent();
     DialogResult = DialogResult.Cancel;
     Task.Run(() => {
         _enumerator = new DeviceEnumerator(DeviceType.Brainbit);
         _enumerator.DeviceListChanged += (sender, args) =>
         {
             BeginInvoke((MethodInvoker) delegate
             {
                 _deviceListBox.Items.Clear();
                 _deviceListBox.Items.AddRange(_enumerator.Devices.Select(x => new DeviceWrapper(x))
                                               .ToArray <object>());
             });
         };
     });
 }
Esempio n. 21
0
        static void Main(string[] args)
        {
            var devices = new List <HidDevice>(DeviceEnumerator.EnumerateKrakenX62Devices());
            var tasks   = new List <Task>();

            var deviceList = new List <HidDevice>(DeviceEnumerator.EnumerateKrakenX62Devices());

            if (deviceList.Count < 1)
            {
                Console.WriteLine("No Kraken X62 device found!");
                return;
            }
            var device = new KrakenDevice(deviceList[0]);

            var messages = KrakenDevice.GenerateCoolingMessage(false, true, 25,
                                                               25,
                                                               25,
                                                               25,
                                                               25,
                                                               25,
                                                               25,
                                                               25,
                                                               35,
                                                               45,
                                                               55,
                                                               75,
                                                               100,
                                                               100,
                                                               100,
                                                               100,
                                                               100,
                                                               100,
                                                               100,
                                                               100,
                                                               100);
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            foreach (var message in messages)
            {
                device.Write(message);
            }
            stopwatch.Start();
            Console.WriteLine($"Time taken: {stopwatch.ElapsedMilliseconds}ms - Avg: {stopwatch.ElapsedMilliseconds / (float) messages.Length}ms");
        }
        public override void Connect()
        {
            //Stop,and Close
            m_imageProvider.Stop();
            m_imageProvider.Close();
            setStatus(GrabInstruction.Connect, GrabStage.Closed, GrabState.Idle);
            Status.IsConnection = false;


            List <DeviceEnumerator.Device> list = DeviceEnumerator.EnumerateDevices();
            var device = list.FirstOrDefault();

            if (device != null)
            {
                m_imageProvider.Open(device.Index);
                setStatus(GrabInstruction.Connect, GrabStage.Connected, GrabState.Idle);
                Status.IsConnection = true;
            }
        }
Esempio n. 23
0
        public static Dictionary <string, CameraProperty> Read(PYLON_DEVICE_HANDLE deviceHandle, string fullName)
        {
            Dictionary <string, CameraProperty> properties = new Dictionary <string, CameraProperty>();

            // Enumerate devices again to make sure we have the correct device index and find the device class.
            DeviceEnumerator.Device        device  = null;
            List <DeviceEnumerator.Device> devices = DeviceEnumerator.EnumerateDevices();

            foreach (DeviceEnumerator.Device candidate in devices)
            {
                if (candidate.FullName != fullName)
                {
                    continue;
                }

                device = candidate;
                break;
            }

            if (device == null)
            {
                return(properties);
            }

            try
            {
                properties.Add("width", ReadIntegerProperty(deviceHandle, "Width", "WidthMax"));
                properties.Add("height", ReadIntegerProperty(deviceHandle, "Height", "HeightMax"));

                // Camera properties in Kinovea combine the value and the "auto" flag.
                // We potentially need to read several Basler camera properties to create one Kinovea camera property.
                ReadFramerate(deviceHandle, properties);
                ReadExposure(deviceHandle, properties);
                ReadGain(deviceHandle, properties);
            }
            catch (Exception e)
            {
                log.ErrorFormat("Error while reading Basler camera properties. {0}.", e.Message);
            }


            return(properties);
        }
Esempio n. 24
0
        public CallibriSearchForm(IReadOnlyCollection <string> exclude)
        {
            InitializeComponent();
            DialogResult = DialogResult.Cancel;
            _enumerator  = new DeviceEnumerator(DeviceType.Callibri);
            _enumerator.DeviceListChanged += (sender, args) =>
            {
                if (!IsHandleCreated)
                {
                    return;
                }

                BeginInvoke((MethodInvoker) delegate
                {
                    var foundDevices = _enumerator.Devices
                                       .Where(info => !exclude.Contains(new DeviceWrapper(info).AddressString))
                                       .ToArray();

                    var disappearedDevices = _deviceListBox.Items
                                             .OfType <DeviceWrapper>()
                                             .Select(x => (DeviceInfo)x)
                                             .Except(foundDevices)
                                             .ToArray();
                    foreach (var disappearedDevice in disappearedDevices)
                    {
                        _deviceListBox.Items.Remove(disappearedDevice);
                    }

                    var newDevices = foundDevices
                                     .Except(_deviceListBox.Items
                                             .OfType <DeviceWrapper>()
                                             .Select(x => (DeviceInfo)x))
                                     .Select(info => new DeviceWrapper(info))
                                     .ToArray();
                    if (newDevices.Length > 0)
                    {
                        _deviceListBox.Items.AddRange(newDevices);
                    }
                });
            };
        }
Esempio n. 25
0
        private void BindDeviceList()
        {
            lstDevices.Items.Clear();
            lstDevices_SelectedIndexChanged(lstDevices, EventArgs.Empty);
            var catIndex = GetSelectedCategoryIndex();

            if (catIndex < 0)
            {
                return;
            }
            var category = (BusDeviceCategory)lstCategory.Items[catIndex].Tag;
            var list     = new List <BusDeviceDescriptor>();

            list.AddRange(DeviceEnumerator.SelectByCategoryWithout(category, GetIgnoreTypes()));
            list.Sort(DeviceNameComparison);
            foreach (var bdd in list)
            {
                lstDevices.Items.Add(bdd);
            }
            //lstDevices.SelectedIndices.Add(0);
        }
Esempio n. 26
0
        internal AyeBlinkinTray()
        {
            trayIcon = new NotifyIcon()
            {
                ContextMenuStrip = MakeContextMenuStrip(),
                Icon             = Icons.Program,
                Visible          = true,
                Text             = AyeBlinkin.Name
            };
            trayIcon.MouseUp        += LeftClickOpenMenu;
            Settings.Model.uiContext = SynchronizationContext.Current;

            settingsForm = new SettingsForm();
            Settings.Model.PropertyChanged += buildPatternOptions;
            Settings.Model.SerialComs       = WindowsEvents.GetUsbDevicePorts();
            Settings.Model.Adapters         = DeviceEnumerator.GetAdapters();
            WasapiSoundCapture.Stop();
#if DEBUG
            OpenSettingsForm(null, null);
#endif
        }
Esempio n. 27
0
 /* Updates the list of available devices in the upper left area. */
 private void UpdateDeviceList()
 {
     try
     {
         /* Clear the device list. */
         deviceListView.Items.Clear();
         /* Ask the device enumerator for a list of devices. */
         List <DeviceEnumerator.Device> list = DeviceEnumerator.EnumerateDevices();
         /* Add each device to the list. */
         foreach (DeviceEnumerator.Device device in list)
         {
             ListViewItem item = new ListViewItem(device.Name);
             item.Tag = device; /* Attach the device data. */
             deviceListView.Items.Add(item);
         }
     }
     catch (Exception e)
     {
         ShowException(e, m_imageProvider.GetLastErrorMessage());
     }
 }
Esempio n. 28
0
        private void BindCategoryList()
        {
            lstCategory.Items.Clear();
            lstCategory.SelectedIndices.Clear();
            var list = new List <BusDeviceCategory>();

            foreach (var bdd in DeviceEnumerator.SelectWithout(GetIgnoreTypes()))
            {
                if (!list.Contains(bdd.Category))
                {
                    list.Add(bdd.Category);
                }
            }
            list.Sort();
            foreach (var category in list)
            {
                ListViewItem lvi = new ListViewItem();
                lvi.Tag        = category;
                lvi.Text       = string.Format("{0}", category);
                lvi.ImageIndex = FormMachineSettings.FindImageIndex(category);
                lstCategory.Items.Add(lvi);
            }
            lstCategory.SelectedIndices.Add(0);
        }
Esempio n. 29
0
        public override List <CameraSummary> DiscoverCameras(IEnumerable <CameraBlurb> blurbs)
        {
            List <CameraSummary> summaries = new List <CameraSummary>();

            // We don't do the discover step every time to avoid UI freeze since Enumerate takes some time.
            if (discoveryStep > 0)
            {
                discoveryStep = (discoveryStep + 1) % discoverySkip;
                foreach (CameraSummary summary in cache.Values)
                {
                    summaries.Add(summary);
                }

                return(summaries);
            }

            discoveryStep = 1;
            List <CameraSummary> found = new List <CameraSummary>();

            List <DeviceEnumerator.Device> devices = DeviceEnumerator.EnumerateDevices();

            foreach (DeviceEnumerator.Device device in devices)
            {
                string identifier = device.FullName;

                bool cached = cache.ContainsKey(identifier);
                if (cached)
                {
                    deviceIndices[identifier] = device.Index;
                    summaries.Add(cache[identifier]);
                    found.Add(cache[identifier]);
                    continue;
                }

                string             alias            = device.Name;
                Bitmap             icon             = null;
                SpecificInfo       specific         = new SpecificInfo();
                Rectangle          displayRectangle = Rectangle.Empty;
                CaptureAspectRatio aspectRatio      = CaptureAspectRatio.Auto;
                deviceIndices[identifier] = device.Index;

                if (blurbs != null)
                {
                    foreach (CameraBlurb blurb in blurbs)
                    {
                        if (blurb.CameraType != this.CameraType || blurb.Identifier != identifier)
                        {
                            continue;
                        }

                        alias            = blurb.Alias;
                        icon             = blurb.Icon ?? defaultIcon;
                        displayRectangle = blurb.DisplayRectangle;
                        if (!string.IsNullOrEmpty(blurb.AspectRatio))
                        {
                            aspectRatio = (CaptureAspectRatio)Enum.Parse(typeof(CaptureAspectRatio), blurb.AspectRatio);
                        }

                        // Restore saved parameters.
                        specific = SpecificInfoDeserialize(blurb.Specific);
                        break;
                    }
                }

                icon = icon ?? defaultIcon;

                CameraSummary summary = new CameraSummary(alias, device.Name, identifier, icon, displayRectangle, aspectRatio, specific, this);

                summaries.Add(summary);
                found.Add(summary);
                cache.Add(identifier, summary);
            }

            List <CameraSummary> lost = new List <CameraSummary>();

            foreach (CameraSummary summary in cache.Values)
            {
                if (!found.Contains(summary))
                {
                    lost.Add(summary);
                }
            }

            foreach (CameraSummary summary in lost)
            {
                cache.Remove(summary.Identifier);
            }

            return(summaries);
        }
        private String SetAutoName()
        {
            String baseName = GetBaseName();

            DeviceEnumerator devices = new DeviceEnumerator(ApplicationSettings.DeviceManagerList);
            String newName = MackayFisher.Utilities.UniqueNameResolver<DeviceManagerDeviceSettings>.ResolveUniqueName(
                baseName, devices, this);
            SetValue("name", newName, "Name", true);
            HasAutoName = true;
            return newName;
        }
Esempio n. 31
0
 public List <MMDevice> GetAllDevices()
 {
     return(DeviceEnumerator.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active).ToList());
 }
 public void RefreshAllDevices()
 {
     DeviceEnumerator deviceEnumerator = new DeviceEnumerator(_DeviceManagerList);
     deviceEnumerator.Reset();
     _AllDevicesList.Clear();
     _AllConsolidationDevicesList.Clear();
     while (deviceEnumerator.MoveNext())
     {
         _AllDevicesList.Add(deviceEnumerator.Current);
         DeviceSettings ds = deviceEnumerator.Current.DeviceSettings;
         if (ds != null && ds.DeviceType == DeviceType.Consolidation)
             _AllConsolidationDevicesList.Add(deviceEnumerator.Current);
     }
 }