Started implementing the browser component.

This commit is contained in:
Damian Büchel 2017-07-24 17:31:28 +02:00
parent 94f356b77a
commit 429685463b
28 changed files with 467 additions and 8 deletions

View file

@ -7,7 +7,11 @@
*/
using System;
using System.Collections.Generic;
using System.Linq;
using CefSharp;
using SafeExamBrowser.Contracts.Behaviour;
using SafeExamBrowser.Contracts.Configuration;
using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.Browser
@ -15,6 +19,25 @@ namespace SafeExamBrowser.Browser
public class BrowserApplicationController : IApplicationController
{
private ITaskbarButton button;
private IList<IApplicationInstance> instances = new List<IApplicationInstance>();
private ISettings settings;
private IUiElementFactory uiFactory;
public BrowserApplicationController(ISettings settings, IUiElementFactory uiFactory)
{
this.settings = settings;
this.uiFactory = uiFactory;
}
public void Initialize()
{
var cefSettings = new CefSettings
{
CachePath = settings.BrowserCachePath
};
Cef.Initialize(cefSettings, true, null);
}
public void RegisterApplicationButton(ITaskbarButton button)
{
@ -22,9 +45,32 @@ namespace SafeExamBrowser.Browser
this.button.OnClick += ButtonClick;
}
public void Terminate()
{
Cef.Shutdown();
}
private void ButtonClick(Guid? instanceId = null)
{
button.RegisterInstance(new BrowserApplicationInstance("A new instance. Yaji..."));
if (instanceId.HasValue)
{
instances.FirstOrDefault(i => i.Id == instanceId)?.Window?.BringToForeground();
}
else
{
CreateNewInstance();
}
}
private void CreateNewInstance()
{
var control = new BrowserControl("www.duckduckgo.com");
var window = uiFactory.CreateBrowserWindow(control);
var instance = new BrowserApplicationInstance("DuckDuckGo");
instances.Add(instance);
instance.RegisterWindow(window);
button.RegisterInstance(instance);
}
}
}

View file

@ -8,6 +8,7 @@
using System;
using SafeExamBrowser.Contracts.Configuration;
using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.Browser
{
@ -15,11 +16,17 @@ namespace SafeExamBrowser.Browser
{
public Guid Id { get; private set; }
public string Name { get; private set; }
public IWindow Window { get; private set; }
public BrowserApplicationInstance(string name)
{
Id = Guid.NewGuid();
Name = name;
}
public void RegisterWindow(IWindow window)
{
Window = window;
}
}
}

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2017 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 CefSharp.Wpf;
using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.Browser
{
class BrowserControl : ChromiumWebBrowser, IBrowserControl
{
public BrowserControl(string url)
{
Address = url;
}
}
}

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\CefSharp.Wpf.57.0.0\build\CefSharp.Wpf.props" Condition="Exists('..\packages\CefSharp.Wpf.57.0.0\build\CefSharp.Wpf.props')" />
<Import Project="..\packages\CefSharp.Common.57.0.0\build\CefSharp.Common.props" Condition="Exists('..\packages\CefSharp.Common.57.0.0\build\CefSharp.Common.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -11,6 +13,8 @@
<AssemblyName>SafeExamBrowser.Browser</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -29,20 +33,43 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="BrowserApplicationController.cs" />
<Compile Include="BrowserApplicationInfo.cs" />
<Compile Include="BrowserApplicationInstance.cs" />
<Compile Include="BrowserControl.cs" />
<Compile Include="BrowserIconResource.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
@ -58,5 +85,23 @@
<SubType>Designer</SubType>
</Resource>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\cef.redist.x64.3.2987.1601\build\cef.redist.x64.targets" Condition="Exists('..\packages\cef.redist.x64.3.2987.1601\build\cef.redist.x64.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\cef.redist.x64.3.2987.1601\build\cef.redist.x64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.3.2987.1601\build\cef.redist.x64.targets'))" />
<Error Condition="!Exists('..\packages\cef.redist.x86.3.2987.1601\build\cef.redist.x86.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.3.2987.1601\build\cef.redist.x86.targets'))" />
<Error Condition="!Exists('..\packages\CefSharp.Common.57.0.0\build\CefSharp.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.57.0.0\build\CefSharp.Common.props'))" />
<Error Condition="!Exists('..\packages\CefSharp.Common.57.0.0\build\CefSharp.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.57.0.0\build\CefSharp.Common.targets'))" />
<Error Condition="!Exists('..\packages\CefSharp.Wpf.57.0.0\build\CefSharp.Wpf.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Wpf.57.0.0\build\CefSharp.Wpf.props'))" />
<Error Condition="!Exists('..\packages\CefSharp.Wpf.57.0.0\build\CefSharp.Wpf.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Wpf.57.0.0\build\CefSharp.Wpf.targets'))" />
</Target>
<Import Project="..\packages\cef.redist.x86.3.2987.1601\build\cef.redist.x86.targets" Condition="Exists('..\packages\cef.redist.x86.3.2987.1601\build\cef.redist.x86.targets')" />
<Import Project="..\packages\CefSharp.Common.57.0.0\build\CefSharp.Common.targets" Condition="Exists('..\packages\CefSharp.Common.57.0.0\build\CefSharp.Common.targets')" />
<Import Project="..\packages\CefSharp.Wpf.57.0.0\build\CefSharp.Wpf.targets" Condition="Exists('..\packages\CefSharp.Wpf.57.0.0\build\CefSharp.Wpf.targets')" />
</Project>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="cef.redist.x64" version="3.2987.1601" targetFramework="net452" />
<package id="cef.redist.x86" version="3.2987.1601" targetFramework="net452" />
<package id="CefSharp.Common" version="57.0.0" targetFramework="net452" />
<package id="CefSharp.Wpf" version="57.0.0" targetFramework="net452" />
</packages>

View file

@ -29,6 +29,24 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />

View file

@ -15,11 +15,21 @@ namespace SafeExamBrowser.Configuration
{
public class Settings : ISettings
{
private const string AppDataFolder = "SafeExamBrowser";
public string BrowserCachePath
{
get
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataFolder, "Cache");
}
}
public string LogFolderPath
{
get
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SafeExamBrowser", "Logs");
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataFolder, "Logs");
}
}

View file

@ -12,9 +12,19 @@ namespace SafeExamBrowser.Contracts.Behaviour
{
public interface IApplicationController
{
/// <summary>
/// Performs any initialization work, if necessary.
/// </summary>
void Initialize();
/// <summary>
/// Registers the taskbar button for this application.
/// </summary>
void RegisterApplicationButton(ITaskbarButton button);
/// <summary>
/// Performs any termination work, e.g. freeing of resources.
/// </summary>
void Terminate();
}
}

View file

@ -7,6 +7,7 @@
*/
using System;
using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.Contracts.Configuration
{
@ -21,5 +22,15 @@ namespace SafeExamBrowser.Contracts.Configuration
/// The name or (document) title of the application instance.
/// </summary>
string Name { get; }
/// <summary>
/// The main window of the application instance.
/// </summary>
IWindow Window { get; }
/// <summary>
/// Registers the given window as the main window of the application instance.
/// </summary>
void RegisterWindow(IWindow window);
}
}

View file

@ -10,6 +10,11 @@ namespace SafeExamBrowser.Contracts.Configuration
{
public interface ISettings
{
/// <summary>
/// The path where the browser cache is to be stored.
/// </summary>
string BrowserCachePath { get; }
/// <summary>
/// The path where the log files are to be stored.
/// </summary>

View file

@ -29,6 +29,24 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@ -64,6 +82,8 @@
<Compile Include="Monitoring\IMouseInterceptor.cs" />
<Compile Include="Monitoring\IProcessMonitor.cs" />
<Compile Include="Monitoring\IWindowMonitor.cs" />
<Compile Include="UserInterface\IBrowserControl.cs" />
<Compile Include="UserInterface\IBrowserWindow.cs" />
<Compile Include="UserInterface\IMessageBox.cs" />
<Compile Include="UserInterface\ITaskbarNotification.cs" />
<Compile Include="UserInterface\ISplashScreen.cs" />
@ -72,6 +92,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserInterface\ITaskbarButton.cs" />
<Compile Include="UserInterface\IUiElementFactory.cs" />
<Compile Include="UserInterface\IWindow.cs" />
<Compile Include="UserInterface\MessageBoxAction.cs" />
<Compile Include="UserInterface\MessageBoxIcon.cs" />
</ItemGroup>

View file

@ -0,0 +1,14 @@
/*
* Copyright (c) 2017 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/.
*/
namespace SafeExamBrowser.Contracts.UserInterface
{
public interface IBrowserControl
{
}
}

View file

@ -0,0 +1,14 @@
/*
* Copyright (c) 2017 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/.
*/
namespace SafeExamBrowser.Contracts.UserInterface
{
public interface IBrowserWindow : IWindow
{
}
}

View file

@ -18,6 +18,11 @@ namespace SafeExamBrowser.Contracts.UserInterface
/// </summary>
ITaskbarButton CreateApplicationButton(IApplicationInfo info);
/// <summary>
/// Creates a new browser window loaded with the given browser control.
/// </summary>
IBrowserWindow CreateBrowserWindow(IBrowserControl control);
/// <summary>
/// Creates a taskbar notification, initialized with the given notification information.
/// </summary>

View file

@ -0,0 +1,18 @@
/*
* Copyright (c) 2017 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/.
*/
namespace SafeExamBrowser.Contracts.UserInterface
{
public interface IWindow
{
/// <summary>
/// Brings the window to the foreground.
/// </summary>
void BringToForeground();
}
}

View file

@ -37,6 +37,24 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=4.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.4.1.0\lib\net45\Castle.Core.dll</HintPath>

View file

@ -45,13 +45,17 @@ namespace SafeExamBrowser.Core.Behaviour.Operations
var browserButton = uiFactory.CreateApplicationButton(browserInfo);
browserController.Initialize();
browserController.RegisterApplicationButton(browserButton);
taskbar.AddButton(browserButton);
}
public void Revert()
{
// Nothing to do here so far...
logger.Info("Terminating browser...");
browserController.Terminate();
logger.Info("Browser successfully terminated.");
}
}
}

View file

@ -29,6 +29,24 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />

View file

@ -29,6 +29,24 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />

View file

@ -0,0 +1,12 @@
<Window x:Class="SafeExamBrowser.UserInterface.BrowserWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface"
mc:Ignorable="d"
Title="BrowserWindow" Height="300" Width="300">
<ContentControl x:Name="BrowserContainer">
</ContentControl>
</Window>

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 2017 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.Windows;
using SafeExamBrowser.Contracts.UserInterface;
namespace SafeExamBrowser.UserInterface
{
public partial class BrowserWindow : Window, IBrowserWindow
{
public BrowserWindow(IBrowserControl browserControl)
{
InitializeComponent();
if (browserControl is UIElement)
{
BrowserContainer.Content = browserControl;
}
}
public void BringToForeground()
{
Activate();
}
}
}

View file

@ -35,7 +35,7 @@ namespace SafeExamBrowser.UserInterface.Controls
{
Icon.Content = IconResourceLoader.Load(info.IconResource);
Text.Text = instance.Name;
Button.ToolTip = $"{instance.Name} - {info.Tooltip}";
Button.ToolTip = $"{instance.Name} - {info.Name}";
}
private void Button_Click(object sender, RoutedEventArgs e)

View file

@ -30,6 +30,24 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
@ -47,6 +65,9 @@
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="BrowserWindow.xaml.cs">
<DependentUpon>BrowserWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ApplicationInstanceButton.xaml.cs">
<DependentUpon>ApplicationInstanceButton.xaml</DependentUpon>
</Compile>
@ -95,6 +116,10 @@
</None>
</ItemGroup>
<ItemGroup>
<Page Include="BrowserWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\ApplicationInstanceButton.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View file

@ -22,9 +22,9 @@ namespace SafeExamBrowser.UserInterface
return new ApplicationButton(info);
}
public void Show(string message, string title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information)
public IBrowserWindow CreateBrowserWindow(IBrowserControl control)
{
MessageBox.Show(message, title, ToButton(action), ToImage(icon));
return new BrowserWindow(control);
}
public ITaskbarNotification CreateNotification(INotificationInfo info)
@ -57,6 +57,11 @@ namespace SafeExamBrowser.UserInterface
return splashScreen;
}
public void Show(string message, string title, MessageBoxAction action = MessageBoxAction.Confirm, MessageBoxIcon icon = MessageBoxIcon.Information)
{
MessageBox.Show(message, title, ToButton(action), ToImage(icon));
}
private MessageBoxButton ToButton(MessageBoxAction action)
{
switch (action)

View file

@ -29,6 +29,24 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />

View file

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.14
VisualStudioVersion = 15.0.26430.15
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser", "SafeExamBrowser\SafeExamBrowser.csproj", "{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}"
EndProject
@ -30,45 +30,83 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}.Debug|x86.ActiveCfg = Debug|x86
{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}.Debug|x86.Build.0 = Debug|x86
{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}.Release|Any CPU.Build.0 = Release|Any CPU
{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}.Release|x86.ActiveCfg = Release|x86
{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}.Release|x86.Build.0 = Release|x86
{3D6FDBB6-A4AF-4626-BB2B-BF329D44F9CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D6FDBB6-A4AF-4626-BB2B-BF329D44F9CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D6FDBB6-A4AF-4626-BB2B-BF329D44F9CC}.Debug|x86.ActiveCfg = Debug|x86
{3D6FDBB6-A4AF-4626-BB2B-BF329D44F9CC}.Debug|x86.Build.0 = Debug|x86
{3D6FDBB6-A4AF-4626-BB2B-BF329D44F9CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D6FDBB6-A4AF-4626-BB2B-BF329D44F9CC}.Release|Any CPU.Build.0 = Release|Any CPU
{3D6FDBB6-A4AF-4626-BB2B-BF329D44F9CC}.Release|x86.ActiveCfg = Release|x86
{3D6FDBB6-A4AF-4626-BB2B-BF329D44F9CC}.Release|x86.Build.0 = Release|x86
{E1BE031A-4354-41E7-83E8-843DED4489FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1BE031A-4354-41E7-83E8-843DED4489FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1BE031A-4354-41E7-83E8-843DED4489FF}.Debug|x86.ActiveCfg = Debug|x86
{E1BE031A-4354-41E7-83E8-843DED4489FF}.Debug|x86.Build.0 = Debug|x86
{E1BE031A-4354-41E7-83E8-843DED4489FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1BE031A-4354-41E7-83E8-843DED4489FF}.Release|Any CPU.Build.0 = Release|Any CPU
{E1BE031A-4354-41E7-83E8-843DED4489FF}.Release|x86.ActiveCfg = Release|x86
{E1BE031A-4354-41E7-83E8-843DED4489FF}.Release|x86.Build.0 = Release|x86
{48B9F2A1-B87D-40F0-BEC9-399E8909860F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48B9F2A1-B87D-40F0-BEC9-399E8909860F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48B9F2A1-B87D-40F0-BEC9-399E8909860F}.Debug|x86.ActiveCfg = Debug|x86
{48B9F2A1-B87D-40F0-BEC9-399E8909860F}.Debug|x86.Build.0 = Debug|x86
{48B9F2A1-B87D-40F0-BEC9-399E8909860F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48B9F2A1-B87D-40F0-BEC9-399E8909860F}.Release|Any CPU.Build.0 = Release|Any CPU
{48B9F2A1-B87D-40F0-BEC9-399E8909860F}.Release|x86.ActiveCfg = Release|x86
{48B9F2A1-B87D-40F0-BEC9-399E8909860F}.Release|x86.Build.0 = Release|x86
{47DA5933-BEF8-4729-94E6-ABDE2DB12262}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47DA5933-BEF8-4729-94E6-ABDE2DB12262}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47DA5933-BEF8-4729-94E6-ABDE2DB12262}.Debug|x86.ActiveCfg = Debug|x86
{47DA5933-BEF8-4729-94E6-ABDE2DB12262}.Debug|x86.Build.0 = Debug|x86
{47DA5933-BEF8-4729-94E6-ABDE2DB12262}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47DA5933-BEF8-4729-94E6-ABDE2DB12262}.Release|Any CPU.Build.0 = Release|Any CPU
{47DA5933-BEF8-4729-94E6-ABDE2DB12262}.Release|x86.ActiveCfg = Release|x86
{47DA5933-BEF8-4729-94E6-ABDE2DB12262}.Release|x86.Build.0 = Release|x86
{04E653F1-98E6-4E34-9DD7-7F2BC1A8B767}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04E653F1-98E6-4E34-9DD7-7F2BC1A8B767}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04E653F1-98E6-4E34-9DD7-7F2BC1A8B767}.Debug|x86.ActiveCfg = Debug|x86
{04E653F1-98E6-4E34-9DD7-7F2BC1A8B767}.Debug|x86.Build.0 = Debug|x86
{04E653F1-98E6-4E34-9DD7-7F2BC1A8B767}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04E653F1-98E6-4E34-9DD7-7F2BC1A8B767}.Release|Any CPU.Build.0 = Release|Any CPU
{04E653F1-98E6-4E34-9DD7-7F2BC1A8B767}.Release|x86.ActiveCfg = Release|x86
{04E653F1-98E6-4E34-9DD7-7F2BC1A8B767}.Release|x86.Build.0 = Release|x86
{EF563531-4EB5-44B9-A5EC-D6D6F204469B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF563531-4EB5-44B9-A5EC-D6D6F204469B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF563531-4EB5-44B9-A5EC-D6D6F204469B}.Debug|x86.ActiveCfg = Debug|x86
{EF563531-4EB5-44B9-A5EC-D6D6F204469B}.Debug|x86.Build.0 = Debug|x86
{EF563531-4EB5-44B9-A5EC-D6D6F204469B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF563531-4EB5-44B9-A5EC-D6D6F204469B}.Release|Any CPU.Build.0 = Release|Any CPU
{EF563531-4EB5-44B9-A5EC-D6D6F204469B}.Release|x86.ActiveCfg = Release|x86
{EF563531-4EB5-44B9-A5EC-D6D6F204469B}.Release|x86.Build.0 = Release|x86
{C388C4DD-A159-457D-AF92-89F7AD185109}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C388C4DD-A159-457D-AF92-89F7AD185109}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C388C4DD-A159-457D-AF92-89F7AD185109}.Debug|x86.ActiveCfg = Debug|x86
{C388C4DD-A159-457D-AF92-89F7AD185109}.Debug|x86.Build.0 = Debug|x86
{C388C4DD-A159-457D-AF92-89F7AD185109}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C388C4DD-A159-457D-AF92-89F7AD185109}.Release|Any CPU.Build.0 = Release|Any CPU
{C388C4DD-A159-457D-AF92-89F7AD185109}.Release|x86.ActiveCfg = Release|x86
{C388C4DD-A159-457D-AF92-89F7AD185109}.Release|x86.Build.0 = Release|x86
{73724659-4150-4792-A94E-42F5F3C1B696}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73724659-4150-4792-A94E-42F5F3C1B696}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73724659-4150-4792-A94E-42F5F3C1B696}.Debug|x86.ActiveCfg = Debug|x86
{73724659-4150-4792-A94E-42F5F3C1B696}.Debug|x86.Build.0 = Debug|x86
{73724659-4150-4792-A94E-42F5F3C1B696}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73724659-4150-4792-A94E-42F5F3C1B696}.Release|Any CPU.Build.0 = Release|Any CPU
{73724659-4150-4792-A94E-42F5F3C1B696}.Release|x86.ActiveCfg = Release|x86
{73724659-4150-4792-A94E-42F5F3C1B696}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -46,7 +46,6 @@ namespace SafeExamBrowser
public void BuildObjectGraph()
{
browserController = new BrowserApplicationController();
browserInfo = new BrowserApplicationInfo();
logger = new Logger();
settings = new Settings();
@ -58,6 +57,7 @@ namespace SafeExamBrowser
text = new Text(textResource);
aboutInfo = new AboutNotificationInfo(text);
browserController = new BrowserApplicationController(settings, uiFactory);
processMonitor = new ProcessMonitor(new ModuleLogger(logger, typeof(ProcessMonitor)));
windowMonitor = new WindowMonitor(new ModuleLogger(logger, typeof(WindowMonitor)));
workingArea = new WorkingArea(new ModuleLogger(logger, typeof(WorkingArea)));

View file

@ -54,6 +54,26 @@
<PropertyGroup>
<ApplicationIcon>SafeExamBrowser.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />