seb-win-refactoring/SafeExamBrowser.Configuration/Settings.cs

84 lines
2.1 KiB
C#
Raw Normal View History

/*
* 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;
using System.IO;
using System.Reflection;
2017-07-28 14:52:15 +02:00
using SafeExamBrowser.Contracts.Configuration.Settings;
namespace SafeExamBrowser.Configuration
{
2017-07-28 14:52:15 +02:00
/// <remarks>
/// TODO: Replace with proper implementation once configuration aspects are clear...
/// </remarks>
public class Settings : ISettings
{
private static readonly string LogFileDate = DateTime.Now.ToString("yyyy-MM-dd\\_HH\\hmm\\mss\\s");
public Settings()
{
2017-07-28 14:52:15 +02:00
Browser = new BrowserSettings(this);
2017-08-04 12:19:56 +02:00
Keyboard = new KeyboardSettings();
2017-08-04 15:20:33 +02:00
Mouse = new MouseSettings();
}
2017-08-07 12:23:56 +02:00
public bool AllowApplicationLog => true;
public bool AllowKeyboardLayout => true;
2017-07-28 14:52:15 +02:00
public string AppDataFolderName => "SafeExamBrowser";
2017-07-28 14:52:15 +02:00
public string ApplicationLogFile
{
2017-07-28 14:52:15 +02:00
get { return Path.Combine(LogFolderPath, $"{RuntimeIdentifier}_Application.txt"); }
}
2017-07-28 14:52:15 +02:00
public IBrowserSettings Browser { get; private set; }
2017-08-04 12:19:56 +02:00
public IKeyboardSettings Keyboard { get; private set; }
2017-08-04 15:20:33 +02:00
public IMouseSettings Mouse { get; private set; }
public string LogFolderPath
{
2017-07-28 14:52:15 +02:00
get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppDataFolderName, "Logs"); }
}
public string ProgramCopyright
{
get
{
var executable = Assembly.GetEntryAssembly();
var copyright = executable.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
return copyright;
}
}
public string ProgramTitle
{
get
{
var executable = Assembly.GetEntryAssembly();
var title = executable.GetCustomAttribute<AssemblyTitleAttribute>().Title;
return title;
}
}
public string ProgramVersion
{
get
{
var executable = Assembly.GetEntryAssembly();
var version = executable.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
return version;
}
}
2017-07-28 14:52:15 +02:00
public string RuntimeIdentifier => LogFileDate;
}
}