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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Controls" xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Controls"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="16" d:DesignWidth="16"> d:DesignHeight="16" d:DesignWidth="16" Margin="5,0">
<Grid> <Grid>
<Button x:Name="IconButton" Click="Icon_Click" Background="#00000000" BorderThickness="0"> <Button x:Name="IconButton" Click="Icon_Click" Background="#00000000" BorderThickness="0">
<Button.Template> <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" /> <SolidColorBrush Color="Black" Opacity="0.8" />
</Window.Background> </Window.Background>
<Grid> <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}" HorizontalScrollBarVisibility="Auto" IsReadOnly="True" Text="{Binding Path=Text, Mode=OneWay}"
VerticalScrollBarVisibility="Auto" TextChanged="LogContent_TextChanged" /> VerticalScrollBarVisibility="Auto" TextChanged="LogContent_TextChanged" />
</Grid> </Grid>

View file

@ -28,15 +28,11 @@ namespace SafeExamBrowser.UserInterface
public LogWindow(ILogger logger, ILogContentFormatter formatter, IText text) public LogWindow(ILogger logger, ILogContentFormatter formatter, IText text)
{ {
InitializeComponent();
this.logger = logger; this.logger = logger;
this.model = new LogViewModel(logger.GetLog(), formatter, text); this.model = new LogViewModel(logger.GetLog(), formatter, text);
DataContext = model; InitializeComponent();
LogContent.DataContext = model; InitializeLogWindow();
logger.Subscribe(model);
} }
public void BringToForeground() public void BringToForeground()
@ -46,11 +42,7 @@ namespace SafeExamBrowser.UserInterface
public new void Close() public new void Close()
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(base.Close);
{
logger.Unsubscribe(model);
base.Close();
});
} }
public new void Show() public new void Show()
@ -62,5 +54,23 @@ namespace SafeExamBrowser.UserInterface
{ {
LogContent.ScrollToEnd(); 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.SetApartmentState(ApartmentState.STA);
logWindowThread.Name = "Log Window Thread"; logWindowThread.Name = nameof(LogWindow);
logWindowThread.IsBackground = true; logWindowThread.IsBackground = true;
logWindowThread.Start(); logWindowThread.Start();
@ -80,7 +80,7 @@ namespace SafeExamBrowser.UserInterface
}); });
splashScreenThread.SetApartmentState(ApartmentState.STA); splashScreenThread.SetApartmentState(ApartmentState.STA);
splashScreenThread.Name = "Splash Screen Thread"; splashScreenThread.Name = nameof(SplashScreen);
splashScreenThread.IsBackground = true; splashScreenThread.IsBackground = true;
splashScreenThread.Start(); splashScreenThread.Start();