Skip to content

Commit

Permalink
Merge pull request #349 from BUTR/dev
Browse files Browse the repository at this point in the history
v2.8.11
  • Loading branch information
Aragas authored Jul 15, 2023
2 parents 5da9b42 + 7a9f132 commit d8e9437
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--Development Variables-->
<PropertyGroup>
<!--Module Version-->
<Version>2.8.10</Version>
<Version>2.8.11</Version>
<!--Harmony Version-->
<HarmonyVersion>2.2.2</HarmonyVersion>
<HarmonyExtensionsVersion>3.2.0.77</HarmonyExtensionsVersion>
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---------------------------------------------------------------------------------------------------
Version: 2.8.11
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.2.0,v1.2.1
* Better Clipboard handling
---------------------------------------------------------------------------------------------------
Version: 2.8.10
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.2.0,v1.2.1
* Japanese language update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ internal HtmlCrashReportForm(CrashReport crashReport)

public async void CopyAsHTML()
{
await SetClipboardTextAsync(ReportInHtml);
if (!await SetClipboardTextAsync(ReportInHtml))
MessageBox.Show("Failed to copy the HTML content to the clipboard!", "Error!");
}

public async void UploadReport()
Expand All @@ -229,8 +230,10 @@ public async void UploadReport()
{
case CrashUploaderStatus.Success:
{
await SetClipboardTextAsync(result.Url ?? string.Empty);
MessageBox.Show($"Report available at\n{result.Url}\nThe url was copied to the clipboard!", "Success!");
if (await SetClipboardTextAsync(result.Url ?? string.Empty))
MessageBox.Show($"Report available at\n{result.Url}\nThe url was copied to the clipboard!", "Success!");
else
MessageBox.Show($"Report available at\n{result.Url}\nFailed to copy the url to the clipboard!", "Success!");
break;
}
case CrashUploaderStatus.MetadataNotFound:
Expand Down Expand Up @@ -319,19 +322,26 @@ private void HtmlRender_Navigating(object sender, WebBrowserNavigatingEventArgs
private static bool UriIsValid(string url) =>
Uri.TryCreate(url, UriKind.Absolute, out var uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);

private static async Task SetClipboardTextAsync(string text)
private static async Task<bool> SetClipboardTextAsync(string text)
{
var completionSource = new TaskCompletionSource<object?>();
var completionSource = new TaskCompletionSource<bool>();
var staThread = new Thread(() =>
{
var dataObject = new DataObject();
dataObject.SetText(text, TextDataFormat.Text);
Clipboard.SetDataObject(dataObject, true, 10, 100);
completionSource.SetResult(null);
try
{
var dataObject = new DataObject();
dataObject.SetText(text, TextDataFormat.Text);
Clipboard.SetDataObject(dataObject, true, 10, 100);
completionSource.SetResult(true);
}
catch (Exception)
{
completionSource.SetResult(false);
}
});
staThread.SetApartmentState(ApartmentState.STA);
staThread.Start();
await completionSource.Task;
return await completionSource.Task;
}
}
}
Expand Down

0 comments on commit d8e9437

Please sign in to comment.