Skip to content

Commit

Permalink
Improve a couple error messages #68
Browse files Browse the repository at this point in the history
  • Loading branch information
jacks authored and jacks committed May 27, 2024
1 parent 66b8e20 commit 2aa5bdd
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions whisperer/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public bool PreFilterMessage(ref Message m)
}

void Form1_Load(object sender, EventArgs e)
{
{
if (!IsAtLeastWindows10())
{
ShowError(@"Unsupported Windows version, will now exit.");
Expand All @@ -72,6 +72,9 @@ void Form1_Load(object sender, EventArgs e)
return;
}

if (Execute("ffmpeg.exe") == 2)
ShowError(ffmpegnotfound);

Thread thr = new Thread(initperfcounter);
thr.IsBackground = true;
thr.Start();
Expand Down Expand Up @@ -413,7 +416,7 @@ void convertandwhisper(string filename)
catch (Exception ex)
{
cancel = true;
ShowError("ffmpeg.exe not found, make sure it is on your path or same folder as Whisperer");
ShowError(ffmpegnotfound);
}
}

Expand Down Expand Up @@ -560,11 +563,11 @@ int Execute(string path)
catch { }
try
{
IntPtr result = ShellExecute(0, "", path, "", dir, SW_SHOWNORMAL);
IntPtr result = ShellExecute(0, "", path, "", dir, path == "ffmpeg.exe" ? SW_HIDE : SW_SHOWNORMAL);
return result.ToInt32();
}
catch { }
return 0;
return -1;
}

void openinplayer(object o)
Expand Down Expand Up @@ -667,6 +670,7 @@ void whisper_Exited(object sender, EventArgs e, string errorOutput)
try
{
var proc = sender as Process;
string filename = getfilename(proc);
try
{
durationrec dr = durations[proc.StartInfo.Domain];
Expand All @@ -676,11 +680,10 @@ void whisper_Exited(object sender, EventArgs e, string errorOutput)
try
{
if (proc.ExitCode != 0)
ShowError($"main.exe has finished with error. Exit code: {proc.ExitCode}\n\n{errorOutput}");
ShowError($"main.exe has finished with error. Exit code: {proc.ExitCode}\n\n{errorOutput}\n\nFile name: {filename}");
}
catch { }

string filename = getfilename(proc);
if (File.Exists(filename))
File.Delete(filename);
completed++;
Expand Down Expand Up @@ -875,7 +878,7 @@ TimeSpan getduration(string filename)
if (!cancel)
{
cancel = true;
ShowError(ex.ToString());
ShowError(ffmpegnotfound);
}
}
return TimeSpan.Zero;
Expand Down Expand Up @@ -1274,7 +1277,10 @@ DialogResult ShowMsgProc(string msg, bool iserr, string caption = "Whisperer", M
mbi = iserr ? MessageBoxIcon.Error : MessageBoxIcon.Information;
else
mbi = MessageBoxIcon.Question;
dr = MessageBox.Show(msg, caption, mbb, mbi);
Invoke(new Action(() =>
{
dr = MessageBox.Show(this, msg, caption, mbb, mbi);
}));
return dr;
}

Expand Down Expand Up @@ -1316,10 +1322,7 @@ void DoTask()
}
else if (had1)
{
string message = "Delete the scheduled task?";
string caption = "Delete Schedule";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result = AskQuestion(message, caption, buttons);
DialogResult result = AskQuestion("Delete the scheduled task?", "Delete Schedule", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
schedtask.DeleteTask("Whisperer");
}
Expand Down Expand Up @@ -1383,6 +1386,8 @@ private void toolStripMenuItem4_Click(object sender, EventArgs e)
fastObjectListView1.RemoveObjects(fastObjectListView1.SelectedObjects);
}

const string ffmpegnotfound = "ffmpeg.exe not found, make sure it is on your path or same folder as Whisperer";
const int SW_HIDE = 0;
const int SW_SHOWNORMAL = 1;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
Expand Down

0 comments on commit 2aa5bdd

Please sign in to comment.