本文整理汇总了C#中System.Windows.Media.Visual.PointToScreen方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.PointToScreen方法的具体用法?C# Visual.PointToScreen怎么用?C# Visual.PointToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Visual
的用法示例。
在下文中一共展示了Visual.PointToScreen方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCaret
/// <summary>
/// Creates an invisible Win32 caret for the specified Visual with the specified size (coordinates local to the owner visual).
/// </summary>
public static bool CreateCaret(Visual owner, Size size)
{
if (owner == null)
throw new ArgumentNullException("owner");
HwndSource source = PresentationSource.FromVisual(owner) as HwndSource;
if (source != null) {
Vector r = owner.PointToScreen(new Point(size.Width, size.Height)) - owner.PointToScreen(new Point(0, 0));
return SafeNativeMethods.CreateCaret(source.Handle, IntPtr.Zero, (int)Math.Ceiling(r.X), (int)Math.Ceiling(r.Y));
} else {
return false;
}
}
示例2: SetMousePosition
/// <summary>
/// This will move the mouse cursor to a new location
/// </summary>
public static void SetMousePosition(Visual relativeTo, Point? offset = null)
{
Point point = offset ?? new Point(0, 0);
Point screenPos = relativeTo.PointToScreen(point);
SetMousePosition(screenPos);
}
示例3: GetPixelSnappingOffset
private static Point GetPixelSnappingOffset(Visual visual, Visual rootVisual)
{
var point = new Point();
if (rootVisual != null)
{
var transform = visual.TransformToAncestor(rootVisual) as Transform;
if ((transform != null) && transform.Value.HasInverse)
{
point = visual.PointFromScreen(visual.PointToScreen(point));
}
}
return point;
}
示例4: ShowWindowMenu
public static void ShowWindowMenu(HwndSource source, Visual element, Point elementPoint,
Size elementSize)
{
if (elementPoint.X < 0.0 || elementPoint.X > elementSize.Width ||
(elementPoint.Y < 0.0 || elementPoint.Y > elementSize.Height))
return;
Point screenPoint = element.PointToScreen(elementPoint);
ShowWindowMenu(source, screenPoint, true);
}
示例5: ConvertRelativePointToScreenInDefaultDpi
/// <summary>
/// Converts point in control to screen point in default DPI.
/// </summary>
/// <param name="control">Parent control.</param>
/// <param name="point">Current mouse position.</param>
/// <returns>Point in default DPI.</returns>
public Point ConvertRelativePointToScreenInDefaultDpi(Visual control, Point point)
{
Point screenPoint = control.PointToScreen(point);
return GetScreenPointInDefaultDpi(screenPoint);
}