mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-17 17:28:53 -05:00
Merge remote-tracking branch 'Reshetnikov/develop'
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user