From a43975aa763f88907b39d8148656837af67aedd2 Mon Sep 17 00:00:00 2001 From: dbuechel Date: Fri, 22 Mar 2019 12:17:14 +0100 Subject: [PATCH] SEBWIN-141: Implemented custom message box for mobile UI. --- SafeExamBrowser.Contracts/I18n/TextKey.cs | 4 + SafeExamBrowser.I18n/Text.xml | 12 ++ .../PasswordDialog.xaml | 2 +- .../MessageBox.cs | 51 +----- .../MessageBoxDialog.xaml | 42 +++++ .../MessageBoxDialog.xaml.cs | 163 ++++++++++++++++++ .../PasswordDialog.xaml | 4 +- ...afeExamBrowser.UserInterface.Mobile.csproj | 8 + .../SplashScreen.xaml | 4 +- 9 files changed, 238 insertions(+), 52 deletions(-) create mode 100644 SafeExamBrowser.UserInterface.Mobile/MessageBoxDialog.xaml create mode 100644 SafeExamBrowser.UserInterface.Mobile/MessageBoxDialog.xaml.cs diff --git a/SafeExamBrowser.Contracts/I18n/TextKey.cs b/SafeExamBrowser.Contracts/I18n/TextKey.cs index d4f9854a..80b96e9f 100644 --- a/SafeExamBrowser.Contracts/I18n/TextKey.cs +++ b/SafeExamBrowser.Contracts/I18n/TextKey.cs @@ -19,6 +19,7 @@ namespace SafeExamBrowser.Contracts.I18n LogWindow_Title, MessageBox_ApplicationError, MessageBox_ApplicationErrorTitle, + MessageBox_CancelButton, MessageBox_ClientConfigurationError, MessageBox_ClientConfigurationErrorTitle, MessageBox_ClientConfigurationQuestion, @@ -31,8 +32,10 @@ namespace SafeExamBrowser.Contracts.I18n MessageBox_InvalidPasswordErrorTitle, MessageBox_InvalidQuitPassword, MessageBox_InvalidQuitPasswordTitle, + MessageBox_NoButton, MessageBox_NotSupportedConfigurationResource, MessageBox_NotSupportedConfigurationResourceTitle, + MessageBox_OkButton, MessageBox_Quit, MessageBox_QuitTitle, MessageBox_QuitError, @@ -51,6 +54,7 @@ namespace SafeExamBrowser.Contracts.I18n MessageBox_StartupErrorTitle, MessageBox_UnexpectedConfigurationError, MessageBox_UnexpectedConfigurationErrorTitle, + MessageBox_YesButton, Notification_AboutTooltip, Notification_LogTooltip, OperationStatus_CloseRuntimeConnection, diff --git a/SafeExamBrowser.I18n/Text.xml b/SafeExamBrowser.I18n/Text.xml index de292475..bf68947e 100644 --- a/SafeExamBrowser.I18n/Text.xml +++ b/SafeExamBrowser.I18n/Text.xml @@ -15,6 +15,9 @@ Application Error + + Cancel + The local client configuration has failed! Please consult the application log for more information. The application will now shut down... @@ -51,12 +54,18 @@ Invalid Quit Password + + No + The configuration resource "%%URI%%" is not supported! Configuration Error + + OK + Would you really like to quit the application? @@ -111,6 +120,9 @@ Configuration Error + + Yes + Information about SEB diff --git a/SafeExamBrowser.UserInterface.Desktop/PasswordDialog.xaml b/SafeExamBrowser.UserInterface.Desktop/PasswordDialog.xaml index c7b3d7fc..c3414ef8 100644 --- a/SafeExamBrowser.UserInterface.Desktop/PasswordDialog.xaml +++ b/SafeExamBrowser.UserInterface.Desktop/PasswordDialog.xaml @@ -24,7 +24,7 @@ - + diff --git a/SafeExamBrowser.UserInterface.Mobile/MessageBox.cs b/SafeExamBrowser.UserInterface.Mobile/MessageBox.cs index 81aad442..c8e1f6ea 100644 --- a/SafeExamBrowser.UserInterface.Mobile/MessageBox.cs +++ b/SafeExamBrowser.UserInterface.Mobile/MessageBox.cs @@ -25,66 +25,23 @@ namespace SafeExamBrowser.UserInterface.Mobile public MessageBoxResult Show(string message, string title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information, IWindow parent = null) { - var result = default(System.Windows.MessageBoxResult); + var result = default(MessageBoxResult); if (parent is Window window) { - result = window.Dispatcher.Invoke(() => System.Windows.MessageBox.Show(window, message, title, ToButton(action), ToImage(icon))); + result = window.Dispatcher.Invoke(() => new MessageBoxDialog(text).Show(message, title, action, icon, window)); } else { - result = System.Windows.MessageBox.Show(message, title, ToButton(action), ToImage(icon)); + result = new MessageBoxDialog(text).Show(message, title, action, icon); } - return ToResult(result); + return result; } public MessageBoxResult Show(TextKey message, TextKey title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information, IWindow parent = null) { return Show(text.Get(message), text.Get(title), action, icon, parent); } - - private MessageBoxButton ToButton(MessageBoxAction action) - { - switch (action) - { - case MessageBoxAction.YesNo: - return MessageBoxButton.YesNo; - default: - return MessageBoxButton.OK; - } - } - - private MessageBoxImage ToImage(MessageBoxIcon icon) - { - switch (icon) - { - case MessageBoxIcon.Error: - return MessageBoxImage.Error; - case MessageBoxIcon.Question: - return MessageBoxImage.Question; - case MessageBoxIcon.Warning: - return MessageBoxImage.Warning; - default: - return MessageBoxImage.Information; - } - } - - private MessageBoxResult ToResult(System.Windows.MessageBoxResult result) - { - switch (result) - { - case System.Windows.MessageBoxResult.Cancel: - return MessageBoxResult.Cancel; - case System.Windows.MessageBoxResult.No: - return MessageBoxResult.No; - case System.Windows.MessageBoxResult.OK: - return MessageBoxResult.Ok; - case System.Windows.MessageBoxResult.Yes: - return MessageBoxResult.Yes; - default: - return MessageBoxResult.None; - } - } } } diff --git a/SafeExamBrowser.UserInterface.Mobile/MessageBoxDialog.xaml b/SafeExamBrowser.UserInterface.Mobile/MessageBoxDialog.xaml new file mode 100644 index 00000000..5252c062 --- /dev/null +++ b/SafeExamBrowser.UserInterface.Mobile/MessageBoxDialog.xaml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +