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


C# GeneralTransform.TryTransform方法代码示例

本文整理汇总了C#中System.Windows.Media.GeneralTransform.TryTransform方法的典型用法代码示例。如果您正苦于以下问题:C# GeneralTransform.TryTransform方法的具体用法?C# GeneralTransform.TryTransform怎么用?C# GeneralTransform.TryTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.GeneralTransform的用法示例。


在下文中一共展示了GeneralTransform.TryTransform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetBounds

        private Rect GetBounds(StylusPoint stylusPoint, 
            Point position,
            IInputElement relativeTo, 
            GeneralTransform elementToRoot,
            GeneralTransform rootToElement)
        {
            // Get width and heith in pixel value 
            double width = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ true);
            double height = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ false); 
 
            // Get the position with respect to root
            Point rootPoint; 
            if (elementToRoot == null ||
                !elementToRoot.TryTransform(position, out rootPoint))
            {
                rootPoint = position; 
            }
 
            // Create a Rect with respect to root and transform it to element coordinate space 
            Rect rectBounds = new Rect(rootPoint.X - width * 0.5, rootPoint.Y - height * 0.5, width, height);
            if (rootToElement != null) 
            {
                rectBounds = rootToElement.TransformBounds(rectBounds);
            }
            return rectBounds; 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:26,代码来源:StylusTouchDevice.cs

示例2: _GetTransformedCaretRect

        // Creates an axis-aligned caret for possibly rotated glyphs
        private Rect _GetTransformedCaretRect(GeneralTransform transform, Point origin, double height)
        {
            Point bottom = origin;
            bottom.Y += height;
            transform.TryTransform(origin, out origin);
            transform.TryTransform(bottom, out bottom);
            Rect caretRect = new Rect(origin, bottom);
            if (caretRect.Width > 0)
            {
                // only vertical carets are supported by TextEditor
                // What to do if height == 0?
                caretRect.X += caretRect.Width / 2;
                caretRect.Width = 0;
            }

            if (caretRect.Height < 1)
            {
                caretRect.Height = 1;
            }

            return caretRect;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:23,代码来源:FixedTextView.cs

示例3: ClipToElement

        // Clips a Point to the ActualWidth/Height of a containing FrameworkElement.
        private static void ClipToElement(FrameworkElement element, GeneralTransform transform,
            ref double horizontalOffset, ref double verticalOffset)
        {
            Point minPoint;
            Point maxPoint;

            Geometry clip = VisualTreeHelper.GetClip(element);

            if (clip != null)
            {
                Rect bounds = clip.Bounds;
                minPoint = new Point(bounds.X, bounds.Y);
                maxPoint = new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height);
            }
            else
            {
                if (element.ActualWidth == 0 && element.ActualHeight == 0)
                {
                    // Some elements, noteably Canvas, have a (0, 0) desired size
                    // and should be ignored.
                    return;
                }

                minPoint = new Point(0, 0);
                maxPoint = new Point(element.ActualWidth, element.ActualHeight);
            }

            transform.TryTransform(minPoint, out minPoint);
            transform.TryTransform(maxPoint, out maxPoint);

            // NB: ClipToBounds will handle the case where transform flips a coordinate
            // axis.  In that case, minPoint.X will be > maxPoint.X.
            horizontalOffset = ClipToBounds(minPoint.X, horizontalOffset, maxPoint.X);
            verticalOffset = ClipToBounds(minPoint.Y, verticalOffset, maxPoint.Y);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:36,代码来源:TextEditorContextMenu.cs


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