當前位置: 首頁>>代碼示例>>C#>>正文


C# Point.Add方法代碼示例

本文整理匯總了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();
     }
 }
開發者ID:xoposhiy,項目名稱:icfpc2015,代碼行數:10,代碼來源:LineSlots.cs

示例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;
        }
開發者ID:nerestaren,項目名稱:mir2,代碼行數:101,代碼來源:PlayerObject.cs

示例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;
//.........這裏部分代碼省略.........
開發者ID:ufaith,項目名稱:cmir2,代碼行數:101,代碼來源:MonsterObject.cs

示例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);
開發者ID:ramoneeza,項目名稱:RopHelperSnippets,代碼行數:7,代碼來源:Rop.Helper.Geom.cs

示例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;
        }
開發者ID:xiaofengzhiyu,項目名稱:CSharpMir,代碼行數:56,代碼來源:NPCObject.cs

示例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);
        }
開發者ID:alexbikfalvi,項目名稱:InetAnalytics,代碼行數:64,代碼來源:NetworkStatusToolTip.cs


注:本文中的System.Drawing.Point.Add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。