Skip to content

Commit

Permalink
Make sure the user knows we're waiting for them
Browse files Browse the repository at this point in the history
Sometimes messageboxes can appear in odd positions on multi-monitor setups or setups that change resolution or number of displays within a session
  • Loading branch information
GrahamTheCoder committed Mar 1, 2020
1 parent e9ec9b4 commit f5df4f9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Vsix/CodeConversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ await _joinableTaskFactory.RunAsync(async () => {
});
} catch (OperationCanceledException) {
if (!_packageCancellation.CancelAll.IsCancellationRequested) {
await _outputWindow.WriteToOutputWindowAsync("Previous conversion cancelled", forceShow: true);
await _outputWindow.WriteToOutputWindowAsync(Environment.NewLine + "Previous conversion cancelled", forceShow: true);
}
}
}
Expand All @@ -80,7 +80,7 @@ await _joinableTaskFactory.RunAsync(async () => {
}
} catch (OperationCanceledException) {
if (!_packageCancellation.CancelAll.IsCancellationRequested) {
await _outputWindow.WriteToOutputWindowAsync("Previous conversion cancelled", forceShow: true);
await _outputWindow.WriteToOutputWindowAsync(Environment.NewLine + "Previous conversion cancelled", forceShow: true);
}
}
}
Expand Down Expand Up @@ -160,17 +160,20 @@ private async Task FinalizeConversionAsync(List<string> files, List<string> erro

}

private Task<bool> UserHasConfirmedOverwriteAsync(List<string> files, List<string> errors, IReadOnlyCollection<string> pathsToOverwrite)
private async Task<bool> UserHasConfirmedOverwriteAsync(List<string> files, List<string> errors, IReadOnlyCollection<string> pathsToOverwrite)
{
var maxExamples = 30; // Avoid a huge unreadable dialog going off the screen
var exampleText = pathsToOverwrite.Count > maxExamples ? $". First {maxExamples} examples" : "";
return VisualStudioInteraction.ShowMessageBoxAsync(_serviceProvider,
await _outputWindow.WriteToOutputWindowAsync(Environment.NewLine + "Awaiting user confirmation for overwrite....", forceShow: true);
bool shouldOverwrite = await VisualStudioInteraction.ShowMessageBoxAsync(_serviceProvider,
"Overwrite solution and referencing projects?",
$@"The current solution file and any referencing projects will be overwritten to reference the new project(s){exampleText}:
* {string.Join(Environment.NewLine + "* ", pathsToOverwrite.Take(maxExamples))}
The old contents will be copied to 'currentFilename.bak'.
Please 'Reload All' when Visual Studio prompts you.", true, files.Count > errors.Count);
await _outputWindow.WriteToOutputWindowAsync(shouldOverwrite ? "confirmed" : "declined");
return shouldOverwrite;
}

private static bool WillOverwriteSource(ConversionResult convertedFile)
Expand Down

0 comments on commit f5df4f9

Please sign in to comment.