本文整理汇总了C#中UIElement.PointToScreen方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.PointToScreen方法的具体用法?C# UIElement.PointToScreen怎么用?C# UIElement.PointToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIElement
的用法示例。
在下文中一共展示了UIElement.PointToScreen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DropAccepted
public void DropAccepted(UIElement sender)
{
Point pos1 = sender.PointToScreen(new Point(0, 0));
Point pos = this.border.PointFromScreen(pos1);
this.adorner.SetLockedPosition(pos.X, pos.Y);
}
示例2: GetScreenPos
public static Rect GetScreenPos(UIElement element)
{
PresentationSource source = PresentationSource.FromVisual(element);
if (source == null)
{
return new Rect();
}
Matrix transformToDevice = source.CompositionTarget.TransformToDevice;
Size size = (Size)transformToDevice.Transform((Vector)element.RenderSize);
Point pointToScreen = element.PointToScreen(new Point(0, 0));
return new Rect(pointToScreen.X, pointToScreen.Y, size.Width, size.Height);
}
示例3: MakeTransform
private void MakeTransform(UIElement child, Point newOffset, int i)
{
int num = Math.Abs((int)(i - this.SelectedItemIndex));
Point point = child.PointToScreen(new Point(0.0, 0.0));
point = base.PointFromScreen(point);
TranslateTransform transform = new TranslateTransform();
ScaleTransform transform2 = new ScaleTransform();
transform2.ScaleX = Math.Pow(this.scaleFactorX, (double)num);
transform2.ScaleY = Math.Pow(this.scaleFactorY, (double)num);
TransformGroup group = new TransformGroup();
group.Children.Add(transform);
group.Children.Add(transform2);
child.RenderTransform = group;
child.RenderTransformOrigin = new Point(0.5, 0.5);
Point point2 = (Point)child.GetValue(ScaleFactorProperty);
transform.BeginAnimation(TranslateTransform.XProperty, MakeAnimation(point.X - newOffset.X, 0.0));
//transform2.BeginAnimation(ScaleTransform.ScaleXProperty, MakeAnimation(point2.X, Math.Pow(this.scaleFactorX, (double)num)));
//transform2.BeginAnimation(ScaleTransform.ScaleYProperty, MakeAnimation(point2.Y, Math.Pow(this.scaleFactorY, (double)num)));
child.SetValue(ScaleFactorProperty, new Point(transform2.ScaleX, transform2.ScaleY));
}
示例4: ResizePopup
public static bool ResizePopup(FrameworkElement itemsPresenter,
Size minDropDownSize,
bool canUserResizeHorizontally,
bool canUserResizeVertically,
bool isDropDownPositionedLeft,
bool isDropDownPositionedAbove,
Rect screenBounds,
UIElement popupRoot,
double horizontalDelta,
double verticalDelta)
{
if (itemsPresenter != null)
{
verticalDelta = isDropDownPositionedAbove ? (-verticalDelta) : verticalDelta;
horizontalDelta = isDropDownPositionedLeft? (-horizontalDelta): horizontalDelta;
Rect rootScreenBounds = new Rect(popupRoot.PointToScreen(new Point()),
popupRoot.PointToScreen(new Point(popupRoot.RenderSize.Width, popupRoot.RenderSize.Height)));
// There is a bug in .net3.5 in PopupRoot. When a Popup reaches a screen edge its size is restricted in both dimensions,
// regardless of which dimension is at the screen edge.
// If Popup is at bottom screen edge and you try to increase width horizontally,
// the contents increase in size but get clipped by the Popup. This has been fixed in 4.0.
// To workaround this bug, we dont allow Popup to ever go beyond top/bottom screen edge via resizing
// Note that Popup could still hit screen edge even before resizing, when Popup is opened for the first time.
// This will cause clipping but we are not going to workaround this case.
// Case 1: Popup is already at screen edge.
// So we want to ignore the delta if trying to increase in direction of screen edge.
bool isAtBottomScreenEdge = DoubleUtil.GreaterThanOrClose(rootScreenBounds.Bottom, screenBounds.Bottom);
bool isAtTopScreenEdge = DoubleUtil.LessThanOrClose(rootScreenBounds.Top, screenBounds.Top + TopScreenEdgeBuffer);
bool isAtRightScreenEdge = DoubleUtil.GreaterThanOrClose(rootScreenBounds.Right, screenBounds.Right);
bool isAtLeftScreenEdge = DoubleUtil.LessThanOrClose(rootScreenBounds.Left, screenBounds.Left);
// Case 2: If applying the deltas will make popup go over the screen edge.
// Truncate delta to whatever is remaining until the screen edge.
bool isAlmostAtBottomScreenEdge = DoubleUtil.GreaterThanOrClose(rootScreenBounds.Bottom + verticalDelta, screenBounds.Bottom);
bool isAlmostAtTopScreenEdge = DoubleUtil.LessThanOrClose(rootScreenBounds.Top - verticalDelta, screenBounds.Top + TopScreenEdgeBuffer);
bool isAlmostAtRightScreenEdge = DoubleUtil.GreaterThanOrClose(rootScreenBounds.Right + horizontalDelta, screenBounds.Right);
bool isAlmostAtLeftScreenEdge = DoubleUtil.LessThanOrClose(rootScreenBounds.Left - horizontalDelta, screenBounds.Left);
if (isDropDownPositionedAbove)
{
if (isAtTopScreenEdge && DoubleUtil.GreaterThanOrClose(verticalDelta, 0))
{
verticalDelta = 0;
}
else if (isAlmostAtTopScreenEdge)
{
verticalDelta = rootScreenBounds.Top - TopScreenEdgeBuffer;
}
}
else if (!isDropDownPositionedAbove)
{
if (isAtBottomScreenEdge && DoubleUtil.GreaterThanOrClose(verticalDelta, 0))
{
verticalDelta = 0;
}
else if (isAlmostAtBottomScreenEdge)
{
verticalDelta = screenBounds.Bottom - rootScreenBounds.Bottom;
}
}
// We need this check because WPF Popup's can render only on single monitor.
// (i.e. wont extend to second monitor in multi-mon setup).
if (isAtRightScreenEdge && DoubleUtil.GreaterThanOrClose(horizontalDelta, 0))
{
horizontalDelta = 0;
}
else if (isAlmostAtRightScreenEdge)
{
horizontalDelta = screenBounds.Right - rootScreenBounds.Right;
}
if (isAtLeftScreenEdge && DoubleUtil.GreaterThanOrClose(horizontalDelta, 0))
{
horizontalDelta = 0;
}
else if (isAlmostAtLeftScreenEdge)
{
horizontalDelta = rootScreenBounds.Left - screenBounds.Left ;
}
double newWidth = itemsPresenter.Width + horizontalDelta;
double newHeight = itemsPresenter.Height + verticalDelta;
return ResizePopupActual(itemsPresenter, minDropDownSize, canUserResizeHorizontally, canUserResizeVertically, newWidth, newHeight);
}
return false;
}