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


C# PathGeometry.Clone方法代码示例

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


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

示例1: GeometryHitTestParameters

        /// <summary>
        /// The constructor takes the geometry to hit test with.
        /// </summary>
        public GeometryHitTestParameters(Geometry geometry) : base()
        {
            // This ctor guarantees that we are initialized in the following way:
            //
            //  1.  The geometry provided by the user is unmodified
            //  2.  _hitGeometryInternal is a PathGeometry equivilent to the supplied geometry
            //  3.  _hitGeometryInternal.Tranform is a MatrixTransform equivilent to the supplied
            //      geometry.Transform
            //  4.  _origBounds is the untransformed bounds of the _hitGeometryInternal (inner space).
            //  5.  _bounds is the transformed bounds of the _hitGeometryInternal (outer space).
            //  6.  _matrixStack is an empty stack.            

            if (geometry == null)
            {                
                throw new ArgumentNullException("geometry");
            }
            
            // Convert the Geometry to an equivilent PathGeometry up front to prevent
            // conversion on every call to DoesContainWithDetail.  If the geometry is
            // animate this also has the side effect of eliminating animation interplay.
            _hitGeometryInternal = geometry.GetAsPathGeometry();

            // If GetAsPathGeometry was a no-op, force the copy because we do not
            // went to modify the user's Geometry.
            if (object.ReferenceEquals(_hitGeometryInternal, geometry))
            {
                _hitGeometryInternal = _hitGeometryInternal.Clone();
            }
            
            // Convert _hitGeometryInternal.Transform to an equivilent MatrixTransform
            // so that we can aggregate in PushMatrix/PopMatrix without building a
            // TransformCollection.
            Transform origTransform = _hitGeometryInternal.Transform;            
            MatrixTransform newTransform = new MatrixTransform();

            _hitGeometryInternal.Transform = newTransform;

            // Before we initialize MatrixTransform.Matrix, cache the bounds of this
            // geometry without any transforms.
            _origBounds = _hitGeometryInternal.Bounds;

            // If we had a non-Identity transform, update our MatrixTransform.Matrix
            // with its Value.  (Note that when GetAsPathGeometry *isn't* a no-op
            // it applies the transform to the figures and returns with a Geometry
            // with an identity Transform.)
            if (origTransform != null && !origTransform.IsIdentity)
            {
                newTransform.Matrix = origTransform.Value;
            }
            
            // Initialize the current transformed bounds of this Geometry
            _bounds = _hitGeometryInternal.Bounds;
            _matrixStack = new MatrixStack();
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:57,代码来源:GeometryHitTestParameters.cs


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