diff --git a/SafeExamBrowser.Applications/ExternalApplicationInstance.cs b/SafeExamBrowser.Applications/ExternalApplicationInstance.cs
index 02448e56..da6e7ea9 100644
--- a/SafeExamBrowser.Applications/ExternalApplicationInstance.cs
+++ b/SafeExamBrowser.Applications/ExternalApplicationInstance.cs
@@ -100,9 +100,6 @@ namespace SafeExamBrowser.Applications
var success = process.TryGetWindowTitle(out var title);
var hasChanged = name?.Equals(title, StringComparison.Ordinal) != true;
- // TODO: Use this and ensure log window doesn't hang on shutdown (if it is open)!
- // logger.Warn($"Success: {success} HasChanged: {hasChanged}");
-
if (success && hasChanged)
{
name = title;
diff --git a/SafeExamBrowser.I18n.Contracts/TextKey.cs b/SafeExamBrowser.I18n.Contracts/TextKey.cs
index 3872fd9a..74f4da6a 100644
--- a/SafeExamBrowser.I18n.Contracts/TextKey.cs
+++ b/SafeExamBrowser.I18n.Contracts/TextKey.cs
@@ -27,6 +27,7 @@ namespace SafeExamBrowser.I18n.Contracts
LockScreen_TerminateOption,
LockScreen_Title,
LockScreen_UnlockButton,
+ LogWindow_AutoScroll,
LogWindow_Title,
MessageBox_ApplicationAutoTerminationDataLossWarning,
MessageBox_ApplicationAutoTerminationQuestion,
diff --git a/SafeExamBrowser.I18n/Text.xml b/SafeExamBrowser.I18n/Text.xml
index 56ee7796..6e05b38d 100644
--- a/SafeExamBrowser.I18n/Text.xml
+++ b/SafeExamBrowser.I18n/Text.xml
@@ -39,6 +39,9 @@
Unlock
+
+ Auto-Scroll
+
Application Log
diff --git a/SafeExamBrowser.UserInterface.Desktop/LogWindow.xaml b/SafeExamBrowser.UserInterface.Desktop/LogWindow.xaml
index d5903c9e..72350a8b 100644
--- a/SafeExamBrowser.UserInterface.Desktop/LogWindow.xaml
+++ b/SafeExamBrowser.UserInterface.Desktop/LogWindow.xaml
@@ -4,8 +4,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Desktop"
- mc:Ignorable="d" Title="{Binding Path=WindowTitle}" Background="Black" Height="500" Width="1100" MinHeight="350" MinWidth="350"
- WindowStartupLocation="CenterScreen" Icon="./Images/LogNotification.ico">
+ mc:Ignorable="d" Title="{Binding Path=WindowTitle}" Background="Black" Foreground="White" Height="500" Width="1100" MinHeight="350"
+ MinWidth="350" WindowStartupLocation="CenterScreen" Icon="./Images/LogNotification.ico">
@@ -14,7 +14,15 @@
-
+
+
+
+
+
+
+
+
diff --git a/SafeExamBrowser.UserInterface.Desktop/LogWindow.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/LogWindow.xaml.cs
index 9bfb6aeb..f3ceb460 100644
--- a/SafeExamBrowser.UserInterface.Desktop/LogWindow.xaml.cs
+++ b/SafeExamBrowser.UserInterface.Desktop/LogWindow.xaml.cs
@@ -8,6 +8,7 @@
using System.ComponentModel;
using System.Windows;
+using System.Windows.Input;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Windows;
@@ -75,6 +76,8 @@ namespace SafeExamBrowser.UserInterface.Desktop
private void LogWindow_Loaded(object sender, RoutedEventArgs e)
{
+ Cursor = Cursors.Wait;
+
var log = logger.GetLog();
foreach (var content in log)
@@ -84,6 +87,8 @@ namespace SafeExamBrowser.UserInterface.Desktop
logger.Subscribe(model);
logger.Debug("Opened log window.");
+
+ Cursor = Cursors.Arrow;
}
private void LogWindow_Closing(object sender, CancelEventArgs e)
diff --git a/SafeExamBrowser.UserInterface.Desktop/ViewModels/LogViewModel.cs b/SafeExamBrowser.UserInterface.Desktop/ViewModels/LogViewModel.cs
index 0ce8e377..788027b3 100644
--- a/SafeExamBrowser.UserInterface.Desktop/ViewModels/LogViewModel.cs
+++ b/SafeExamBrowser.UserInterface.Desktop/ViewModels/LogViewModel.cs
@@ -23,6 +23,8 @@ namespace SafeExamBrowser.UserInterface.Desktop.ViewModels
private ScrollViewer scrollViewer;
private TextBlock textBlock;
+ public bool AutoScroll { get; set; } = true;
+ public string AutoScrollTitle => text.Get(TextKey.LogWindow_AutoScroll);
public string WindowTitle => text.Get(TextKey.LogWindow_Title);
public LogViewModel(IText text, ScrollViewer scrollViewer, TextBlock textBlock)
@@ -45,29 +47,25 @@ namespace SafeExamBrowser.UserInterface.Desktop.ViewModels
default:
throw new NotImplementedException($"The log window is not yet implemented for log content of type {content.GetType()}!");
}
-
- scrollViewer.Dispatcher.Invoke(scrollViewer.ScrollToEnd);
}
private void AppendLogText(ILogText logText)
{
- textBlock.Dispatcher.Invoke(() =>
+ textBlock.Dispatcher.InvokeAsync(() =>
{
var isHeader = logText.Text.StartsWith("/* ");
var isComment = logText.Text.StartsWith("# ");
var brush = isHeader || isComment ? Brushes.LimeGreen : textBlock.Foreground;
+ var fontWeight = isHeader ? FontWeights.Bold : FontWeights.Normal;
- textBlock.Inlines.Add(new Run($"{logText.Text}{Environment.NewLine}")
- {
- FontWeight = isHeader ? FontWeights.Bold : FontWeights.Normal,
- Foreground = brush
- });
+ textBlock.Inlines.Add(new Run($"{logText.Text}{Environment.NewLine}") { FontWeight = fontWeight, Foreground = brush });
+ ScrollToEnd();
});
}
private void AppendLogMessage(ILogMessage message)
{
- textBlock.Dispatcher.Invoke(() =>
+ textBlock.Dispatcher.InvokeAsync(() =>
{
var date = message.DateTime.ToString("HH:mm:ss.fff");
var severity = message.Severity.ToString().ToUpper();
@@ -80,6 +78,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.ViewModels
textBlock.Inlines.Add(infoRun);
textBlock.Inlines.Add(messageRun);
+ ScrollToEnd();
});
}
@@ -97,5 +96,13 @@ namespace SafeExamBrowser.UserInterface.Desktop.ViewModels
return Brushes.White;
}
}
+
+ private void ScrollToEnd()
+ {
+ if (AutoScroll)
+ {
+ scrollViewer.ScrollToEnd();
+ }
+ }
}
}
diff --git a/SafeExamBrowser.UserInterface.Mobile/LogWindow.xaml b/SafeExamBrowser.UserInterface.Mobile/LogWindow.xaml
index 4f74a79c..37ca97bf 100644
--- a/SafeExamBrowser.UserInterface.Mobile/LogWindow.xaml
+++ b/SafeExamBrowser.UserInterface.Mobile/LogWindow.xaml
@@ -4,8 +4,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Mobile"
- mc:Ignorable="d" Title="{Binding Path=WindowTitle}" Background="Black" Height="500" Width="1100" MinHeight="350" MinWidth="350"
- WindowState="Maximized" WindowStartupLocation="CenterScreen" Icon="./Images/LogNotification.ico">
+ mc:Ignorable="d" Title="{Binding Path=WindowTitle}" Background="Black" Foreground="White" Height="500" Width="1100" MinHeight="350"
+ MinWidth="350" WindowState="Maximized" WindowStartupLocation="CenterScreen" Icon="./Images/LogNotification.ico">
@@ -14,8 +14,15 @@
-
+
+
+
+
+
+
+
+
diff --git a/SafeExamBrowser.UserInterface.Mobile/LogWindow.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/LogWindow.xaml.cs
index ef1d6acb..1256804a 100644
--- a/SafeExamBrowser.UserInterface.Mobile/LogWindow.xaml.cs
+++ b/SafeExamBrowser.UserInterface.Mobile/LogWindow.xaml.cs
@@ -8,6 +8,7 @@
using System.ComponentModel;
using System.Windows;
+using System.Windows.Input;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Windows;
@@ -75,6 +76,8 @@ namespace SafeExamBrowser.UserInterface.Mobile
private void LogWindow_Loaded(object sender, RoutedEventArgs e)
{
+ Cursor = Cursors.Wait;
+
var log = logger.GetLog();
foreach (var content in log)
@@ -84,6 +87,8 @@ namespace SafeExamBrowser.UserInterface.Mobile
logger.Subscribe(model);
logger.Debug("Opened log window.");
+
+ Cursor = Cursors.Arrow;
}
private void LogWindow_Closing(object sender, CancelEventArgs e)
diff --git a/SafeExamBrowser.UserInterface.Mobile/ViewModels/LogViewModel.cs b/SafeExamBrowser.UserInterface.Mobile/ViewModels/LogViewModel.cs
index f13ebc99..e9517227 100644
--- a/SafeExamBrowser.UserInterface.Mobile/ViewModels/LogViewModel.cs
+++ b/SafeExamBrowser.UserInterface.Mobile/ViewModels/LogViewModel.cs
@@ -23,6 +23,8 @@ namespace SafeExamBrowser.UserInterface.Mobile.ViewModels
private ScrollViewer scrollViewer;
private TextBlock textBlock;
+ public bool AutoScroll { get; set; } = true;
+ public string AutoScrollTitle => text.Get(TextKey.LogWindow_AutoScroll);
public string WindowTitle => text.Get(TextKey.LogWindow_Title);
public LogViewModel(IText text, ScrollViewer scrollViewer, TextBlock textBlock)
@@ -45,29 +47,25 @@ namespace SafeExamBrowser.UserInterface.Mobile.ViewModels
default:
throw new NotImplementedException($"The log window is not yet implemented for log content of type {content.GetType()}!");
}
-
- scrollViewer.Dispatcher.Invoke(scrollViewer.ScrollToEnd);
}
private void AppendLogText(ILogText logText)
{
- textBlock.Dispatcher.Invoke(() =>
+ textBlock.Dispatcher.InvokeAsync(() =>
{
var isHeader = logText.Text.StartsWith("/* ");
var isComment = logText.Text.StartsWith("# ");
var brush = isHeader || isComment ? Brushes.LimeGreen : textBlock.Foreground;
+ var fontWeight = isHeader ? FontWeights.Bold : FontWeights.Normal;
- textBlock.Inlines.Add(new Run($"{logText.Text}{Environment.NewLine}")
- {
- FontWeight = isHeader ? FontWeights.Bold : FontWeights.Normal,
- Foreground = brush
- });
+ textBlock.Inlines.Add(new Run($"{logText.Text}{Environment.NewLine}") { FontWeight = fontWeight, Foreground = brush });
+ ScrollToEnd();
});
}
private void AppendLogMessage(ILogMessage message)
{
- textBlock.Dispatcher.Invoke(() =>
+ textBlock.Dispatcher.InvokeAsync(() =>
{
var date = message.DateTime.ToString("HH:mm:ss.fff");
var severity = message.Severity.ToString().ToUpper();
@@ -80,6 +78,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.ViewModels
textBlock.Inlines.Add(infoRun);
textBlock.Inlines.Add(messageRun);
+ ScrollToEnd();
});
}
@@ -97,5 +96,13 @@ namespace SafeExamBrowser.UserInterface.Mobile.ViewModels
return Brushes.White;
}
}
+
+ private void ScrollToEnd()
+ {
+ if (AutoScroll)
+ {
+ scrollViewer.ScrollToEnd();
+ }
+ }
}
}