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...");
|
logger.Info("Reinitializing working area...");
|
||||||
displayMonitor.InitializePrimaryDisplay(taskbar.GetAbsoluteHeight());
|
displayMonitor.InitializePrimaryDisplay(taskbar.GetAbsoluteHeight());
|
||||||
logger.Info("Reinitializing taskbar bounds...");
|
logger.Info("Reinitializing shell...");
|
||||||
taskbar.InitializeBounds();
|
taskbar.InitializeBounds();
|
||||||
|
actionCenter.UpdateTaskbarHeight(taskbar.GetRelativeHeight());
|
||||||
logger.Info("Desktop successfully restored.");
|
logger.Info("Desktop successfully restored.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,8 +368,9 @@ namespace SafeExamBrowser.Client
|
||||||
explorerShell.Terminate();
|
explorerShell.Terminate();
|
||||||
logger.Info("Reinitializing working area...");
|
logger.Info("Reinitializing working area...");
|
||||||
displayMonitor.InitializePrimaryDisplay(taskbar.GetAbsoluteHeight());
|
displayMonitor.InitializePrimaryDisplay(taskbar.GetAbsoluteHeight());
|
||||||
logger.Info("Reinitializing taskbar bounds...");
|
logger.Info("Reinitializing shell...");
|
||||||
taskbar.InitializeBounds();
|
taskbar.InitializeBounds();
|
||||||
|
actionCenter.UpdateTaskbarHeight(taskbar.GetRelativeHeight());
|
||||||
logger.Info("Desktop successfully restored.");
|
logger.Info("Desktop successfully restored.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ namespace SafeExamBrowser.Client
|
||||||
windowMonitor = new WindowMonitor(new ModuleLogger(logger, nameof(WindowMonitor)), nativeMethods);
|
windowMonitor = new WindowMonitor(new ModuleLogger(logger, nameof(WindowMonitor)), nativeMethods);
|
||||||
wirelessNetwork = new WirelessNetwork(new ModuleLogger(logger, nameof(WirelessNetwork)), text);
|
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 explorerShell = new ExplorerShell(new ModuleLogger(logger, nameof(ExplorerShell)), nativeMethods);
|
||||||
var hashAlgorithm = new HashAlgorithm();
|
var hashAlgorithm = new HashAlgorithm();
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
{
|
{
|
||||||
logger.Info("Initializing action center...");
|
logger.Info("Initializing action center...");
|
||||||
actionCenter.InitializeText(text);
|
actionCenter.InitializeText(text);
|
||||||
|
actionCenter.UpdateTaskbarHeight(taskbar.GetRelativeHeight());
|
||||||
|
|
||||||
InitializeAboutNotificationForActionCenter();
|
InitializeAboutNotificationForActionCenter();
|
||||||
InitializeClockForActionCenter();
|
InitializeClockForActionCenter();
|
||||||
|
|
|
@ -61,6 +61,11 @@ namespace SafeExamBrowser.Contracts.UserInterface.Shell
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Register(IActionCenterActivator activator);
|
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>
|
/// <summary>
|
||||||
/// Makes the action center visible.
|
/// Makes the action center visible.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -51,6 +51,11 @@ namespace SafeExamBrowser.Contracts.UserInterface.Shell
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int GetAbsoluteHeight();
|
int GetAbsoluteHeight();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the relative height of the taskbar (i.e. in logical pixels).
|
||||||
|
/// </summary>
|
||||||
|
int GetRelativeHeight();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Moves the taskbar to the bottom of and resizes it according to the current working area.
|
/// Moves the taskbar to the bottom of and resizes it according to the current working area.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -12,7 +12,9 @@ using Microsoft.Win32;
|
||||||
using SafeExamBrowser.Contracts.Logging;
|
using SafeExamBrowser.Contracts.Logging;
|
||||||
using SafeExamBrowser.Contracts.Monitoring;
|
using SafeExamBrowser.Contracts.Monitoring;
|
||||||
using SafeExamBrowser.Contracts.Monitoring.Events;
|
using SafeExamBrowser.Contracts.Monitoring.Events;
|
||||||
|
using SafeExamBrowser.Contracts.SystemComponents;
|
||||||
using SafeExamBrowser.Contracts.WindowsApi;
|
using SafeExamBrowser.Contracts.WindowsApi;
|
||||||
|
using OperatingSystem = SafeExamBrowser.Contracts.SystemComponents.OperatingSystem;
|
||||||
|
|
||||||
namespace SafeExamBrowser.Monitoring.Display
|
namespace SafeExamBrowser.Monitoring.Display
|
||||||
{
|
{
|
||||||
|
@ -21,14 +23,16 @@ namespace SafeExamBrowser.Monitoring.Display
|
||||||
private IBounds originalWorkingArea;
|
private IBounds originalWorkingArea;
|
||||||
private ILogger logger;
|
private ILogger logger;
|
||||||
private INativeMethods nativeMethods;
|
private INativeMethods nativeMethods;
|
||||||
|
private ISystemInfo systemInfo;
|
||||||
private string wallpaper;
|
private string wallpaper;
|
||||||
|
|
||||||
public event DisplayChangedEventHandler DisplayChanged;
|
public event DisplayChangedEventHandler DisplayChanged;
|
||||||
|
|
||||||
public DisplayMonitor(ILogger logger, INativeMethods nativeMethods)
|
public DisplayMonitor(ILogger logger, INativeMethods nativeMethods, ISystemInfo systemInfo)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.nativeMethods = nativeMethods;
|
this.nativeMethods = nativeMethods;
|
||||||
|
this.systemInfo = systemInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitializePrimaryDisplay(int taskbarHeight)
|
public void InitializePrimaryDisplay(int taskbarHeight)
|
||||||
|
@ -89,12 +93,16 @@ namespace SafeExamBrowser.Monitoring.Display
|
||||||
|
|
||||||
private void InitializeWallpaper()
|
private void InitializeWallpaper()
|
||||||
{
|
{
|
||||||
var path = nativeMethods.GetWallpaperPath();
|
if (systemInfo.OperatingSystem == OperatingSystem.Windows7)
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(path))
|
|
||||||
{
|
{
|
||||||
wallpaper = path;
|
var path = nativeMethods.GetWallpaperPath();
|
||||||
logger.Info($"Saved wallpaper image: {wallpaper}.");
|
|
||||||
|
if (!String.IsNullOrEmpty(path))
|
||||||
|
{
|
||||||
|
wallpaper = path;
|
||||||
|
logger.Info($"Saved wallpaper image: {wallpaper}.");
|
||||||
|
}
|
||||||
|
|
||||||
nativeMethods.RemoveWallpaper();
|
nativeMethods.RemoveWallpaper();
|
||||||
logger.Info("Removed current wallpaper.");
|
logger.Info("Removed current wallpaper.");
|
||||||
}
|
}
|
||||||
|
@ -117,7 +125,7 @@ namespace SafeExamBrowser.Monitoring.Display
|
||||||
|
|
||||||
private void ResetWallpaper()
|
private void ResetWallpaper()
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(wallpaper))
|
if (systemInfo.OperatingSystem == OperatingSystem.Windows7 && !String.IsNullOrEmpty(wallpaper))
|
||||||
{
|
{
|
||||||
nativeMethods.SetWallpaper(wallpaper);
|
nativeMethods.SetWallpaper(wallpaper);
|
||||||
logger.Info($"Restored wallpaper image: {wallpaper}.");
|
logger.Info($"Restored wallpaper image: {wallpaper}.");
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Warn($"No original desktop found when attempting to close new desktop!");
|
logger.Warn($"No original desktop found to activate!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NewDesktop != null)
|
if (NewDesktop != null)
|
||||||
|
@ -144,7 +144,7 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Warn($"No new desktop found when attempting to close new desktop!");
|
logger.Warn($"No new desktop found to close!");
|
||||||
}
|
}
|
||||||
|
|
||||||
explorerShell.Resume();
|
explorerShell.Resume();
|
||||||
|
|
|
@ -17,6 +17,8 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
||||||
{
|
{
|
||||||
public partial class ActionCenter : Window, IActionCenter
|
public partial class ActionCenter : Window, IActionCenter
|
||||||
{
|
{
|
||||||
|
private int taskbarHeight = 40;
|
||||||
|
|
||||||
public bool ShowClock
|
public bool ShowClock
|
||||||
{
|
{
|
||||||
set { Dispatcher.Invoke(() => Clock.Visibility = value ? Visibility.Visible : Visibility.Collapsed); }
|
set { Dispatcher.Invoke(() => Clock.Visibility = value ? Visibility.Visible : Visibility.Collapsed); }
|
||||||
|
@ -82,6 +84,11 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
||||||
Dispatcher.Invoke(ShowAnimated);
|
Dispatcher.Invoke(ShowAnimated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateTaskbarHeight(int height)
|
||||||
|
{
|
||||||
|
taskbarHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
private void HideAnimated()
|
private void HideAnimated()
|
||||||
{
|
{
|
||||||
var storyboard = new Storyboard();
|
var storyboard = new Storyboard();
|
||||||
|
@ -125,7 +132,7 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
||||||
|
|
||||||
private void InitializeBounds()
|
private void InitializeBounds()
|
||||||
{
|
{
|
||||||
Height = SystemParameters.WorkArea.Height;
|
Height = SystemParameters.PrimaryScreenHeight - taskbarHeight;
|
||||||
Top = 0;
|
Top = 0;
|
||||||
Left = -Width;
|
Left = -Width;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,19 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
||||||
{
|
{
|
||||||
var height = (int) this.TransformToPhysical(Width, Height).Y;
|
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;
|
return height;
|
||||||
});
|
});
|
||||||
|
@ -81,14 +93,14 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
||||||
{
|
{
|
||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
Width = SystemParameters.WorkArea.Right;
|
Width = SystemParameters.PrimaryScreenWidth;
|
||||||
Left = SystemParameters.WorkArea.Right - Width;
|
Left = 0;
|
||||||
Top = SystemParameters.WorkArea.Bottom;
|
Top = SystemParameters.PrimaryScreenHeight - Height;
|
||||||
|
|
||||||
var position = this.TransformToPhysical(Left, Top);
|
var position = this.TransformToPhysical(Left, Top);
|
||||||
var size = this.TransformToPhysical(Width, Height);
|
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)
|
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)
|
if (!success)
|
||||||
{
|
{
|
||||||
|
@ -370,7 +370,7 @@ namespace SafeExamBrowser.WindowsApi
|
||||||
public void SetWorkingArea(IBounds bounds)
|
public void SetWorkingArea(IBounds bounds)
|
||||||
{
|
{
|
||||||
var workingArea = new RECT { Left = bounds.Left, Top = bounds.Top, Right = bounds.Right, Bottom = bounds.Bottom };
|
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)
|
if (!success)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue