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


C# RectangleF.Contains方法代码示例

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


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

示例1: DoesLineIntersectRectangle

        public static bool DoesLineIntersectRectangle(RectangleF pobjRectangle, Line pobjLine, ref Line pobjIntersectingPortionOfLine)
        {
            RectangleF objLineAsRectangle = default(RectangleF);
            objLineAsRectangle = pobjLine.ToRectangle();

            if (!pobjRectangle.IntersectsWith(objLineAsRectangle))
            {
                return false;
            }
            else
            {
                bool blnIsPointAIn = false;
                bool blnIsPointBIn = false;

                blnIsPointAIn = pobjRectangle.Contains(pobjLine.PointA);
                blnIsPointBIn = pobjRectangle.Contains(pobjLine.PointB);

                if (blnIsPointAIn && blnIsPointBIn)
                {
                    pobjIntersectingPortionOfLine = pobjLine;
                }
                else
                {
                    PointF[] colIntersections = new PointF[2];
                    // Either one or two intersections.
                    List<Line> colLines = null;
                    colLines = GeometryHelper.RectangleTo4Lines(pobjRectangle);

                    foreach (Line objLine in colLines)
                    {
                        if (colIntersections[0].IsEmpty)
                        {
                            DoLinesIntersect(objLine, pobjLine, ref colIntersections[0]);
                        }
                        else if (colIntersections[1].IsEmpty)
                        {
                            DoLinesIntersect(objLine, pobjLine, ref colIntersections[1]);
                        }
                    }

                    if (!blnIsPointAIn && !blnIsPointBIn)
                    {
                        pobjIntersectingPortionOfLine = new Line(colIntersections[0], colIntersections[1]);
                    }
                    else
                    {
                        if (blnIsPointAIn)
                        {
                            pobjIntersectingPortionOfLine = new Line(colIntersections[0], pobjLine.PointA);
                        }
                        else
                        {
                            pobjIntersectingPortionOfLine = new Line(colIntersections[0], pobjLine.PointB);
                        }
                    }
                }

                return true;
            }
        }
开发者ID:rlugojr,项目名称:Alferd-Spritesheet-Unpacker,代码行数:60,代码来源:IntersectionHelpers.cs

示例2: intersects

 public bool intersects(RectangleF r)
 {
     return LineIntersectsLine(start, end, new PointD(r.X, r.Y), new PointD(r.X + r.Width, r.Y)) ||
            LineIntersectsLine(start, end, new PointD(r.X + r.Width, r.Y), new PointD(r.X + r.Width, r.Y + r.Height)) ||
            LineIntersectsLine(start, end, new PointD(r.X + r.Width, r.Y + r.Height), new PointD(r.X, r.Y + r.Height)) ||
            LineIntersectsLine(start, end, new PointD(r.X, r.Y + r.Height), new PointD(r.X, r.Y)) ||
            (r.Contains(new PointF((float)start.x, (float)start.y)) && r.Contains(new PointF((float)end.x, (float)end.y)));
 }
开发者ID:ackratos,项目名称:USTCMap,代码行数:8,代码来源:Toolkit.cs

示例3: KeyboardDidShowNotification

        protected virtual void KeyboardDidShowNotification(NSNotification notification)
        {
            UIView activeView = KeyboardGetActiveView();
            if (activeView == null)
                return;

            ((UITextField)activeView).ShowDoneButtonOnKeyboard();

            UIScrollView scrollView = activeView.FindSuperviewOfType(this.View, typeof(UIScrollView)) as UIScrollView;
            if (scrollView == null)
                return;

            RectangleF keyboardBounds = UIKeyboard.BoundsFromNotification(notification);

            UIEdgeInsets contentInsets = new UIEdgeInsets(0.0f, 0.0f, keyboardBounds.Size.Height, 0.0f);
            scrollView.ContentInset = contentInsets;
            scrollView.ScrollIndicatorInsets = contentInsets;

            // If activeField is hidden by keyboard, scroll it so it's visible
            RectangleF viewRectAboveKeyboard = new RectangleF(this.View.Frame.Location, new SizeF(this.View.Frame.Width, this.View.Frame.Size.Height - keyboardBounds.Size.Height));

            RectangleF activeFieldAbsoluteFrame = activeView.Superview.ConvertRectToView(activeView.Frame, this.View);
            // activeFieldAbsoluteFrame is relative to this.View so does not include any scrollView.ContentOffset

            // Check if the activeField will be partially or entirely covered by the keyboard
            if (!viewRectAboveKeyboard.Contains(activeFieldAbsoluteFrame)) {
                // Scroll to the activeField Y position + activeField.Height + current scrollView.ContentOffset.Y - the keyboard Height
                PointF scrollPoint = new PointF(0.0f, activeFieldAbsoluteFrame.Location.Y + activeFieldAbsoluteFrame.Height + scrollView.ContentOffset.Y - viewRectAboveKeyboard.Height);
                scrollView.SetContentOffset(scrollPoint, true);
            }
        }
开发者ID:fdibartolo,项目名称:boletamovil,代码行数:31,代码来源:ScrollableViewController.cs

示例4: IsPointOnEdge

        /// <summary>
        ///   Determines whether a given point is inside and close to the edge of a given rectangle.
        /// </summary>
        /// <param name="rectangle">The rectangle within which the point should be located.</param>
        /// <param name="test">The point to test for.</param>
        /// <param name="tolerance">
        ///   The tolerance. This is subtracted from the bounds of the rectangle to create a border within which the
        ///   <paramref
        ///     name="test" />
        ///   point must be located.
        /// </param>
        /// <param name="toTest">The edges that should be tested.</param>
        /// <returns>A combination of Edge flags depending on which edges the point is close to.</returns>
        internal static Edge IsPointOnEdge( RectangleF rectangle, PointF test, float tolerance, EdgeTest toTest )
        {
            // If the point is not within the rectangle, then there is no need for further tests.
              if( !rectangle.Contains( test ) ) {
            return Edge.None;
              }

              Edge result = Edge.None;
              // Test vertical edges.
              if( ( toTest & EdgeTest.Vertical ) != 0 ) {
            if( test.Y >= rectangle.Y && test.Y <= rectangle.Y + tolerance ) {
              result |= Edge.Top;
            }
            if( test.Y <= rectangle.Y + rectangle.Height && test.Y >= rectangle.Y + rectangle.Height - tolerance ) {
              result |= Edge.Bottom;
            }
              }
              // Test horizontal edges.
              if( ( toTest & EdgeTest.Horizontal ) != 0 ) {
            if( test.X <= rectangle.X + rectangle.Width && test.X >= rectangle.X + rectangle.Width - tolerance ) {
              result |= Edge.Right;
            }
            if( test.X >= rectangle.X && test.X <= rectangle.X + tolerance ) {
              result |= Edge.Left;
            }
              }

              return result;
        }
开发者ID:Kagamia,项目名称:TimeBeam,代码行数:42,代码来源:RectangleHelper.cs

示例5: ContainsF

		public void ContainsF ()
		{
			// from bug #5985
			RectangleF outer = new RectangleF (100, 150, 300, 300);
			RectangleF inner = new RectangleF (139.3323f, 188.4053f, 140.2086f, 210.3129f);
			
			Assert.IsTrue (outer.Contains (inner), "a");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:TestRectangleF.cs

示例6: RectangleD

        public RectangleD(RectangleF outer, RectangleF inner)
        {
            if (!outer.Contains(inner))
                throw new ArgumentOutOfRangeException(nameof(inner), nameof(outer) + " must contain " + nameof(inner));

            this.Inner = inner;
            this.Outer = outer;
        }
开发者ID:tomgrv,项目名称:PA.TileList,代码行数:8,代码来源:RectangleD.cs

示例7: IsSelected

 /// <summary>
 ///   Check if a given rectangle would be selected by another rectangle.
 ///   By default, checks whether the selection rectangle intersects with the bounding rectangle.
 ///   If Alt is pressed, the selection rectangle has to contain the complete bounding rectangle.
 /// </summary>
 /// <param name="selectionRectangle">The rectangle that represents the selection.</param>
 /// <param name="boundingRectangle">The rectangle that should be tested whether it is selected.</param>
 /// <param name="modifierKeys">The modifier keys that are currently pressed.</param>
 /// <returns>
 ///   <see langword="true" /> if the rectangle is selected; <see langword="false" /> otherwise.
 /// </returns>
 public static bool IsSelected( RectangleF selectionRectangle, RectangleF boundingRectangle, Keys modifierKeys )
 {
     if( ( modifierKeys & Keys.Alt ) != 0 ) {
     return selectionRectangle.Contains( boundingRectangle );
       } else {
     return selectionRectangle.IntersectsWith( boundingRectangle );
       }
 }
开发者ID:Kagamia,项目名称:TimeBeam,代码行数:19,代码来源:SelectionHelper.cs

示例8: Hit

 internal override bool Hit(PointF p)
 {
     RectangleF r = new RectangleF(p, new SizeF(0,0));
     RectangleF env = new RectangleF(this.mCurrentPoint,new SizeF(10,10));
     env.Offset(-5,-5);
     mHovered = env.Contains(r);
     //Debug.WriteLine("(" + p.X + "," + p.Y + ") c " + "(" + mCurrentPoint.X + ","  + mCurrentPoint.Y +")");
     return mHovered;
 }
开发者ID:BackupTheBerlios,项目名称:ferdadataminer-svn,代码行数:9,代码来源:TangentHandle.cs

示例9: Simulation

        /// <summary>
        ///     Initializes a new instance of the <see cref="Simulation" /> class.
        /// </summary>
        /// <param name="teams">The teams to be played against each other.</param>
        /// <param name="ball">The ball.</param>
        /// <param name="pitchBounds">The pitch boundaries.</param>
        /// <param name="friction">The friction coefficient.</param>
        public Simulation(ReadOnlyCollection<Team> teams, PointMass ball, RectangleF pitchBounds, float friction)
        {
            Contract.Requires<ArgumentNullException>(teams != null);
            Contract.Requires<ArgumentNullException>(ball != null);
            Contract.Requires<ArgumentException>(friction >= 0);
            Contract.Requires<ArgumentException>(pitchBounds.Width > 0 && pitchBounds.Height > 0);
            Contract.Requires<ArgumentException>(Contract.ForAll(teams, t =>
                t != null &&
                pitchBounds.IntersectsOrBorders(t.GoalBounds) &&
                t.Players.All(p => pitchBounds.Contains(p.Position))));
            Contract.Requires<ArgumentException>(pitchBounds.Contains(ball.Position));

            _simulate = SimulatePlaying;
            _teams = teams;
            _startingPositions = (from t in teams select (from p in t.Players select p.Position).ToList().AsReadOnly()).ToList().AsReadOnly();
            _ball = ball;
            _ballStartingPosition = ball.Position;
            PitchBounds = pitchBounds;
            Friction = friction;
        }
开发者ID:PurdueSIGAI,项目名称:Soccer,代码行数:27,代码来源:Simulation.cs

示例10: RectangleD

        public RectangleD(RectangleF outer, RectangleF inner)
        {

            if (!outer.Contains(inner))
            {
                throw new ArgumentOutOfRangeException("inner", "Outer RectangleF must contain Inner RectangleF");
            }

            this.Inner = inner;
            this.Outer = outer;
        }
开发者ID:tomgrv,项目名称:PA.LibraryTools,代码行数:11,代码来源:RectangleD.cs

示例11: Simulation

        /// <summary>
        ///     Initializes a new instance of the <see cref="Simulation" /> class.
        /// </summary>
        /// <param name="teams">The teams to be played against each other.</param>
        /// <param name="ball">The ball.</param>
        /// <param name="pitchBounds">The pitch boundaries.</param>
        /// <param name="friction">The friction coefficient.</param>
        public Simulation(ReadOnlyCollection<Team> teams, PointMass ball, RectangleF pitchBounds, float friction)
        {
            Contract.Requires<ArgumentNullException>(teams != null);
            Contract.Requires<ArgumentNullException>(ball != null);
            Contract.Requires<ArgumentException>(friction >= 0);
            Contract.Requires<ArgumentException>(pitchBounds.Width > 0 && pitchBounds.Height > 0);
            Contract.Requires<ArgumentException>(Contract.ForAll(teams, t => t != null && t.IsValid(pitchBounds)));
            Contract.Requires<ArgumentException>(pitchBounds.Contains(ball.Position));

            _simulate = SimulatePlaying;
            _teams = teams;
            _startingPositions = from t in teams select t.PlayerPositions;
            _ball = ball;
            _ballStartingPosition = ball.Position;
            PitchBounds = pitchBounds;
            Friction = friction;
        }
开发者ID:prashast1310,项目名称:Soccer,代码行数:24,代码来源:Simulation.cs

示例12: GetIdxAtMountLocation

		///<summary>Returns the index in the DocsInMount array of the given location (relative to the upper left-hand corner of the pictureBoxMain control) or -1 if the location is outside all documents in the current mount. A mount must be currently selected to call this function.</summary>
		private int GetIdxAtMountLocation(Point location) {
			PointF relativeLocation=new PointF(
				(location.X-PointTranslation.X)/(ZoomImage*ZoomOverall)+MountSelected.Width/2,
				(location.Y-PointTranslation.Y)/(ZoomImage*ZoomOverall)+MountSelected.Height/2);
			//Enumerate the image locations.
			for(int i=0;i<MountItemsForSelected.Count;i++) {
				RectangleF itemLocation=new RectangleF(MountItemsForSelected[i].Xpos,MountItemsForSelected[i].Ypos,
					MountItemsForSelected[i].Width,MountItemsForSelected[i].Height);
				if(itemLocation.Contains(relativeLocation)) {
					return i;
				}
			}
			return -1;//No document selected in the current mount.
		}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:15,代码来源:ContrImages.cs

示例13: RecursiveExpanderCheck

        /// <summary>
        /// Method that find the node for which the expander was triggered
        /// </summary>
        /// <param name="node"> the node to be checked</param>
        /// <param name="nodeLevel"> the level of the node</param>
        /// <param name="crtExpanderRow"> the row associated with the node</param>
        /// <param name="insideClickPoint">the location inside the structure where de mouse was clicked</param>
        /// <param name="parentIsExpanded">true if parent node is expanded, false otherwhise</param>
        /// <returns></returns>
        private Node RecursiveExpanderCheck(Node node, int nodeLevel, ref int crtExpanderRow,
			Point insideClickPoint, bool parentIsExpanded)
        {
            int cY = rowHeight * crtExpanderRow + nodesDrawingTopPosition - location.Y + TITLE_OFFSET;
            RectangleF rowRectangleToCheck = new RectangleF(LEFT_PADDING, cY, EXPANDER_SIZE, EXPANDER_SIZE);

            if (!node.IsLeaf) {

                if (node.Parent != null && node.Parent.IsExpanded) {
                    rowRectangleToCheck.Offset(nodeLevel * TAB_NOD_SIZE, 0);
                }

                if (rowRectangleToCheck.Contains(insideClickPoint))
                    return node;

                foreach (Node childNode in node.Nodes) {
                    Node ndr = null;
                    if (parentIsExpanded) {
                        crtExpanderRow++;
                    }
                    ndr = RecursiveExpanderCheck(childNode, nodeLevel + 1, ref crtExpanderRow,
                        insideClickPoint, parentIsExpanded && childNode.IsExpanded);
                    if (ndr != null)
                        return ndr;
                }
            }
            return null;
        }
开发者ID:lvoinescu,项目名称:samDiagrams,代码行数:37,代码来源:StructureDrawing.cs

示例14: GetNodAtXYRec

 private Node GetNodAtXYRec(Node nod, int x, int y, int mouseX, int mouseY, bool parentIsExpanded)
 {
     int cY = y + rowHeight * crtNodCheck;
     int cX = x;
     float yT = cY;
     RectangleF r = new RectangleF(cX, yT, size.Width, rowHeight);
     if (r.Contains(mouseX, mouseY)) {
         nodDblX = location.X + x + EXPANDER_SIZE;
         nodDblY = location.Y + nodesDrawingTopPosition + crtNodCheck * rowHeight;
         return nod;
     }
     if (nod.IsExpanded) {
         x += TAB_NOD_SIZE;
     }
     for (int i = 0; i < nod.Nodes.Count; i++) {
         Node ndr = null;
         if (parentIsExpanded)
             crtNodCheck++;
         ndr = GetNodAtXYRec(nod.Nodes[i], x, y, mouseX, mouseY, parentIsExpanded && nod.Nodes[i].IsExpanded);
         if (ndr != null) {
             nodDblX = location.X + x + LEFT_PADDING;
             nodDblY = location.Y + nodesDrawingTopPosition + crtNodCheck * rowHeight;
             return ndr;
         }
     }
     return null;
 }
开发者ID:lvoinescu,项目名称:samDiagrams,代码行数:27,代码来源:StructureDrawing.cs

示例15: PointToHandPiece

        /// <summary>
        /// 指定の座標値に駒台上の駒があればそれを取得します。
        /// </summary>
        private BoardPiece PointToHandPiece(System.Drawing.Point pos)
        {
            var boxTypeN = PointToPieceBoxType(pos);
            if (boxTypeN == null)
            {
                return null;
            }

            var boxType = boxTypeN.Value;
            foreach (var pieceType in EnumEx.GetValues<PieceType>())
            {
                var center = HandPieceToPoint(pieceType, boxType);
                var rect = new RectangleF(
                    (float)(center.X - SquareSize.Width / 2),
                    (float)(center.Y - SquareSize.Height / 2),
                    SquareSize.Width,
                    SquareSize.Height);

                if (rect.Contains(pos))
                {
                    return new BoardPiece(pieceType, false, boxType);
                }
            }

            return null;
        }
开发者ID:leontius,项目名称:Ragnarok,代码行数:29,代码来源:GLShogiElement.move.cs


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