diff --git a/DiscordAudioStream/MainForm.cs b/DiscordAudioStream/MainForm.cs index d356913..7d2d789 100644 --- a/DiscordAudioStream/MainForm.cs +++ b/DiscordAudioStream/MainForm.cs @@ -157,33 +157,33 @@ private void RefreshAreaInfo() if (windowIndex == -1) { // Index right before first Window: Custom area - hideTaskbarCheckBox.Enabled = false; captureState.Target = CaptureState.CaptureTarget.CustomArea; } else if (windowIndex >= 0) { // Window - hideTaskbarCheckBox.Enabled = false; captureState.WindowHandle = processHandleList[windowIndex]; } else { // Screen - hideTaskbarCheckBox.Enabled = true; - if (Screen.AllScreens.Length > 1 && areaComboBox.SelectedIndex == numberOfScreens - 1) { // All screens - hideTaskbarCheckBox.Enabled = false; captureState.Target = CaptureState.CaptureTarget.AllScreens; } else { // Single screen - hideTaskbarCheckBox.Enabled = true; captureState.Screen = Screen.AllScreens[areaComboBox.SelectedIndex]; } } + + hideTaskbarCheckBox.Enabled = captureState.HideTaskbarSupported; + if (captureState.HideTaskbarSupported) + { + captureState.HideTaskbar = hideTaskbarCheckBox.Checked; + } } private void RefreshAudioDevices() @@ -487,10 +487,11 @@ private void settingsBtn_Click(object sender, EventArgs e) { SettingsForm settingsBox = new SettingsForm(darkMode, captureState); settingsBox.Owner = this; - if (this.TopMost) - { - settingsBox.TopMost = true; - } + settingsBox.CaptureMethodChanged += RefreshAreaInfo; + + // If this window is topmost, settings is too + if (TopMost) settingsBox.TopMost = true; + settingsBox.ShowDialog(); } diff --git a/DiscordAudioStream/ScreenCapture/CaptureState.cs b/DiscordAudioStream/ScreenCapture/CaptureState.cs index 705f964..faf825c 100644 --- a/DiscordAudioStream/ScreenCapture/CaptureState.cs +++ b/DiscordAudioStream/ScreenCapture/CaptureState.cs @@ -60,6 +60,17 @@ public bool HideTaskbar } } + // True if this method supports hiding the taskbar + public bool HideTaskbarSupported + { + get + { + // Only BitBlt screen capture supports hiding taskbar + if (Target != CaptureTarget.Screen) return false; + return (ScreenMethod == ScreenCaptureMethod.BitBlt); + } + } + // What kind of item are we capturing now? public CaptureTarget Target { get diff --git a/DiscordAudioStream/SettingsForm.cs b/DiscordAudioStream/SettingsForm.cs index eeea61a..c7fef71 100644 --- a/DiscordAudioStream/SettingsForm.cs +++ b/DiscordAudioStream/SettingsForm.cs @@ -8,7 +8,10 @@ namespace DiscordAudioStream { partial class SettingsForm : Form { - readonly CaptureState captureState; + public delegate void CaptureMethodChangedDelegate(); + public event CaptureMethodChangedDelegate CaptureMethodChanged; + + private readonly CaptureState captureState; public SettingsForm(bool darkMode, CaptureState state) { @@ -123,11 +126,13 @@ private void autoExitCheckbox_CheckedChanged(object sender, EventArgs e) private void fullscreenMethodComboBox_SelectedIndexChanged(object sender, EventArgs e) { captureState.ScreenMethod = (CaptureState.ScreenCaptureMethod) fullscreenMethodComboBox.SelectedIndex; + CaptureMethodChanged?.Invoke(); } private void windowMethodComboBox_SelectedIndexChanged(object sender, EventArgs e) { captureState.WindowMethod = (CaptureState.WindowCaptureMethod) windowMethodComboBox.SelectedIndex; + CaptureMethodChanged?.Invoke(); } } }