SEBWIN-106: Fixed placement of browser menu.
This commit is contained in:
parent
5ad8a8a2fb
commit
ebdd5b1e03
2 changed files with 27 additions and 17 deletions
|
@ -20,7 +20,7 @@
|
|||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="0" BorderBrush="LightGray" BorderThickness="0,0,0,1" Margin="5,0">
|
||||
<Border x:Name="Toolbar" Grid.Row="0" BorderBrush="LightGray" BorderThickness="0,0,0,1" Margin="5,0">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
@ -37,8 +37,8 @@
|
|||
<fa:ImageAwesome x:Name="LoadingIcon" Foreground="Gray" HorizontalAlignment="Right" Icon="Spinner" Margin="5,3" SpinDuration="1.5" Visibility="Collapsed" />
|
||||
</Grid>
|
||||
<Button Grid.Column="4" x:Name="MenuButton" Height="30" HorizontalAlignment="Center" Margin="5" Template="{StaticResource BrowserButton}" VerticalAlignment="Center" />
|
||||
<Popup x:Name="MenuPopup" IsOpen="False" Placement="Bottom" PlacementTarget="{Binding ElementName=MenuButton}" HorizontalOffset="-215" VerticalOffset="4">
|
||||
<Border Background="{StaticResource BackgroundBrush}" BorderBrush="LightGray" BorderThickness="0.75,0,0.75,0.75" Width="250">
|
||||
<Popup x:Name="MenuPopup" IsOpen="False" AllowsTransparency="True" PopupAnimation="Slide" Placement="Custom" PlacementTarget="{Binding ElementName=BrowserControlHost}">
|
||||
<Border Background="{StaticResource BackgroundBrush}" BorderBrush="LightGray" BorderThickness="1,0,1,1" Width="250">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Grid Height="40">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
|
|
@ -10,6 +10,7 @@ using System;
|
|||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
@ -121,20 +122,6 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
Dispatcher.Invoke(() => Title = title);
|
||||
}
|
||||
|
||||
private void InitializeBrowserWindow(IBrowserControl browserControl)
|
||||
{
|
||||
if (browserControl is System.Windows.Forms.Control control)
|
||||
{
|
||||
BrowserControlHost.Child = control;
|
||||
}
|
||||
|
||||
RegisterEvents();
|
||||
InitializeBounds();
|
||||
ApplySettings();
|
||||
LoadIcons();
|
||||
LoadText();
|
||||
}
|
||||
|
||||
private void BrowserWindow_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (isMainWindow)
|
||||
|
@ -155,6 +142,14 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
}
|
||||
}
|
||||
|
||||
private CustomPopupPlacement[] MenuPopup_PlacementCallback(Size popupSize, Size targetSize, Point offset)
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
new CustomPopupPlacement(new Point(targetSize.Width - Toolbar.Margin.Right - popupSize.Width, -2), PopupPrimaryAxis.None)
|
||||
};
|
||||
}
|
||||
|
||||
private void SystemParameters_StaticPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(SystemParameters.WorkArea))
|
||||
|
@ -180,6 +175,20 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
}
|
||||
}
|
||||
|
||||
private void InitializeBrowserWindow(IBrowserControl browserControl)
|
||||
{
|
||||
if (browserControl is System.Windows.Forms.Control control)
|
||||
{
|
||||
BrowserControlHost.Child = control;
|
||||
}
|
||||
|
||||
RegisterEvents();
|
||||
InitializeBounds();
|
||||
ApplySettings();
|
||||
LoadIcons();
|
||||
LoadText();
|
||||
}
|
||||
|
||||
private void RegisterEvents()
|
||||
{
|
||||
var originalBrush = MenuButton.Background;
|
||||
|
@ -189,6 +198,7 @@ namespace SafeExamBrowser.UserInterface.Desktop
|
|||
ForwardButton.Click += (o, args) => ForwardNavigationRequested?.Invoke();
|
||||
MenuButton.Click += (o, args) => MenuPopup.IsOpen = !MenuPopup.IsOpen;
|
||||
MenuButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = MenuPopup.IsMouseOver));
|
||||
MenuPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(MenuPopup_PlacementCallback);
|
||||
MenuPopup.Closed += (o, args) => MenuButton.Background = originalBrush;
|
||||
MenuPopup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = IsMouseOver));
|
||||
MenuPopup.Opened += (o, args) => MenuButton.Background = Brushes.LightGray;
|
||||
|
|
Loading…
Reference in a new issue