本文整理汇总了C#中System.Drawing.Point.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Point.Add方法的具体用法?C# Point.Add怎么用?C# Point.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Point
的用法示例。
在下文中一共展示了Point.Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPath
static IEnumerable<Point> GetPath(int startX, int startY, double dx, double dy)
{
var geo = new Point(startX, startY).ToGeometry();
var deltaPoint = new PointF((float)dx, (float)dy);
while (true)
{
geo = geo.Add(deltaPoint);
yield return geo.ToMap();
}
}
示例2: Process
//.........这里部分代码省略.........
else if (CurrentAction == MirAction.Running)
i = (Sprint && !Sneaking ? 3 : 2);
else i = 1;
if (CurrentAction == MirAction.Jump) i = -JumpDistance;
if (CurrentAction == MirAction.DashAttack) i = JumpDistance;
Movement = Functions.PointMove(CurrentLocation, Direction, CurrentAction == MirAction.Pushed ? 0 : -i);
int count = Frame.Count;
int index = FrameIndex;
if (CurrentAction == MirAction.DashR || CurrentAction == MirAction.DashL)
{
count = 3;
index %= 3;
}
switch (Direction)
{
case MirDirection.Up:
OffSetMove = new Point(0, (int)((MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
case MirDirection.UpRight:
OffSetMove = new Point((int)((-MapControl.CellWidth * i / (float)(count)) * (index + 1)), (int)((MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
case MirDirection.Right:
OffSetMove = new Point((int)((-MapControl.CellWidth * i / (float)(count)) * (index + 1)), 0);
break;
case MirDirection.DownRight:
OffSetMove = new Point((int)((-MapControl.CellWidth * i / (float)(count)) * (index + 1)), (int)((-MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
case MirDirection.Down:
OffSetMove = new Point(0, (int)((-MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
case MirDirection.DownLeft:
OffSetMove = new Point((int)((MapControl.CellWidth * i / (float)(count)) * (index + 1)), (int)((-MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
case MirDirection.Left:
OffSetMove = new Point((int)((MapControl.CellWidth * i / (float)(count)) * (index + 1)), 0);
break;
case MirDirection.UpLeft:
OffSetMove = new Point((int)((MapControl.CellWidth * i / (float)(count)) * (index + 1)), (int)((MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
}
OffSetMove = new Point(OffSetMove.X % 2 + OffSetMove.X, OffSetMove.Y % 2 + OffSetMove.Y);
break;
default:
OffSetMove = Point.Empty;
Movement = CurrentLocation;
break;
}
#endregion
DrawY = Movement.Y > CurrentLocation.Y ? Movement.Y : CurrentLocation.Y;
DrawLocation = new Point((Movement.X - User.Movement.X + MapControl.OffSetX) * MapControl.CellWidth, (Movement.Y - User.Movement.Y + MapControl.OffSetY) * MapControl.CellHeight);
if (this != User)
{
DrawLocation.Offset(User.OffSetMove);
DrawLocation.Offset(-OffSetMove.X, -OffSetMove.Y);
}
if (BodyLibrary != null && update)
{
FinalDrawLocation = DrawLocation.Add(BodyLibrary.GetOffSet(DrawFrame));
DisplayRectangle = new Rectangle(DrawLocation, BodyLibrary.GetTrueSize(DrawFrame));
}
for (int i = 0; i < Effects.Count; i++)
Effects[i].Process();
Color colour = DrawColour;
DrawColour = Color.White;
if (Poison != PoisonType.None)
{
if (Poison.HasFlag(PoisonType.Green))
DrawColour = Color.Green;
if (Poison.HasFlag(PoisonType.Red))
DrawColour = Color.Red;
if (Poison.HasFlag(PoisonType.Bleeding))
DrawColour = Color.DarkRed;
if (Poison.HasFlag(PoisonType.Slow))
DrawColour = Color.Purple;
if (Poison.HasFlag(PoisonType.Stun))
DrawColour = Color.Yellow;
if (Poison.HasFlag(PoisonType.Frozen))
DrawColour = Color.Blue;
if (Poison.HasFlag(PoisonType.Paralysis))
DrawColour = Color.Gray;
if (Poison.HasFlag(PoisonType.DelayedExplosion))
DrawColour = Color.Orange;
}
if (colour != DrawColour) GameScene.Scene.MapControl.TextureValid = false;
}
示例3: Process
public override void Process()
{
bool update = CMain.Time >= NextMotion || GameScene.CanMove;
SkipFrames = ActionFeed.Count > 1;
ProcessFrames();
if (Frame == null)
DrawFrame = 0;
else DrawFrame = Frame.Start + (Frame.OffSet * (byte)Direction) + FrameIndex;
#region Moving OffSet
switch (CurrentAction)
{
case MirAction.Walking:
case MirAction.Running:
case MirAction.Pushed:
case MirAction.DashL:
case MirAction.DashR:
if (Frame == null)
{
OffSetMove = Point.Empty;
Movement = CurrentLocation;
break;
}
int i = CurrentAction == MirAction.Running ? 2 : 1;
Movement = Functions.PointMove(CurrentLocation, Direction, CurrentAction == MirAction.Pushed ? 0 : -i);
int count = Frame.Count;
int index = FrameIndex;
if (CurrentAction == MirAction.DashR || CurrentAction == MirAction.DashL)
{
count = 3;
index %= 3;
}
switch (Direction)
{
case MirDirection.Up:
OffSetMove = new Point(0, (int)((MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
case MirDirection.UpRight:
OffSetMove = new Point((int)((-MapControl.CellWidth * i / (float)(count)) * (index + 1)), (int)((MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
case MirDirection.Right:
OffSetMove = new Point((int)((-MapControl.CellWidth * i / (float)(count)) * (index + 1)), 0);
break;
case MirDirection.DownRight:
OffSetMove = new Point((int)((-MapControl.CellWidth * i / (float)(count)) * (index + 1)), (int)((-MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
case MirDirection.Down:
OffSetMove = new Point(0, (int)((-MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
case MirDirection.DownLeft:
OffSetMove = new Point((int)((MapControl.CellWidth * i / (float)(count)) * (index + 1)), (int)((-MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
case MirDirection.Left:
OffSetMove = new Point((int)((MapControl.CellWidth * i / (float)(count)) * (index + 1)), 0);
break;
case MirDirection.UpLeft:
OffSetMove = new Point((int)((MapControl.CellWidth * i / (float)(count)) * (index + 1)), (int)((MapControl.CellHeight * i / (float)(count)) * (index + 1)));
break;
}
OffSetMove = new Point(OffSetMove.X % 2 + OffSetMove.X, OffSetMove.Y % 2 + OffSetMove.Y);
break;
default:
OffSetMove = Point.Empty;
Movement = CurrentLocation;
break;
}
#endregion
DrawY = Movement.Y > CurrentLocation.Y ? Movement.Y : CurrentLocation.Y;
DrawLocation = new Point((Movement.X - User.Movement.X + MapControl.OffSetX) * MapControl.CellWidth, (Movement.Y - User.Movement.Y + MapControl.OffSetY) * MapControl.CellHeight);
DrawLocation.Offset(-OffSetMove.X, -OffSetMove.Y);
DrawLocation.Offset(User.OffSetMove);
DrawLocation = DrawLocation.Add(ManualLocationOffset);
if (BodyLibrary != null && update)
{
FinalDrawLocation = DrawLocation.Add(BodyLibrary.GetOffSet(DrawFrame));
DisplayRectangle = new Rectangle(DrawLocation, BodyLibrary.GetTrueSize(DrawFrame));
}
for (int i = 0; i < Effects.Count; i++)
Effects[i].Process();
Color colour = DrawColour;
switch (Poison)
{
case PoisonType.None:
DrawColour = Color.White;
break;
//.........这里部分代码省略.........
示例4: Center
/// <summary>
/// Center between two points
/// </summary>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <returns>Center Point</returns>
public static Point Center(Point p1, Point p2) => p2.Add(p1).Scale(0.5f);
示例5: Process
public override void Process()
{
bool update = CMain.Time >= NextMotion || GameScene.CanMove;
ProcessFrames();
if (Frame == null)
DrawFrame = 0;
else
DrawFrame = Frame.Start + (Frame.OffSet * (byte)Direction) + FrameIndex;
DrawY = CurrentLocation.Y;
DrawLocation = new Point((Movement.X - User.Movement.X + MapControl.OffSetX) * MapControl.CellWidth, (Movement.Y - User.Movement.Y + MapControl.OffSetY) * MapControl.CellHeight);
DrawLocation.Offset(User.OffSetMove);
if (BodyLibrary != null)
FinalDrawLocation = DrawLocation.Add(BodyLibrary.GetOffSet(DrawFrame));
if (BodyLibrary != null && update)
{
FinalDrawLocation = DrawLocation.Add(BodyLibrary.GetOffSet(DrawFrame));
DisplayRectangle = new Rectangle(DrawLocation, BodyLibrary.GetTrueSize(DrawFrame));
}
for (int i = 0; i < Effects.Count; i++)
Effects[i].Process();
Color colour = DrawColour;
switch (Poison)
{
case PoisonType.None:
DrawColour = Color.White;
break;
case PoisonType.Green:
DrawColour = Color.Green;
break;
case PoisonType.Red:
DrawColour = Color.Red;
break;
case PoisonType.Slow:
DrawColour = Color.Purple;
break;
case PoisonType.Stun:
DrawColour = Color.Yellow;
break;
case PoisonType.Frozen:
DrawColour = Color.Blue;
break;
case PoisonType.Paralysis:
DrawColour = Color.Gray;
break;
}
if (colour != DrawColour) GameScene.Scene.MapControl.TextureValid = false;
}
示例6: Show
// Public methods.
/// <summary>
/// Shows the tooltip.
/// </summary>
/// <param name="control">The control.</param>
/// <param name="location">The location relative to the control.</param>
/// <param name="alignment">The alignment relative to the location.</param>
public void Show(IWin32Window control, Point location, ContentAlignment alignment)
{
// Create the title font.
using (Font font = new Font(Window.DefaultFont, FontStyle.Bold))
{
// Compute the tooltip strings.
this.messageTitle = NetworkStatusToolTip.message[(int)NetworkStatus.IsInternetAvailable];
this.messageIcmp = "ICMP connectivity: {0}".FormatWith(NetworkStatus.IsInternetIcmpAvailable ? "Yes" : "No");
this.messageHttp = "HTTP connectivity: {0}".FormatWith(NetworkStatus.IsInternetHttpAvailable ? "Yes" : "No");
this.messageHttps = "HTTPS connectivity: {0}".FormatWith(NetworkStatus.IsInternetHttpsAvailable ? "Yes" : "No");
this.messageUpdated = "Connectivity last checked at {0}".FormatWith(NetworkStatus.InternetAvailableLastUpdated.ToLongTimeString());
// Compute the strings size.
Size sizeTitle = TextRenderer.MeasureText(messageTitle, font);
Size sizeIcmp = TextRenderer.MeasureText(messageIcmp, Window.DefaultFont);
Size sizeHttp = TextRenderer.MeasureText(messageHttp, Window.DefaultFont);
Size sizeHttps = TextRenderer.MeasureText(messageHttps, Window.DefaultFont);
Size sizeUpdated = TextRenderer.MeasureText(messageUpdated, Window.DefaultFont);
// Compute the spacing size.
int spacing = (int)(Window.DefaultFont.SizeInPoints * spacingFactor);
// Get the icon.
this.icon = NetworkStatusToolTip.icons[(int)NetworkStatus.IsInternetAvailable];
// Compute the bounds.
this.boundsIcon = new Rectangle(new Point(spacing << 1, spacing << 1), this.icon.Size);
this.boundsTitle = new Rectangle(this.boundsIcon.Right + (spacing << 1), this.boundsIcon.Top, sizeTitle.Width, sizeTitle.Height);
this.boundsIcmp = new Rectangle(this.boundsTitle.Left, this.boundsTitle.Bottom + (spacing << 1), sizeIcmp.Width, sizeIcmp.Height);
this.boundsHttp = new Rectangle(this.boundsTitle.Left, this.boundsIcmp.Bottom + spacing, sizeHttp.Width, sizeHttp.Height);
this.boundsHttps = new Rectangle(this.boundsTitle.Left, this.boundsHttp.Bottom + spacing, sizeHttps.Width, sizeHttps.Height);
this.boundsUpdated = new Rectangle(this.boundsTitle.Left, this.boundsHttps.Bottom + (spacing << 1), sizeUpdated.Width, sizeUpdated.Height);
// Compute the maximum bounds.
Rectangle boundsMax = Geometry.Max(this.boundsIcon, this.boundsTitle, this.boundsIcmp, this.boundsHttp, this.boundsHttps, this.boundsUpdated);
// Compute the size.
this.size = new Size(boundsMax.Width + (spacing << 2), boundsMax.Height + (spacing << 2));
// Update the location according to the alignment.
switch (alignment)
{
case ContentAlignment.TopCenter: location = location.Add(-(this.size.Width >> 1), 0); break;
case ContentAlignment.TopRight: location = location.Add(-this.size.Width, 0); break;
case ContentAlignment.MiddleLeft: location = location.Add(0, -(this.size.Height >> 1)); break;
case ContentAlignment.MiddleCenter: location = location.Add(-(this.size.Width >> 1), -(this.size.Height >> 1)); break;
case ContentAlignment.MiddleRight: location = location.Add(-this.size.Width, -this.size.Height); break;
case ContentAlignment.BottomLeft: location = location.Add(0, -this.size.Height); break;
case ContentAlignment.BottomCenter: location = location.Add(-(this.size.Width >> 1), -this.size.Height); break;
case ContentAlignment.BottomRight: location = location.Add(-this.size.Width, -this.size.Height); break;
}
}
// Show the tooltip.
base.Show(" ", control, location);
}