void App_Activated(object sender, EventArgs e) { if (!firstClick) { timer = new System.Timers.Timer(1000); //one second for double click. timer.Elapsed += resetClick; timer.Start(); firstClick = true; } else { if (reader.State == readerState.stopped) { reader.play(); } else if (reader.State == readerState.paused) { if (reader.SameTextAsLastSpoken()) { reader.pause(); } else { reader.play(); } } else if (reader.State == readerState.playing) { reader.pause(); } firstClick = false; timer.Dispose(); } // source: http://stackoverflow.com/questions/13384191/how-to-remove-focus-from-wpf-window-like-in-close-event // Get the WPF window handle IntPtr hWnd = new WindowInteropHelper(this).Handle; // Look for next visible window in Z order IntPtr hNext = hWnd; do { hNext = GetWindow(hNext, GW_HWNDNEXT); }while (!IsWindowVisible(hNext)); // Bring the window to foreground SetForegroundWindow(hNext); }
private void PauseButton_Click(object sender, RoutedEventArgs e) { if (reader.canPause) { reader.pause(); if (reader.State == readerState.playing) { PauseButton.Content = "Pause"; PauseButton.Background = (Brush)this.Resources["PauseButton"]; } else { PauseButton.Content = "Unpause"; PauseButton.Background = (Brush)this.Resources["PlayButton"]; PlayButton.Content = "Restart"; PlayButton.Background = (Brush)this.Resources["RestartButton"]; } } }