当前位置: 首页>>代码示例>>C#>>正文


C# UIElement.PointToScreen方法代码示例

本文整理汇总了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);
        }
开发者ID:joshreve,项目名称:Touchmote,代码行数:7,代码来源:KeymapOutputItem.xaml.cs

示例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);
        }
开发者ID:WKlingonsmith,项目名称:FCS-Project,代码行数:15,代码来源:GeneralUtilities.cs

示例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));
 }
开发者ID:luiseduardohdbackup,项目名称:dotnet-1,代码行数:20,代码来源:AnimatedStackPanel.cs

示例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;
        }
开发者ID:kasicass,项目名称:kasicass,代码行数:91,代码来源:RibbonDropDownHelper.cs


注:本文中的UIElement.PointToScreen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。