Fixed error when attempting to close and subsequently re-open the log window and added new notification icon.

This commit is contained in:
Damian Büchel 2017-08-07 15:08:38 +02:00
parent e959c8cb39
commit 893febdf00
5 changed files with 25 additions and 15 deletions

View file

@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Controls"
mc:Ignorable="d"
d:DesignHeight="16" d:DesignWidth="16">
d:DesignHeight="16" d:DesignWidth="16" Margin="5,0">
<Grid>
<Button x:Name="IconButton" Click="Icon_Click" Background="#00000000" BorderThickness="0">
<Button.Template>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 91 KiB

View file

@ -11,7 +11,7 @@
<SolidColorBrush Color="Black" Opacity="0.8" />
</Window.Background>
<Grid>
<TextBox x:Name="LogContent" AcceptsReturn="True" Background="Transparent" FontFamily="Consolas" Foreground="White"
<TextBox x:Name="LogContent" AcceptsReturn="True" Background="Transparent" FontFamily="Consolas" Foreground="ForestGreen"
HorizontalScrollBarVisibility="Auto" IsReadOnly="True" Text="{Binding Path=Text, Mode=OneWay}"
VerticalScrollBarVisibility="Auto" TextChanged="LogContent_TextChanged" />
</Grid>

View file

@ -28,15 +28,11 @@ namespace SafeExamBrowser.UserInterface
public LogWindow(ILogger logger, ILogContentFormatter formatter, IText text)
{
InitializeComponent();
this.logger = logger;
this.model = new LogViewModel(logger.GetLog(), formatter, text);
DataContext = model;
LogContent.DataContext = model;
logger.Subscribe(model);
InitializeComponent();
InitializeLogWindow();
}
public void BringToForeground()
@ -46,11 +42,7 @@ namespace SafeExamBrowser.UserInterface
public new void Close()
{
Dispatcher.Invoke(() =>
{
logger.Unsubscribe(model);
base.Close();
});
Dispatcher.Invoke(base.Close);
}
public new void Show()
@ -62,5 +54,23 @@ namespace SafeExamBrowser.UserInterface
{
LogContent.ScrollToEnd();
}
private void InitializeLogWindow()
{
DataContext = model;
LogContent.DataContext = model;
Closing += LogWindow_Closing;
logger.Subscribe(model);
logger.Info("Opened log window.");
}
private void LogWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
logger.Unsubscribe(model);
logger.Info("Closed log window.");
closing?.Invoke();
}
}
}

View file

@ -50,7 +50,7 @@ namespace SafeExamBrowser.UserInterface
});
logWindowThread.SetApartmentState(ApartmentState.STA);
logWindowThread.Name = "Log Window Thread";
logWindowThread.Name = nameof(LogWindow);
logWindowThread.IsBackground = true;
logWindowThread.Start();
@ -80,7 +80,7 @@ namespace SafeExamBrowser.UserInterface
});
splashScreenThread.SetApartmentState(ApartmentState.STA);
splashScreenThread.Name = "Splash Screen Thread";
splashScreenThread.Name = nameof(SplashScreen);
splashScreenThread.IsBackground = true;
splashScreenThread.Start();