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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SafeExamBrowser.UserInterface.Mobile/MessageBoxDialog.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/MessageBoxDialog.xaml.cs
new file mode 100644
index 00000000..93175c47
--- /dev/null
+++ b/SafeExamBrowser.UserInterface.Mobile/MessageBoxDialog.xaml.cs
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows;
+using System.Windows.Interop;
+using System.Windows.Media.Imaging;
+using SafeExamBrowser.Contracts.I18n;
+using SafeExamBrowser.Contracts.UserInterface.MessageBox;
+using MessageBoxResult = SafeExamBrowser.Contracts.UserInterface.MessageBox.MessageBoxResult;
+
+namespace SafeExamBrowser.UserInterface.Mobile
+{
+ public partial class MessageBoxDialog : Window
+ {
+ private readonly IText text;
+
+ public MessageBoxDialog(IText text)
+ {
+ this.text = text;
+
+ InitializeComponent();
+ InitializeMessageBox();
+ }
+
+ public MessageBoxResult Show(string message, string title, MessageBoxAction action, MessageBoxIcon icon, Window parent = null)
+ {
+ Message.Text = message;
+ Title = title;
+
+ if (parent is Window)
+ {
+ Owner = parent as Window;
+ }
+
+ InitializeBounds();
+ InitializeAction(action);
+ InitializeIcon(icon);
+
+ ShowDialog();
+
+ return ResultFor(action);
+ }
+
+ private void InitializeAction(MessageBoxAction action)
+ {
+ switch (action)
+ {
+ case MessageBoxAction.Confirm:
+ OkButton.Visibility = Visibility.Visible;
+ OkButton.Focus();
+ YesButton.Visibility = Visibility.Collapsed;
+ NoButton.Visibility = Visibility.Collapsed;
+ break;
+ case MessageBoxAction.YesNo:
+ OkButton.Visibility = Visibility.Collapsed;
+ YesButton.Visibility = Visibility.Visible;
+ NoButton.Visibility = Visibility.Visible;
+ NoButton.Focus();
+ break;
+ }
+ }
+
+ private void InitializeBounds()
+ {
+ Left = 0;
+ Top = 0;
+ Height = SystemParameters.PrimaryScreenHeight;
+ Width = SystemParameters.PrimaryScreenWidth;
+ }
+
+ private void InitializeIcon(MessageBoxIcon icon)
+ {
+ var handle = default(IntPtr);
+
+ switch (icon)
+ {
+ case MessageBoxIcon.Error:
+ handle = SystemIcons.Error.Handle;
+ break;
+ case MessageBoxIcon.Information:
+ handle = SystemIcons.Information.Handle;
+ break;
+ case MessageBoxIcon.Question:
+ handle = SystemIcons.Question.Handle;
+ break;
+ case MessageBoxIcon.Warning:
+ handle = SystemIcons.Warning.Handle;
+ break;
+ }
+
+ if (handle != default(IntPtr))
+ {
+ Image.Content = new System.Windows.Controls.Image
+ {
+ Source = Imaging.CreateBitmapSourceFromHIcon(handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
+ };
+ }
+ }
+
+ private void InitializeMessageBox()
+ {
+ InitializeBounds();
+
+ NoButton.Content = text.Get(TextKey.MessageBox_NoButton);
+ NoButton.Click += NoButton_Click;
+
+ OkButton.Content = text.Get(TextKey.MessageBox_OkButton);
+ OkButton.Click += OkButton_Click;
+
+ YesButton.Content = text.Get(TextKey.MessageBox_YesButton);
+ YesButton.Click += YesButton_Click;
+
+ SystemParameters.StaticPropertyChanged += SystemParameters_StaticPropertyChanged;
+ }
+
+ private MessageBoxResult ResultFor(MessageBoxAction action)
+ {
+ switch (action)
+ {
+ case MessageBoxAction.Confirm:
+ return DialogResult == true ? MessageBoxResult.Ok : MessageBoxResult.None;
+ case MessageBoxAction.YesNo:
+ return DialogResult == true ? MessageBoxResult.Yes : MessageBoxResult.No;
+ default:
+ return MessageBoxResult.None;
+ }
+ }
+
+ private void NoButton_Click(object sender, RoutedEventArgs e)
+ {
+ DialogResult = false;
+ Close();
+ }
+
+ private void OkButton_Click(object sender, RoutedEventArgs e)
+ {
+ DialogResult = true;
+ Close();
+ }
+
+ private void YesButton_Click(object sender, RoutedEventArgs e)
+ {
+ DialogResult = true;
+ Close();
+ }
+
+ private void SystemParameters_StaticPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == nameof(SystemParameters.WorkArea))
+ {
+ Dispatcher.InvokeAsync(InitializeBounds);
+ }
+ }
+ }
+}
diff --git a/SafeExamBrowser.UserInterface.Mobile/PasswordDialog.xaml b/SafeExamBrowser.UserInterface.Mobile/PasswordDialog.xaml
index 24a93a96..73b76968 100644
--- a/SafeExamBrowser.UserInterface.Mobile/PasswordDialog.xaml
+++ b/SafeExamBrowser.UserInterface.Mobile/PasswordDialog.xaml
@@ -27,13 +27,13 @@
-
+
-
+
diff --git a/SafeExamBrowser.UserInterface.Mobile/SafeExamBrowser.UserInterface.Mobile.csproj b/SafeExamBrowser.UserInterface.Mobile/SafeExamBrowser.UserInterface.Mobile.csproj
index ff24fac7..8ee15ff4 100644
--- a/SafeExamBrowser.UserInterface.Mobile/SafeExamBrowser.UserInterface.Mobile.csproj
+++ b/SafeExamBrowser.UserInterface.Mobile/SafeExamBrowser.UserInterface.Mobile.csproj
@@ -54,6 +54,7 @@
..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll
+
@@ -139,6 +140,9 @@
LogWindow.xaml
+
+ MessageBoxDialog.xaml
+
PasswordDialog.xaml
@@ -342,6 +346,10 @@
MSBuild:Compile
Designer
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
diff --git a/SafeExamBrowser.UserInterface.Mobile/SplashScreen.xaml b/SafeExamBrowser.UserInterface.Mobile/SplashScreen.xaml
index 4a73e73d..c6d0791c 100644
--- a/SafeExamBrowser.UserInterface.Mobile/SplashScreen.xaml
+++ b/SafeExamBrowser.UserInterface.Mobile/SplashScreen.xaml
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Mobile"
mc:Ignorable="d"
- Title="SplashScreen" Background="White" FontSize="16" Height="250" Width="500" WindowStyle="None" WindowStartupLocation="CenterScreen"
+ Title="SplashScreen" Background="White" FontSize="16" Height="300" Width="500" WindowStyle="None" WindowStartupLocation="CenterScreen"
Cursor="Wait" Icon="./Images/SafeExamBrowser.ico" ResizeMode="NoResize" Topmost="True">
@@ -13,7 +13,7 @@
-
+