SEBWIN-117: Changed layout & positioning of the taskbar and action center (WPF caches the current working area but does not allow to manually reset the cache). Ensured that the wallpaper is only changed on Windows 7.
This commit is contained in:
parent
14abfccc2e
commit
517ceaca4e
10 changed files with 60 additions and 20 deletions
|
@ -323,8 +323,9 @@ namespace SafeExamBrowser.Client
|
|||
{
|
||||
logger.Info("Reinitializing working area...");
|
||||
displayMonitor.InitializePrimaryDisplay(taskbar.GetAbsoluteHeight());
|
||||
logger.Info("Reinitializing taskbar bounds...");
|
||||
logger.Info("Reinitializing shell...");
|
||||
taskbar.InitializeBounds();
|
||||
actionCenter.UpdateTaskbarHeight(taskbar.GetRelativeHeight());
|
||||
logger.Info("Desktop successfully restored.");
|
||||
}
|
||||
|
||||
|
@ -367,8 +368,9 @@ namespace SafeExamBrowser.Client
|
|||
explorerShell.Terminate();
|
||||
logger.Info("Reinitializing working area...");
|
||||
displayMonitor.InitializePrimaryDisplay(taskbar.GetAbsoluteHeight());
|
||||
logger.Info("Reinitializing taskbar bounds...");
|
||||
logger.Info("Reinitializing shell...");
|
||||
taskbar.InitializeBounds();
|
||||
actionCenter.UpdateTaskbarHeight(taskbar.GetRelativeHeight());
|
||||
logger.Info("Desktop successfully restored.");
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace SafeExamBrowser.Client
|
|||
windowMonitor = new WindowMonitor(new ModuleLogger(logger, nameof(WindowMonitor)), nativeMethods);
|
||||
wirelessNetwork = new WirelessNetwork(new ModuleLogger(logger, nameof(WirelessNetwork)), text);
|
||||
|
||||
var displayMonitor = new DisplayMonitor(new ModuleLogger(logger, nameof(DisplayMonitor)), nativeMethods);
|
||||
var displayMonitor = new DisplayMonitor(new ModuleLogger(logger, nameof(DisplayMonitor)), nativeMethods, systemInfo);
|
||||
var explorerShell = new ExplorerShell(new ModuleLogger(logger, nameof(ExplorerShell)), nativeMethods);
|
||||
var hashAlgorithm = new HashAlgorithm();
|
||||
|
||||
|
|
|
@ -106,6 +106,7 @@ namespace SafeExamBrowser.Client.Operations
|
|||
{
|
||||
logger.Info("Initializing action center...");
|
||||
actionCenter.InitializeText(text);
|
||||
actionCenter.UpdateTaskbarHeight(taskbar.GetRelativeHeight());
|
||||
|
||||
InitializeAboutNotificationForActionCenter();
|
||||
InitializeClockForActionCenter();
|
||||
|
|
|
@ -61,6 +61,11 @@ namespace SafeExamBrowser.Contracts.UserInterface.Shell
|
|||
/// </summary>
|
||||
void Register(IActionCenterActivator activator);
|
||||
|
||||
/// <summary>
|
||||
/// Informs the action center about the relative height (i.e. height in logical pixels) of the taskbar.
|
||||
/// </summary>
|
||||
void UpdateTaskbarHeight(int height);
|
||||
|
||||
/// <summary>
|
||||
/// Makes the action center visible.
|
||||
/// </summary>
|
||||
|
|
|
@ -51,6 +51,11 @@ namespace SafeExamBrowser.Contracts.UserInterface.Shell
|
|||
/// </summary>
|
||||
int GetAbsoluteHeight();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the relative height of the taskbar (i.e. in logical pixels).
|
||||
/// </summary>
|
||||
int GetRelativeHeight();
|
||||
|
||||
/// <summary>
|
||||
/// Moves the taskbar to the bottom of and resizes it according to the current working area.
|
||||
/// </summary>
|
||||
|
|
|
@ -12,7 +12,9 @@ using Microsoft.Win32;
|
|||
using SafeExamBrowser.Contracts.Logging;
|
||||
using SafeExamBrowser.Contracts.Monitoring;
|
||||
using SafeExamBrowser.Contracts.Monitoring.Events;
|
||||
using SafeExamBrowser.Contracts.SystemComponents;
|
||||
using SafeExamBrowser.Contracts.WindowsApi;
|
||||
using OperatingSystem = SafeExamBrowser.Contracts.SystemComponents.OperatingSystem;
|
||||
|
||||
namespace SafeExamBrowser.Monitoring.Display
|
||||
{
|
||||
|
@ -21,14 +23,16 @@ namespace SafeExamBrowser.Monitoring.Display
|
|||
private IBounds originalWorkingArea;
|
||||
private ILogger logger;
|
||||
private INativeMethods nativeMethods;
|
||||
private ISystemInfo systemInfo;
|
||||
private string wallpaper;
|
||||
|
||||
public event DisplayChangedEventHandler DisplayChanged;
|
||||
|
||||
public DisplayMonitor(ILogger logger, INativeMethods nativeMethods)
|
||||
public DisplayMonitor(ILogger logger, INativeMethods nativeMethods, ISystemInfo systemInfo)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.nativeMethods = nativeMethods;
|
||||
this.systemInfo = systemInfo;
|
||||
}
|
||||
|
||||
public void InitializePrimaryDisplay(int taskbarHeight)
|
||||
|
@ -89,12 +93,16 @@ namespace SafeExamBrowser.Monitoring.Display
|
|||
|
||||
private void InitializeWallpaper()
|
||||
{
|
||||
var path = nativeMethods.GetWallpaperPath();
|
||||
|
||||
if (!String.IsNullOrEmpty(path))
|
||||
if (systemInfo.OperatingSystem == OperatingSystem.Windows7)
|
||||
{
|
||||
wallpaper = path;
|
||||
logger.Info($"Saved wallpaper image: {wallpaper}.");
|
||||
var path = nativeMethods.GetWallpaperPath();
|
||||
|
||||
if (!String.IsNullOrEmpty(path))
|
||||
{
|
||||
wallpaper = path;
|
||||
logger.Info($"Saved wallpaper image: {wallpaper}.");
|
||||
}
|
||||
|
||||
nativeMethods.RemoveWallpaper();
|
||||
logger.Info("Removed current wallpaper.");
|
||||
}
|
||||
|
@ -117,7 +125,7 @@ namespace SafeExamBrowser.Monitoring.Display
|
|||
|
||||
private void ResetWallpaper()
|
||||
{
|
||||
if (!String.IsNullOrEmpty(wallpaper))
|
||||
if (systemInfo.OperatingSystem == OperatingSystem.Windows7 && !String.IsNullOrEmpty(wallpaper))
|
||||
{
|
||||
nativeMethods.SetWallpaper(wallpaper);
|
||||
logger.Info($"Restored wallpaper image: {wallpaper}.");
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace SafeExamBrowser.Runtime.Operations
|
|||
}
|
||||
else
|
||||
{
|
||||
logger.Warn($"No original desktop found when attempting to close new desktop!");
|
||||
logger.Warn($"No original desktop found to activate!");
|
||||
}
|
||||
|
||||
if (NewDesktop != null)
|
||||
|
@ -144,7 +144,7 @@ namespace SafeExamBrowser.Runtime.Operations
|
|||
}
|
||||
else
|
||||
{
|
||||
logger.Warn($"No new desktop found when attempting to close new desktop!");
|
||||
logger.Warn($"No new desktop found to close!");
|
||||
}
|
||||
|
||||
explorerShell.Resume();
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
{
|
||||
public partial class ActionCenter : Window, IActionCenter
|
||||
{
|
||||
private int taskbarHeight = 40;
|
||||
|
||||
public bool ShowClock
|
||||
{
|
||||
set { Dispatcher.Invoke(() => Clock.Visibility = value ? Visibility.Visible : Visibility.Collapsed); }
|
||||
|
@ -82,6 +84,11 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
Dispatcher.Invoke(ShowAnimated);
|
||||
}
|
||||
|
||||
public void UpdateTaskbarHeight(int height)
|
||||
{
|
||||
taskbarHeight = height;
|
||||
}
|
||||
|
||||
private void HideAnimated()
|
||||
{
|
||||
var storyboard = new Storyboard();
|
||||
|
@ -125,7 +132,7 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
|
||||
private void InitializeBounds()
|
||||
{
|
||||
Height = SystemParameters.WorkArea.Height;
|
||||
Height = SystemParameters.PrimaryScreenHeight - taskbarHeight;
|
||||
Top = 0;
|
||||
Left = -Width;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,19 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
{
|
||||
var height = (int) this.TransformToPhysical(Width, Height).Y;
|
||||
|
||||
logger.Info($"Calculated physical taskbar height is {height}px.");
|
||||
logger.Debug($"Calculated physical taskbar height is {height}px.");
|
||||
|
||||
return height;
|
||||
});
|
||||
}
|
||||
|
||||
public int GetRelativeHeight()
|
||||
{
|
||||
return Dispatcher.Invoke(() =>
|
||||
{
|
||||
var height = (int) Height;
|
||||
|
||||
logger.Debug($"Logical taskbar height is {height}px.");
|
||||
|
||||
return height;
|
||||
});
|
||||
|
@ -81,14 +93,14 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
Width = SystemParameters.WorkArea.Right;
|
||||
Left = SystemParameters.WorkArea.Right - Width;
|
||||
Top = SystemParameters.WorkArea.Bottom;
|
||||
Width = SystemParameters.PrimaryScreenWidth;
|
||||
Left = 0;
|
||||
Top = SystemParameters.PrimaryScreenHeight - Height;
|
||||
|
||||
var position = this.TransformToPhysical(Left, Top);
|
||||
var size = this.TransformToPhysical(Width, Height);
|
||||
|
||||
logger.Info($"Set taskbar bounds to {Width}x{Height} at ({Left}/{Top}), in physical pixels: {size.X}x{size.Y} at ({position.X}/{position.Y}).");
|
||||
logger.Debug($"Set taskbar bounds to {Width}x{Height} at ({Left}/{Top}), in physical pixels: {size.X}x{size.Y} at ({position.X}/{position.Y}).");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ namespace SafeExamBrowser.WindowsApi
|
|||
|
||||
public void SetWallpaper(string filePath)
|
||||
{
|
||||
var success = User32.SystemParametersInfo(SPI.SETDESKWALLPAPER, 0, filePath, SPIF.UPDATEANDCHANGE);
|
||||
var success = User32.SystemParametersInfo(SPI.SETDESKWALLPAPER, 0, filePath, SPIF.NONE);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
|
@ -370,7 +370,7 @@ namespace SafeExamBrowser.WindowsApi
|
|||
public void SetWorkingArea(IBounds bounds)
|
||||
{
|
||||
var workingArea = new RECT { Left = bounds.Left, Top = bounds.Top, Right = bounds.Right, Bottom = bounds.Bottom };
|
||||
var success = User32.SystemParametersInfo(SPI.SETWORKAREA, 0, ref workingArea, SPIF.UPDATEINIFILE);
|
||||
var success = User32.SystemParametersInfo(SPI.SETWORKAREA, 0, ref workingArea, SPIF.NONE);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue