Merge remote-tracking branch 'Reshetnikov/develop'

This commit is contained in:
jr
2015-07-09 18:11:57 +02:00
4 changed files with 75 additions and 53 deletions

View File

@@ -153,6 +153,14 @@ namespace Hardcodet.Wpf.TaskbarNotification
#endregion
#region Custom Balloons
public delegate Point GetCustomPopupPosition();
public GetCustomPopupPosition CustomPopupPosition;
public Point GetPopupTrayPosition()
{
return TrayInfo.GetTrayLocation();
}
/// <summary>
/// Shows a custom control as a tooltip in the tray location.
@@ -225,8 +233,8 @@ namespace Hardcodet.Wpf.TaskbarNotification
popup.Placement = PlacementMode.AbsolutePoint;
popup.StaysOpen = true;
Point position = TrayInfo.GetTrayLocation();
position = GetDeviceCoordinates(position);
Point position = this.CustomPopupPosition != null ? this.CustomPopupPosition() : this.GetPopupTrayPosition();
popup.HorizontalOffset = position.X - 1;
popup.VerticalOffset = position.Y - 1;
@@ -402,7 +410,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
WinApi.GetCursorPos(ref cursorPosition);
}
cursorPosition = GetDeviceCoordinates(cursorPosition);
cursorPosition = TrayInfo.GetDeviceCoordinates(cursorPosition);
bool isLeftClickCommandInvoked = false;
@@ -962,34 +970,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
#endregion
/// <summary>
/// Recalculates OS coordinates in order to support WPFs coordinate
/// system if OS scaling (DPIs) is not 100%.
/// </summary>
/// <param name="point"></param>
/// <returns></returns>
private Point GetDeviceCoordinates(Point point)
{
if (double.IsNaN(scalingFactor))
{
//calculate scaling factor in order to support non-standard DPIs
var presentationSource = PresentationSource.FromVisual(this);
if (presentationSource == null)
{
scalingFactor = 1;
}
else
{
var transform = presentationSource.CompositionTarget.TransformToDevice;
scalingFactor = 1/transform.M11;
}
}
//on standard DPI settings, just return the point
if (scalingFactor == 1.0) return point;
return new Point() {X = (int) (point.X*scalingFactor), Y = (int) (point.Y*scalingFactor)};
}
#region Dispose / Exit