Added post-build event to copy browser libraries to output directory of the main executable.

This commit is contained in:
Damian Büchel 2017-07-25 09:02:32 +02:00
parent 429685463b
commit 386d0e7a7a
7 changed files with 29 additions and 10 deletions

View file

@ -36,7 +36,12 @@ namespace SafeExamBrowser.Browser
CachePath = settings.BrowserCachePath CachePath = settings.BrowserCachePath
}; };
Cef.Initialize(cefSettings, true, null); var success = Cef.Initialize(cefSettings, true, null);
if (!success)
{
throw new Exception("Failed to initialize the browser engine!");
}
} }
public void RegisterApplicationButton(ITaskbarButton button) public void RegisterApplicationButton(ITaskbarButton button)
@ -64,13 +69,17 @@ namespace SafeExamBrowser.Browser
private void CreateNewInstance() private void CreateNewInstance()
{ {
var control = new BrowserControl("www.duckduckgo.com"); var control = new BrowserControl();
var window = uiFactory.CreateBrowserWindow(control); var window = uiFactory.CreateBrowserWindow(control);
var instance = new BrowserApplicationInstance("DuckDuckGo"); var instance = new BrowserApplicationInstance("DuckDuckGo");
instances.Add(instance); instances.Add(instance);
instance.RegisterWindow(window); instance.RegisterWindow(window);
button.RegisterInstance(instance); button.RegisterInstance(instance);
control.Address = "www.duckduckgo.com";
window.Display();
} }
} }
} }

View file

@ -13,9 +13,5 @@ namespace SafeExamBrowser.Browser
{ {
class BrowserControl : ChromiumWebBrowser, IBrowserControl class BrowserControl : ChromiumWebBrowser, IBrowserControl
{ {
public BrowserControl(string url)
{
Address = url;
}
} }
} }

View file

@ -104,4 +104,7 @@
<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\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.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')" /> <Import Project="..\packages\CefSharp.Wpf.57.0.0\build\CefSharp.Wpf.targets" Condition="Exists('..\packages\CefSharp.Wpf.57.0.0\build\CefSharp.Wpf.targets')" />
<PropertyGroup>
<PostBuildEvent>xcopy /E /Y "$(ProjectDir)bin\$(PlatformName)\$(ConfigurationName)" "$(SolutionDir)SafeExamBrowser\bin\$(PlatformName)\$(ConfigurationName)"</PostBuildEvent>
</PropertyGroup>
</Project> </Project>

View file

@ -14,5 +14,10 @@ namespace SafeExamBrowser.Contracts.UserInterface
/// Brings the window to the foreground. /// Brings the window to the foreground.
/// </summary> /// </summary>
void BringToForeground(); void BringToForeground();
/// <summary>
/// Shows the window to the user.
/// </summary>
void Display();
} }
} }

View file

@ -39,12 +39,12 @@ namespace SafeExamBrowser.Core.Behaviour
{ {
InitializeSplashScreen(); InitializeSplashScreen();
RevertOperations(operations); RevertOperations(operations);
FinalizeApplicationLog(); FinishFinalization();
} }
catch (Exception e) catch (Exception e)
{ {
LogAndShowException(e); LogAndShowException(e);
FinalizeApplicationLog(false); FinishFinalization(false);
} }
} }
@ -75,7 +75,7 @@ namespace SafeExamBrowser.Core.Behaviour
uiFactory.Show(text.Get(Key.MessageBox_ShutdownError), text.Get(Key.MessageBox_ShutdownErrorTitle), icon: MessageBoxIcon.Error); uiFactory.Show(text.Get(Key.MessageBox_ShutdownError), text.Get(Key.MessageBox_ShutdownErrorTitle), icon: MessageBoxIcon.Error);
} }
private void FinalizeApplicationLog(bool success = true) private void FinishFinalization(bool success = true)
{ {
if (success) if (success)
{ {
@ -83,6 +83,7 @@ namespace SafeExamBrowser.Core.Behaviour
} }
logger.Log($"{Environment.NewLine}# Application terminated at {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}"); logger.Log($"{Environment.NewLine}# Application terminated at {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}");
splashScreen?.InvokeClose();
} }
} }
} }

View file

@ -121,7 +121,7 @@ namespace SafeExamBrowser.Core.Behaviour
if (success) if (success)
{ {
logger.Info("--- Application successfully initialized! ---"); logger.Info("--- Application successfully initialized! ---");
splashScreen.InvokeClose(); splashScreen?.InvokeClose();
} }
else else
{ {

View file

@ -27,5 +27,10 @@ namespace SafeExamBrowser.UserInterface
{ {
Activate(); Activate();
} }
public void Display()
{
Show();
}
} }
} }