private async Task ExecuteDeleteItemCommand(IAimTimerListItemViewModel aimTimerListItemViewModel) { if (await _alertManager.DisplayAlert("Warning!", "Would you like to remove the timer completely?", "Yes", "No")) { _aimTimerService.DeleteAimTimer(aimTimerListItemViewModel.GetAimTimerItem().AimTimer); AimTimerListItemViewModels.Remove(aimTimerListItemViewModel); } }
private void OnItemUpdated(IAimTimerItem aimTimerItem) { var result = AimTimerListItemViewModels.FirstOrDefault(i => i.GetAimTimerItem() == aimTimerItem); if (result == null) { //_aimTimerNotificationService.Stop(); result = _aimTimerItemViewModelFactory.Create(aimTimerItem); AimTimerListItemViewModels.Add(result); //_aimTimerNotificationService.Start(); } result.Refresh(); }
public void Init() { //_aimTimerNotificationService.Stop(); AimTimerListItemViewModels.CollectionChanged -= AimTimerItemViewModels_CollectionChanged; //_aimTimerNotificationService.OnStatusChanged -= AimTimerNotificationService_OnStatusChanged; _messagingCenter.Unsubscribe <IAimTimerItem>(this, MessagingCenterMessages.AimTimerUpdated); AimTimerListItemViewModels.Clear(); foreach (var aimTimerItem in _aimTimerService.GetActiveAimTimers()) { AimTimerListItemViewModels.Add(_aimTimerItemViewModelFactory.Create(aimTimerItem)); } //_aimTimerNotificationService.SetItemsToFollow(AimTimerListItemViewModels.Select(i => i.GetAimTimerItem()).ToList()); AimTimerListItemViewModels.CollectionChanged += AimTimerItemViewModels_CollectionChanged; //_aimTimerNotificationService.OnStatusChanged += AimTimerNotificationService_OnStatusChanged; //_aimTimerNotificationService.Start(); _messagingCenter.Subscribe <IAimTimerItem>(this, MessagingCenterMessages.AimTimerUpdated, OnItemUpdated); InitTimer(); OnPropertyChanged(nameof(Title)); }