private IntersectsWith ( Rectangle rect ) : bool | ||
rect | Rectangle | |
return | bool |
void CropSelector_MouseDown(object sender, MouseEventArgs e) { mouse_state=1; Rectangle r=new Rectangle (MousePosition, new Size (10, 10)); if (r.IntersectsWith (new Rectangle (button5.PointToScreen (Point.Empty), button5.Size))) { //v> mode=9; OldSize=this.Size; } else if (r.IntersectsWith (new Rectangle (button6.PointToScreen (Point.Empty), button6.Size))) { //vvv mode=2; OldSize=this.Size; } else if (r.IntersectsWith (new Rectangle (button8.PointToScreen (Point.Empty), button8.Size))) { //>>> mode=5; OldSize=this.Size; } else { mode=1; OldMouse=MousePosition; Dif=new Point (Absolute (OldMouse.X-this.Location.X), Absolute (OldMouse.Y-this.Location.Y)); } }
public void Arrange(IExportColumn exportColumn) { if (exportColumn == null) throw new ArgumentNullException("exportColumn"); var container = exportColumn as IExportContainer; if ((container != null) && (container.ExportedItems.Any())) { List<IExportColumn> canGrowItems = CreateCanGrowList(container); if (canGrowItems.Any()) { var containerSize = ArrangeInternal(container); if (containerSize.Height > container.DesiredSize.Height) { container.DesiredSize = new Size(containerSize.Width,containerSize.Height + 15); } } } var fixedElements = container.ExportedItems.Where(x => !x.CanGrow); var growables = container.ExportedItems.Where(x => x.CanGrow); foreach (var growable in growables) { var r = new Rectangle(growable.Location,growable.DesiredSize); foreach (var x in fixedElements) { var xr = new Rectangle(x.Location,x.DesiredSize); if (r.IntersectsWith(xr)) { x.Location = new Point(x.Location.X, r.Bottom + 5); } } } }
/* Checks whether this window is overlapping this object * if it is, and it's not our playing window, we need to hide ourselves */ public virtual void CheckForWindowOverlay(String windowTitle, Rectangle windowRect) { if (windowTitle == this.Text) return; // Proceed only if this is not our table window and the hud is visible if (windowTitle != table.WindowTitle) { Rectangle ourRect = this.RectangleToScreen(this.ClientRectangle); if (windowRect.IntersectsWith(ourRect)) { Visible = false; } else { Visible = true; } } // If the window is the our table window, make sure we are displaying it! else if (windowTitle == table.WindowTitle) { Visible = true; } }
private void validateIntersection(Slide slide, IList<JupiterWindow> list) { for (int i = 0; i < list.Count - 1; i++) { for (int j = i + 1; j < list.Count; j++) { Window current = list[i]; Window other = list[j]; Rectangle rect1 = new Rectangle(current.Left, current.Top, current.Width, current.Height); Rectangle rect2 = new Rectangle(other.Left, other.Top, other.Width, other.Height); string currentResourceInfoName = current.Source.ResourceDescriptor == null ? string.Empty : current.Source.ResourceDescriptor.ResourceInfo.Name; string otherResourceInfoName = other.Source.ResourceDescriptor == null ? string.Empty : other.Source.ResourceDescriptor.ResourceInfo.Name; if (rect1.IntersectsWith(rect2)) throw new Exception(String.Concat( "Сохранение сцены ", slide.Name, " невозможно. На раскладке сцены окна с источниками ", currentResourceInfoName, " и ", otherResourceInfoName, " не должны перекрываться между собой")); } } }
public Direction? CharacterCollision(Rectangle entity, Rectangle anotherEntity) { // check if collision happened if (!entity.IntersectsWith(anotherEntity)) return null; // get diagonals through anotherEntity Point center = new Point((entity.Right + entity.Left) / 2, (entity.Bottom + entity.Top) / 2); //Line a Point a1 = new Point(anotherEntity.Left, anotherEntity.Top); Point a2 = new Point(anotherEntity.Right, anotherEntity.Bottom); //Line b Point b1 = new Point(anotherEntity.Left, anotherEntity.Bottom); Point b2 = new Point(anotherEntity.Right, anotherEntity.Top); var abovea1 = !isLeft(center, a1, a2); var abovea2 = !isLeft(center, b1, b2); if (abovea1 && abovea2) return Direction.up; else if (abovea1 && !abovea2) return Direction.right; else if (!abovea1 && abovea2) return Direction.left; else return Direction.down; }
public void Removedirt( Player speler,Level level) { Rectangle onder = new Rectangle(speler.Position.X+10, speler.Position.Y + 50, 45, 4); Rectangle left = new Rectangle(speler.Position.X, speler.Position.Y + 10, 4, 35); if (speler.down == true && onder.IntersectsWith(level.SaveColDirt.Rect)) { if(level.SaveColDirt.ID!=5) { level.dirtobject.Remove(level.SaveColDirt); saveLeeg = copyEigenschappen(level.SaveColDirt); level.leegObject.Add(saveLeeg); speler.MaxY = 600; speler.MaxX = 750; speler.MinX = 0; score += level.SaveColDirt.ID * 10; foreach (Dirt g in level.dirtobject) { g.Update(); } foreach(Leeg L in level.leegObject) { L.Update(); } level.SaveColDirt = new Dirt(); } } }
//击中敌机 public void shootEnemy(Graphics g, List<Bullet> bulletList, List<Enemy> enemyList, Player player) { for (int i = 0; i < bulletList.Count; i++) { //创建子弹的矩形变量 Rectangle bues = new Rectangle(bulletList[i].BulX, bulletList[i].BulY, bulletList[i].BulletImage.Width, bulletList[i].BulletImage.Height); for (int j = 0; j < enemyList.Count; j++) { //创建敌机矩形变量 Rectangle emes = new Rectangle(enemyList[j].ENEMY_X, enemyList[j].ENEMY_Y, enemyList[j].PLANE.Width, enemyList[j].PLANE.Height); if (emes.IntersectsWith(bues))//敌机碰撞测试 { bulletList.Remove(bulletList[i]); if (1 == enemyList[j].Blood)//判断敌机血量是否会减为0 { player.ChangeScore(enemyList[j].Score); Bomb bomb = new Bomb(enemyList[j].ENEMY_X, enemyList[j].ENEMY_Y); enemyList.Remove(enemyList[j]); bomb.Draw(g);//画出爆炸效果 bomb.bombplay();//音效效果 } else { enemyList[j].Blood = enemyList[j].Blood - 1; } } } } }
public override void Paint(Graphics g, Rectangle rect) { if (rect.Width <= 0 || rect.Height <= 0) { return; } HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers"); int fontHeight = textArea.TextView.FontHeight; Brush fillBrush = textArea.Enabled ? BrushRegistry.GetBrush(lineNumberPainterColor.BackgroundColor) : SystemBrushes.InactiveBorder; Brush drawBrush = BrushRegistry.GetBrush(lineNumberPainterColor.Color); for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / fontHeight + 1; ++y) { int ypos = drawingPosition.Y + fontHeight * y - textArea.TextView.VisibleLineDrawingRemainder; Rectangle backgroundRectangle = new Rectangle(drawingPosition.X, ypos, drawingPosition.Width, fontHeight); if (rect.IntersectsWith(backgroundRectangle)) { g.FillRectangle(fillBrush, backgroundRectangle); int curLine = textArea.Document.GetFirstLogicalLine(textArea.Document.GetVisibleLine(textArea.TextView.FirstVisibleLine) + y); if (curLine < textArea.Document.TotalNumberOfLines) { g.DrawString((curLine + 1).ToString(), lineNumberPainterColor.GetFont(TextEditorProperties.FontContainer), drawBrush, backgroundRectangle, numberStringFormat); } } } }
public override void Paint(Graphics g, Rectangle rect) { if (rect.Width <= 0 || rect.Height <= 0) { return; } HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers"); HighlightColor foldLineColor = textArea.Document.HighlightingStrategy.GetColorFor("FoldLine"); for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / textArea.TextView.FontHeight + 1; ++y) { Rectangle markerRectangle = new Rectangle(DrawingPosition.X, DrawingPosition.Top + y * textArea.TextView.FontHeight - textArea.TextView.VisibleLineDrawingRemainder, DrawingPosition.Width, textArea.TextView.FontHeight); if (rect.IntersectsWith(markerRectangle)) { // draw dotted separator line if (textArea.Document.TextEditorProperties.ShowLineNumbers) { g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder), new Rectangle(markerRectangle.X + 1, markerRectangle.Y, markerRectangle.Width - 1, markerRectangle.Height)); g.DrawLine(BrushRegistry.GetDotPen(lineNumberPainterColor.Color, lineNumberPainterColor.BackgroundColor), base.drawingPosition.X, markerRectangle.Y, base.drawingPosition.X, markerRectangle.Bottom); } else { g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder), markerRectangle); } int currentLine = textArea.Document.GetFirstLogicalLine(textArea.Document.GetVisibleLine(textArea.TextView.FirstVisibleLine) + y); PaintFoldMarker(g, currentLine, markerRectangle); } } }
public void caretHit(Rectangle caretRect) { if (caretRect.IntersectsWith(_rect)) { speedY *= -1; } }
public static bool checkCollision(PictureBox collider, int x, int y, List<Rectangle> listObj) { Rectangle frame = new Rectangle(x, y, collider.Width, collider.Height); foreach (Rectangle obj in listObj) if (frame.IntersectsWith(obj)) return false; return true; }
// Ensure that the proposed window position intersects // at least one screen area. private static bool IsVisiblePosition(Point location, Size size) { Rectangle myArea = new Rectangle(location, size); bool intersect = false; foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens) { intersect |= myArea.IntersectsWith(screen.WorkingArea); } return intersect; }
public static bool checkCollision() { Rectangle hBox = new Rectangle((int)Player.sprite.Position.X - 10, (int)Player.sprite.Position.Y - 30, 70, 100); Rectangle hBoxS1 = new Rectangle((int)Schaf1.sprite.Position.X + 20, (int)Schaf1.sprite.Position.Y, 35, 70); Rectangle hBoxS2 = new Rectangle((int)Schaf2.sprite.Position.X + 20, (int)Schaf2.sprite.Position.Y, 35, 70); // fix all sheeps in edge problem if (hBoxS1.IntersectsWith(hBoxS2)) Schaf1.sprite.Position = new Vector2f(Schaf1.sprite.Position.X - 30, Schaf1.sprite.Position.Y); if (hBox.IntersectsWith(hBoxS1)||hBox.IntersectsWith(hBoxS2)) { Console.WriteLine("Game Over"); Console.WriteLine("You survived " + watch.Elapsed.Minutes +" minutes "+ watch.Elapsed.Seconds + " seconds " + watch.Elapsed.Milliseconds + " milliseconds"); Console.WriteLine("Press 'n' to restart or 'Esc' to close the game"); return true; } return false; }
void timer_Elapsed(object sender, ElapsedEventArgs e) { if (NativeHelpers.ActiveApplTitle().Contains(appTitleToDisableOn)) { var position = Cursor.Position; var rectangle = new Rectangle(position, new Size(1, 1)); if (!rectangle.IntersectsWith(dockRootForm.Bounds)) Cursor.Position = dockRootForm.Location; } }
public bool IsIntersectingRect(Rectangle rect) { foreach(BodyPart Part in m_SnakeParts) { Point PartPos = Part.GetPosition(); if (rect.IntersectsWith(new Rectangle(PartPos.X, PartPos.Y, m_CircleRadius, m_CircleRadius))) return true; } return false; }
/// <summary> /// /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="w1"></param> /// <param name="h1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="w2"></param> /// <param name="h2"></param> /// <returns></returns> public static bool RectsIntersect(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) { Rectangle rect = new Rectangle(x1, y1, w1, h1); Rectangle rect2 = new Rectangle(x2, y2, w2, h2); return rect.IntersectsWith(rect2); //if (x1 >= (x2 + w2) || (x1 + w1) <= x2) return false; //if (y1 >= (y2 + h2) || (y1 + h1) <= y2) return false; //return true; }
protected override void OnPaint(PaintEventArgs e) { if (Parent != null) { float tx = -Left, ty = -Top; // make adjustments to tx and ty here if your control // has a non-client area, borders or similar e.Graphics.TranslateTransform(tx, ty); using (PaintEventArgs pea = new PaintEventArgs(e.Graphics, e.ClipRectangle)) { InvokePaintBackground(Parent, pea); InvokePaint(Parent, pea); } e.Graphics.TranslateTransform(-tx, -ty); // loop through children of parent which are under ourselves int start = Parent.Controls.GetChildIndex(this); Rectangle rect = new Rectangle(Left, Top, Width, Height); for (int i = Parent.Controls.Count - 1; i > start; i--) { Control c = Parent.Controls[i]; // skip ... // ... invisible controls // ... or controls that have zero width/height (Autosize Labels without content!) // ... or controls that don't intersect with ourselves if (!c.Visible || c.Width == 0 || c.Height == 0 || !rect.IntersectsWith(new Rectangle(c.Left, c.Top, c.Width, c.Height))) continue; using (Bitmap b = new Bitmap(c.Width, c.Height, e.Graphics)) { c.DrawToBitmap(b, new Rectangle(0, 0, c.Width, c.Height)); tx = c.Left - Left; ty = c.Top - Top; // make adjustments to tx and ty here if your control // has a non-client area, borders or similar e.Graphics.TranslateTransform(tx, ty); e.Graphics.DrawImageUnscaled(b, new Point(0, 0)); e.Graphics.TranslateTransform(-tx, -ty); } } } for (int i = 5; i < 90; i += 10) e.Graphics.DrawEllipse(new Pen(Brushes.Red, 2), (this.Width / 2) - i / 2, (this.Width / 2) - i / 2, i, i); //e.Graphics.DrawEllipse(new Pen(new SolidBrush(this.Color), 5), 5, 5, 90, 90); }
private void MapPBox_MouseClick(object sender, MouseEventArgs e) { int index = 0; int tempX; int tempY; Rectangle tempRect = new Rectangle(); foreach (FootHold.Foothold foothold in Footholds) { tempX= (int)(Footholds.ToArray()[index].Shape.X * scale); tempY= (int)(Footholds.ToArray()[index].Shape.Y * scale); tempRect = new Rectangle(tempX, tempY,(int)( foothold.Shape.Width * scale),(int) (foothold.Shape.Height * scale)); if (tempRect.IntersectsWith(new Rectangle(e.X, e.Y, 1, 1))) { Edit editFoothold = new Edit(); editFoothold.Text = "Foothold: "+ foothold.Data.Name; editFoothold.fh = Footholds.ToArray()[index]; editFoothold.settings = settings; editFoothold.ShowDialog(); } index++; } index = 0; foreach (Portals.Portal portal in thePortals) { tempX = (int)(thePortals.ToArray()[index].Shape.X * scale); tempY = (int)(thePortals.ToArray()[index].Shape.Y * scale); tempRect = new Rectangle(tempX, tempY, (int)(portal.Shape.Width * scale), (int)(portal.Shape.Height * scale)); if (tempRect.IntersectsWith(new Rectangle(e.X, e.Y, 1, 1))) { EditPortals editPortals = new EditPortals(); editPortals.Text = "Portal: " + portal.Data.Name; editPortals.portal = thePortals.ToArray()[index]; editPortals.Settings = settings; editPortals.ShowDialog(); } index++; } index = 0; foreach (SpawnPoint.Spawnpoint spawnpoint in MobSpawnPoints) { tempX = (int)(MobSpawnPoints.ToArray()[index].Shape.X * scale); tempY = (int)(MobSpawnPoints.ToArray()[index].Shape.Y * scale); tempRect = new Rectangle(tempX, tempY, (int)(spawnpoint.Shape.Width * scale), (int)(spawnpoint.Shape.Height * scale)); if (tempRect.IntersectsWith(new Rectangle(e.X, e.Y, 1, 1))) { SpawnpointInfo spawnInfo = new SpawnpointInfo(); spawnInfo.spawnpoint = spawnpoint; spawnInfo.Text = "Mob spawnpoint: " + spawnpoint.Data.Name; spawnInfo.ShowDialog(); } index++; } }
public bool collidePlayer(arcanoid player) { Rectangle r1 = new Rectangle(player.x, player.y, player.size.Width, player.size.Height); Rectangle r2 = new Rectangle((int)x, (int)y, size.Width, size.Height); if(r1.IntersectsWith(r2)) { return true; } return false; }
private List<Character> getCharactersInRectangle(Rectangle rectangle) { List<Character> ret = new List<Character>(); foreach (Character ch in this.selectableCharacters) { Rectangle characterRectangle = ch.BoundingCylinder.projectToScreen(); if (rectangle.IntersectsWith(characterRectangle)) ret.Add(ch); } return ret; }
private bool HasColision(Rectangle rect) { foreach (PictureBox wall in this._wallsList) { if (rect.IntersectsWith(wall.Bounds)) { return true; } } this.player.Bounds = rect; return false; }
public override void Paint(Graphics g, Rectangle rect) { try { if (rect.Width <= 0 || rect.Height <= 0) { return; } HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers"); for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / textArea.TextView.FontHeight + 1; ++y) { Rectangle markerRectangle = new Rectangle(DrawingPosition.X, DrawingPosition.Top + y * textArea.TextView.FontHeight - textArea.TextView.VisibleLineDrawingRemainder, DrawingPosition.Width, textArea.TextView.FontHeight); if (rect.IntersectsWith(markerRectangle)) { // draw dotted separator line if (textArea.Document.TextEditorProperties.ShowLineNumbers) { g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder), markerRectangle); g.DrawLine(BrushRegistry.GetDotPen(lineNumberPainterColor.Color), base.drawingPosition.X, markerRectangle.Y, base.drawingPosition.X, markerRectangle.Bottom); } else { g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder), markerRectangle); } int currentLine = textArea.Document.GetFirstLogicalLine(textArea.TextView.FirstPhysicalLine + y); if (currentLine < textArea.Document.TotalNumberOfLines) { PaintFoldMarker(g, currentLine, markerRectangle); } } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("in FoldMargin " + ex.Message); } }
public bool collideBrick(brick brick) { if (brick.alive) { Rectangle r1 = new Rectangle(brick.x, brick.y, brick.size.Width, brick.size.Height); Rectangle r2 = new Rectangle((int)x, (int)y, size.Width, size.Height); if (r1.IntersectsWith(r2)) { return true; } } return false; }
public void getSuperGun(Graphics g, Player player, SuperGun gun) { Rectangle plaRec = new Rectangle(player.PLANEX, player.PLANEY, player.Myplane.Width, player.Myplane.Height); Rectangle gunRec = new Rectangle(gun.GunX, gun.GunY, gun.Gun.Width, gun.Gun.Height); if (gunRec.IntersectsWith(plaRec)) { player.getSuperGun(); gun.getGun(); gun.Exist = false; } else { gun.Draw(g); } }
public void getBloodBox(Graphics g, Player player, BloodBox box) { Rectangle plaRec = new Rectangle(player.PLANEX, player.PLANEY, player.Myplane.Width, player.Myplane.Height); Rectangle boxRec = new Rectangle(box.BoxX, box.BoxY, box.Box.Width, box.Box.Height); if (boxRec.IntersectsWith(plaRec) && player.ChangeBlood(0) && box.Exist) { player.ChangeBlood(20); box.getBox(); box.Exist = false; } else { box.Draw(g); } }
public void Remove(Rectangle rect) { for (int i = this.m_Count - 1; i >= 0; i--) { Rectangle rectangle = this.m_Rects[i]; if (rect.IntersectsWith(rectangle)) { this.InternalRemove(i); Rectangle[] rectangleArray = Punch(rectangle, rect); for (int j = 0; j < rectangleArray.Length; j++) { this.InternalAdd(rectangleArray[j]); } } } }
/// <summary> /// returns true if the mouse pointer is inside the shape /// </summary> /// <param name="pPoint"></param> /// <returns></returns> public bool IsCollision(Point pPoint) { // determine type of collision /* * For now just see if there is any kind of collision * with the mouse cursor */ Rectangle lrectCursorRect = new Rectangle(pPoint, new Size(2, 2)); Rectangle region = new Rectangle(Location, new Size(40, 40)); if (region.IntersectsWith(lrectCursorRect)) { //this.Cursor = Cursors.SizeAll; return true; } return false; }
public void Add(Rectangle rect) { for (int i = 0; i < this.m_Count; i++) { Rectangle rectangle = this.m_Rects[i]; if (rect.IntersectsWith(rectangle)) { Rectangle[] rectangleArray = Punch(rect, rectangle); for (int j = 0; j < rectangleArray.Length; j++) { this.Add(rectangleArray[j]); } return; } } this.InternalAdd(rect); }
private static bool h_collidedWith(BaseActor actor1, BaseActor actor2) { Rectangle rectangle1; { int actorX = (int) actor1.Position.X; int actorY = (int) actor1.Position.Y; rectangle1 = new Rectangle(actorX, actorY, actor1.Width, actor1.Height); } Rectangle rectangle2; { int actorX = (int) actor2.Position.X; int actorY = (int) actor2.Position.Y; rectangle2 = new Rectangle(actorX, actorY, actor2.Width, actor2.Height); } return rectangle1.IntersectsWith(rectangle2); }
//Move the Boss rcokets on the screen public void moveBossRocket() { for (int i = 0; i < bossRockets.Count; i++) { Rectangle roc = new Rectangle(bossRockets[i].getX(),bossRockets[i].getY(),bossRockets[i].getImage().Width, bossRockets[i].getImage().Height); Rectangle r1 = new Rectangle(playerPlane.getX(), playerPlane.getY(), playerPlane.getImage().Width, playerPlane.getImage().Height); if (roc.IntersectsWith(r1)) { playerPlane.loseLife(); bossRockets.Remove(bossRockets[i]); } else if (bossRockets[i].getY() > 780) { bossRockets.Remove(bossRockets[i]); } else bossRockets[i].moveRocket(); } }