public void PauseResumeButton_Click() { switch (mSession.State) { case Session.SessionState.Started: SessionState = Session.SessionState.Paused; break; case Session.SessionState.Paused: SessionState = Session.SessionState.Started; break; } }
private void SessionState_Change(Session.SessionState state) { switch (state) { case Session.SessionState.Started: mTimer.Start(); break; case Session.SessionState.Paused: mTimer.Pause(); break; } }
// Constructor public SessionViewModel(Session session) { // Set instance variables mSession = session; mTimer = new SecondsTimer(mSession.Interval); mSoundManager = new SoundManager(); // shuffle Session's list of image paths Random randy = new Random(); mShuffledImagePaths = mSession.ImagePaths.OrderBy(path => randy.Next()).ToList(); // Handle changes to SecondsTimer's properties mTimer.PropertyChanged += (sender, args) => { switch (args.PropertyName) { case "State": IntervalTimerState_Change(mTimer.State); break; case "RemainingSeconds": IntervalTimerRemainingSeconds_Change(mTimer.RemainingSeconds); break; } }; // Handle changes to Session's properties mSession.PropertyChanged += (sender, args) => { switch (args.PropertyName) { case "State": SessionState_Change(mSession.State); break; } }; // Initialize view to SecondsTimer's properties IntervalTimerState_Change(mTimer.State); IntervalTimerRemainingSeconds_Change(mTimer.RemainingSeconds); // Initialize view to Session's properties SessionState_Change(mSession.State); // Display first image CurrentImageIndex = 0; CurrentImagePath = mShuffledImagePaths[CurrentImageIndex]; // Start the interval timer by setting SessionState to Started SessionState = Session.SessionState.Started; }
private void SessionState_Change(Session.SessionState state) { // Set pauseResumeButton's icon by setting its Style property, // and set remainingTimeTextBlock's Background Path p; switch (state) { case Session.SessionState.Started: p = (Path)pauseResumeButton.Content; p.Style = (Style)FindResource("Icon.Pause"); remainingTimeTextBlock.Background = new SolidColorBrush(Color.FromArgb(0x7f, 0, 0, 0)); break; case Session.SessionState.Paused: p = (Path)pauseResumeButton.Content; p.Style = (Style)FindResource("Icon.Play"); remainingTimeTextBlock.Background = new SolidColorBrush(Color.FromArgb(0x7f, 255, 0, 0)); break; } }