private void StartBT_Click(object sender, RoutedEventArgs e) { if (StartBT.Content.ToString() == "START") { dispatcherTimer.Start(); StartBT.Content = "Zatrzymaj"; TimerWidgetCB.IsEnabled = false; settingsGrid.IsEnabled = false; OperationGrid.IsEnabled = false; if (MinimalizeRB.IsChecked == true) { WindowState = WindowState.Minimized; } if (GoToTrayRB.IsChecked == true) { Hide(); notify.Visible = true; } if (TimerWidgetCB.IsChecked == true) { string color = ""; if (RedRB.IsChecked == true) { color = "red"; } if (BlackRB.IsChecked == true) { color = "black"; } if (GreenRB.IsChecked == true) { color = "green"; } if (WhiteRB.IsChecked == true) { color = "white"; } if (BlueRB.IsChecked == true) { color = "blue"; } widget = new TimerWidget(hours, minutes, seconds, color); widget.Show(); } } else { dispatcherTimer.Stop(); StartBT.Content = "START"; TimerWidgetCB.IsEnabled = true; settingsGrid.IsEnabled = true; OperationGrid.IsEnabled = true; if (widget != null) { widget.Close(); widget = null; } } }
private void Window_Closing(object sender, CancelEventArgs e) { if (widget != null) { widget.Close(); widget = null; } }