2019-03-21 16:05:16 +01:00
|
|
|
|
/*
|
2021-02-03 00:45:33 +01:00
|
|
|
|
* Copyright (c) 2021 ETH Zürich, Educational Development and Technology (LET)
|
2019-03-21 16:05:16 +01:00
|
|
|
|
*
|
|
|
|
|
* 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.Windows;
|
2019-08-30 09:55:26 +02:00
|
|
|
|
using SafeExamBrowser.I18n.Contracts;
|
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
|
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
2020-03-17 10:37:08 +01:00
|
|
|
|
using SafeExamBrowser.UserInterface.Mobile.Windows;
|
2019-08-30 09:55:26 +02:00
|
|
|
|
using MessageBoxResult = SafeExamBrowser.UserInterface.Contracts.MessageBox.MessageBoxResult;
|
2019-03-21 16:05:16 +01:00
|
|
|
|
|
|
|
|
|
namespace SafeExamBrowser.UserInterface.Mobile
|
|
|
|
|
{
|
2020-03-17 11:07:40 +01:00
|
|
|
|
public class MessageBoxFactory : IMessageBox
|
2019-03-21 16:05:16 +01:00
|
|
|
|
{
|
|
|
|
|
private IText text;
|
|
|
|
|
|
2020-03-17 11:07:40 +01:00
|
|
|
|
public MessageBoxFactory(IText text)
|
2019-03-21 16:05:16 +01:00
|
|
|
|
{
|
|
|
|
|
this.text = text;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-09 23:07:09 +01:00
|
|
|
|
public MessageBoxResult Show(string message, string title, MessageBoxAction action = MessageBoxAction.Ok, MessageBoxIcon icon = MessageBoxIcon.Information, IWindow parent = null)
|
2019-03-21 16:05:16 +01:00
|
|
|
|
{
|
2021-02-09 23:07:09 +01:00
|
|
|
|
var result = default(MessageBoxResult);
|
2019-03-21 16:05:16 +01:00
|
|
|
|
|
|
|
|
|
if (parent is Window window)
|
|
|
|
|
{
|
2019-03-22 12:17:14 +01:00
|
|
|
|
result = window.Dispatcher.Invoke(() => new MessageBoxDialog(text).Show(message, title, action, icon, window));
|
2019-03-21 16:05:16 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-03-22 12:17:14 +01:00
|
|
|
|
result = new MessageBoxDialog(text).Show(message, title, action, icon);
|
2019-03-21 16:05:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-22 12:17:14 +01:00
|
|
|
|
return result;
|
2019-03-21 16:05:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-09 23:07:09 +01:00
|
|
|
|
public MessageBoxResult Show(TextKey message, TextKey title, MessageBoxAction action = MessageBoxAction.Ok, MessageBoxIcon icon = MessageBoxIcon.Information, IWindow parent = null)
|
2019-03-21 16:05:16 +01:00
|
|
|
|
{
|
|
|
|
|
return Show(text.Get(message), text.Get(title), action, icon, parent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|