Storyboard GetAnimationForTimer(PinTimer timer) { var item = TimersListBox.ItemContainerGenerator.ContainerFromItem(timer) as ListBoxItem; return item.Tag != null ? item.Tag as Storyboard : null; }
public TimerSettingsSetup(PinTimer timer) : this() { Timer = timer ?? new PinTimer(TimeSpan.Zero) { AudioSource = AudioItemData.ListOfPossible[0]}; DataContext = Timer; }
void DisplaySetupTimerDialog(PinTimer timer = null) { _timerSetupControl = new TimerSettingsSetup(timer); NavigationService.Navigate(new Uri("/CustomDialogPage.xaml", UriKind.Relative)); }
private void HandleTimerTap(PinTimer timer) { if (!timer.IsActive) { timer.StartTimer(); PreloadSoundForNextExpireTimer(); } else { timer.StopTimer(); timer.ResetTime(); } ConfigIdleDetectionMode(); }
private void HandleSoundAndAnimation(PinTimer obj, bool inBackground) { ListBoxItem item = TimersListBox.ItemContainerGenerator.ContainerFromItem(obj) as ListBoxItem; ConfigIdleDetectionMode(); if (item == null) _listNeedAmimationFor.Add(obj); else { StartCompleteAnimation(item); if (!String.IsNullOrEmpty(obj.ContentMessage)) ShowPopup(obj.ContentMessage, 5000); } if (!inBackground) { if (media.Source == null || System.IO.Path.GetFullPath(media.Source.OriginalString) != System.IO.Path.GetFullPath(obj.AudioSource.Path.OriginalString) || media.CurrentState == MediaElementState.AcquiringLicense || media.CurrentState == MediaElementState.Opening || media.CurrentState == MediaElementState.Individualizing) { // if sound goes through one of opening state subscribe for play it later media.MediaOpened += media_MediaOpened; media.Source = obj.AudioSource.Path; } else media.Play(); // if sound loaded and opened successful then play } }
void OnTimerCompleted(PinTimer obj, bool inBackground) { if (Dispatcher.CheckAccess()) HandleSoundAndAnimation(obj, inBackground); else Dispatcher.BeginInvoke(() => { HandleSoundAndAnimation(obj, inBackground); }); }
private void ShiftTimeForActiveTimers(PinTimer excepHandleTimer = null) { if (TimersListBox.Items.Count == 0) return; var activeTimers = TimersListBox.Items.Cast<PinTimer>().Where(w => w.IsActive && !w.IsPaused && w != excepHandleTimer).ToList(); if (activeTimers.Count() == 0) return; TimeSpan lastTime = GetLastActiveTime(); TimeSpan shiftTime = TimeSpan.FromSeconds(Math.Floor(DateTime.Now.TimeOfDay.TotalSeconds - lastTime.TotalSeconds)); activeTimers.ForEach(fe => fe.ElapsedTime -= shiftTime); }