fixed #6586: Only allow choosing .wav audio files

This commit is contained in:
Jaex 2022-11-10 05:29:03 +03:00
parent 234def8f86
commit 221fe463a8
2 changed files with 7 additions and 6 deletions

View file

@ -380,16 +380,17 @@ public static string GetUniqueFilePath(string filePath)
return filePath; return filePath;
} }
public static bool BrowseFile(TextBox tb, string initialDirectory = "", bool detectSpecialFolders = false) public static bool BrowseFile(TextBox tb, string initialDirectory = "", bool detectSpecialFolders = false, string filter = "")
{ {
return BrowseFile("ShareX - " + Resources.Helpers_BrowseFile_Choose_file, tb, initialDirectory, detectSpecialFolders); return BrowseFile("ShareX - " + Resources.Helpers_BrowseFile_Choose_file, tb, initialDirectory, detectSpecialFolders, filter);
} }
public static bool BrowseFile(string title, TextBox tb, string initialDirectory = "", bool detectSpecialFolders = false) public static bool BrowseFile(string title, TextBox tb, string initialDirectory = "", bool detectSpecialFolders = false, string filter = "")
{ {
using (OpenFileDialog ofd = new OpenFileDialog()) using (OpenFileDialog ofd = new OpenFileDialog())
{ {
ofd.Title = title; ofd.Title = title;
ofd.Filter = filter;
try try
{ {

View file

@ -882,7 +882,7 @@ private void txtCustomCaptureSoundPath_TextChanged(object sender, EventArgs e)
private void btnCustomCaptureSoundPath_Click(object sender, EventArgs e) private void btnCustomCaptureSoundPath_Click(object sender, EventArgs e)
{ {
FileHelpers.BrowseFile(txtCustomCaptureSoundPath); FileHelpers.BrowseFile(txtCustomCaptureSoundPath, filter: "Audio file (*.wav)|*.wav");
} }
private void cbUseCustomTaskCompletedSound_CheckedChanged(object sender, EventArgs e) private void cbUseCustomTaskCompletedSound_CheckedChanged(object sender, EventArgs e)
@ -898,7 +898,7 @@ private void txtCustomTaskCompletedSoundPath_TextChanged(object sender, EventArg
private void btnCustomTaskCompletedSoundPath_Click(object sender, EventArgs e) private void btnCustomTaskCompletedSoundPath_Click(object sender, EventArgs e)
{ {
FileHelpers.BrowseFile(txtCustomTaskCompletedSoundPath); FileHelpers.BrowseFile(txtCustomTaskCompletedSoundPath, filter: "Audio file (*.wav)|*.wav");
} }
private void cbUseCustomErrorSound_CheckedChanged(object sender, EventArgs e) private void cbUseCustomErrorSound_CheckedChanged(object sender, EventArgs e)
@ -914,7 +914,7 @@ private void txtCustomErrorSoundPath_TextChanged(object sender, EventArgs e)
private void btnCustomErrorSoundPath_Click(object sender, EventArgs e) private void btnCustomErrorSoundPath_Click(object sender, EventArgs e)
{ {
FileHelpers.BrowseFile(txtCustomErrorSoundPath); FileHelpers.BrowseFile(txtCustomErrorSoundPath, filter: "Audio file (*.wav)|*.wav");
} }
private void cbDisableNotifications_CheckedChanged(object sender, EventArgs e) private void cbDisableNotifications_CheckedChanged(object sender, EventArgs e)