PbPercent.Text = ((pb.Value / pb.Maximum) * 100).ToString("F2") + "%" Īsync private void AggregateBattery_ReportUpdated(Battery sender, object args)Īwait Dispatcher.RunAsync(CoreDispatcherPriority. Pb.Value = Convert.ToDouble(report.RemainingCapacityInMilliwattHours) Pb.Maximum = Convert.ToDouble(report.FullChargeCapacityInMilliwattHours) (report.RemainingCapacityInMilliwattHours = null)) If ((report.FullChargeCapacityInMilliwattHours = null)|| Disable progress bar if values are null This should return a list of PnP Devices, their. You can get information on Bluetooth devices using the Get-PnpDevice cmdlet. 3 Look for the battery percentage (if supported ) of your Bluetooth device (s) on the right side. PbPercent.FontFamily = new FontFamily("Segoe UI") 2 Click/tap on Bluetooth & devices on the left side, and click/tap on Devices on the right side. PbPercent.Margin = new Thickness(0, 5, 0, 10) Pb.HorizontalAlignment = HorizontalAlignment.Left PbLabel.FontFamily = new FontFamily("Segoe UI") PbLabel.Margin = new Thickness(0,10, 0, 5) Var battery = await Battery.FromIdAsync(device.Id) ĪddReportUI(BatteryReportPanel, report, battery.DeviceId) Ĭatch Var deviceInfo = await DeviceInformation.FindAllAsync(Battery.GetDeviceSelector()) įoreach(DeviceInformation device in deviceInfo) async private void RequestIndividualBatteryReports() This example shows how to create a battery report for all batteries connected to the device. Finally, call GetReport to get the individual battery report. Then, using the Id property of the desired DeviceInformation object, create a corresponding Battery with the FromIdAsync method. Use GetDeviceSelector with the FindAllAsync method to obtain a collection of DeviceInformation objects that represent any battery controllers that are connected to the device. You can also create a BatteryReport object for individual batteries. Var aggBattery = Battery.AggregateBattery ĪddReportUI(BatteryReportPanel, report, aggBattery.DeviceId) private void RequestAggregateBatteryReport() Once you have an aggregate battery object, call GetReport to get the corresponding BatteryReport. Other times, the battery object may be null. Thus, it's possible to create a battery object even when no batteries are present. Depending on the device, sometimes the controller is attached to the physical battery and sometimes it's attached to the device enclosure. Note A Battery class actually corresponds to a battery controller. The aggregate battery represents all battery controllers connected to the device and can provide a single overall BatteryReport object. This is where the AggregateBattery class comes in. Some devices have more than one battery and it's not always obvious how each battery contributes to the overall energy capacity of the device. This topic describes how to get a battery report that includes detailed battery information (such as the charge, capacity, and status of a battery or aggregate of batteries), and handle state changes to any items in the report.Ĭode examples are from the basic battery app that's listed at the end of this topic.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |