Skip to content

Commit

Permalink
Enable "Hide taskbar" checkbox only if supported
Browse files Browse the repository at this point in the history
  • Loading branch information
pol-rivero committed May 7, 2022
1 parent d289379 commit 31e331e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
21 changes: 11 additions & 10 deletions DiscordAudioStream/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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();
}

Expand Down
11 changes: 11 additions & 0 deletions DiscordAudioStream/ScreenCapture/CaptureState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion DiscordAudioStream/SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
}
}
}

0 comments on commit 31e331e

Please sign in to comment.