2013-11-03 23:53:49 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2019-01-02 20:43:52 +13:00
|
|
|
|
Copyright (c) 2007-2019 ShareX Team
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
namespace ShareX.HelpersLib
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-02-26 09:55:54 +13:00
|
|
|
|
public partial class ErrorForm : Form
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-12-15 00:06:50 +13:00
|
|
|
|
public bool IsUnhandledException { get; private set; }
|
2013-11-03 23:53:49 +13:00
|
|
|
|
public string LogPath { get; private set; }
|
|
|
|
|
public string BugReportPath { get; private set; }
|
|
|
|
|
|
2016-04-07 04:02:48 +12:00
|
|
|
|
public ErrorForm(Exception error, string logPath, string bugReportPath) : this(error.Message, error.ToString(), logPath, bugReportPath)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-15 00:06:50 +13:00
|
|
|
|
public ErrorForm(string errorTitle, string errorMessage, string logPath, string bugReportPath, bool unhandledException = true)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-02-26 09:55:54 +13:00
|
|
|
|
Icon = ShareXResources.Icon;
|
|
|
|
|
|
2015-12-15 00:06:50 +13:00
|
|
|
|
IsUnhandledException = unhandledException;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
LogPath = logPath;
|
|
|
|
|
BugReportPath = bugReportPath;
|
|
|
|
|
|
2015-12-15 00:06:50 +13:00
|
|
|
|
if (IsUnhandledException)
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteException(errorMessage, "Unhandled exception");
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-06-12 08:46:00 +12:00
|
|
|
|
lblErrorMessage.Text = errorTitle;
|
|
|
|
|
txtException.Text = errorMessage;
|
|
|
|
|
txtException.SelectionStart = txtException.TextLength;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
btnSendBugReport.Visible = !string.IsNullOrEmpty(BugReportPath);
|
2015-10-18 00:37:40 +13:00
|
|
|
|
btnOpenLogFile.Visible = !string.IsNullOrEmpty(LogPath) && File.Exists(LogPath);
|
2015-12-15 00:06:50 +13:00
|
|
|
|
btnContinue.Visible = IsUnhandledException;
|
|
|
|
|
btnClose.Visible = IsUnhandledException;
|
|
|
|
|
btnOK.Visible = !IsUnhandledException;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 08:46:00 +12:00
|
|
|
|
private void ErrorForm_Shown(object sender, EventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-03-10 05:37:54 +13:00
|
|
|
|
this.ForceActivate();
|
2014-06-12 08:46:00 +12:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2015-10-18 00:37:40 +13:00
|
|
|
|
private void btnSendBugReport_Click(object sender, EventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-10-18 00:37:40 +13:00
|
|
|
|
URLHelpers.OpenURL(BugReportPath);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-18 00:37:40 +13:00
|
|
|
|
private void btnOpenLogFile_Click(object sender, EventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-10-18 00:37:40 +13:00
|
|
|
|
Helpers.OpenFile(LogPath);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnContinue_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-06-12 08:46:00 +12:00
|
|
|
|
DebugHelper.WriteLine("ShareX continue.");
|
2013-11-03 23:53:49 +13:00
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-03-29 08:59:17 +13:00
|
|
|
|
DebugHelper.WriteLine("ShareX closing. Reason: Unhandled exception.");
|
2013-11-03 23:53:49 +13:00
|
|
|
|
Application.Exit();
|
|
|
|
|
}
|
2015-12-15 00:06:50 +13:00
|
|
|
|
|
|
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|