diff --git a/SafeExamBrowser.Client/App.config b/SafeExamBrowser.Client/App.config new file mode 100644 index 00000000..731f6de6 --- /dev/null +++ b/SafeExamBrowser.Client/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SafeExamBrowser.Client/App.cs b/SafeExamBrowser.Client/App.cs new file mode 100644 index 00000000..fef3ac0a --- /dev/null +++ b/SafeExamBrowser.Client/App.cs @@ -0,0 +1,86 @@ +/* + * 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.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Threading; +using System.Windows; +using SafeExamBrowser.Contracts.Behaviour; + +namespace SafeExamBrowser.Client +{ + public class App : Application + { + private static readonly Mutex Mutex = new Mutex(true, "safe_exam_browser_client_mutex"); + private CompositionRoot instances = new CompositionRoot(); + + [STAThread] + public static void Main() + { + try + { + StartApplication(); + } + catch (Exception e) + { + MessageBox.Show(e.Message + "\n\n" + e.StackTrace, "Fatal Error", MessageBoxButton.OK, MessageBoxImage.Error); + } + finally + { + Mutex.Close(); + } + } + + private static void StartApplication() + { + if (NoInstanceRunning()) + { + new App().Run(); + } + else + { + MessageBox.Show("You can only run one instance of SEB at a time.", "Startup Not Allowed", MessageBoxButton.OK, MessageBoxImage.Information); + } + } + + private static bool NoInstanceRunning() + { + return Mutex.WaitOne(TimeSpan.Zero, true); + } + + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + + instances.BuildObjectGraph(); + + var success = instances.StartupController.TryInitializeApplication(instances.StartupOperations); + + if (success) + { + MainWindow = instances.Taskbar; + MainWindow.Closing += MainWindow_Closing; + MainWindow.Show(); + } + else + { + Shutdown(); + } + } + + private void MainWindow_Closing(object sender, CancelEventArgs e) + { + var operations = new Queue(instances.StartupOperations.Reverse()); + + MainWindow.Hide(); + instances.ShutdownController.FinalizeApplication(operations); + } + } +} diff --git a/SafeExamBrowser.Client/CompositionRoot.cs b/SafeExamBrowser.Client/CompositionRoot.cs new file mode 100644 index 00000000..1c964675 --- /dev/null +++ b/SafeExamBrowser.Client/CompositionRoot.cs @@ -0,0 +1,27 @@ +/* + * 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.Collections.Generic; +using SafeExamBrowser.Contracts.Behaviour; +using SafeExamBrowser.UserInterface.Classic; + +namespace SafeExamBrowser.Client +{ + internal class CompositionRoot + { + public IShutdownController ShutdownController { get; private set; } + public IStartupController StartupController { get; private set; } + public Queue StartupOperations { get; private set; } + public Taskbar Taskbar { get; private set; } + + public void BuildObjectGraph() + { + + } + } +} diff --git a/SafeExamBrowser.Client/Properties/AssemblyInfo.cs b/SafeExamBrowser.Client/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..599f30a9 --- /dev/null +++ b/SafeExamBrowser.Client/Properties/AssemblyInfo.cs @@ -0,0 +1,53 @@ +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SafeExamBrowser.Client")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SafeExamBrowser.Client")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SafeExamBrowser.Client/Properties/Resources.Designer.cs b/SafeExamBrowser.Client/Properties/Resources.Designer.cs new file mode 100644 index 00000000..5a919136 --- /dev/null +++ b/SafeExamBrowser.Client/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SafeExamBrowser.Client.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SafeExamBrowser.Client.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/SafeExamBrowser.Client/Properties/Resources.resx b/SafeExamBrowser.Client/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/SafeExamBrowser.Client/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SafeExamBrowser.Client/Properties/Settings.Designer.cs b/SafeExamBrowser.Client/Properties/Settings.Designer.cs new file mode 100644 index 00000000..1b0d43f9 --- /dev/null +++ b/SafeExamBrowser.Client/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SafeExamBrowser.Client.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/SafeExamBrowser.Client/Properties/Settings.settings b/SafeExamBrowser.Client/Properties/Settings.settings new file mode 100644 index 00000000..033d7a5e --- /dev/null +++ b/SafeExamBrowser.Client/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/SafeExamBrowser.Client/SafeExamBrowser.Client.csproj b/SafeExamBrowser.Client/SafeExamBrowser.Client.csproj new file mode 100644 index 00000000..6fd95278 --- /dev/null +++ b/SafeExamBrowser.Client/SafeExamBrowser.Client.csproj @@ -0,0 +1,85 @@ + + + + + Debug + AnyCPU + {7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7} + WinExe + SafeExamBrowser.Client + SafeExamBrowser.Client + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + 4.0 + + + + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + {47DA5933-BEF8-4729-94E6-ABDE2DB12262} + SafeExamBrowser.Contracts + + + {A502DF54-7169-4647-94BD-18B192924866} + SafeExamBrowser.UserInterface.Classic + + + + \ No newline at end of file diff --git a/SafeExamBrowser.sln b/SafeExamBrowser.sln index 9109ae99..795f5e22 100644 --- a/SafeExamBrowser.sln +++ b/SafeExamBrowser.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27004.2008 +VisualStudioVersion = 15.0.27130.2020 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser", "SafeExamBrowser\SafeExamBrowser.csproj", "{E3AED2F8-B5DF-45D1-AC19-48066923D6D8}" EndProject @@ -35,6 +35,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{ Libraries\SimpleWifi.dll = Libraries\SimpleWifi.dll EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SafeExamBrowser.Client", "SafeExamBrowser.Client\SafeExamBrowser.Client.csproj", "{7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -131,6 +133,14 @@ Global {A502DF54-7169-4647-94BD-18B192924866}.Release|Any CPU.Build.0 = Release|Any CPU {A502DF54-7169-4647-94BD-18B192924866}.Release|x86.ActiveCfg = Release|Any CPU {A502DF54-7169-4647-94BD-18B192924866}.Release|x86.Build.0 = Release|Any CPU + {7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|x86.ActiveCfg = Debug|Any CPU + {7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Debug|x86.Build.0 = Debug|Any CPU + {7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|Any CPU.Build.0 = Release|Any CPU + {7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|x86.ActiveCfg = Release|Any CPU + {7CC5A895-E0D3-4E43-9B39-CCEC05A5A6A7}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SafeExamBrowser/App.cs b/SafeExamBrowser/App.cs index 69a309ed..2634c2ca 100644 --- a/SafeExamBrowser/App.cs +++ b/SafeExamBrowser/App.cs @@ -18,7 +18,7 @@ namespace SafeExamBrowser { public class App : Application { - private static readonly Mutex Mutex = new Mutex(true, "safe_exam_browser_single_instance_mutex"); + private static readonly Mutex Mutex = new Mutex(true, "safe_exam_browser_runtime_mutex"); private CompositionRoot instances = new CompositionRoot(); [STAThread]