SEBWIN-106: Working on browser zoom...
This commit is contained in:
parent
20962fab05
commit
91c2417930
6 changed files with 33 additions and 19 deletions
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
using CefSharp;
|
using CefSharp;
|
||||||
using CefSharp.WinForms;
|
using CefSharp.WinForms;
|
||||||
using SafeExamBrowser.Browser.Handlers;
|
using SafeExamBrowser.Browser.Handlers;
|
||||||
|
@ -67,6 +68,7 @@ namespace SafeExamBrowser.Browser
|
||||||
{
|
{
|
||||||
AddressChanged += BrowserControl_AddressChanged;
|
AddressChanged += BrowserControl_AddressChanged;
|
||||||
LoadingStateChanged += (o, args) => loadingStateChanged?.Invoke(args.IsLoading);
|
LoadingStateChanged += (o, args) => loadingStateChanged?.Invoke(args.IsLoading);
|
||||||
|
MouseWheel += BrowserControl_MouseWheel;
|
||||||
TitleChanged += (o, args) => titleChanged?.Invoke(args.Title);
|
TitleChanged += (o, args) => titleChanged?.Invoke(args.Title);
|
||||||
|
|
||||||
DownloadHandler = downloadHandler;
|
DownloadHandler = downloadHandler;
|
||||||
|
@ -103,5 +105,21 @@ namespace SafeExamBrowser.Browser
|
||||||
logger.Debug($"Navigated to '{args.Address}'.");
|
logger.Debug($"Navigated to '{args.Address}'.");
|
||||||
addressChanged?.Invoke(args.Address);
|
addressChanged?.Invoke(args.Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void BrowserControl_MouseWheel(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (settings.AllowPageZoom && ModifierKeys == Keys.Control)
|
||||||
|
{
|
||||||
|
var browser = GetBrowser();
|
||||||
|
|
||||||
|
browser.GetZoomLevelAsync().ContinueWith(task =>
|
||||||
|
{
|
||||||
|
if (task.IsCompleted)
|
||||||
|
{
|
||||||
|
browser.SetZoomLevel(task.Result + e.Delta * 0.1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,14 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MapPageZoom(Settings settings, object value)
|
||||||
|
{
|
||||||
|
if (value is bool enabled)
|
||||||
|
{
|
||||||
|
settings.Browser.AllowPageZoom = enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MapUserAgentMode(IDictionary<string, object> rawData, Settings settings)
|
private void MapUserAgentMode(IDictionary<string, object> rawData, Settings settings)
|
||||||
{
|
{
|
||||||
const int DEFAULT = 0;
|
const int DEFAULT = 0;
|
||||||
|
@ -41,15 +49,5 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
settings.Browser.CustomUserAgent = rawData[Keys.Browser.CustomUserAgentMobile] as string;
|
settings.Browser.CustomUserAgent = rawData[Keys.Browser.CustomUserAgentMobile] as string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MapZoomMode(Settings settings, object value)
|
|
||||||
{
|
|
||||||
const int PAGE = 0;
|
|
||||||
|
|
||||||
if (value is int mode)
|
|
||||||
{
|
|
||||||
// TODO: settings.Browser.ZoomMode = mode == PAGE ? BrowserZoomMode.Page : BrowserZoomMode.Text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,17 +28,11 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case Keys.Browser.EnablePageZoom:
|
case Keys.Browser.EnablePageZoom:
|
||||||
// TODO: MapPageZoom(settings, value);
|
MapPageZoom(settings, value);
|
||||||
break;
|
|
||||||
case Keys.Browser.EnableTextZoom:
|
|
||||||
// TODO: MapTextZoom(settings, value);
|
|
||||||
break;
|
break;
|
||||||
case Keys.Browser.MainWindowMode:
|
case Keys.Browser.MainWindowMode:
|
||||||
MapMainWindowMode(settings, value);
|
MapMainWindowMode(settings, value);
|
||||||
break;
|
break;
|
||||||
case Keys.Browser.ZoomMode:
|
|
||||||
MapZoomMode(settings, value);
|
|
||||||
break;
|
|
||||||
case Keys.ConfigurationFile.ConfigurationPurpose:
|
case Keys.ConfigurationFile.ConfigurationPurpose:
|
||||||
MapConfigurationMode(settings, value);
|
MapConfigurationMode(settings, value);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -96,6 +96,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
settings.Browser.AllowDeveloperConsole = false;
|
settings.Browser.AllowDeveloperConsole = false;
|
||||||
settings.Browser.AllowDownloads = false;
|
settings.Browser.AllowDownloads = false;
|
||||||
settings.Browser.AllowForwardNavigation = false;
|
settings.Browser.AllowForwardNavigation = false;
|
||||||
|
settings.Browser.AllowPageZoom = true;
|
||||||
settings.Browser.AllowReloading = true;
|
settings.Browser.AllowReloading = true;
|
||||||
|
|
||||||
settings.Keyboard.AllowAltEsc = false;
|
settings.Keyboard.AllowAltEsc = false;
|
||||||
|
|
|
@ -23,11 +23,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
internal const string CustomUserAgentDesktop = "browserUserAgentWinDesktopModeCustom";
|
internal const string CustomUserAgentDesktop = "browserUserAgentWinDesktopModeCustom";
|
||||||
internal const string CustomUserAgentMobile = "browserUserAgentWinTouchModeCustom";
|
internal const string CustomUserAgentMobile = "browserUserAgentWinTouchModeCustom";
|
||||||
internal const string EnablePageZoom = "enableZoomPage";
|
internal const string EnablePageZoom = "enableZoomPage";
|
||||||
internal const string EnableTextZoom = "enableZoomText";
|
|
||||||
internal const string MainWindowMode = "browserViewMode";
|
internal const string MainWindowMode = "browserViewMode";
|
||||||
internal const string UserAgentModeDesktop = "browserUserAgentWinDesktopMode";
|
internal const string UserAgentModeDesktop = "browserUserAgentWinDesktopMode";
|
||||||
internal const string UserAgentModeMobile = "browserUserAgentWinTouchMode";
|
internal const string UserAgentModeMobile = "browserUserAgentWinTouchMode";
|
||||||
internal const string ZoomMode = "zoomMode";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class ConfigurationFile
|
internal static class ConfigurationFile
|
||||||
|
|
|
@ -46,6 +46,11 @@ namespace SafeExamBrowser.Contracts.Configuration.Settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AllowForwardNavigation { get; set; }
|
public bool AllowForwardNavigation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the user should be allowed to zoom webpages.
|
||||||
|
/// </summary>
|
||||||
|
public bool AllowPageZoom { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether the user should be allowed to reload webpages.
|
/// Determines whether the user should be allowed to reload webpages.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue