Continue to tweak offset
This commit is contained in:
@@ -2,16 +2,15 @@
|
||||
x:Class="NotificationFlyoutSample.SampleFlyout"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:TheXamlGuy.NotificationFlyout.Uwp.UI.Controls">
|
||||
xmlns:controls="using:TheXamlGuy.NotificationFlyout.Uwp.UI.Controls"
|
||||
VerticalContentAlignment="Top">
|
||||
<controls:NotificationFlyout.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem Click="OnCloseMenuFlyoutItemClick" Text="Close" />
|
||||
</MenuFlyout>
|
||||
</controls:NotificationFlyout.ContextFlyout>
|
||||
<StackPanel
|
||||
|
||||
Margin="24"
|
||||
VerticalAlignment="Top">
|
||||
<Grid Margin="24" VerticalAlignment="Top">
|
||||
<StackPanel Background="Red">
|
||||
<ToggleSwitch
|
||||
Header="Is light dimissed enabled"
|
||||
IsOn="True"
|
||||
@@ -26,7 +25,9 @@
|
||||
<TextBox />
|
||||
<CalendarDatePicker />
|
||||
<CalendarView />
|
||||
<Button Content="hello" Click="Button_Click" />
|
||||
<Button Click="Button_Click" Content="hello" />
|
||||
<TimePicker />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</controls:NotificationFlyout>
|
||||
+14
-13
@@ -38,7 +38,7 @@ namespace TheXamlGuy.NotificationFlyout.Uwp.UI.Controls
|
||||
typeof(NotificationFlyoutTemplateSettings), typeof(NotificationFlyout),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
private const double OffsetValue = 1;
|
||||
private const double OffsetValue = 6;
|
||||
|
||||
private static INotificationFlyoutApplication _applicationInstance;
|
||||
|
||||
@@ -143,8 +143,8 @@ namespace TheXamlGuy.NotificationFlyout.Uwp.UI.Controls
|
||||
|
||||
_child.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
|
||||
var width = _child.DesiredSize.Width;
|
||||
var height = Placement == NotificationFlyoutPlacement.Auto ? _child.DesiredSize.Height : workingAreaHeight;
|
||||
var width = _child.DesiredSize.Width - 1;
|
||||
var height = Placement == NotificationFlyoutPlacement.Auto ? _child.DesiredSize.Height : workingAreaHeight + 1;
|
||||
|
||||
var desiredHorizontalOffset = horizontalOffset;
|
||||
var desiredVerticalOffset = verticalOffset;
|
||||
@@ -161,15 +161,15 @@ namespace TheXamlGuy.NotificationFlyout.Uwp.UI.Controls
|
||||
desiredVerticalOffset -= height;
|
||||
break;
|
||||
case NotificationFlyoutTaskbarPlacement.Top:
|
||||
desiredHorizontalOffset -= width;
|
||||
desiredHorizontalOffset -= width + OffsetValue;
|
||||
desiredVerticalOffset -= OffsetValue;
|
||||
break;
|
||||
case NotificationFlyoutTaskbarPlacement.Right:
|
||||
desiredHorizontalOffset -= width;
|
||||
desiredHorizontalOffset -= width + OffsetValue;
|
||||
desiredVerticalOffset -= height;
|
||||
break;
|
||||
case NotificationFlyoutTaskbarPlacement.Bottom:
|
||||
desiredHorizontalOffset -= width;
|
||||
desiredHorizontalOffset -= width + OffsetValue;
|
||||
desiredVerticalOffset -= height;
|
||||
break;
|
||||
}
|
||||
@@ -180,19 +180,20 @@ namespace TheXamlGuy.NotificationFlyout.Uwp.UI.Controls
|
||||
switch (flyoutTaskbarPlacement)
|
||||
{
|
||||
case NotificationFlyoutTaskbarPlacement.Left:
|
||||
desiredHorizontalOffset += workingAreaWidth - width;
|
||||
desiredVerticalOffset = 0;
|
||||
desiredHorizontalOffset += workingAreaWidth - width - OffsetValue;
|
||||
desiredVerticalOffset = -OffsetValue;
|
||||
break;
|
||||
case NotificationFlyoutTaskbarPlacement.Top:
|
||||
desiredHorizontalOffset = workingAreaWidth - width;
|
||||
desiredHorizontalOffset = workingAreaWidth - width - OffsetValue;
|
||||
desiredVerticalOffset += -OffsetValue;
|
||||
break;
|
||||
case NotificationFlyoutTaskbarPlacement.Right:
|
||||
desiredHorizontalOffset -= width;
|
||||
desiredVerticalOffset = 0;
|
||||
desiredHorizontalOffset -= width + OffsetValue;
|
||||
desiredVerticalOffset = -OffsetValue;
|
||||
break;
|
||||
case NotificationFlyoutTaskbarPlacement.Bottom:
|
||||
desiredHorizontalOffset = workingAreaWidth - width;
|
||||
desiredVerticalOffset = 0;
|
||||
desiredHorizontalOffset -= width + OffsetValue;
|
||||
desiredVerticalOffset = -OffsetValue;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
+10
-7
@@ -71,7 +71,6 @@ namespace TheXamlGuy.NotificationFlyout.Wpf.UI.Controls
|
||||
window.Show();
|
||||
}
|
||||
|
||||
|
||||
public void OpenFlyout()
|
||||
{
|
||||
if (Flyout == null) return;
|
||||
@@ -119,12 +118,15 @@ namespace TheXamlGuy.NotificationFlyout.Wpf.UI.Controls
|
||||
|
||||
_isDpiChanging = true;
|
||||
|
||||
UpdateIcons();
|
||||
_notificationFlyoutXamlHost.Visibility = Visibility.Visible;
|
||||
|
||||
await Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
VisualTreeHelper.SetRootDpi(_notificationFlyoutXamlHost, args.OldDpi);
|
||||
}), DispatcherPriority.ContextIdle, null);
|
||||
|
||||
await Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
VisualTreeHelper.SetRootDpi(_notificationFlyoutXamlHost, args.NewDpi);
|
||||
}), DispatcherPriority.ContextIdle, null);
|
||||
|
||||
@@ -133,6 +135,8 @@ namespace TheXamlGuy.NotificationFlyout.Wpf.UI.Controls
|
||||
_notificationFlyoutXamlHost.Visibility = Visibility.Hidden;
|
||||
_isDpiChanging = false;
|
||||
}), DispatcherPriority.ContextIdle, null);
|
||||
|
||||
UpdateIcons();
|
||||
}
|
||||
|
||||
private void OnTaskbarChanged(object sender, EventArgs args) => UpdateFlyoutPlacement();
|
||||
@@ -187,8 +191,9 @@ namespace TheXamlGuy.NotificationFlyout.Wpf.UI.Controls
|
||||
{
|
||||
if (Flyout == null) return;
|
||||
|
||||
_notificationFlyoutXamlHost.Left = 0;
|
||||
_notificationFlyoutXamlHost.Top = 0;
|
||||
var taskbarState = _taskbarHelper.GetCurrentState();
|
||||
_notificationFlyoutXamlHost.Left = taskbarState.Screen.Bounds.Left;
|
||||
_notificationFlyoutXamlHost.Top = taskbarState.Screen.Bounds.Top;
|
||||
|
||||
double horizontalOffset;
|
||||
double verticalOffset;
|
||||
@@ -196,12 +201,10 @@ namespace TheXamlGuy.NotificationFlyout.Wpf.UI.Controls
|
||||
var dpiX = _notificationFlyoutXamlHost.DpiX();
|
||||
var dpiY = _notificationFlyoutXamlHost.DpiY();
|
||||
|
||||
NotificationFlyoutTaskbarPlacement flyoutTaskBarPlacement;
|
||||
|
||||
var taskbarState = _taskbarHelper.GetCurrentState();
|
||||
var workingAreaHeight = taskbarState.Screen.WorkingArea.Height / dpiX;
|
||||
var workingAreaWidth = taskbarState.Screen.WorkingArea.Width / dpiY;
|
||||
|
||||
NotificationFlyoutTaskbarPlacement flyoutTaskBarPlacement;
|
||||
switch (taskbarState.Placement)
|
||||
{
|
||||
case TaskbarPlacement.Left:
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace TheXamlGuy.NotificationFlyout.Wpf.UI.Controls
|
||||
{
|
||||
internal class TransparentXamlHost<TXamlContent> : XamlHost<TXamlContent> where TXamlContent : Windows.UI.Xaml.UIElement
|
||||
{
|
||||
internal const double WindowSize = 1;
|
||||
internal const double WindowSize = 10;
|
||||
|
||||
public TransparentXamlHost() => PrepareDefaultWindow();
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace TheXamlGuy.NotificationFlyout.Wpf.UI.Controls
|
||||
WindowStyle = WindowStyle.None;
|
||||
ResizeMode = ResizeMode.NoResize;
|
||||
AllowsTransparency = true;
|
||||
Background = new SolidColorBrush(Colors.Transparent);
|
||||
Background = new SolidColorBrush(Colors.Red);
|
||||
Height = WindowSize;
|
||||
Width = WindowSize;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user