Skip to content

Commit beaaa60

Browse files
authored
Net5ex (#127)
* Shared method * Standardize creating git issue
1 parent 6311157 commit beaaa60

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

KoAR.SaveEditor/App.xaml.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ partial class App
1616

1717
public static Version Version { get; } = new(Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>()!.InformationalVersion);
1818

19+
public static void CreateGithubIssue(string titlePrefix) => App.OpenInBrowser(
20+
$"https://github.com/mburbea/koar-item-editor/issues/new?labels=bug&template=bug_report.md&title={WebUtility.UrlEncode($"{titlePrefix} (in v{App.Version})")}"
21+
);
22+
23+
public static void OpenInBrowser(string url) => Process.Start(startInfo: new(url) { UseShellExecute = true })?.Dispose();
24+
1925
public static void ShowExceptionDialog(string mainInstruction, Exception exception)
2026
{
2127
string content = $"{exception.GetType().FullName}: {exception.Message}";
@@ -35,11 +41,7 @@ public static void ShowExceptionDialog(string mainInstruction, Exception excepti
3541
TaskDialog.ShowDialog(page);
3642
if (page.Verification!.Checked)
3743
{
38-
string title = $"{content} (in v{App.Version})";
39-
Process.Start(new ProcessStartInfo($"https://github.com/mburbea/koar-item-editor/issues/new?labels=bug&template=bug_report.md&title={WebUtility.UrlEncode(title)}")
40-
{
41-
UseShellExecute = true
42-
})?.Dispose();
44+
App.CreateGithubIssue(content);
4345
}
4446
}
4547

@@ -66,4 +68,4 @@ private void App_DispatcherUnhandledException(object sender, DispatcherUnhandled
6668
App.ShowExceptionDialog("Unhandled Error Encountered", e.Exception);
6769
Environment.Exit(0);
6870
}
69-
}
71+
}

KoAR.SaveEditor/Views/Main/MainWindow.xaml.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Diagnostics;
32
using System.Threading;
43
using System.Windows.Forms;
54
using System.Windows.Input;
@@ -61,7 +60,7 @@ 1. Your saves are usually not in the same folder as the game. The editor attemps
6160
}
6261
if (tag == 1)
6362
{
64-
OpenInBrowser("https://github.com/mburbea/koar-item-editor/issues/new?labels=bug&template=bug_report.md");
63+
App.CreateGithubIssue("Enter title here");
6564
return;
6665
}
6766
using CancellationTokenSource source = new(2500);
@@ -83,11 +82,9 @@ 1. Your saves are usually not in the same folder as the game. The editor attemps
8382
if (release is null)
8483
{
8584
// this might fail if the github is down or your internet sucks. For now let's try to open a browser window to nexusmods.
86-
OpenInBrowser("https://www.nexusmods.com/kingdomsofamalurreckoning/mods/10?tab=files");
85+
App.OpenInBrowser("https://www.nexusmods.com/kingdomsofamalurreckoning/mods/10?tab=files");
8786
}
8887
}
89-
90-
static void OpenInBrowser(string url) => Process.Start(startInfo: new(url) { UseShellExecute = true })?.Dispose();
9188
}
9289

9390
private void Open_Executed(object sender, ExecutedRoutedEventArgs e) => this.ViewModel.OpenFile();

0 commit comments

Comments
 (0)