|
@@ -1,18 +1,12 @@
|
|
|
using PixiEditor.Helpers;
|
|
|
using PixiEditor.Models.DataHolders;
|
|
|
using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
+using System.IO;
|
|
|
using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
+using System.Web;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
-using System.Windows.Data;
|
|
|
-using System.Windows.Documents;
|
|
|
using System.Windows.Input;
|
|
|
-using System.Windows.Media;
|
|
|
-using System.Windows.Media.Imaging;
|
|
|
-using System.Windows.Shapes;
|
|
|
|
|
|
namespace PixiEditor.Views.Dialogs
|
|
|
{
|
|
@@ -21,6 +15,8 @@ namespace PixiEditor.Views.Dialogs
|
|
|
/// </summary>
|
|
|
public partial class SendCrashReportWindow : Window
|
|
|
{
|
|
|
+ const string DiscordInviteLink = "https://discord.gg/eh8gx6vNEp";
|
|
|
+
|
|
|
private readonly CrashReport report;
|
|
|
|
|
|
public SendCrashReportWindow(CrashReport report)
|
|
@@ -29,6 +25,16 @@ namespace PixiEditor.Views.Dialogs
|
|
|
InitializeComponent();
|
|
|
}
|
|
|
|
|
|
+ private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ e.CanExecute = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CommandBinding_Executed_Close(object sender, ExecutedRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ SystemCommands.CloseWindow(this);
|
|
|
+ }
|
|
|
+
|
|
|
private void CopyToClipboard(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
Clipboard.SetFileDropList(new() { report.FilePath });
|
|
@@ -36,15 +42,65 @@ namespace PixiEditor.Views.Dialogs
|
|
|
|
|
|
private void OpenInExplorer(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- ProcessHelpers.ShellExecute(report.FilePath);
|
|
|
+ string tempPath = Path.Combine(
|
|
|
+ Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
|
|
+ "PixiEditor",
|
|
|
+ "crash_logs",
|
|
|
+ "to-copy");
|
|
|
+
|
|
|
+ DirectoryInfo info = Directory.CreateDirectory(tempPath);
|
|
|
+
|
|
|
+ foreach (var file in info.EnumerateFiles())
|
|
|
+ {
|
|
|
+ file.Delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ File.Copy(report.FilePath, Path.Combine(tempPath, Path.GetFileName(report.FilePath)), true);
|
|
|
+
|
|
|
+ ProcessHelpers.ShellExecute(tempPath);
|
|
|
}
|
|
|
|
|
|
private void OpenHyperlink(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
var button = sender as Button;
|
|
|
+ var tag = button.Tag as string;
|
|
|
+
|
|
|
+ string body = HttpUtility.UrlEncode($"** IMPORTANT: Drop the \"{Path.GetFileName(report.FilePath)}\" file in here **");
|
|
|
+
|
|
|
+ var result = tag switch
|
|
|
+ {
|
|
|
+ "github" => GetGitHubLink(),
|
|
|
+ "discord" => DiscordInviteLink,
|
|
|
+ "email" => GetMailtoLink(),
|
|
|
+ _ => throw new NotImplementedException()
|
|
|
+ };
|
|
|
+
|
|
|
+ OpenInExplorer(null, null);
|
|
|
+ ProcessHelpers.ShellExecute(result);
|
|
|
+
|
|
|
+ string GetGitHubLink()
|
|
|
+ {
|
|
|
+ StringBuilder builder = new();
|
|
|
+
|
|
|
+ builder.Append("https://github.com/PixiEditor/PixiEditor/issues/new?title=");
|
|
|
+ builder.Append(HttpUtility.UrlEncode($"Crash Report"));
|
|
|
+ builder.Append("&body=");
|
|
|
+ builder.Append(body);
|
|
|
+
|
|
|
+ return builder.ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ string GetMailtoLink()
|
|
|
+ {
|
|
|
+ StringBuilder builder = new();
|
|
|
+
|
|
|
+ builder.Append("mailto:[email protected]?subject=");
|
|
|
+ builder.Append(HttpUtility.UrlEncode($"Crash Report"));
|
|
|
+ builder.Append("&body=");
|
|
|
+ builder.Append(body);
|
|
|
|
|
|
- CopyToClipboard(null, null);
|
|
|
- ProcessHelpers.ShellExecute(button.Tag as string);
|
|
|
+ return builder.ToString();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|