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


C# Rect.Intersect方法代码示例

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


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

示例1: Apply

		/// <summary>
		/// Applies the specified old data rect.
		/// </summary>
		/// <param name="oldDataRect">The old data rect.</param>
		/// <param name="newDataRect">The new data rect.</param>
		/// <param name="viewport">The viewport.</param>
		/// <returns></returns>
        /// 
		public override Rect Apply(Rect oldDataRect, Rect newDataRect, Viewport2D viewport)
		{
			DataRect res = domain;
			if (domain.IsEmpty)
			{
				res = newDataRect;
			}
			else if (newDataRect.IntersectsWith(domain))
			{
				res = newDataRect;
                if (newDataRect.Size == oldDataRect.Size)
                {
                    if (res.XMin < domain.XMin) res.XMin = domain.XMin;
                    if (res.YMin < domain.YMin) res.YMin = domain.YMin;
                    if (res.XMax > domain.XMax) res.XMin += domain.XMax - res.XMax;
                    if (res.YMax > domain.YMax) res.YMin += domain.YMax - res.YMax;
                }
                else
                {
                    newDataRect.Intersect(domain);
                    res = newDataRect;
                }
			}

			return res;
		}
开发者ID:BdGL3,项目名称:CXPortal,代码行数:34,代码来源:DomainRestriction.cs

示例2: GetCoordinatesInView

        internal static Point GetCoordinatesInView(this FrameworkElement element, UIElement visualRoot)
        {
            var point = element.TransformToVisual(visualRoot).Transform(new Point(0, 0));
            var center = new Point(point.X + (int)(element.ActualWidth / 2), point.Y + (int)(element.ActualHeight / 2));
            var bounds = new Rect(point, new Size(element.ActualWidth, element.ActualHeight));
            var boundsInView = new Rect(new Point(0, 0), visualRoot.RenderSize);
            boundsInView.Intersect(bounds);

            return boundsInView.IsEmpty ? center : new Point(boundsInView.X + (int)(boundsInView.Width / 2), boundsInView.Y + (int)(boundsInView.Height / 2));
        }
开发者ID:sleekweasel,项目名称:winphonedriver,代码行数:10,代码来源:FrameworkElementExtensions.cs

示例3: IsUserVisible

        internal static bool IsUserVisible(this FrameworkElement element, UIElement visualRoot)
        {
            var zero = new Point(0, 0);
            var elementSize = new Size(element.ActualWidth, element.ActualHeight);

            // Check if element is of zero size
            if (!(elementSize.Width > 0 && elementSize.Height > 0))
            {
                return false;
            }

            var rect = new Rect(zero, elementSize);
            var bound = element.TransformToVisual(visualRoot).TransformBounds(rect);
            var rootRect = new Rect(zero, visualRoot.RenderSize);
            rootRect.Intersect(bound);

            // Check if element is offscreen
            if (rootRect.IsEmpty)
            {
                return false;
            }

            while (true)
            {
                if (element.Visibility != Visibility.Visible || !element.IsHitTestVisible || !(element.Opacity > 0))
                {
                    return false;
                }

                var container = VisualTreeHelper.GetParent(element) as FrameworkElement;
                if (container == null)
                {
                    return true;
                }

                element = container;
            }
        }
开发者ID:sleekweasel,项目名称:winphonedriver,代码行数:38,代码来源:FrameworkElementExtensions.cs

示例4: collidesWith

        public bool collidesWith(Entity entity)
        {
            int x1 = this.PosX;
            int y1 = this.PosY;
            int w1 = this.Width;
            int h1 = this.Height;
            Rect box1 = new Rect(x1, y1, w1, h1);

            int x2 = entity.PosX;
            int y2 = entity.PosY;
            int w2 = entity.Width;
            int h2 = entity.Height;
            Rect box2 = new Rect(x2, y2, w2, h2);

            box1.Intersect(box2);
            if (box1 == Rect.Empty)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
开发者ID:calvcoll,项目名称:DotShot,代码行数:24,代码来源:Entity.cs

示例5: VisibleTiles

        // Returns the visible tiles inside a rectangle on any level
        private IEnumerable<Tile> VisibleTiles(Rect rectangle, int level)
        {
            rectangle.Intersect(new Rect(ImageSize));

            var top = Math.Floor(rectangle.Top / TileSize);
            var left = Math.Floor(rectangle.Left / TileSize);
            var right = Math.Ceiling(rectangle.Right / TileSize);
            var bottom = Math.Ceiling(rectangle.Bottom / TileSize);

            right = right.AtMost(ColumnsAtLevel(level));
            bottom = bottom.AtMost(RowsAtLevel(level));

            var width = (right - left).AtLeast(0);
            var height = (bottom - top).AtLeast(0);

            if (top == 0.0 && left == 0.0 && width == 1.0 && height == 1.0) // This level only has one tile
                yield return new Tile(level, 0, 0);
            else
            {
                foreach (var pt in Quadivide(new Rect(left, top, width, height)))
                    yield return new Tile(level, (int)pt.X, (int)pt.Y);
            }
        }
开发者ID:Jlinc,项目名称:Test_SurfaceWPF,代码行数:24,代码来源:MultiScaleTileSource.cs

示例6: Intersect

		public void Intersect ()
		{
			Rect r;

			// fully contained
			r = new Rect (0, 0, 50, 50);
			r.Intersect (new Rect (10, 10, 10, 10));
			Assert.AreEqual (new Rect (10, 10, 10, 10), r);

			// crosses top side
			r = new Rect (0, 0, 50, 50);
			r.Intersect (new Rect (5, -5, 10, 10));
			Assert.AreEqual (new Rect (5, 0, 10, 5), r);

			// crosses right side
			r = new Rect (0, 0, 50, 50);
			r.Intersect (new Rect (5, 5, 50, 10));
			Assert.AreEqual (new Rect (5, 5, 45, 10), r);

			// crosses bottom side
			r = new Rect (0, 0, 50, 50);
			r.Intersect (new Rect (5, 5, 10, 50));

			// crosses left side
			r = new Rect (0, 0, 50, 50);
			r.Intersect (new Rect (-5, 5, 10, 10));

			// completely outside (top)
			r = new Rect (0, 0, 50, 50);
			r.Intersect (new Rect (5, -5, 1, 1));
			Assert.AreEqual (Rect.Empty, r);

			// completely outside (right)
			r = new Rect (0, 0, 50, 50);
			r.Intersect (new Rect (75, 5, 1, 1));
			Assert.AreEqual (Rect.Empty, r);

			// completely outside (bottom)
			r = new Rect (0, 0, 50, 50);
			r.Intersect (new Rect (5, 75, 1, 1));
			Assert.AreEqual (Rect.Empty, r);

			// completely outside (left)
			r = new Rect (0, 0, 50, 50);
			r.Intersect (new Rect (-25, 5, 1, 1));
			Assert.AreEqual (Rect.Empty, r);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:47,代码来源:RectTest.cs

示例7: FitMouse

 private Point FitMouse()
 {
     double x = this.placementRect.Left;
     double y = this.placementRect.Top;
     if (this.IsRightToLeft)
     {
         x = this.viewPortRect.Width - x;
     }
     y += 20.0 + this.offset.Y;
     x += this.offset.X;
     y = Math.Max(2.0, y);
     x = Math.Max(2.0, x);
     Rect rect = new Rect(x, y, this.popupSize.Width, this.popupSize.Height);
     Rect rect2 = new Rect(0.0, 0.0, this.viewPortRect.Width, this.viewPortRect.Height);
     rect2.Intersect(rect);
     if ((Math.Abs(rect2.Width - rect.Width) < 2.0) && (Math.Abs(rect2.Height - rect.Height) < 2.0))
     {
         if (this.IsRightToLeft)
         {
             x = this.viewPortRect.Width - x;
         }
     }
     else
     {
         if ((y + rect.Height) > this.viewPortRect.Height)
         {
             y = (this.viewPortRect.Height - rect.Height) - 2.0;
         }
         if (y < 0.0)
         {
             y = 0.0;
         }
         if ((x + rect.Width) > this.viewPortRect.Width)
         {
             x = (this.viewPortRect.Width - rect.Width) - 2.0;
         }
         if (x < 0.0)
         {
             x = 0.0;
         }
         if (this.IsRightToLeft)
         {
             x = this.viewPortRect.Width - x;
         }
     }
     return new Point(x, y);
 }
开发者ID:mparsin,项目名称:Elements,代码行数:47,代码来源:PlacementHelper.cs

示例8: CalculateVisibleBoundingRect

        ///<summary>
        /// This eliminates the part of bounding rectangle if it is at all being overlapped/clipped by any of the visual ancestor up in the parent chain
        ///</summary>
        internal static Rect CalculateVisibleBoundingRect(UIElement uiElement)
        {
            Rect boundingRect = Rect.Empty;

            boundingRect = new Rect(uiElement.RenderSize);
            // Compute visible portion of the rectangle.

            Visual visual = VisualTreeHelper.GetParent(uiElement) as Visual;
            while (visual != null && boundingRect != Rect.Empty && boundingRect.Height != 0 && boundingRect.Width != 0)
            {
                Geometry clipGeometry = VisualTreeHelper.GetClip(visual);
                if (clipGeometry != null)
                {
                    GeneralTransform transform = uiElement.TransformToAncestor(visual).Inverse;
                    // Safer version of transform to descendent (doing the inverse ourself and saves us changing the co-ordinate space of the owner's bounding rectangle), 
                    // we want the rect inside of our space. (Which is always rectangular and much nicer to work with)
                    if (transform != null)
                    {
                        Rect clipBounds = clipGeometry.Bounds;
                        clipBounds = transform.TransformBounds(clipBounds);
                        boundingRect.Intersect(clipBounds);
                    }
                    else
                    {
                        // No visibility if non-invertable transform exists.
                        boundingRect = Rect.Empty;
                    }
                }
                visual = VisualTreeHelper.GetParent(visual) as Visual;
            }

            return boundingRect;
        }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:36,代码来源:DataGridAutomationPeer.cs

示例9: MakeVisible

        /// <summary>
        /// RibbonGalleryCategoriesPanel implementation of <seealso cref="IScrollInfo.MakeVisible" />.
        /// </summary>
        /// <param name="visual">The Visual that should become visible</param>
        /// <param name="rectangle">A rectangle representing in the visual's coordinate space to make visible.</param>
        /// <returns>
        /// A rectangle in the IScrollInfo's coordinate space that has been made visible.
        /// Other ancestors to in turn make this new rectangle visible.
        /// The rectangle should generally be a transformed version of the input rectangle.  In some cases, like
        /// when the input rectangle cannot entirely fit in the viewport, the return value might be smaller.
        /// </returns>
        public Rect MakeVisible(Visual visual, Rect rectangle)
        {
            // We can only work on visuals that are us or children.
            // An empty rect has no size or position.  We can't meaningfully use it.
            if (rectangle.IsEmpty
                || visual == null
                || visual == (Visual)this
                || !this.IsAncestorOf(visual))
            {
                return Rect.Empty;
            }
            #pragma warning disable 1634, 1691
            #pragma warning disable 56506
            // Compute the child's rect relative to (0,0) in our coordinate space.
            // This is a false positive by PreSharp. visual cannot be null because of the 'if' check above
            GeneralTransform childTransform = visual.TransformToAncestor(this);
            #pragma warning restore 56506
            #pragma warning restore 1634, 1691
            rectangle = childTransform.TransformBounds(rectangle);

            // We can't do any work unless we're scrolling.
            if (!IsScrolling)
            {
                return rectangle;
            }

            // Initialize the viewport
            Rect viewport = new Rect(HorizontalOffset, VerticalOffset, ViewportWidth, ViewportHeight);
            rectangle.X += viewport.X;
            rectangle.Y += viewport.Y;

            // Compute the offsets required to minimally scroll the child maximally into view.
            double minX = ComputeScrollOffsetWithMinimalScroll(viewport.Left, viewport.Right, rectangle.Left, rectangle.Right);
            double minY = ComputeScrollOffsetWithMinimalScroll(viewport.Top, viewport.Bottom, rectangle.Top, rectangle.Bottom);

            // We have computed the scrolling offsets; scroll to them.
            SetHorizontalOffset(minX);
            SetVerticalOffset(minY);

            // Compute the visible rectangle of the child relative to the viewport.
            viewport.X = minX;
            viewport.Y = minY;
            rectangle.Intersect(viewport);

            if (!rectangle.IsEmpty)
            {
                rectangle.X -= viewport.X;
                rectangle.Y -= viewport.Y;
            }

            // Return the rectangle
            return rectangle;
        }
开发者ID:amitkr2007,项目名称:groups-dct-sms,代码行数:64,代码来源:RibbonGalleryCategoriesPanel.cs

示例10: GetMultilineBoundingRectangles

        // helper function to accumulate a list of bounding rectangles for a potentially mult-line range
        private ArrayList GetMultilineBoundingRectangles(string text, Point mapClientToScreen, Rect clippingRectangle)
        {
            // remember the line height
            int height = Math.Abs(_provider.GetLogfont().lfHeight);;

            // get the starting and ending lines for the range.
            int start = Start;
            int end = End;

            int startLine = _provider.LineFromChar(start);
            int endLine = _provider.LineFromChar(end - 1);

            // adjust the start based on the first visible line

            int firstVisibleLine = _provider.GetFirstVisibleLine();
            if (firstVisibleLine > startLine)
            {
                startLine = firstVisibleLine;
                start = _provider.LineIndex(startLine);
            }

            // adjust the end based on the last visible line
            int lastVisibleLine = firstVisibleLine + _provider.LinesPerPage() - 1;
            if (lastVisibleLine < endLine)
            {
                endLine = lastVisibleLine;
                end = _provider.LineIndex(endLine) - 1;
            }

            // adding a rectangle for each line
            ArrayList rects = new ArrayList(Math.Max(endLine - startLine + 1, 0));
            int nextLineIndex = _provider.LineIndex(startLine);
            for (int i = startLine; i <= endLine; i++)
            {
                // determine the starting coordinate on this line
                Point startPoint;
                if (i == startLine)
                {
                    startPoint = _provider.PosFromChar(start);
                }
                else
                {
                    startPoint = _provider.PosFromChar(nextLineIndex);
                }

                // determine the ending coordinate on this line
                Point endPoint;
                if (i == endLine)
                {
                    endPoint = _provider.PosFromCharUR(end-1, text); 
                }
                else
                {
                    nextLineIndex = _provider.LineIndex(i + 1);
                    endPoint = _provider.PosFromChar(nextLineIndex - 1);
                }

                // add a bounding rectangle for this line if it is nonempty
                Rect rect = new Rect(startPoint.X, startPoint.Y, endPoint.X - startPoint.X, height);
                rect.Intersect(clippingRectangle);
                if (rect.Width > 0 && rect.Height > 0)  // r.Empty is true only if both width & height are zero.  Duh!
                {
                    rect.Offset(mapClientToScreen.X, mapClientToScreen.Y);
                    rects.Add(rect);
                }
            }

            return rects;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:70,代码来源:WindowsEditBoxRange.cs

示例11: MakeVisible

        public Rect MakeVisible(Visual visual, Rect rectangle)
        {
            if (rectangle.IsEmpty ||
                visual == null ||
                visual == this ||
                !IsAncestorOf(visual))
            {
                return Rect.Empty;
            }

            rectangle = visual.TransformToAncestor(this).TransformBounds(rectangle);

            var viewRect = new Rect(HorizontalOffset, VerticalOffset, ViewportWidth, ViewportHeight);
            rectangle.X += viewRect.X;
            rectangle.Y += viewRect.Y;

            viewRect.X = CalculateNewScrollOffset(viewRect.Left, viewRect.Right, rectangle.Left, rectangle.Right);
            viewRect.Y = CalculateNewScrollOffset(viewRect.Top, viewRect.Bottom, rectangle.Top, rectangle.Bottom);

            SetHorizontalOffset(viewRect.X);
            SetVerticalOffset(viewRect.Y);
            rectangle.Intersect(viewRect);

            rectangle.X -= viewRect.X;
            rectangle.Y -= viewRect.Y;

            return rectangle;
        }
开发者ID:jdehaan,项目名称:Funani,代码行数:28,代码来源:VirtualizingWrapPanel.cs

示例12: CalculateVisibleBoundingRect

        ///<summary>
        /// This eliminates the part of bounding rectangle if it is at all being overlapped/clipped by any of the visual ancestor up in the parent chain
        ///</summary>
        internal static Rect CalculateVisibleBoundingRect(UIElement owner)
        {
            Rect boundingRect = new Rect(owner.RenderSize);
            
            // Compute visible portion of the rectangle.

            DependencyObject parent = VisualTreeHelper.GetParent(owner);
            
            while (parent != null && 
                   !DoubleUtil.AreClose(boundingRect, Rect.Empty) && 
                   !DoubleUtil.AreClose(boundingRect.Height, 0) && 
                   !DoubleUtil.AreClose(boundingRect.Width, 0))
            {
                Visual visualParent = parent as Visual;
                if (visualParent != null)
                {
                    Geometry clipGeometry = VisualTreeHelper.GetClip(visualParent);
                    if (clipGeometry != null)
                    {
                        GeneralTransform transform = owner.TransformToAncestor(visualParent).Inverse;
                        // Safer version of transform to descendent (doing the inverse ourself and saves us changing the co-ordinate space of the owner's bounding rectangle), 
                        // we want the rect inside of our space. (Which is always rectangular and much nicer to work with)
                        if (transform != null)
                        {
                            Rect clipBounds = clipGeometry.Bounds;
                            clipBounds = transform.TransformBounds(clipBounds);
                            boundingRect.Intersect(clipBounds);
                        }
                        else
                        {
                            // No visibility if non-invertable transform exists.
                            boundingRect = Rect.Empty;
                        }
                    }
                }

                parent = VisualTreeHelper.GetParent(parent);
            }

            return boundingRect;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:44,代码来源:UIElementAutomationPeer.cs

示例13: ValidateEndpoints

        double[] ITextRangeProvider.GetBoundingRectangles()
        {
            // Return zero rectangles for a degenerate range.   We don't return an empty, 
            // but properly positioned, rectangle for degenerate ranges because
            // there is ambiguity at line breaks and some international scenarios.
            if (IsDegenerate)
            {
                return new double[0];
            }

            // we'll need to have the text eventually (so we can measure characters) so get it up
            // front so we can check the endpoints before proceeding.
            string text = _provider.GetText();
            ValidateEndpoints();

            // get the mapping from client coordinates to screen coordinates
            NativeMethods.Win32Point w32point;
            w32point.x = 0;
            w32point.y = 0;
            if (!Misc.MapWindowPoints(_provider.WindowHandle, IntPtr.Zero, ref w32point, 1))
            {
                return new double[0];
            }
            Point mapClientToScreen = new Point(w32point.x, w32point.y);

            // clip the rectangles to the edit control's formatting rectangle
            Rect clippingRectangle = _provider.GetRect();

            // we accumulate rectangles onto a list
            ArrayList rects;

            if (_provider.IsMultiline)
            {
                rects = GetMultilineBoundingRectangles(text, mapClientToScreen, clippingRectangle);
            }
            else
            {
                // single line edit control

                rects = new ArrayList(1);

                // figure out the rectangle for this one line
                Point startPoint = _provider.PosFromChar(Start);
                Point endPoint = _provider.PosFromCharUR(End - 1, text);
                Rect rect = new Rect(startPoint.X, startPoint.Y, endPoint.X - startPoint.X, clippingRectangle.Height);
                rect.Intersect(clippingRectangle);

                // use the rectangle if it is non-empty.
                if (rect.Width > 0 && rect.Height > 0)  // r.Empty is true only if both width & height are zero.  Duh!
                {
                    rect.Offset(mapClientToScreen.X, mapClientToScreen.Y);
                    rects.Add(rect);
                }
            }

            // convert the list of rectangles into an array for returning
            Rect[] rectArray = new Rect[rects.Count];
            rects.CopyTo(rectArray);

            return Misc.RectArrayToDoubleArray(rectArray);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:61,代码来源:WindowsEditBoxRange.cs

示例14: MakeVisible

        /// <summary>
        /// <see cref="IScrollInfo.MakeVisible"/>
        /// </summary>
        internal Rect MakeVisible(UIElement owner, Visual visual, Rect rectangle)
        {
            // We can only work on visuals that are us or children.
            // An empty rect has no size or position.  We can't meaningfully use it.
            if (rectangle.IsEmpty ||
                visual == null ||
                (visual != owner && !owner.IsAncestorOf(visual)))
            {
                return Rect.Empty;
            }

            // Compute the child's rect relative to (0,0) in our coordinate space.
            GeneralTransform childTransform = visual.TransformToAncestor(owner);
            rectangle = childTransform.TransformBounds(rectangle);

            // Initialize the viewport
            Rect viewport = new Rect(_offset.X, _offset.Y, _viewport.Width, _viewport.Height);
            rectangle.X += viewport.X;
            rectangle.Y += viewport.Y;

            // Compute the offsets required to minimally scroll the child maximally into view.
            double minX = ComputeScrollOffset(viewport.Left, viewport.Right, rectangle.Left, rectangle.Right);
            double minY = ComputeScrollOffset(viewport.Top, viewport.Bottom, rectangle.Top, rectangle.Bottom);

            // We have computed the scrolling offsets; scroll to them.
            SetHorizontalOffset(owner, minX);
            SetVerticalOffset(owner, minY);

            // Compute the visible rectangle of the child relative to the viewport.
            if (this.CanHorizontallyScroll)
            {
                viewport.X = minX;
            }
            else
            {
                // munge the intersection
                rectangle.X = viewport.X;
            }
            if (this.CanVerticallyScroll)
            {
                viewport.Y = minY;
            }
            else
            {
                // munge the intersection
                rectangle.Y = viewport.Y;
            }
            rectangle.Intersect(viewport);
            if (!rectangle.IsEmpty)
            {
                rectangle.X -= viewport.X;
                rectangle.Y -= viewport.Y;
            }

            // Return the rectangle
            return rectangle;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:60,代码来源:ScrollData.cs

示例15: GetLayoutClip


//.........这里部分代码省略.........
                Transform rtlMirror = GetFlowDirectionTransform();

                if (needToClipLocally && !needToClipSlot) 
                {
                    Rect clipRect = new Rect(0, 0, maxWidthClip, maxHeightClip); 
 
                    if (useLayoutRounding)
                    { 
                        clipRect = UIElement.RoundLayoutRect(clipRect, DpiScaleX, DpiScaleY);
                    }

                    RectangleGeometry localClip = new RectangleGeometry(clipRect); 
                    if (rtlMirror != null) localClip.Transform = rtlMirror;
                    return localClip; 
                } 

                if (needToClipSlot) 
                {
                    Vector offset = ComputeAlignmentOffset(clippingSize, inkSize);

                    if (ltd != null) 
                    {
                        Rect slotClipRect = new Rect(-offset.X + inkRectTransformed.X, 
                                                     -offset.Y + inkRectTransformed.Y, 
                                                     clippingSize.Width,
                                                     clippingSize.Height); 

                        if (useLayoutRounding)
                        {
                            slotClipRect = UIElement.RoundLayoutRect(slotClipRect, DpiScaleX, DpiScaleY); 
                        }
 
                        RectangleGeometry slotClip = new RectangleGeometry(slotClipRect); 
                        Matrix m = ltd.Transform.Value;
                        if (m.HasInverse) 
                        {
                            m.Invert();
                            slotClip.Transform = new MatrixTransform(m);
                        } 

                        if (needToClipLocally) 
                        { 
                            Rect localClipRect = new Rect(0, 0, maxWidthClip, maxHeightClip);
 
                            if (useLayoutRounding)
                            {
                                localClipRect = UIElement.RoundLayoutRect(localClipRect, DpiScaleX, DpiScaleY);
                            } 

                            RectangleGeometry localClip = new RectangleGeometry(localClipRect); 
                            PathGeometry combinedClip = Geometry.Combine(localClip, slotClip, GeometryCombineMode.Intersect, null); 
                            if (rtlMirror != null) combinedClip.Transform = rtlMirror;
                            return combinedClip; 
                        }
                        else
                        {
                            if (rtlMirror != null) 
                            {
                                if (slotClip.Transform != null) 
                                    slotClip.Transform = new MatrixTransform(slotClip.Transform.Value * rtlMirror.Value); 
                                else
                                    slotClip.Transform = rtlMirror; 
                            }
                            return slotClip;
                        }
                    } 
                    else //no layout transform, intersect axis-aligned rects
                    { 
                        Rect slotRect = new Rect(-offset.X + inkRectTransformed.X, 
                                                 -offset.Y + inkRectTransformed.Y,
                                                  clippingSize.Width, 
                                                  clippingSize.Height);

                        if (useLayoutRounding)
                        { 
                            slotRect = UIElement.RoundLayoutRect(slotRect, DpiScaleX, DpiScaleY);
                        } 
 
                        if (needToClipLocally) //intersect 2 rects
                        { 
                            Rect localRect = new Rect(0, 0, maxWidthClip, maxHeightClip);

                            if (useLayoutRounding)
                            { 
                                localRect = UIElement.RoundLayoutRect(localRect, DpiScaleX, DpiScaleY);
                            } 
 
                            slotRect.Intersect(localRect);
                        } 

                        RectangleGeometry combinedClip = new RectangleGeometry(slotRect);
                        if (rtlMirror != null) combinedClip.Transform = rtlMirror;
                        return combinedClip; 
                    }
                } 
 
                return null;
            } 
            return base.GetLayoutClip(layoutSlotSize);
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:101,代码来源:FrameworkElement.cs


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