private void Window_Activated(object sender, EventArgs e) { if (!Settings.Default.PopupOnFinish) { TaskbarUtility.StopFlash(interopHelper.Handle); } }
private void MainTextBox_GotFocus(object sender, RoutedEventArgs e) { if (MainTextBox.Text == "Timer expired") { MainTextBox.Text = ToString(Settings.Default.LastTimeSpan.Ticks < 0 ? TimeSpan.Zero : Settings.Default.LastTimeSpan); } MainTextBox.SelectAll(); TaskbarUtility.StopFlash(interopHelper.Handle); }
private void UpdateProgress(TimeSpan elapsed, TimeSpan total) { var newProgress = Math.Min(100.0, 100.0 * elapsed.Ticks / total.Ticks); if (MainProgressBar.Value != newProgress) { MainProgressBar.Value = newProgress; TaskbarUtility.SetProgressValue(interopHelper.Handle, (ulong)MainProgressBar.Value, 100); } }
private void StopNotificationButton_Click(object sender, RoutedEventArgs e) { if (notification != null) { notification.Stop(); notification = null; StopNotificationButton.Visibility = System.Windows.Visibility.Collapsed; TaskbarUtility.StopFlash(interopHelper.Handle); } ; }
private void Notify() { try { notified = true; if (Settings.Default.CloseOnFinish || closeOnFinishThisTime) { sp.PlaySync(); } else if (Settings.Default.LoopNotification) { if (notification != null) { notification.Stop(); } notification = sp; notification.PlayLooping(); StopNotificationButton.Visibility = Visibility.Visible; } else { sp.Play(); } if (Settings.Default.PopupOnFinish) { Show(); WindowState = restorableWindowState; Activate(); Topmost = true; Topmost = false; } if (Settings.Default.FlashOnFinish) { TaskbarUtility.StartFlash(interopHelper.Handle); } } catch (Exception) { } }
private void StopNotificationButton_Click(object sender, RoutedEventArgs e) { if (notification != null) { notification.Stop(); notification = null; StopNotificationButton.Visibility = Visibility.Collapsed; if (MainTextBox.Text == "Timer expired") { MainTextBox.Text = ToString(Settings.Default.LastTimeSpan.Ticks < 0 ? TimeSpan.Zero : Settings.Default.LastTimeSpan); } MainTextBox.SelectAll(); MainTextBox.Focus(); TaskbarUtility.StopFlash(interopHelper.Handle); } }
private void TimerExpired() { if (!MainTextBox.IsFocused) { MainTextBox.Text = "Timer expired"; } if (notifyIcon != null) { notifyIcon.Text = "Timer expired"; } Title = "Orzeszek Timer"; MainProgressBar.Value = 100; TaskbarUtility.SetProgressState(interopHelper.Handle, TaskbarProgressState.NoProgress); if (!notified) { Notify(); } if (Settings.Default.CloseOnFinish || closeOnFinishThisTime) { closeFromTray = true; Close(); } else if (Settings.Default.LoopTimer && Settings.Default.LastTimeSpan != TimeSpan.Zero) { start = DateTime.Now; end = start.Add(Settings.Default.LastTimeSpan); notified = false; } else { updaterThread.Abort(); updaterThread = null; } }
private void Window_KeyUp(object sender, KeyEventArgs e) { TaskbarUtility.StopFlash(interopHelper.Handle); }
private void Window_MouseUp(object sender, MouseButtonEventArgs e) { TaskbarUtility.StopFlash(interopHelper.Handle); }
private void Window_Deactivated(object sender, EventArgs e) { TaskbarUtility.StopFlash(interopHelper.Handle); }
private void UpdateInterface() { while (true) { DispatcherOperation op = Dispatcher.BeginInvoke(new Action(delegate() { DateTime now = DateTime.Now; TimeSpan elapsed = now - start; TimeSpan remaining = end - now; TimeSpan total = end - start; if (remaining.Ticks <= 0) { if (!MainTextBox.IsFocused) { MainTextBox.Text = "Timer expired"; } if (notifyIcon != null) { notifyIcon.Text = "Timer expired"; } Title = "Orzeszek Timer"; MainProgressBar.Value = 100; TaskbarUtility.SetProgressState(interopHelper.Handle, TaskbarProgressState.NoProgress); if (!notified) { try { notified = true; string exePath = Assembly.GetExecutingAssembly().Location; string exeDir = new FileInfo(exePath).DirectoryName; string soundsDir = System.IO.Path.Combine(exeDir, "Sounds"); SoundPlayer sp = new SoundPlayer(System.IO.Path.Combine(soundsDir, Settings.Default.AlarmSound)); if (Settings.Default.CloseOnFinish || closeOnFinishThisTime) { sp.PlaySync(); } else if (Settings.Default.LoopNotification) { if (notification != null) { notification.Stop(); } notification = sp; notification.PlayLooping(); StopNotificationButton.Visibility = System.Windows.Visibility.Visible; } else { sp.Play(); } if (Settings.Default.PopupOnFinish) { Show(); WindowState = restorableWindowState; Activate(); Topmost = true; Topmost = false; } if (Settings.Default.FlashOnFinish) { TaskbarUtility.StartFlash(interopHelper.Handle); } } catch (Exception) { } } if (Settings.Default.CloseOnFinish || closeOnFinishThisTime) { closeFromTray = true; Close(); } else if (Settings.Default.LoopTimer && Settings.Default.LastTimeSpan != TimeSpan.Zero) { start = DateTime.Now; end = start.Add(Settings.Default.LastTimeSpan); notified = false; } else { updaterThread.Abort(); updaterThread = null; } } else { if (!MainTextBox.IsFocused) { MainTextBox.Text = ToString(remaining); } if (notifyIcon != null) { notifyIcon.Text = ToString(remaining); } Title = MainTextBox.Text; MainProgressBar.Value = Math.Min(100.0, 100.0 * elapsed.Ticks / total.Ticks); TaskbarUtility.SetProgressValue(interopHelper.Handle, (ulong)MainProgressBar.Value, 100); } } )); op.Wait(); Thread.Sleep((int)Math.Max(Math.Min((end - start).TotalSeconds / MainProgressBar.ActualWidth, 1000), 10)); } }
private void MainTextBox_GotFocus(object sender, RoutedEventArgs e) { MainTextBox.SelectAll(); TaskbarUtility.StopFlash(interopHelper.Handle); }