SEBWIN-106: Ensured the main browser window cannot be closed by the user.
This commit is contained in:
parent
36719c584a
commit
0a184e3c8e
1 changed files with 26 additions and 8 deletions
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
@ -78,7 +79,12 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
||||||
|
|
||||||
public new void Close()
|
public new void Close()
|
||||||
{
|
{
|
||||||
Dispatcher.Invoke(base.Close);
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
Closing -= BrowserWindow_Closing;
|
||||||
|
closing?.Invoke();
|
||||||
|
base.Close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public new void Hide()
|
public new void Hide()
|
||||||
|
@ -128,12 +134,15 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
||||||
LoadText();
|
LoadText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UrlTextBox_GotMouseCapture(object sender, MouseEventArgs e)
|
private void BrowserWindow_Closing(object sender, CancelEventArgs e)
|
||||||
{
|
{
|
||||||
if (UrlTextBox.Tag as bool? != true)
|
if (isMainWindow)
|
||||||
{
|
{
|
||||||
UrlTextBox.SelectAll();
|
e.Cancel = true;
|
||||||
UrlTextBox.Tag = true;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
closing?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +154,15 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UrlTextBox_GotMouseCapture(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (UrlTextBox.Tag as bool? != true)
|
||||||
|
{
|
||||||
|
UrlTextBox.SelectAll();
|
||||||
|
UrlTextBox.Tag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UrlTextBox_KeyUp(object sender, KeyEventArgs e)
|
private void UrlTextBox_KeyUp(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
|
@ -158,13 +176,13 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
||||||
var originalBrush = MenuButton.Background;
|
var originalBrush = MenuButton.Background;
|
||||||
|
|
||||||
BackwardButton.Click += (o, args) => BackwardNavigationRequested?.Invoke();
|
BackwardButton.Click += (o, args) => BackwardNavigationRequested?.Invoke();
|
||||||
Closing += (o, args) => closing?.Invoke();
|
Closing += BrowserWindow_Closing;
|
||||||
ForwardButton.Click += (o, args) => ForwardNavigationRequested?.Invoke();
|
ForwardButton.Click += (o, args) => ForwardNavigationRequested?.Invoke();
|
||||||
MenuButton.Click += (o, args) => MenuPopup.IsOpen = !MenuPopup.IsOpen;
|
MenuButton.Click += (o, args) => MenuPopup.IsOpen = !MenuPopup.IsOpen;
|
||||||
MenuButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = MenuPopup.IsMouseOver));
|
MenuButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = MenuPopup.IsMouseOver));
|
||||||
MenuPopup.Closed += (o, args) => { MenuButton.Background = originalBrush; };
|
MenuPopup.Closed += (o, args) => MenuButton.Background = originalBrush;
|
||||||
MenuPopup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = IsMouseOver));
|
MenuPopup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = IsMouseOver));
|
||||||
MenuPopup.Opened += (o, args) => { MenuButton.Background = Brushes.LightGray; };
|
MenuPopup.Opened += (o, args) => MenuButton.Background = Brushes.LightGray;
|
||||||
KeyUp += BrowserWindow_KeyUp;
|
KeyUp += BrowserWindow_KeyUp;
|
||||||
ReloadButton.Click += (o, args) => ReloadRequested?.Invoke();
|
ReloadButton.Click += (o, args) => ReloadRequested?.Invoke();
|
||||||
UrlTextBox.GotKeyboardFocus += (o, args) => UrlTextBox.SelectAll();
|
UrlTextBox.GotKeyboardFocus += (o, args) => UrlTextBox.SelectAll();
|
||||||
|
|
Loading…
Reference in a new issue