2018-01-25 11:59:44 +01:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018 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.Windows;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using SafeExamBrowser.Contracts.Configuration;
|
2018-01-26 12:33:36 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.I18n;
|
2018-01-25 11:59:44 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.Logging;
|
2018-01-26 12:33:36 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface;
|
2018-01-25 11:59:44 +01:00
|
|
|
|
|
|
|
|
|
namespace SafeExamBrowser.UserInterface.Classic
|
|
|
|
|
{
|
2018-01-26 12:33:36 +01:00
|
|
|
|
public partial class RuntimeWindow : Window, ILogObserver, IRuntimeWindow
|
2018-01-25 11:59:44 +01:00
|
|
|
|
{
|
|
|
|
|
private ILogContentFormatter formatter;
|
|
|
|
|
private IRuntimeInfo runtimeInfo;
|
2018-01-26 12:33:36 +01:00
|
|
|
|
private IText text;
|
|
|
|
|
private WindowClosingEventHandler closing;
|
2018-01-25 11:59:44 +01:00
|
|
|
|
|
2018-01-26 12:33:36 +01:00
|
|
|
|
event WindowClosingEventHandler IWindow.Closing
|
|
|
|
|
{
|
|
|
|
|
add { closing += value; }
|
|
|
|
|
remove { closing -= value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RuntimeWindow(ILogContentFormatter formatter, IRuntimeInfo runtimeInfo, IText text)
|
2018-01-25 11:59:44 +01:00
|
|
|
|
{
|
|
|
|
|
this.formatter = formatter;
|
|
|
|
|
this.runtimeInfo = runtimeInfo;
|
2018-01-26 12:33:36 +01:00
|
|
|
|
this.text = text;
|
2018-01-25 11:59:44 +01:00
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
InitializeRuntimeWindow();
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-26 12:33:36 +01:00
|
|
|
|
public void BringToForeground()
|
|
|
|
|
{
|
|
|
|
|
Dispatcher.Invoke(Activate);
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-25 11:59:44 +01:00
|
|
|
|
public void Notify(ILogContent content)
|
|
|
|
|
{
|
2018-01-26 12:33:36 +01:00
|
|
|
|
Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
LogTextBlock.Text += formatter.Format(content) + Environment.NewLine;
|
|
|
|
|
LogScrollViewer.ScrollToEnd();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateStatus(TextKey key)
|
|
|
|
|
{
|
|
|
|
|
Dispatcher.Invoke(() => StatusTextBlock.Text = text.Get(key));
|
2018-01-25 11:59:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeRuntimeWindow()
|
|
|
|
|
{
|
2018-01-26 12:33:36 +01:00
|
|
|
|
Title = $"{runtimeInfo.ProgramTitle} - Version {runtimeInfo.ProgramVersion}";
|
2018-01-25 11:59:44 +01:00
|
|
|
|
InfoTextBlock.Inlines.Add(new Run($"Version {runtimeInfo.ProgramVersion}") { FontStyle = FontStyles.Italic });
|
|
|
|
|
InfoTextBlock.Inlines.Add(new LineBreak());
|
|
|
|
|
InfoTextBlock.Inlines.Add(new LineBreak());
|
|
|
|
|
InfoTextBlock.Inlines.Add(new Run(runtimeInfo.ProgramCopyright) { FontSize = 10 });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|