本文整理汇总了C#中System.Drawing.Rectangle.IntersectsWith方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.IntersectsWith方法的具体用法?C# Rectangle.IntersectsWith怎么用?C# Rectangle.IntersectsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Rectangle
的用法示例。
在下文中一共展示了Rectangle.IntersectsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CropSelector_MouseDown
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));
}
}
示例2: Arrange
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);
}
}
}
}
示例3: CheckForWindowOverlay
/* 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;
}
}
示例4: validateIntersection
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,
" не должны перекрываться между собой"));
}
}
}
示例5: CharacterCollision
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;
}
示例6: Removedirt
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();
}
}
}
示例7: shootEnemy
//击中敌机
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;
}
}
}
}
}
示例8: Paint
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);
}
}
}
}
示例9: Paint
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);
}
}
}
示例10: caretHit
public void caretHit(Rectangle caretRect)
{
if (caretRect.IntersectsWith(_rect))
{
speedY *= -1;
}
}
示例11: checkCollision
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;
}
示例12: IsVisiblePosition
// 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;
}
示例13: checkCollision
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;
}
示例14: timer_Elapsed
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;
}
}
示例15: IsIntersectingRect
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;
}