2020-01-22 15:16:11 +01:00
|
|
|
|
/*
|
2024-03-05 18:37:42 +01:00
|
|
|
|
* Copyright (c) 2024 ETH Zürich, IT Services
|
2020-01-22 15:16:11 +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;
|
|
|
|
|
using SafeExamBrowser.I18n.Contracts;
|
2023-09-01 12:28:03 +02:00
|
|
|
|
using SafeExamBrowser.SystemComponents.Contracts;
|
2020-01-22 15:16:11 +01:00
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts.FileSystemDialog;
|
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
2020-03-16 18:29:06 +01:00
|
|
|
|
using SafeExamBrowser.UserInterface.Desktop.Windows;
|
2020-01-22 15:16:11 +01:00
|
|
|
|
|
|
|
|
|
namespace SafeExamBrowser.UserInterface.Desktop
|
|
|
|
|
{
|
|
|
|
|
public class FileSystemDialogFactory : IFileSystemDialog
|
|
|
|
|
{
|
2023-09-01 12:28:03 +02:00
|
|
|
|
private readonly ISystemInfo systemInfo;
|
2023-03-09 22:49:54 +01:00
|
|
|
|
private readonly IText text;
|
2020-01-22 15:16:11 +01:00
|
|
|
|
|
2023-09-01 12:28:03 +02:00
|
|
|
|
public FileSystemDialogFactory(ISystemInfo systemInfo, IText text)
|
2020-01-22 15:16:11 +01:00
|
|
|
|
{
|
2023-09-01 12:28:03 +02:00
|
|
|
|
this.systemInfo = systemInfo;
|
2020-01-22 15:16:11 +01:00
|
|
|
|
this.text = text;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-05 22:55:38 +02:00
|
|
|
|
public FileSystemDialogResult Show(
|
|
|
|
|
FileSystemElement element,
|
|
|
|
|
FileSystemOperation operation,
|
2023-03-09 22:49:54 +01:00
|
|
|
|
string initialPath = default,
|
|
|
|
|
string message = default,
|
|
|
|
|
string title = default,
|
|
|
|
|
IWindow parent = default,
|
|
|
|
|
bool restrictNavigation = false,
|
|
|
|
|
bool showElementPath = true)
|
2020-01-22 15:16:11 +01:00
|
|
|
|
{
|
2020-01-24 11:07:52 +01:00
|
|
|
|
if (parent is Window window)
|
2020-01-22 15:16:11 +01:00
|
|
|
|
{
|
2023-09-01 12:28:03 +02:00
|
|
|
|
return window.Dispatcher.Invoke(() => new FileSystemDialog(element, operation, systemInfo, text, initialPath, message, title, parent, restrictNavigation, showElementPath).Show());
|
2020-01-22 15:16:11 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-09-01 12:28:03 +02:00
|
|
|
|
return new FileSystemDialog(element, operation, systemInfo, text, initialPath, message, title, restrictNavigation: restrictNavigation, showElementPath: showElementPath).Show();
|
2020-01-22 15:16:11 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|