diff --git a/SafeExamBrowser.Browser/BrowserApplicationController.cs b/SafeExamBrowser.Browser/BrowserApplicationController.cs index 209192d7..6683b61b 100644 --- a/SafeExamBrowser.Browser/BrowserApplicationController.cs +++ b/SafeExamBrowser.Browser/BrowserApplicationController.cs @@ -33,7 +33,8 @@ namespace SafeExamBrowser.Browser { var cefSettings = new CefSettings { - CachePath = settings.BrowserCachePath + CachePath = settings.BrowserCachePath, + LogFile = settings.BrowserLogFile }; var success = Cef.Initialize(cefSettings, true, null); @@ -64,8 +65,6 @@ namespace SafeExamBrowser.Browser else { CreateNewInstance(); - CreateNewInstance(); - CreateNewInstance(); } } @@ -79,7 +78,7 @@ namespace SafeExamBrowser.Browser instance.RegisterWindow(window); button.RegisterInstance(instance); - window.Display(); + window.Show(); } } } diff --git a/SafeExamBrowser.Configuration/Settings.cs b/SafeExamBrowser.Configuration/Settings.cs index becb0217..1fde9f4e 100644 --- a/SafeExamBrowser.Configuration/Settings.cs +++ b/SafeExamBrowser.Configuration/Settings.cs @@ -16,21 +16,26 @@ namespace SafeExamBrowser.Configuration public class Settings : ISettings { private const string AppDataFolder = "SafeExamBrowser"; + private static readonly string LogFileDate = DateTime.Now.ToString("yyyy-MM-dd HH\\hmm\\mss\\s"); + + public string ApplicationLogFile + { + get { return Path.Combine(LogFolderPath, $"{LogFileDate} Application.txt"); } + } + + public string BrowserLogFile + { + get { return Path.Combine(LogFolderPath, $"{LogFileDate} Browser.txt"); } + } public string BrowserCachePath { - get - { - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataFolder, "Cache"); - } + get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataFolder, "Cache"); } } public string LogFolderPath { - get - { - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataFolder, "Logs"); - } + get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataFolder, "Logs"); } } public string ProgramCopyright diff --git a/SafeExamBrowser.Contracts/Configuration/ISettings.cs b/SafeExamBrowser.Contracts/Configuration/ISettings.cs index b5a80ae0..9e577b69 100644 --- a/SafeExamBrowser.Contracts/Configuration/ISettings.cs +++ b/SafeExamBrowser.Contracts/Configuration/ISettings.cs @@ -10,11 +10,21 @@ namespace SafeExamBrowser.Contracts.Configuration { public interface ISettings { + /// + /// The file path under which the application log is to be stored. + /// + string ApplicationLogFile { get; } + /// /// The path where the browser cache is to be stored. /// string BrowserCachePath { get; } + /// + /// The file path under which the browser log is to be stored. + /// + string BrowserLogFile { get; } + /// /// The path where the log files are to be stored. /// diff --git a/SafeExamBrowser.Contracts/UserInterface/IWindow.cs b/SafeExamBrowser.Contracts/UserInterface/IWindow.cs index 9195cb2e..01869079 100644 --- a/SafeExamBrowser.Contracts/UserInterface/IWindow.cs +++ b/SafeExamBrowser.Contracts/UserInterface/IWindow.cs @@ -18,6 +18,6 @@ namespace SafeExamBrowser.Contracts.UserInterface /// /// Shows the window to the user. /// - void Display(); + void Show(); } } diff --git a/SafeExamBrowser.Core/Behaviour/Operations/BrowserInitializationOperation.cs b/SafeExamBrowser.Core/Behaviour/Operations/BrowserInitializationOperation.cs index 9bde5d97..93bbbfc9 100644 --- a/SafeExamBrowser.Core/Behaviour/Operations/BrowserInitializationOperation.cs +++ b/SafeExamBrowser.Core/Behaviour/Operations/BrowserInitializationOperation.cs @@ -49,6 +49,7 @@ namespace SafeExamBrowser.Core.Behaviour.Operations browserController.RegisterApplicationButton(browserButton); taskbar.AddButton(browserButton); + logger.Info("Browser successfully initialized."); } public void Revert() diff --git a/SafeExamBrowser.Core/Behaviour/StartupController.cs b/SafeExamBrowser.Core/Behaviour/StartupController.cs index 492ed7ed..494caac4 100644 --- a/SafeExamBrowser.Core/Behaviour/StartupController.cs +++ b/SafeExamBrowser.Core/Behaviour/StartupController.cs @@ -43,7 +43,7 @@ namespace SafeExamBrowser.Core.Behaviour InitializeApplicationLog(); InitializeSplashScreen(operations.Count); - PerformOperations(operations); + Perform(operations); FinishInitialization(); @@ -59,7 +59,7 @@ namespace SafeExamBrowser.Core.Behaviour } } - private void PerformOperations(Queue operations) + private void Perform(Queue operations) { foreach (var operation in operations) { diff --git a/SafeExamBrowser.Core/Logging/LogFileWriter.cs b/SafeExamBrowser.Core/Logging/LogFileWriter.cs index a5e78d6b..c8db9014 100644 --- a/SafeExamBrowser.Core/Logging/LogFileWriter.cs +++ b/SafeExamBrowser.Core/Logging/LogFileWriter.cs @@ -6,7 +6,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -using System; using System.IO; using System.Text; using SafeExamBrowser.Contracts.Configuration; @@ -21,14 +20,12 @@ namespace SafeExamBrowser.Core.Logging public LogFileWriter(ISettings settings) { - var fileName = $"{DateTime.Now.ToString("yyyy-MM-dd HH\\hmm\\mss\\s")}.txt"; - if (!Directory.Exists(settings.LogFolderPath)) { Directory.CreateDirectory(settings.LogFolderPath); } - filePath = Path.Combine(settings.LogFolderPath, fileName); + filePath = settings.ApplicationLogFile; } public void Notify(ILogContent content) diff --git a/SafeExamBrowser.UserInterface/BrowserWindow.xaml b/SafeExamBrowser.UserInterface/BrowserWindow.xaml index c16bd483..f09eba9e 100644 --- a/SafeExamBrowser.UserInterface/BrowserWindow.xaml +++ b/SafeExamBrowser.UserInterface/BrowserWindow.xaml @@ -5,8 +5,24 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:SafeExamBrowser.UserInterface" mc:Ignorable="d" - Title="BrowserWindow" Height="300" Width="300"> + Title="BrowserWindow" Height="500" Width="500" WindowState="Maximized"> - + + + + + + + + + + + + + + + + + diff --git a/SafeExamBrowser.UserInterface/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface/BrowserWindow.xaml.cs index 7719f4bf..a8581053 100644 --- a/SafeExamBrowser.UserInterface/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface/BrowserWindow.xaml.cs @@ -16,21 +16,25 @@ namespace SafeExamBrowser.UserInterface public BrowserWindow(IBrowserControl browserControl) { InitializeComponent(); + InitializeBrowserWindow(browserControl); + } + public void BringToForeground() + { + if (WindowState == WindowState.Minimized) + { + WindowState = WindowState.Normal; + } + + Activate(); + } + + private void InitializeBrowserWindow(IBrowserControl browserControl) + { if (browserControl is System.Windows.Forms.Control) { BrowserControlHost.Child = browserControl as System.Windows.Forms.Control; } } - - public void BringToForeground() - { - Activate(); - } - - public void Display() - { - Show(); - } } } diff --git a/SafeExamBrowser.UserInterface/Taskbar.xaml b/SafeExamBrowser.UserInterface/Taskbar.xaml index 08ef9925..5b35fe25 100644 --- a/SafeExamBrowser.UserInterface/Taskbar.xaml +++ b/SafeExamBrowser.UserInterface/Taskbar.xaml @@ -6,7 +6,8 @@ xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Controls" xmlns:s="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" - Title="Taskbar" Height="40" Width="750" WindowStyle="None" AllowsTransparency="True" Topmost="True" Visibility="Collapsed" Icon="./Images/SafeExamBrowser.ico"> + Title="Taskbar" Height="40" Width="750" WindowStyle="None" AllowsTransparency="True" Topmost="True" Visibility="Collapsed" + ResizeMode="NoResize" Icon="./Images/SafeExamBrowser.ico">