public void UpdateDashboard(BaseMessageParser parser) { if (parser.GetType() == typeof(ExtendedStatusUpdateParser)) { if (_allowGetAllResponse) { BluetoothService.Instance.SendAsync(SPPMessageBuilder.Info.GetAllData()); } Dispatcher.Invoke(() => { if (BluetoothService.Instance.ActiveModel == Model.BudsPlus || BluetoothService.Instance.ActiveModel == Model.BudsLive) { ExtendedStatusUpdateParser p = (ExtendedStatusUpdateParser)parser; UpdatePlusPlacement(p.PlacementL, p.PlacementR); _lastPlacementL = p.PlacementL; _lastPlacementR = p.PlacementR; BatteryCase.Content = BluetoothService.Instance.ActiveModel == Model.Buds ? "" : $"{p.BatteryCase}%"; CaseLabel.Visibility = BluetoothService.Instance.ActiveModel == Model.Buds ? Visibility.Hidden : Visibility.Visible; } if (BluetoothService.Instance.ActiveModel == Model.BudsLive) { ExtendedStatusUpdateParser p = (ExtendedStatusUpdateParser)parser; AncToggle.SetChecked(p.NoiceCancelling); } }); } else if (parser.GetType() == typeof(StatusUpdateParser)) { if (_allowGetAllResponse) { BluetoothService.Instance.SendAsync(SPPMessageBuilder.Info.GetAllData()); } Dispatcher.Invoke(() => { if (BluetoothService.Instance.ActiveModel == Model.BudsPlus || BluetoothService.Instance.ActiveModel == Model.BudsLive) { StatusUpdateParser p = (StatusUpdateParser)parser; UpdatePlusPlacement(p.PlacementL, p.PlacementR); _lastPlacementL = p.PlacementL; _lastPlacementR = p.PlacementR; BatteryCase.Content = BluetoothService.Instance.ActiveModel == Model.Buds ? "" : $"{p.BatteryCase}%"; CaseLabel.Visibility = BluetoothService.Instance.ActiveModel == Model.Buds ? Visibility.Hidden : Visibility.Visible; } }); } else if (parser.GetType() == typeof(DebugGetAllDataParser)) { var p = (DebugGetAllDataParser)parser; UpdateBatteryPercentage((int)Math.Round(p.LeftAdcSOC), Side.L); UpdateBatteryPercentage((int)Math.Round(p.RightAdcSOC), Side.R); Dispatcher.Invoke(() => { UpdateDetails(p); }); } }
private void Instance_AncEnabledUpdateResponse(object sender, bool e) { AncToggle.SetChecked(e); }
private void Anc_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { AncToggle.Toggle(); BluetoothService.Instance.SendAsync(SPPMessageBuilder.SetANC(AncToggle.IsChecked)); }