本文整理汇总了C#中System.Drawing.Point.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Point.Equals方法的具体用法?C# Point.Equals怎么用?C# Point.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Point
的用法示例。
在下文中一共展示了Point.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Contains
/// <summary>
/// 目标点是否在线段上 (y2-y1)(x-x1) = (y-y1)(x2-x1)
/// </summary>
public bool Contains(Point pt)
{
if((pt.Equals(this.pt1)) ||(pt.Equals(this.pt2)))
{
return true ;
}
float left = (this.pt2.Y - this.pt1.Y) * (pt.X - this.pt1.X) ;
float right = (pt.Y - this.pt1.Y) * (this.pt2.X - this.pt1.X) ;
if(Math.Abs(left - right) < GeometryHelper.ToleranceForFloat)
{
return false ;
}
if(! GeometryHelper.IsInRegion(pt.X ,this.pt1.X ,this.pt2.X))
{
return false ;
}
if(! GeometryHelper.IsInRegion(pt.Y ,this.pt1.Y ,this.pt2.Y))
{
return false ;
}
return true ;
}
示例2: CheckIfSegmentIntersectInteriorSegment
public static bool CheckIfSegmentIntersectInteriorSegment(Segment s)
{
foreach (var seg in SegmentsManager.InteriorSegments)
{
if (!s.A.X.Equals(seg.A.X) && !s.A.X.Equals(seg.B.X) && !s.B.X.Equals(seg.A.X) && !s.B.X.Equals(seg.B.X))
{
VerificaIntersectia = new Intersectie(seg.A, seg.B, s.A, s.B);
if (VerificaIntersectia.Intersectation())
{
var pt = new Point(Convert.ToInt32(VerificaIntersectia.x), Convert.ToInt32(VerificaIntersectia.y));
if (!(pt.Equals(s.A) || pt.Equals(s.B)))
return true;
}
}
}
return false;
}
示例3: huir
public void huir(MouseEventArgs e,Point puntoAntiguoRaton,int heightForm,int widthForm)
{
int pixlMovimiento = 0;//Cantidad de pixeles que se va a mover por cada movimiento del ratón.
Point nuevoPunto = new Point(posicion.X, posicion.Y);
if (Math.Abs(posicion.X - e.X) < Math.Abs(posicion.X - puntoAntiguoRaton.X) ||
Math.Abs(posicion.Y - e.Y) < Math.Abs(posicion.Y - puntoAntiguoRaton.Y)) /*se comprueba que el ratón se haya acercado a la persona*/
{
if (!puntoAntiguoRaton.Equals(e.Location))/*se comprueba que el ratón se haya movido*/
{
/* dependiendo de la distancia,se cambia lo que se mueve*/
if (distancia(posicion, e.Location) > vista)
{
pixlMovimiento = 0;
}
if (distancia(posicion, e.Location) < vista)
{
pixlMovimiento = velocidadAndar;
}
if (distancia(posicion, e.Location) < vista/2)
{
pixlMovimiento = velocidadCorrer;
}
/* Se comprueba la posición del ratón con respecto al botón para que se mueva huyendo de él*/
if (posicion.X > e.Location.X)
{
nuevoPunto.X = nuevoPunto.X + pixlMovimiento;
}
else
{
nuevoPunto.X = nuevoPunto.X - pixlMovimiento;
}
if (posicion.Y > e.Location.Y)
{
nuevoPunto.Y = nuevoPunto.Y + pixlMovimiento;
}
else
{
nuevoPunto.Y = nuevoPunto.Y - 1;
}
if (nuevoPunto.X > 10 && nuevoPunto.Y > 10 && nuevoPunto.Y < heightForm - 10 - tamanio && nuevoPunto.X < widthForm - 10 - tamanio)
{
posicion = nuevoPunto;
boton.Location = posicion;
}
}
}
}
示例4: OnDragOver
/// <summary>
/// On dragging, we updates the cursor and displays an insertion marker.
/// </summary>
/// <param name="e"></param>
protected override void OnDragOver(DragEventArgs e)
{
base.OnDragOver(e);
var draggedTab = GetDraggedTab(e);
// Retrieve the point in client coordinates
Point pt = new Point(e.X, e.Y);
pt = PointToClient(pt);
if (pt.Equals(m_lastPoint)) return;
m_lastPoint = pt;
// Make sure there is a TabPage being dragged.
if (draggedTab == null)
{
e.Effect = DragDropEffects.None;
return;
}
// Retrieve the dragged page. If same as dragged page, return
var hoveredTab = GetTabPageAt(pt);
if (draggedTab == hoveredTab)
{
e.Effect = DragDropEffects.None;
m_markerIndex = -1;
return;
}
// Get the old and new marker indices
bool onLeft;
int newIndex = GetMarkerIndex(draggedTab, pt, out onLeft);
var oldIndex = m_markerIndex;
m_markerIndex = newIndex;
m_markerOnLeft = onLeft;
// Updates the new tab index
if (oldIndex != newIndex)
{
UpdateMarker();
}
e.Effect = DragDropEffects.Move;
}
示例5: LeftMouseUp
public void LeftMouseUp(ref EditorData data, Point gridPosition)
{
if(gridPosition.Equals(_mInitial))
{
if(!data.CtrlHeld) data.SelectedEntities.Clear();
var selected = data.Level.SelectEntity(gridPosition);
if (selected != null && !data.SelectedEntities.Contains(selected))
data.SelectedEntities.Add(selected);
else if (selected == null && !data.CtrlHeld)
data.SelectedEntities.Clear();
}
if (data.SelectedEntities.Count > 0)
{
data.Level.MoveEntity(data.SelectedEntities,
new Size(Point.Subtract(_mInitial, new Size(gridPosition))), false);
data.Level.MoveEntity(data.SelectedEntities,
new Size(Point.Subtract(gridPosition, new Size(_mInitial))), true);
}
_mouseDown = false;
}
示例6: Test
public static bool Test()
{
bool ok = true;
string s = string.Empty;
// DecodePoint
Point p1 = new Point(5, 104);
s = DecodePointInverse(p1);
Point p2 = DecodePoint(s);
if (!p1.Equals(p2))
ok = false;
// DecodeSize
Size s1 = new Size(1254, 67);
s = DecodeSizeInverse(s1);
Size s2 = DecodeSize(s);
if (!s1.Equals(s2))
ok = false;
// DecodeFont
Font f1 = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point);
s = DecodeFontInverse(f1);
Font f2 = DecodeFont(s);
if (!f1.Equals(f2))
ok = false;
// DecodeDateTime
DateTime t1 = DateTime.Today;
s = DecodeDateTimeInverse(t1);
DateTime t2 = DecodeDateTime(s);
if (!t1.Equals(t2))
ok = false;
// DecodeAppearance
Appearance a1 = Appearance.Button;
s = DecodeAppearanceInverse(a1);
Appearance a2 = DecodeAppearance(s);
if (!t1.Equals(t2))
ok = false;
// DecodeScrollBars
ScrollBars sb1 = ScrollBars.Both;
s = DecodeScrollBarsInverse(sb1);
ScrollBars sb2 = DecodeScrollBars(s);
if (!sb1.Equals(sb2))
ok = false;
// DecodeSelectionMode
SelectionMode sm1 = SelectionMode.MultiSimple;
s = DecodeSelectionModeInverse(sm1);
SelectionMode sm2 = DecodeSelectionMode(s);
if (!sm1.Equals(sm2))
ok = false;
// DecodeView
View v1 = View.LargeIcon;
s = DecodeViewInverse(v1);
View v2 = DecodeView(s);
if (!v1.Equals(v2))
ok = false;
// DecodeOrientation
Orientation o1 = Orientation.Vertical;
s = DecodeOrientationInverse(o1);
Orientation o2 = DecodeOrientation(s);
if (!o1.Equals(o2))
ok = false;
// DecodeTickStyle
TickStyle ts1 = TickStyle.BottomRight;
s = DecodeTickStyleInverse(ts1);
TickStyle ts2 = DecodeTickStyle(s);
if (!ts1.Equals(ts2))
ok = false;
// DecodeTabAlignment
TabAlignment ta1 = TabAlignment.Right;
s = DecodeTabAlignmentInverse(ta1);
TabAlignment ta2 = DecodeTabAlignment(s);
if (!ta1.Equals(ta2))
ok = false;
// DecodeListViewItem (single)
ListViewItem lv1 = new ListViewItem("John Doe");
s = DecodeListViewItemInverse(lv1);
ListViewItem lv2 = DecodeListViewItem(s);
/* not comparable (only by reference)
if (!lv1.Equals(lv2))
//.........这里部分代码省略.........
示例7: MoveExact
private void MoveExact(int x, int y)
{
float effectiveX = x / (POWER * 1f),
effectiveY = y / (POWER * 1f);
var actualX = (int)Math.Floor((float)(x + (POWER / 2)) / POWER);
var actualY = (int)Math.Floor((float)(y + (POWER / 2)) / POWER);
var targets = GetHitTargets();
var sourceLeft = effectiveX * _map.TileSize;
var sourceTop = effectiveY * _map.TileSize;
var sourceRect = new RectangleF(sourceLeft, sourceTop, _map.TileSize, _map.TileSize);
var collisions = new List<Point>();
var possible = new List<Point>();
foreach (var t in targets)
{
int targetX = actualX + t.X,
targetY = actualY + t.Y;
var targetRect = new RectangleF(targetX * _map.TileSize, targetY * _map.TileSize, _map.TileSize, _map.TileSize);
var movable = Movable(targetX, targetY);
var intersects = sourceRect.IntersectsWith(targetRect);
if (!movable && intersects)
{
collisions.Add(new Point(targetX, targetY));
}
else
{
possible.Add(new Point(targetX, targetY));
}
}
if (collisions.Count == 0)
{
SetDirection(DirectionX, DirectionY);
X = actualX;
Y = actualY;
ExactX = x;
ExactY = y;
}
else
{
var candidates = new List<Tuple<int, int, Point>>();
Tuple<int, int, Point> candidate = null;
var p1 = new Point(actualX + DirectionX, actualY);
var p2 = new Point(actualX, actualY + DirectionY);
foreach (var nextMove in possible)
{
if (p1.Equals(nextMove))
{
candidates.Add(Tuple.Create(DirectionX, 0, p1));
}
if (p2.Equals(nextMove))
{
candidates.Add(Tuple.Create(0, DirectionY, p2));
}
}
if (candidates.Count == 1)
{
candidate = candidates[0];
}
else if (candidates.Count == 2)
{
int minDistance = Int32.MaxValue;
for (int i = 0; i < candidates.Count; ++i)
{
var targetCandidate = candidates[i];
int xs = (ExactX - candidates[i].Item3.X * POWER);
int ys = (ExactY - candidates[i].Item3.Y * POWER);
int distance = xs * xs + ys * ys;
if (distance < minDistance)
{
minDistance = distance;
candidate = targetCandidate;
}
}
}
if (candidate != null)
{
var diffX = candidate.Item3.X * POWER - ExactX;
var diffY = candidate.Item3.Y * POWER - ExactY;
var absX = Math.Abs(diffX);
var absY = Math.Abs(diffY);
int effectiveDirectionX = 0;
int effectiveDirectionY = 0;
if (absX == 100)
{
effectiveDirectionX = 0;
}
else
{
effectiveDirectionX = Math.Sign(diffX);
//.........这里部分代码省略.........
示例8: TestMinMax2
public void TestMinMax2()
{
Matrix<Single> matrix = new Matrix<Single> (10, 10);
matrix.SetValue (5);
matrix [5, 5] = 10;
matrix [3, 3] = 0;
double minVal = 5;
double maxVal = 5;
Point minLoc = new Point();
Point maxLoc = new Point();
matrix.MinMax (out minVal, out maxVal, out minLoc, out maxLoc);
EmguAssert.IsTrue(minVal == 0);
EmguAssert.IsTrue(maxVal == 10);
EmguAssert.IsTrue(minLoc.Equals(new Point(3, 3)));
EmguAssert.IsTrue(maxLoc.Equals(new Point(5, 5)));
}
示例9: ProcessObstacles
private void ProcessObstacles()
{
ModelGame mg = (ModelGame)model;
// We moeten een 2e array maken om door heen te loopen
// Er is kans dat we de array door lopen en ook tegelijkertijd een explosie toevoegen
// We voegen dan als het ware iets toe en lezen tegelijk, dit mag niet
List<GameObject> safeListArray = new List<GameObject>(mg.GameObjects);
SlowingObstacle slowedDownObstacle = null;
// Loop door alle obstacles objecten en roep methode aan
foreach (GameObject gameObject in safeListArray)
{
if (gameObject is MovingExplodingObstacle)
{
MovingExplodingObstacle gameObstacle = (MovingExplodingObstacle)gameObject;
//Opslaan van huidige locatie in variable om vervolgens te vergelijken
Point currentLocation = new Point(gameObstacle.Location.X, gameObstacle.Location.Y);
gameObstacle.ChasePlayer(mg.player, "x");
gameObstacle.ProcessCollision(safeListArray, "x");
gameObstacle.ChasePlayer(mg.player, "y");
gameObstacle.ProcessCollision(safeListArray, "y");
if (gameObstacle.IsSmart && currentLocation.Equals(gameObstacle.Location) && !gameObstacle.SmartMovingEnabled)
{
gameObstacle.SmartmovingTime = DateTime.Now.AddMilliseconds(2500);
gameObstacle.SmartMovingEnabled = true;
}
if (gameObstacle.IsSmart && gameObstacle.SmartMovingEnabled)
{
//Controleert als het object nog steeds slim moet zijn
if (gameObstacle.SmartmovingTime >= DateTime.Now)
{
//Probeert weg te komen van stilstaant object
gameObstacle.TryToEscape();
}
else
{
gameObstacle.SmartMovingEnabled = false;
gameObstacle.SmartmovingDirection = ""; // Reset direction voor smart movement
gameObstacle.DirectionTime = default(DateTime);
}
}
if (gameObstacle.CollidesWith(mg.player))
{
score = 0;
mg.player.Location = new Point(0, 0);
UpdatePlayerPosition();
mg.InitializeField();
mg.GameObjects.Add(new Explosion(gameObstacle.Location, 10, 10));
mg.player.ObjectImage = Resources.Player;
}
}
if (gameObject is SlowingObstacle)
{
SlowingObstacle gameObstacle = (SlowingObstacle)gameObject;
//Opslaan van huidige locatie in variable om vervolgens te vergelijken
Point currentLocation = gameObstacle.Location;
gameObstacle.ChasePlayer(mg.player, "x");
gameObstacle.ProcessCollision(safeListArray, "x");
gameObstacle.ChasePlayer(mg.player, "y");
gameObstacle.ProcessCollision(safeListArray, "y");
if (gameObstacle.IsSmart && currentLocation.Equals(gameObstacle.Location) && !gameObstacle.SmartMovingEnabled)
{
gameObstacle.SmartmovingTime = DateTime.Now.AddMilliseconds(2500);
gameObstacle.SmartMovingEnabled = true;
}
if (gameObstacle.IsSmart && gameObstacle.SmartMovingEnabled)
{
//Controleert als het object nog steeds slim moet zijn
if (gameObstacle.SmartmovingTime >= DateTime.Now)
{
//Probeert weg te komen van stilstaant object
gameObstacle.TryToEscape();
}
else
{
gameObstacle.SmartMovingEnabled = false;
gameObstacle.SmartmovingDirection = ""; // Reset direction voor smart movement
gameObstacle.DirectionTime = default(DateTime);
}
}
if (mg.player.CollidesWith(gameObstacle))
{
slowedDownObstacle = gameObstacle;
//.........这里部分代码省略.........
示例10: wavefront
private void wavefront(Point start, Point goal, int val)
{
if (start.x < 0 || start.x > 7 || start.y < 0 || start.y > 3)
{
return;
}
int cell = getCell(start);
if (cell < 0 || (cell > 0 && cell < val))
{
return;
}
setCell(start, val);
//Console.Out.WriteLine("x: " + start.x + " y: " + start.y + " val: " + getCell(start));
if (start.Equals(goal))
{
return;
}
wavefront(new Point(start.x - 1, start.y), goal, val + 1);
wavefront(new Point(start.x + 1, start.y), goal, val + 1);
wavefront(new Point(start.x, start.y - 1), goal, val + 1);
wavefront(new Point(start.x, start.y + 1), goal, val + 1);
wavefront(new Point(start.x - 1, start.y-1), goal, val + 1);
wavefront(new Point(start.x + 1, start.y-1), goal, val + 1);
wavefront(new Point(start.x-1, start.y - 1), goal, val + 1);
wavefront(new Point(start.x+1, start.y + 1), goal, val + 1);
}
示例11: check_food
private void check_food()
{
int food_num = 0;
Point tmp = new Point();
if (food_status == 1)
{
for (int i = 0; i < row - 1; i++)
{
for (int j = 0; j < col - 1; j++)
{
if (all[i, j] == 2)
{
food_num++;
tmp.X = i;
tmp.Y = j;
}
}
}
if (food_num != 1)
{
//MessageBox.Show("food to much , error");
}
if (!tmp.Equals(food_cur))
{
//MessageBox.Show("food not to match , error");
}
return;
}
//MessageBox.Show("no food , error");
}
示例12: SearchRunPoints
/// <summary>
/// Calculates the distances to the enemy of every point around the target and returns the points ordered in a list.
/// </summary>
/// <param name="player"></param>
/// <param name="playerTeam"></param>
/// <param name="targetPoint"></param>
/// <param name="range">The range around the target point</param>
/// <param name="amountOfPlayers">The amount of players which are allowed to stand around the calculated point </param>
/// <param name="rangeRectangle"></param>
/// <returns></returns>
public List<Point> SearchRunPoints(Player player, Team playerTeam, Point targetPoint, int range, int amountOfPlayers, Rectangle rangeRectangle)
{
Pathfinding pathfinding = new Pathfinding();
Point rootPoint = targetPoint;
List<Point> neighbors = new List<Point>();
List<double> distancesToTarget = new List<double>();
double rootDistanceToTarget = Pathfinding.DistanceBetweenPoints(player.Location, targetPoint);
Point? bestNeighbor = null;
int bestSurroundingEnemies = -1;
for (int v = -2; v <= 2; v++)
{
for (int h = -2; h <= 2; h++)
{
Point neighbor = new Point(rootPoint.X + h, rootPoint.Y + v);
int surroundingEnemies = SurroundingPlayers(GetEnemyTeam(playerTeam), range, neighbor, 1).Count;
double tmpDistanceToTarget = Pathfinding.DistanceBetweenPoints(neighbor, targetPoint);
if (pathfinding.IsWithinField(neighbor) && !neighbor.Equals(player.Location) && (!Pathfinding.CurrentBlockedRoom.Room.Contains(neighbor) || Pathfinding.CurrentBlockedRoom.AllowedTeam.Equals(playerTeam)))
{
if (tmpDistanceToTarget < rootDistanceToTarget && (bestSurroundingEnemies == -1 || surroundingEnemies < bestSurroundingEnemies))
{
bestNeighbor = neighbor;
bestSurroundingEnemies = surroundingEnemies;
}
if (rangeRectangle.Contains(neighbor) && pathfinding.StandsPlayerOnPosition(neighbor, 1) == null && surroundingEnemies <= amountOfPlayers)
{
if (neighbors.Count == 0)
{
neighbors.Add(neighbor);
distancesToTarget.Add(tmpDistanceToTarget);
}
else
{
for (int i = 0; i <= distancesToTarget.Count; i++)
{
if (i == distancesToTarget.Count || tmpDistanceToTarget < distancesToTarget[i])
{
neighbors.Insert(i, neighbor);
distancesToTarget.Insert(i, tmpDistanceToTarget);
break;
}
}
}
}
}
}
}
if (neighbors.Count == 0)
{
if (bestNeighbor.HasValue)
{
neighbors.Add(bestNeighbor.Value);
}
else
{
neighbors.Add(targetPoint);
}
}
return neighbors;
}
示例13: AnimateFrame
private void AnimateFrame(Rectangle box, Graphics g, ref int marqueeX) {
if (box == null || g == null || box.Width <= 1) { return; }
Pen penb = new Pen(new SolidBrush(blend));
g.FillRectangle(new SolidBrush(color1), box);
for (int i = box.Right + marqueeX; i > box.Left; i -= ((box.Height * 2) + StripeSpacing - 1)) {
Point theoreticalRightTop = new Point(i, box.Top);
Point theoreticalRightBottom = new Point(i - box.Height, box.Bottom);
Point theoreticalLeftTop = new Point(i - box.Height, box.Top);
Point theoreticalLeftBottom = new Point(i - (box.Height * 2), box.Bottom);
Point leftTop, leftBottom, rightTop, rightBottom;
using (GraphicsPath gp = new GraphicsPath()) {
if (theoreticalLeftTop.X <= box.Left) {
// left triangle
int diff = i - box.Height;
rightTop = new Point(i, box.Top);
rightBottom = new Point(box.Left, box.Bottom + diff);
leftTop = new Point(box.Left, box.Top);
leftBottom = leftTop;
if (rightBottom.Equals(rightTop)) { continue; }
gp.AddLine(rightTop, rightBottom);
gp.AddLine(rightBottom, leftTop);
gp.AddLine(leftTop, new Point(i, box.Top));
} else if (theoreticalLeftBottom.X <= box.Left) {
// left pentagon
int diff = i - (box.Height * 2);
rightTop = new Point(i, box.Top);
rightBottom = new Point(i - box.Height, box.Bottom);
leftTop = new Point(i - box.Height, box.Top);
leftBottom = new Point(box.Left, box.Bottom + diff);
gp.AddLine(rightTop, rightBottom);
gp.AddLine(rightBottom, new Point(box.Left, box.Bottom));
gp.AddLine(new Point(box.Left, box.Bottom), leftBottom);
gp.AddLine(leftBottom, leftTop);
gp.AddLine(leftTop, rightTop);
} else if (theoreticalRightBottom.X >= box.Right) {
// right triangle
int diff = marqueeX - box.Height;
leftTop = new Point(box.Right, box.Top + diff); //= something funky
leftBottom = theoreticalLeftBottom;
rightBottom = new Point(box.Right, box.Bottom);
rightTop = rightBottom;
if (leftBottom.Equals(leftTop)) { continue; }
gp.AddLine(leftTop, rightBottom);
gp.AddLine(rightBottom, leftBottom);
gp.AddLine(leftBottom, leftTop);
} else if (theoreticalRightTop.X >= box.Right) {
// right pentagon
int diff = i - box.Right;
Point topRight = new Point(box.Right, box.Top);
rightTop = new Point(box.Right, box.Top + diff);
rightBottom = new Point(i - box.Height, box.Bottom);
leftTop = new Point(i - box.Height, box.Top);
leftBottom = new Point(i - (box.Height * 2), box.Bottom);
gp.AddLine(leftTop, topRight);
gp.AddLine(topRight, rightTop);
gp.AddLine(rightTop, rightBottom);
gp.AddLine(rightBottom, leftBottom);
gp.AddLine(leftBottom, leftTop);
} else {
// mid-range rectangle
rightTop = new Point(i, box.Top);
rightBottom = new Point(i - box.Height, box.Bottom);
leftTop = new Point(i - box.Height, box.Top);
leftBottom = new Point(i - (box.Height * 2), box.Bottom);
gp.AddLine(rightTop, rightBottom);
gp.AddLine(rightBottom, leftBottom);
gp.AddLine(leftBottom, leftTop);
gp.AddLine(leftTop, rightTop);
}
g.FillPath(new SolidBrush(color2), gp);
}
if (!leftTop.Equals(leftBottom)) {
g.DrawLine(penb, leftTop, leftBottom);
}
if (!rightTop.Equals(rightBottom)) {
g.DrawLine(penb, rightTop, rightBottom);
}
}
g.DrawLine(penb, new Point(box.Left, box.Bottom), new Point(box.Right, box.Bottom));
if (++marqueeX > (box.Height * 2) + StripeSpacing) {
marqueeX = 1;
}
}
示例14: dif_height
//On dif height
private void dif_height(Point inp, Point outp, int ot)
{
Point a = new Point(outp.X, inp.Y);
Point b = new Point(inp.X - ot, inp.Y);
if (!testX(a, b) || !testY(outp,a))
{
Point b0 = b;
Point a0 = new Point(outp.X, outp.Y - ot);
Point a1 = a0;
//And here
for (int i = 0; i < field_matrix.GetLength(0); i++)
{
if (testX(a, b)) break;
a.Y +=(int)Math.Pow(-1, i) * (i + 1) * sc;
b.Y +=(int)Math.Pow(-1, i) * (i + 1) * sc;
}
for (int i = 0; i < field_matrix.GetLength(0); i++)
{
if (testY(a0, a)) break;
a0.X += (int)Math.Pow(-1, i) * (i + 1) * sc;
a.X += (int)Math.Pow(-1, i) * (i + 1) * sc;
}
for (int i = 0; i < field_matrix.GetLength(0); i++)
{
if (testY(b0, b)) break;
b0.X += (int)Math.Pow(-1, i) * (i + 1) * sc;
b.X += (int)Math.Pow(-1, i) * (i + 1) * sc;
}
if (!points.ContainsKey(outp)) points.Add(outp, a1);
if (!points.ContainsKey(a1) && !a1.Equals(a)) points.Add(a1, a0);
if (!points.ContainsKey(a0) && !a0.Equals(a)) points.Add(a0, a);
if (!points.ContainsKey(a)) points.Add(a, b);
if (!points.ContainsKey(b)) points.Add(b, b0);
if (!points.ContainsKey(b0) && !b0.Equals(b)) points.Add(b0, inp);
}
else
{
points.Add(outp, a);
points.Add(a, inp);
}
int ar = 5;
if (inp.X < outp.X) ar = -ar;
points.Add(new Point(inp.X - ar, inp.Y - ar), inp);
points.Add(new Point(inp.X - ar, inp.Y + ar), inp);
}
示例15: one_height
//On one height
private void one_height(Point inp, Point outp, int ot)
{
Point a = new Point(outp.X + ot, outp.Y);
Point b = new Point(inp.X - ot, inp.Y);
if (!testX(a, b))
{
Point a0 = new Point(outp.X + ot, outp.Y);
Point b0 = new Point(inp.X - ot, inp.Y);
//Сюда тот цикл со сменой знака
for (int i = 0; i < field_matrix.GetLength(0); i++)
{
if (testX(a, b)) break;
a.Y += (int)Math.Pow(-1, i) * (i + 1) * sc;
b.Y += (int)Math.Pow(-1, i) * (i + 1) * sc;
}
for (int i = 0; i < field_matrix.GetLength(0); i++)
{
if (testY(a0, a)) break;
a0.X += (int)Math.Pow(-1, i) * (i + 1) * sc;
a.X += (int)Math.Pow(-1, i) * (i + 1) * sc;
}
for (int i = 0; i < field_matrix.GetLength(0); i++)
{
if (testY(b0, b)) break;
b0.X += (int)Math.Pow(-1, i) * (i + 1) * sc;
b.X += (int)Math.Pow(-1, i) * (i + 1) * sc;
}
if (!points.ContainsKey(outp)) points.Add(outp, a0);
if (!points.ContainsKey(a0) && !a0.Equals(a)) points.Add(a0, a);
if (!points.ContainsKey(a)) points.Add(a, b);
if (!points.ContainsKey(b)) points.Add(b, b0);
if (!points.ContainsKey(b0) && !b0.Equals(b)) points.Add(b0, inp);
}
else
{
if (!points.ContainsKey(outp)) points.Add(outp, inp);
}
int ar = 5;
points.Add(new Point(inp.X - ar, inp.Y - ar), inp);
points.Add(new Point(inp.X - ar, inp.Y + ar), inp);
}