示例#1
0
        void DeviceChanged(object o, DeviceListChangedEventArgs changed)
        {
            // Sadly we don't get any info on which device changed.
            // So we need to manually check
            var newGenerators = InternalGenerators.ToArray();

            foreach (var added in newGenerators.Except(generators))
            {
                GeneratorAdded(added);
            }
            foreach (var removed in generators.Except(newGenerators))
            {
                GeneratorRemoved(removed);
            }

            generators = generators.Intersect(newGenerators).Union(newGenerators).ToArray();

            var newPulses = InternalHeartRateMonitors.ToArray();

            foreach (var added in newPulses.Except(monitors))
            {
                MonitorAdded(added);
            }
            foreach (var removed in monitors.Except(newPulses))
            {
                MonitorRemoved(removed);
            }

            monitors = monitors.Intersect(newPulses).Union(newPulses).ToArray();
        }
示例#2
0
 public HardwareList()
 {
     list          = DeviceList.Local;
     generators    = InternalGenerators.ToArray();
     monitors      = InternalHeartRateMonitors.ToArray();
     list.Changed += DeviceChanged;
 }