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