Skip to content

Commit

Permalink
Merge pull request #2836 from MahApps/develop
Browse files Browse the repository at this point in the history
Merging content for 1.4.3 develop to master
  • Loading branch information
punker76 authored Feb 2, 2017
2 parents 8709b27 + 41fd0a4 commit 324adee
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 22 deletions.
23 changes: 21 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# PLEASE READ BEFORE POSTING AN ISSUE

This is a place for issues for MahApps itself. Questions are better asked in the [Gitter](https://gitter.im/MahApps/MahApps.Metro) room or at [stackoverflow](http://stackoverflow.com/questions/tagged/mahapps.metro).

### Seriously consider creating and linking to a test repo which takes absolutely minimal setup to illustrate how reproduce the problem.

My time is limited and .Zip files, code snippets and partial examples are often a time sink. GitHub also provides great communication and code review tools which can be utilised.

## HOW TO POST A GOOD SAMPLE.

Follow these guidelines and I will most likely look at the issue sooner:

* Post a full GitHub repository. Not a zip file, half baked snippet etc. If GitHub is new to you consider it a great learning opportunity and chance to get involved.
* The repository should have just ONE step max for me to get running, and that is "Restore NuGet Packages". If there are any other missing dependencies, or uncompiling features I will most likely move on to another issue.
* I'm not trying to be awkward. I'm just busy and I'm helping a lot of people, not just you, so help me out and I will help you out.


## What steps will reproduce this issue?

_Write problem description here_
Expand All @@ -6,11 +23,13 @@ _Write problem description here_

_Write expected outcome here_

### Repo

_Link to the Repo_

--
### Environment

- MahApps.Metro __v?.?.?__
- Windows __??__
- Windows OS __??__
- Visual Studio __20xx__
- .NET Framework __?.?__
65 changes: 65 additions & 0 deletions docs/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions docs/logo.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<UserControl x:Class="MaterialBlend.MahApps"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MaterialBlend"
mc:Ignorable="d" Height="349.5" Width="342.727">
<Grid>
<Path Data="M204.10463,161.30817 C193.68001,161.19063 185.10269,163.60248 185.10269,163.60248 144.24985,171.9998 120.99989,223.49998 99.499748,221.00005 84.499748,221.00005 58.999649,188.00003 58.499645,192.49994 57.999649,196.99985 61.999672,308.50076 131.99968,313.50076 191.99968,318.50037 238.5,249.25021 238.5,249.25021 L239.29802,249.91621 C239.29802,249.91621 285.79837,319.16635 345.79837,314.16675 415.79837,309.16675 419.79837,197.66585 419.29837,193.16594 418.79837,188.66603 393.29828,221.66603 378.29828,221.66603 356.79816,224.166 333.54819,172.66577 292.69534,164.26848 292.69534,164.26848 274.54831,159.16573 258.96503,164.16626 252.94939,166.74416 246.1281,168.73558 239.73712,173.507 L239.32588,173.8278 238.06091,172.84102 C231.66992,168.06958 224.84865,166.07816 218.83302,163.50027 213.96324,161.93761 208.84311,161.36159 204.10463,161.30817 z M237.5,0.5 C368.39148,0.5 474.5,106.60851 474.5,237.5 474.5,368.39148 368.39148,474.5 237.5,474.5 106.60851,474.5 0.5,368.39148 0.5,237.5 0.5,106.60851 106.60851,0.5 237.5,0.5 z" Fill="#FF0071BD" Stretch="Fill" Stroke="Black"/>

</Grid>
</UserControl>
11 changes: 11 additions & 0 deletions docs/release-notes/1.4.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 1.4.3 Notes

## Changes / Fixes

- Fix Flyout AutoClose sample
- Try to handle call fail of GetPhysicalCursorPos. [#2830](https://github.com/MahApps/MahApps.Metro/issues/2830)

## Closed Issues

- [#2832](https://github.com/MahApps/MahApps.Metro/issues/2832) Wrong window maximize on two monitor systems.
- [#2830](https://github.com/MahApps/MahApps.Metro/issues/2830) GetPhysicalCursorPos
2 changes: 1 addition & 1 deletion src/MahApps.Metro.Build/MahApps.Metro.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata>
<id>MahApps.Metro</id>
<version>1.4.2.0</version>
<version>1.4.3.0</version>
<title>MahApps.Metro</title>
<authors>Jan Karger, Dennis Daume, Brendan Forster, Paul Jenkins, Jake Ginnivan, Alex Mitchell</authors>
<owners>punker76,shiftkey,aeoth,jakeginnivan</owners>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private void ShowDynamicFlyout(object sender, RoutedEventArgs e)

private void ShowAutoCloseFlyout(object sender, RoutedEventArgs e)
{
this.ToggleFlyout(12);
this.ToggleFlyout(13);
}

private async void ClickMeOnClick(object sender, RoutedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,11 @@ private void HandleMaximize()
var monitorInfo = new MONITORINFO();
UnsafeNativeMethods.GetMonitorInfo(monitor, monitorInfo);

var x = monitorInfo.rcMonitor.left;
var y = monitorInfo.rcMonitor.top;
var cx = Math.Abs(monitorInfo.rcMonitor.right - x);
var cy = Math.Abs(monitorInfo.rcMonitor.bottom - y);
var desktopRect = ignoreTaskBar ? monitorInfo.rcMonitor : monitorInfo.rcWork;
var x = desktopRect.left;
var y = desktopRect.top;
var cx = Math.Abs(desktopRect.right - x);
var cy = Math.Abs(desktopRect.bottom - y);

if (ignoreTaskBar && this.isWindwos10OrHigher)
{
Expand Down
14 changes: 10 additions & 4 deletions src/MahApps.Metro/MahApps.Metro.Shared/Controls/GlowWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,11 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
case WM.LBUTTONDOWN:
if (this.ownerHandle != IntPtr.Zero && UnsafeNativeMethods.GetWindowRect(this.ownerHandle, out rect))
{
var pt = WinApiHelper.GetRelativeMousePosition(this.handle);
NativeMethods.PostMessage(this.ownerHandle, (uint)WM.NCLBUTTONDOWN, (IntPtr)this.getHitTestValue(pt, rect), IntPtr.Zero);
Point pt;
if (WinApiHelper.TryGetRelativeMousePosition(this.handle, out pt))
{
NativeMethods.PostMessage(this.ownerHandle, (uint)WM.NCLBUTTONDOWN, (IntPtr)this.getHitTestValue(pt, rect), IntPtr.Zero);
}
}
break;
case WM.NCHITTEST:
Expand All @@ -313,8 +316,11 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
{
if (this.ownerHandle != IntPtr.Zero && UnsafeNativeMethods.GetWindowRect(this.ownerHandle, out rect))
{
var pt = WinApiHelper.GetRelativeMousePosition(this.handle);
cursor = this.getCursor(pt, rect);
Point pt;
if (WinApiHelper.TryGetRelativeMousePosition(this.handle, out pt))
{
cursor = this.getCursor(pt, rect);
}
}
}
if (cursor != null && cursor != this.Cursor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ internal static void DoWindowTitleThumbMoveOnDragDelta(IMetroThumb thumb, [NotNu
// tage from DragMove internal code
window.VerifyAccess();

var cursorPos = WinApiHelper.GetPhysicalCursorPos();
//var cursorPos = WinApiHelper.GetPhysicalCursorPos();

// if the window is maximized dragging is only allowed on title bar (also if not visible)
var windowIsMaximized = window.WindowState == WindowState.Maximized;
Expand All @@ -1261,7 +1261,7 @@ internal static void DoWindowTitleThumbMoveOnDragDelta(IMetroThumb thumb, [NotNu

if (windowIsMaximized)
{
var cursorXPos = cursorPos.x;
//var cursorXPos = cursorPos.x;
EventHandler windowOnStateChanged = null;
windowOnStateChanged = (sender, args) =>
{
Expand Down
23 changes: 23 additions & 0 deletions src/MahApps.Metro/MahApps.Metro.Shared/Controls/WinApiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,33 @@ public static System.Windows.Point GetRelativeMousePosition(IntPtr hWnd)
return new System.Windows.Point(point.x, point.y);
}

/// <summary>
/// Try to get the relative mouse position to the given handle in client coordinates.
/// </summary>
/// <param name="hWnd">The handle for this method.</param>
public static bool TryGetRelativeMousePosition(IntPtr hWnd, out System.Windows.Point point)
{
Standard.POINT pt = new Standard.POINT();
var returnValue = hWnd != IntPtr.Zero && Standard.NativeMethods.TryGetPhysicalCursorPos(out pt);
if (returnValue)
{
Standard.NativeMethods.ScreenToClient(hWnd, ref pt);
point = new System.Windows.Point(pt.x, pt.y);
}
else
{
point = new System.Windows.Point();
}
return returnValue;
}

internal static Standard.POINT GetPhysicalCursorPos()
{
try
{
// Sometimes Win32 will fail this call, such as if you are
// not running in the interactive desktop. For example,
// a secure screen saver may be running.
return Standard.NativeMethods.GetPhysicalCursorPos();
}
catch (Exception exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2997,11 +2997,13 @@ public static RECT GetClientRect(IntPtr hwnd)
return rc;
}

[SecurityCritical]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "GetCursorPos", SetLastError = true)]
[DllImport("user32.dll", EntryPoint = "GetCursorPos", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _GetCursorPos(out POINT lpPoint);

[SecurityCritical]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static POINT GetCursorPos()
{
Expand All @@ -3010,15 +3012,33 @@ public static POINT GetCursorPos()
{
HRESULT.ThrowLastError();
}

return pt;
}

[SecurityCritical]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static bool TryGetCursorPos(out POINT pt)
{
var returnValue = _GetCursorPos(out pt);
// Sometimes Win32 will fail this call, such as if you are
// not running in the interactive desktop. For example,
// a secure screen saver may be running.
if (!returnValue)
{
System.Diagnostics.Debug.WriteLine("GetCursorPos failed!");
pt.x = 0;
pt.y = 0;
}
return returnValue;
}

[SecurityCritical]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("user32.dll", EntryPoint = "GetPhysicalCursorPos", SetLastError = true)]
[DllImport("user32.dll", EntryPoint = "GetPhysicalCursorPos", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool _GetPhysicalCursorPos(out POINT lpPoint);

[SecurityCritical]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static POINT GetPhysicalCursorPos()
{
Expand All @@ -3027,10 +3047,26 @@ public static POINT GetPhysicalCursorPos()
{
HRESULT.ThrowLastError();
}

return pt;
}

[SecurityCritical]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static bool TryGetPhysicalCursorPos(out POINT pt)
{
var returnValue = _GetPhysicalCursorPos(out pt);
// Sometimes Win32 will fail this call, such as if you are
// not running in the interactive desktop. For example,
// a secure screen saver may be running.
if (!returnValue)
{
System.Diagnostics.Debug.WriteLine("GetPhysicalCursorPos failed!");
pt.x = 0;
pt.y = 0;
}
return returnValue;
}

[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DllImport("uxtheme.dll", EntryPoint = "GetCurrentThemeName", CharSet = CharSet.Unicode)]
private static extern HRESULT _GetCurrentThemeName(
Expand Down
8 changes: 4 additions & 4 deletions src/MahApps.Metro/MahApps.Metro/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[assembly: AssemblyDescription("A toolkit for creating Metro / Modern UI styled WPF apps.")]
[assembly: AssemblyCompany("MahApps")]

[assembly: AssemblyVersion("1.4.2.0")]
[assembly: AssemblyFileVersion("1.4.2.0")]
[assembly: AssemblyInformationalVersion("1.4.2.0")]
[assembly: AssemblyProduct("MahApps.Metro 1.4.2")]
[assembly: AssemblyVersion("1.4.3.0")]
[assembly: AssemblyFileVersion("1.4.3.0")]
[assembly: AssemblyInformationalVersion("1.4.3.0")]
[assembly: AssemblyProduct("MahApps.Metro 1.4.3")]

0 comments on commit 324adee

Please sign in to comment.