本文整理汇总了C#中System.Windows.Window.TranslatePoint方法的典型用法代码示例。如果您正苦于以下问题:C# Window.TranslatePoint方法的具体用法?C# Window.TranslatePoint怎么用?C# Window.TranslatePoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Window
的用法示例。
在下文中一共展示了Window.TranslatePoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Lookup
public Lookup(TextBox parent, Window owner)
: this()
{
_parent = parent;
Owner = owner;
var relative = new Point(0, parent.ActualHeight);
Point desiredLocation = owner.TranslatePoint(relative, parent);
Point point = Owner.PointToScreen(desiredLocation);
Top = point.Y;
Left = point.X;
Show();
}
示例2: RefreshScalingLine
private void RefreshScalingLine(Window wnd, Element element, Canvas canvas)
{
Vector offset = new Vector(wnd.Width / 2, 0);//ScalingWindow.Height + 125);
Point translatedPoint = wnd.TranslatePoint(new Point(0, 0) + offset, canvas);
canvas.Children.Remove(ScalingLine);
ScalingLine = new Line();
ScalingLine.X1 = translatedPoint.X;
ScalingLine.Y1 = translatedPoint.Y;
ScalingLine.X2 = element.Position.X + element.Width / 2;
ScalingLine.Y2 = element.Position.Y + element.Height / 8;
SolidColorBrush redBrush = new SolidColorBrush();
redBrush.Color = Colors.DarkGreen;
ScalingLine.StrokeThickness = 3;
ScalingLine.Stroke = redBrush;
//проверка, находится ли это окно в области канваса
if (new Rect(canvas.RenderSize).Contains(new Point(ScalingLine.X1, ScalingLine.Y1)))
canvas.Children.Add(ScalingLine);
}
示例3: DraggedDelta
private static Vector DraggedDelta(InputDevice inputDevice, Window window, UIElement relativeTo)
{
MouseDevice mouse = inputDevice as MouseDevice;
Contact contact = inputDevice as Contact;
// get the current position
Point currentPosition = (mouse == null) ? contact.GetPosition(window) : mouse.GetPosition(window);
// get the down state
if (!deviceStateDictionary.ContainsKey(inputDevice))
{
return ZeroVector;
}
// translate to the relativeTo elementToDrag
Point downPosition = deviceStateDictionary[inputDevice].Position;
if (relativeTo != window)
{
currentPosition = window.TranslatePoint(currentPosition, relativeTo);
downPosition = window.TranslatePoint(downPosition, relativeTo);
}
return (currentPosition - downPosition);
}