Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing glow border corners #2142

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions MahApps.Metro/Controls/GlowWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public GlowWindow(Window owner, GlowDirection direction)
glow.Orientation = Orientation.Vertical;
glow.HorizontalAlignment = HorizontalAlignment.Right;
getLeft = (rect) => rect.left - glowSize;
getTop = (rect) => rect.top - owner.BorderThickness.Top;
getTop = (rect) => rect.top - owner.BorderThickness.Top + 1;
getWidth = (rect) => glowSize;
getHeight = (rect) => rect.Height + owner.BorderThickness.Top + owner.BorderThickness.Bottom;
getHeight = (rect) => rect.Height + owner.BorderThickness.Top + owner.BorderThickness.Bottom - 2;
getHitTestValue = p => new Rect(0, 0, ActualWidth, edgeSize).Contains(p)
? HitTestValues.HTTOPLEFT
: new Rect(0, ActualHeight - edgeSize, ActualWidth, edgeSize).Contains(p)
Expand All @@ -81,9 +81,9 @@ public GlowWindow(Window owner, GlowDirection direction)
glow.Orientation = Orientation.Vertical;
glow.HorizontalAlignment = HorizontalAlignment.Left;
getLeft = (rect) => rect.right;
getTop = (rect) => rect.top - owner.BorderThickness.Top;
getTop = (rect) => rect.top - owner.BorderThickness.Top + 1;
getWidth = (rect) => glowSize;
getHeight = (rect) => rect.Height + owner.BorderThickness.Top + owner.BorderThickness.Bottom;
getHeight = (rect) => rect.Height + owner.BorderThickness.Top + owner.BorderThickness.Bottom - 2;
getHitTestValue = p => new Rect(0, 0, ActualWidth, edgeSize).Contains(p)
? HitTestValues.HTTOPRIGHT
: new Rect(0, ActualHeight - edgeSize, ActualWidth, edgeSize).Contains(p)
Expand All @@ -103,9 +103,9 @@ public GlowWindow(Window owner, GlowDirection direction)
case GlowDirection.Top:
glow.Orientation = Orientation.Horizontal;
glow.VerticalAlignment = VerticalAlignment.Bottom;
getLeft = (rect) => rect.left - owner.BorderThickness.Left;
getLeft = (rect) => rect.left - owner.BorderThickness.Left - glowSize;
getTop = (rect) => rect.top - glowSize;
getWidth = (rect) => rect.Width + owner.BorderThickness.Left + owner.BorderThickness.Right;
getWidth = (rect) => rect.Width + owner.BorderThickness.Left + owner.BorderThickness.Right + glowSize + glowSize;
getHeight = (rect) => glowSize;
getHitTestValue = p => new Rect(0, 0, edgeSize - glowSize, ActualHeight).Contains(p)
? HitTestValues.HTTOPLEFT
Expand All @@ -128,9 +128,9 @@ public GlowWindow(Window owner, GlowDirection direction)
case GlowDirection.Bottom:
glow.Orientation = Orientation.Horizontal;
glow.VerticalAlignment = VerticalAlignment.Top;
getLeft = (rect) => rect.left - owner.BorderThickness.Left;
getLeft = (rect) => rect.left - owner.BorderThickness.Left - glowSize;
getTop = (rect) => rect.bottom;
getWidth = (rect) => rect.Width + owner.BorderThickness.Left + owner.BorderThickness.Right;
getWidth = (rect) => rect.Width + owner.BorderThickness.Left + owner.BorderThickness.Right + glowSize + glowSize;
getHeight = (rect) => glowSize;
getHitTestValue = p => new Rect(0, 0, edgeSize - glowSize, ActualHeight).Contains(p)
? HitTestValues.HTBOTTOMLEFT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3297,6 +3297,11 @@ public static RECT GetWindowRect(IntPtr hwnd)
[DllImport("gdiplus.dll")]
public static extern Status GdiplusShutdown(IntPtr token);

[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsZoomed(IntPtr hwnd);

[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
Expand Down
3 changes: 1 addition & 2 deletions MahApps.Metro/Microsoft.Windows.Shell/WindowChromeWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,7 @@ private IntPtr _HandleGetMinMaxInfo(WM uMsg, IntPtr wParam, IntPtr lParam, out b
* MonitorFromWindow gives us the wrong (old) monitor! This is fixed in _HandleMoveForRealSize.
*/
var ignoreTaskBar = _chromeInfo.IgnoreTaskbarOnMaximize;// || _chromeInfo.UseNoneWindowStyle;
WindowState state = _GetHwndState();
if (ignoreTaskBar && state == WindowState.Maximized)
if (ignoreTaskBar && NativeMethods.IsZoomed(_hwnd))
{
MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
IntPtr monitor = NativeMethods.MonitorFromWindow(_hwnd, (uint)MonitorOptions.MONITOR_DEFAULTTONEAREST);
Expand Down
4 changes: 2 additions & 2 deletions MahApps.Metro/Themes/Glow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
Value="Horizontal">
<Setter TargetName="glowBorder"
Property="Margin"
Value="1,0" />
Value="8,0" />
<Setter TargetName="glowSource"
Property="Margin"
Value="0,-1" />
Value="7,-1" />
</Trigger>
<Trigger Property="BorderThickness"
Value="0">
Expand Down