diff --git a/Apollo/Helpers/DriverChecker.cs b/Apollo/Helpers/DriverChecker.cs index f44f73b8..7de994aa 100644 --- a/Apollo/Helpers/DriverChecker.cs +++ b/Apollo/Helpers/DriverChecker.cs @@ -48,14 +48,13 @@ static MessageWindow CreateDriverError(bool IsOldVersion) { "computer.\n\n" ) + "Please install at least version 2.22.0.10 of the driver before using Apollo Studio.", - new string[] {"Download Driver", "OK"} + new string[] {"Download Driver", "OK"}, + result => { + if (result == "Download Driver") + App.URL("https://github.com/mat1jaczyyy/apollo-studio/raw/master/Publish/novationusbmidi.exe"); + } ); - ret.Completed.Task.ContinueWith(result => { - if (result.Result == "Download Driver") - App.URL("https://github.com/mat1jaczyyy/apollo-studio/raw/master/Publish/novationusbmidi.exe"); - }); - return ret; } diff --git a/Apollo/Windows/MessageWindow.cs b/Apollo/Windows/MessageWindow.cs index c875996f..9e221b30 100644 --- a/Apollo/Windows/MessageWindow.cs +++ b/Apollo/Windows/MessageWindow.cs @@ -17,13 +17,14 @@ public class MessageWindow: Window { Button Default; + public Action OnComplete; public TaskCompletionSource Completed = new(); void UpdateTopmost(bool value) => Topmost = value; public MessageWindow() => new InvalidOperationException(); - public MessageWindow(string message, string[] options = null) { + public MessageWindow(string message, string[] options = null, Action oncomplete = null) { InitializeComponent(); #if DEBUG this.AttachDevTools(); @@ -44,6 +45,8 @@ public MessageWindow(string message, string[] options = null) { Buttons.Children.Add(btn); return btn; }).ToList().Last(); // ToList required otherwise Last will only resolve Select on the last item + + OnComplete = oncomplete; } void Loaded(object sender, EventArgs e) { @@ -56,7 +59,7 @@ void Loaded(object sender, EventArgs e) { void Unloaded(object sender, CancelEventArgs e) { if (!Completed.Task.IsCompleted) - Completed.SetResult((string)Default.Content); + Result((string)Default.Content); Preferences.AlwaysOnTopChanged -= UpdateTopmost; @@ -68,8 +71,13 @@ void Unloaded(object sender, CancelEventArgs e) { this.Content = null; } + void Result(string result) { + OnComplete?.Invoke(result); + Completed.SetResult(result); + } + void Complete(object sender, EventArgs e) { - Completed.SetResult((string)((Button)sender).Content); + Result((string)((Button)sender).Content); Close(); }