From 735e0b6dca7aa3df7ba0f326898bda3183dd2408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Wed, 1 Apr 2020 13:49:32 +0200 Subject: [PATCH] SEBWIN-384: Ensured the action center is automatically hidden during shell initialization. --- .../ClientControllerTests.cs | 5 ++++- SafeExamBrowser.Client/ClientController.cs | 2 +- .../Shell/IActionCenter.cs | 5 +++++ .../Windows/ActionCenter.xaml.cs | 12 ++++++++++++ .../Windows/ActionCenter.xaml.cs | 12 ++++++++++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs b/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs index 420114d0..74e009ca 100644 --- a/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs +++ b/SafeExamBrowser.Client.UnitTests/ClientControllerTests.cs @@ -946,12 +946,14 @@ namespace SafeExamBrowser.Client.UnitTests settings.ActionCenter.EnableActionCenter = true; sut.TryStart(); - actionCenter.Verify(t => t.Show(), Times.Once); + actionCenter.Verify(t => t.Promote(), Times.Once); + actionCenter.Verify(t => t.Show(), Times.Never); actionCenter.Reset(); operationSequence.Setup(o => o.TryPerform()).Returns(OperationResult.Aborted); sut.TryStart(); + actionCenter.Verify(t => t.Promote(), Times.Never); actionCenter.Verify(t => t.Show(), Times.Never); actionCenter.Reset(); @@ -959,6 +961,7 @@ namespace SafeExamBrowser.Client.UnitTests operationSequence.Setup(o => o.TryPerform()).Returns(OperationResult.Success); sut.TryStart(); + actionCenter.Verify(t => t.Promote(), Times.Never); actionCenter.Verify(t => t.Show(), Times.Never); } diff --git a/SafeExamBrowser.Client/ClientController.cs b/SafeExamBrowser.Client/ClientController.cs index 5314fce7..bbef75f0 100644 --- a/SafeExamBrowser.Client/ClientController.cs +++ b/SafeExamBrowser.Client/ClientController.cs @@ -238,7 +238,7 @@ namespace SafeExamBrowser.Client { if (Settings.ActionCenter.EnableActionCenter) { - actionCenter.Show(); + actionCenter.Promote(); } if (Settings.Taskbar.EnableTaskbar) diff --git a/SafeExamBrowser.UserInterface.Contracts/Shell/IActionCenter.cs b/SafeExamBrowser.UserInterface.Contracts/Shell/IActionCenter.cs index bac238a2..e60e7fa2 100644 --- a/SafeExamBrowser.UserInterface.Contracts/Shell/IActionCenter.cs +++ b/SafeExamBrowser.UserInterface.Contracts/Shell/IActionCenter.cs @@ -61,6 +61,11 @@ namespace SafeExamBrowser.UserInterface.Contracts.Shell /// void InitializeText(IText text); + /// + /// Makes the action center visible and automatically hides it after a short delay. + /// + void Promote(); + /// /// Registers the specified activator to control the visibility of the action center. /// diff --git a/SafeExamBrowser.UserInterface.Desktop/Windows/ActionCenter.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Windows/ActionCenter.xaml.cs index 6a53c2d7..8c6adfa2 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Windows/ActionCenter.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Windows/ActionCenter.xaml.cs @@ -7,6 +7,8 @@ */ using System; +using System.Threading; +using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Animation; using SafeExamBrowser.I18n.Contracts; @@ -87,6 +89,16 @@ namespace SafeExamBrowser.UserInterface.Desktop.Windows QuitButton.Text.Text = text.Get(TextKey.Shell_QuitButton); } + public void Promote() + { + Task.Run(() => + { + Dispatcher.Invoke(ShowAnimated); + Thread.Sleep(2000); + Dispatcher.Invoke(HideAnimated); + }); + } + public void Register(IActionCenterActivator activator) { activator.Activated += Activator_Activated; diff --git a/SafeExamBrowser.UserInterface.Mobile/Windows/ActionCenter.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Windows/ActionCenter.xaml.cs index 24e28ca5..2b887036 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Windows/ActionCenter.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Windows/ActionCenter.xaml.cs @@ -7,6 +7,8 @@ */ using System; +using System.Threading; +using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Animation; using SafeExamBrowser.I18n.Contracts; @@ -87,6 +89,16 @@ namespace SafeExamBrowser.UserInterface.Mobile.Windows QuitButton.Text.Text = text.Get(TextKey.Shell_QuitButton); } + public void Promote() + { + Task.Run(() => + { + Dispatcher.Invoke(ShowAnimated); + Thread.Sleep(2000); + Dispatcher.Invoke(HideAnimated); + }); + } + public void Register(IActionCenterActivator activator) { activator.Activated += Activator_Activated;