private void Window_Closing(object sender, CancelEventArgs e) { if (_config.CloseToTray && Visibility != Visibility.Hidden) { Hide(); e.Cancel = true; } if (RecordingState != RecordingState.Stopped) { if (MessageBox.Show(Messages.GUIStopRecording, Messages.GUIStopRecordingTitle, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { e.Cancel = true; return; } UpdateRecordingNumber(); } _audioRecorder.Dispose(); if (_isSizeChanged) { _config.SetWindowSize(Name, Width, Height); } if (_isSizeChanged || _config.HasChanges()) { ConfigHandler.SaveConfig(_config); } HotkeyUtils.UnregisterAllHotkeys(GuiHelper.GetWindowHandle(this)); HotkeyUtils.GlobalHoykeyPressed -= HotkeyUtils_GlobalHoykeyPressed; }
private void settingsMenuItem_Click(object sender, RoutedEventArgs e) { SettingsWindow settingsWindow = new SettingsWindow(_config); Topmost = false; IntPtr windowHandle = GuiHelper.GetWindowHandle(this); HotkeyUtils.UnregisterAllHotkeys(windowHandle); if (settingsWindow.ShowDialog() == true) { _config = settingsWindow.Config; ApplySettings(); if (_config.HasPropertyChanged(nameof(_config.OutputFormat)) || _config.HasPropertyChanged(nameof(_config.MP3EncodingPreset))) { InitAudioDevices(); } } HotkeyUtils.RegisterAllHotkeys(windowHandle, _config.GlobalHotkeys); }