コード例 #1
0
        public async void LoadAsync()
        {
            // While WinRT designer can show you actual available devices it can also cause weird stuff. (like "Element not found!" exception or VS crash)
#if SILVERLIGHT
            if (DesignerProperties.IsInDesignTool)
#elif NETFX_CORE
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
#endif
            {
                // Show some devices in design time.
                Devices.Add(new DeviceInformation {
                    DisplayName = "Mock device"
                });
                Devices.Add(new DeviceInformation {
                    DisplayName = "HxM device"
                });

                HeartBeatSensorData                    = new HeartBeatSensorData();
                HeartBeatSensorData.Battery            = 90;
                HeartBeatSensorData.Distance           = 23.3452;
                HeartBeatSensorData.Firmware           = "9500.550.V1f";
                HeartBeatSensorData.Hardware           = "9500.550.V1f";
                HeartBeatSensorData.HeartBeatPerMinute = 67;
                HeartBeatSensorData.TotalHeartBeats    = 234;
                HeartBeatSensorData.Stride             = 123;
                HeartBeatSensorData.Speed              = 5.456;
                HeartBeatSensorData.IsAvailable        = true;
                HeartBeatSensorData.IsStrideAvailabe   = true;

                OnPropertyChanged("HeartBeatSensorData");

                return;
            }

            // Get devices in platform independent data structure.
            // Method sensorController.ConnectToDeviceAsync will figure out what to do with it.
            var devices = await devicesController.GetAllDevicesAsync();

            foreach (var device in devices)
            {
                Devices.Add(device);
            }
        }