SEBSP-107: Added property to control activation of notifications and created placeholder for screen proctoring notification icons.

This commit is contained in:
Damian Büchel 2024-02-23 18:32:44 +01:00
parent e5c02a1f74
commit 0777644f0e
19 changed files with 82 additions and 22 deletions

View file

@ -24,6 +24,7 @@ namespace SafeExamBrowser.Client.Notifications
private IWindow window; private IWindow window;
public bool CanActivate { get; }
public string Tooltip { get; } public string Tooltip { get; }
public IconResource IconResource { get; } public IconResource IconResource { get; }
@ -34,6 +35,7 @@ namespace SafeExamBrowser.Client.Notifications
this.appConfig = appConfig; this.appConfig = appConfig;
this.uiFactory = uiFactory; this.uiFactory = uiFactory;
CanActivate = true;
IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/AboutNotification.xaml") }; IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/AboutNotification.xaml") };
Tooltip = text.Get(TextKey.Notification_AboutTooltip); Tooltip = text.Get(TextKey.Notification_AboutTooltip);
} }

View file

@ -24,6 +24,7 @@ namespace SafeExamBrowser.Client.Notifications
private IWindow window; private IWindow window;
public bool CanActivate { get; }
public string Tooltip { get; } public string Tooltip { get; }
public IconResource IconResource { get; } public IconResource IconResource { get; }
@ -34,6 +35,7 @@ namespace SafeExamBrowser.Client.Notifications
this.logger = logger; this.logger = logger;
this.uiFactory = uiFactory; this.uiFactory = uiFactory;
CanActivate = true;
IconResource = new BitmapIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/LogNotification.ico") }; IconResource = new BitmapIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/LogNotification.ico") };
Tooltip = text.Get(TextKey.Notification_LogTooltip); Tooltip = text.Get(TextKey.Notification_LogTooltip);
} }

View file

@ -17,15 +17,20 @@ namespace SafeExamBrowser.Core.Contracts.Notifications
public interface INotification public interface INotification
{ {
/// <summary> /// <summary>
/// The tooltip for the notification. /// Determines whether the notification can be activated.
/// </summary> /// </summary>
string Tooltip { get; } bool CanActivate { get; }
/// <summary> /// <summary>
/// The resource providing the notification icon. /// The resource providing the notification icon.
/// </summary> /// </summary>
IconResource IconResource { get; } IconResource IconResource { get; }
/// <summary>
/// The tooltip for the notification.
/// </summary>
string Tooltip { get; }
/// <summary> /// <summary>
/// Event fired when the notification has changed. /// Event fired when the notification has changed.
/// </summary> /// </summary>
@ -35,7 +40,7 @@ namespace SafeExamBrowser.Core.Contracts.Notifications
/// Executes the notification functionality. /// Executes the notification functionality.
/// </summary> /// </summary>
void Activate(); void Activate();
/// <summary> /// <summary>
/// Terminates the notification functionality and release all used resources. /// Terminates the notification functionality and release all used resources.
/// </summary> /// </summary>

View file

@ -245,15 +245,19 @@ namespace SafeExamBrowser.Proctoring.JitsiMeet
private void ShowNotificationActive() private void ShowNotificationActive()
{ {
IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ProctoringNotification_Active.xaml") }; CanActivate = true;
IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Proctoring_Active.xaml") };
Tooltip = text.Get(TextKey.Notification_ProctoringActiveTooltip); Tooltip = text.Get(TextKey.Notification_ProctoringActiveTooltip);
NotificationChanged?.Invoke(); NotificationChanged?.Invoke();
} }
private void ShowNotificationInactive() private void ShowNotificationInactive()
{ {
IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ProctoringNotification_Inactive.xaml") }; CanActivate = false;
IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Proctoring_Inactive.xaml") };
Tooltip = text.Get(TextKey.Notification_ProctoringInactiveTooltip); Tooltip = text.Get(TextKey.Notification_ProctoringInactiveTooltip);
NotificationChanged?.Invoke(); NotificationChanged?.Invoke();
} }
} }

View file

@ -17,6 +17,7 @@ namespace SafeExamBrowser.Proctoring
{ {
internal abstract string Name { get; } internal abstract string Name { get; }
public bool CanActivate { get; protected set; }
public string Tooltip { get; protected set; } public string Tooltip { get; protected set; }
public IconResource IconResource { get; protected set; } public IconResource IconResource { get; protected set; }

View file

@ -176,18 +176,16 @@ namespace SafeExamBrowser.Proctoring.ScreenProctoring
private void UpdateNotification(bool live) private void UpdateNotification(bool live)
{ {
// TODO: Replace with actual icon! CanActivate = false;
// TODO: Extend INotification with IsEnabled or CanActivate!
// TODO: Service health, HD space and caching indicators!
if (live) if (live)
{ {
IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ProctoringNotification_Active.xaml") }; IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ScreenProctoring_Active.xaml") };
Tooltip = text.Get(TextKey.Notification_ProctoringActiveTooltip); Tooltip = text.Get(TextKey.Notification_ProctoringActiveTooltip);
} }
else else
{ {
IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ProctoringNotification_Inactive.xaml") }; IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ScreenProctoring_Inactive.xaml") };
Tooltip = text.Get(TextKey.Notification_ProctoringInactiveTooltip); Tooltip = text.Get(TextKey.Notification_ProctoringInactiveTooltip);
} }

View file

@ -14,7 +14,7 @@
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<Grid Background="{StaticResource ActionCenterDarkBrush}" Height="64" Margin="2"> <Grid Background="{StaticResource ActionCenterDarkBrush}" Height="64" Margin="2">
<Button x:Name="IconButton" Click="IconButton_Click" Padding="2" Template="{StaticResource ActionCenterButton}"> <Button x:Name="IconButton" Click="IconButton_Click" Padding="2" Template="{StaticResource ActionCenterButton}" ToolTipService.ShowOnDisabled="True">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="2*" /> <RowDefinition Height="2*" />

View file

@ -29,7 +29,10 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter
private void IconButton_Click(object sender, RoutedEventArgs e) private void IconButton_Click(object sender, RoutedEventArgs e)
{ {
notification.Activate(); if (notification.CanActivate)
{
notification.Activate();
}
} }
private void InitializeNotification() private void InitializeNotification()
@ -40,6 +43,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter
private void UpdateNotification() private void UpdateNotification()
{ {
Icon.Content = IconResourceLoader.Load(notification.IconResource); Icon.Content = IconResourceLoader.Load(notification.IconResource);
IconButton.IsEnabled = notification.CanActivate;
IconButton.ToolTip = notification.Tooltip; IconButton.ToolTip = notification.Tooltip;
Text.Text = notification.Tooltip; Text.Text = notification.Tooltip;
} }

View file

@ -14,6 +14,7 @@
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<Button x:Name="IconButton" Background="{StaticResource BackgroundBrush}" Click="IconButton_Click" Padding="7.5" Template="{StaticResource TaskbarButton}" Width="40" /> <Button x:Name="IconButton" Background="{StaticResource BackgroundBrush}" Click="IconButton_Click" Padding="7.5"
Template="{StaticResource TaskbarButton}" ToolTipService.ShowOnDisabled="True" Width="40" />
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -30,7 +30,10 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar
private void IconButton_Click(object sender, RoutedEventArgs e) private void IconButton_Click(object sender, RoutedEventArgs e)
{ {
notification.Activate(); if (notification.CanActivate)
{
notification.Activate();
}
} }
private void InitializeNotification() private void InitializeNotification()
@ -40,8 +43,9 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar
private void UpdateNotification() private void UpdateNotification()
{ {
IconButton.ToolTip = notification.Tooltip;
IconButton.Content = IconResourceLoader.Load(notification.IconResource); IconButton.Content = IconResourceLoader.Load(notification.IconResource);
IconButton.IsEnabled = notification.CanActivate;
IconButton.ToolTip = notification.Tooltip;
AutomationProperties.SetName(this, notification.Tooltip); AutomationProperties.SetName(this, notification.Tooltip);
} }

View file

@ -0,0 +1,11 @@
<Viewbox
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<fa:ImageAwesome Icon="Television" HorizontalAlignment="Stretch" Foreground="Green" VerticalAlignment="Stretch" />
<Canvas HorizontalAlignment="Center" VerticalAlignment="Center">
<Ellipse Fill="Red" Canvas.Left="-15" Canvas.Top="-23" Width="30" Height="30" />
</Canvas>
</Grid>
</Viewbox>

View file

@ -0,0 +1,11 @@
<Viewbox
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<fa:ImageAwesome Icon="Television" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Canvas HorizontalAlignment="Center" VerticalAlignment="Center">
<Ellipse Fill="Gray" Canvas.Left="-15" Canvas.Top="-23" Width="30" Height="30" />
</Canvas>
</Grid>
</Viewbox>

View file

@ -191,11 +191,11 @@
<Compile Include="ViewModels\LogViewModel.cs" /> <Compile Include="ViewModels\LogViewModel.cs" />
<Compile Include="ViewModels\ProgressIndicatorViewModel.cs" /> <Compile Include="ViewModels\ProgressIndicatorViewModel.cs" />
<Compile Include="ViewModels\RuntimeWindowViewModel.cs" /> <Compile Include="ViewModels\RuntimeWindowViewModel.cs" />
<Resource Include="Images\ProctoringNotification_Inactive.xaml"> <Resource Include="Images\Proctoring_Inactive.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Resource> </Resource>
<Resource Include="Images\ProctoringNotification_Active.xaml"> <Resource Include="Images\Proctoring_Active.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Resource> </Resource>
@ -215,6 +215,14 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Resource> </Resource>
<Resource Include="Images\ScreenProctoring_Inactive.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Resource>
<Resource Include="Images\ScreenProctoring_Active.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Resource>
<Page Include="Windows\AboutWindow.xaml"> <Page Include="Windows\AboutWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

View file

@ -14,7 +14,7 @@
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<Grid Background="{StaticResource ActionCenterDarkBrush}" Height="82" Margin="2"> <Grid Background="{StaticResource ActionCenterDarkBrush}" Height="82" Margin="2">
<Button x:Name="IconButton" Click="IconButton_Click" Padding="2" Template="{StaticResource ActionCenterButton}"> <Button x:Name="IconButton" Click="IconButton_Click" Padding="2" Template="{StaticResource ActionCenterButton}" ToolTipService.ShowOnDisabled="True">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="2*" /> <RowDefinition Height="2*" />

View file

@ -29,7 +29,10 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter
private void IconButton_Click(object sender, RoutedEventArgs e) private void IconButton_Click(object sender, RoutedEventArgs e)
{ {
notification.Activate(); if (notification.CanActivate)
{
notification.Activate();
}
} }
private void InitializeNotification() private void InitializeNotification()
@ -40,6 +43,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter
private void UpdateNotification() private void UpdateNotification()
{ {
Icon.Content = IconResourceLoader.Load(notification.IconResource); Icon.Content = IconResourceLoader.Load(notification.IconResource);
IconButton.IsEnabled = notification.CanActivate;
IconButton.ToolTip = notification.Tooltip; IconButton.ToolTip = notification.Tooltip;
Text.Text = notification.Tooltip; Text.Text = notification.Tooltip;
} }

View file

@ -14,6 +14,7 @@
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<Button x:Name="IconButton" Background="{StaticResource BackgroundBrush}" Click="IconButton_Click" Padding="7.5" Template="{StaticResource TaskbarButton}" Width="60" /> <Button x:Name="IconButton" Background="{StaticResource BackgroundBrush}" Click="IconButton_Click" Padding="7.5"
Template="{StaticResource TaskbarButton}" ToolTipService.ShowOnDisabled="True" Width="60" />
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -30,7 +30,10 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar
private void IconButton_Click(object sender, RoutedEventArgs e) private void IconButton_Click(object sender, RoutedEventArgs e)
{ {
notification.Activate(); if (notification.CanActivate)
{
notification.Activate();
}
} }
private void InitializeNotification() private void InitializeNotification()
@ -40,8 +43,9 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar
private void UpdateNotification() private void UpdateNotification()
{ {
IconButton.ToolTip = notification.Tooltip;
IconButton.Content = IconResourceLoader.Load(notification.IconResource); IconButton.Content = IconResourceLoader.Load(notification.IconResource);
IconButton.IsEnabled = notification.CanActivate;
IconButton.ToolTip = notification.Tooltip;
AutomationProperties.SetName(this, notification.Tooltip); AutomationProperties.SetName(this, notification.Tooltip);
} }