System.Drawing.Rectangle.Contains C# (CSharp) Method

Contains() private method

private Contains ( Point pt ) : bool
pt Point
return bool
        public bool Contains(Point pt) => Contains(pt.X, pt.Y);

Same methods

Rectangle::Contains ( Rectangle rect ) : bool
Rectangle::Contains ( System pt ) : bool
Rectangle::Contains ( int x, int y ) : bool

Usage Example

Beispiel #1
0
        // This was taken from FindReplaceDialog. Obviously some refactoring is called for
        // since we have common code. However I'm holding off on this because I'm coming
        // up with some other ideas for the FindReplaceDialog. Right now every scintilla
        // gets its own FindReplaceDialog, but they really need to be sharable across 
        // multiple scintillas much like how DropMarkers work.

        private void MoveFormAwayFromSelection()
        {
            if (!Visible)
                return;

            int pos = Scintilla.Caret.Position;
            int x = Scintilla.PointXFromPosition(pos);
            int y = Scintilla.PointYFromPosition(pos);

            Point cursorPoint = Scintilla.PointToScreen(new Point(x, y));

            Rectangle r = new Rectangle(Location, Size);
            if (r.Contains(cursorPoint))
            {
                Point newLocation;
                if (cursorPoint.Y < (Screen.PrimaryScreen.Bounds.Height / 2))
                {
                    // Top half of the screen
                    newLocation = Scintilla.PointToClient(
                        new Point(Location.X, cursorPoint.Y + Scintilla.Lines.Current.Height * 2)
                        );
                }
                else
                {
                    // Bottom half of the screen
                    newLocation = Scintilla.PointToClient(
                        new Point(Location.X, cursorPoint.Y - Height - (Scintilla.Lines.Current.Height * 2))
                        );
                }
                newLocation = Scintilla.PointToScreen(newLocation);
                Location = newLocation;
            }
        }
All Usage Examples Of System.Drawing.Rectangle::Contains