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

View file

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

View file

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

View file

@ -245,15 +245,19 @@ namespace SafeExamBrowser.Proctoring.JitsiMeet
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);
NotificationChanged?.Invoke();
}
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);
NotificationChanged?.Invoke();
}
}

View file

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

View file

@ -176,18 +176,16 @@ namespace SafeExamBrowser.Proctoring.ScreenProctoring
private void UpdateNotification(bool live)
{
// TODO: Replace with actual icon!
// TODO: Extend INotification with IsEnabled or CanActivate!
// TODO: Service health, HD space and caching indicators!
CanActivate = false;
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);
}
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);
}

View file

@ -14,7 +14,7 @@
</ResourceDictionary>
</UserControl.Resources>
<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.RowDefinitions>
<RowDefinition Height="2*" />

View file

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

View file

@ -14,6 +14,7 @@
</ResourceDictionary>
</UserControl.Resources>
<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>
</UserControl>

View file

@ -30,7 +30,10 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar
private void IconButton_Click(object sender, RoutedEventArgs e)
{
notification.Activate();
if (notification.CanActivate)
{
notification.Activate();
}
}
private void InitializeNotification()
@ -40,8 +43,9 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar
private void UpdateNotification()
{
IconButton.ToolTip = notification.Tooltip;
IconButton.Content = IconResourceLoader.Load(notification.IconResource);
IconButton.IsEnabled = notification.CanActivate;
IconButton.ToolTip = 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\ProgressIndicatorViewModel.cs" />
<Compile Include="ViewModels\RuntimeWindowViewModel.cs" />
<Resource Include="Images\ProctoringNotification_Inactive.xaml">
<Resource Include="Images\Proctoring_Inactive.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Resource>
<Resource Include="Images\ProctoringNotification_Active.xaml">
<Resource Include="Images\Proctoring_Active.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Resource>
@ -215,6 +215,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</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">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View file

@ -14,7 +14,7 @@
</ResourceDictionary>
</UserControl.Resources>
<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.RowDefinitions>
<RowDefinition Height="2*" />

View file

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

View file

@ -14,6 +14,7 @@
</ResourceDictionary>
</UserControl.Resources>
<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>
</UserControl>

View file

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