当前位置: 首页>>代码示例>>C#>>正文


C# Point.Offset方法代码示例

本文整理汇总了C#中Point.Offset方法的典型用法代码示例。如果您正苦于以下问题:C# Point.Offset方法的具体用法?C# Point.Offset怎么用?C# Point.Offset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Point的用法示例。


在下文中一共展示了Point.Offset方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Right

 public static Point Right(Point p, MirDirection d)
 {
     switch (d)
     {
         case MirDirection.Up:
             p.Offset(1, 0);
             break;
         case MirDirection.UpRight:
             p.Offset(1, 1);
             break;
         case MirDirection.Right:
             p.Offset(0, 1);
             break;
         case MirDirection.DownRight:
             p.Offset(-1, 1);
             break;
         case MirDirection.Down:
             p.Offset(-1, 0);
             break;
         case MirDirection.DownLeft:
             p.Offset(-1,-1);
             break;
         case MirDirection.Left:
             p.Offset(0, -1);
             break;
         case MirDirection.UpLeft:
             p.Offset(1, -1);
             break;
     }
     return p;
 }
开发者ID:thedeaths,项目名称:official-mir2c-,代码行数:31,代码来源:Common.cs

示例2: UpdateMousePosition

        void UpdateMousePosition()
        {
            mouse_current = System.Windows.Forms.Cursor.Position;
            if (FreeMouse)
            {
                //System.Windows.Forms.Cursor.Hide();
                mouse_current.Offset(-X, -Y);
                mouse_current.Offset(0, -20);
                //System.Windows.Forms.Cursor.Show();
            }
            if (!Focused)
            {
                return;
            }
            mouseleftclick = (!wasmouseleft) && Mouse[OpenTK.Input.MouseButton.Left];
            mouserightclick = (!wasmouseright) && Mouse[OpenTK.Input.MouseButton.Right];
            mouseleftdeclick = wasmouseleft && (!Mouse[OpenTK.Input.MouseButton.Left]);
            mouserightdeclick = wasmouseright && (!Mouse[OpenTK.Input.MouseButton.Right]);
            wasmouseleft = Mouse[OpenTK.Input.MouseButton.Left];
            wasmouseright = Mouse[OpenTK.Input.MouseButton.Right];
            if (freemousejustdisabled)
            {
                mouse_previous = mouse_current;
                freemousejustdisabled = false;
            }
            if (!FreeMouse)
            {
                int centerx = Bounds.Left + (Bounds.Width / 2);
                int centery = Bounds.Top + (Bounds.Height / 2);

                mouse_delta = new Point(mouse_current.X - mouse_previous.X,
                    mouse_current.Y - mouse_previous.Y);
                mouse_previous = mouse_current;

                if ((Math.Abs(System.Windows.Forms.Cursor.Position.X - centerx) > 100)
                    || (Math.Abs(System.Windows.Forms.Cursor.Position.Y - centery) > 100))
                {
                    System.Windows.Forms.Cursor.Position =
                        new Point(centerx, centery);
                    mouse_previous = new Point(centerx, centery);
                }
            }
        }
开发者ID:cilution,项目名称:digger-stole-my-bike,代码行数:43,代码来源:GameWindow.cs

示例3: PointMove

 public static Point PointMove(Point p, MirDirection d, int i)
 {
     switch (d)
     {
         case MirDirection.Up:
             p.Offset(0, -i);
             break;
         case MirDirection.UpRight:
             p.Offset(i, -i);
             break;
         case MirDirection.Right:
             p.Offset(i, 0);
             break;
         case MirDirection.DownRight:
             p.Offset(i, i);
             break;
         case MirDirection.Down:
             p.Offset(0, i);
             break;
         case MirDirection.DownLeft:
             p.Offset(-i, i);
             break;
         case MirDirection.Left:
             p.Offset(-i, 0);
             break;
         case MirDirection.UpLeft:
             p.Offset(-i, -i);
             break;
     }
     return p;
 }
开发者ID:thedeaths,项目名称:official-mir2c-,代码行数:31,代码来源:Common.cs

示例4: WndProc

            protected override void WndProc(ref Message m)
            {
                switch (m.Msg)
                {
                    case WM_LButtonDown:
                        if (GetValueRec().IsVisible(new Point(m.LParam.ToInt32())))
                        {
                            dragin = true;
                            lpoint = m.LParam.ToInt32();
                            Point tp = new Point(lpoint);
                            tp.Offset(-3, -3);
                            europeanswallow = new Rectangle(tp, new Size(6, 6));
                            ltime = DateTime.Now.Ticks;
                            Cursor.Current = Cursors.Hand;
                            cans = true;
                        }
                        break;
                    case WM_MouseMove:
                        if (dragin)
                        {

                            Point p = new Point(m.LParam.ToInt32());
                            if (cans)
                            {
                                if (europeanswallow.Contains(p))
                                {
                                    double f = DateTime.Now.Subtract(new DateTime(ltime)).TotalSeconds;
                                    if (f >= 1.5)
                                        cans = false;
                                    else if (f >= 0.5)
                                    {
                                        dragin = false;
                                        Cursor.Current = Cursors.SizeAll;
                                        break;
                                    }
                                }
                                else
                                    cans = false;
                            }

                            float v = (float)(((AnalogMeter.PointToAngle(p)) / 180f) * (1023));
                            vm.Value = Math.Max(0, Math.Min(1023, v));
                            Cursor.Current = Cursors.Hand;
                            return;
                        }
                        else if (GetValueRec().IsVisible(new Point(m.LParam.ToInt32())))
                        {
                            inadorn = true;
                            Cursor.Current = Cursors.Hand;
                        }
                        else
                            inadorn = false;

                        break;
                    case WM_LButtonUp:
                        if (dragin)
                            dragin = false;
                        break;
                }
                base.WndProc(ref m);
            }
开发者ID:byteit101,项目名称:ZomB-Dashboard-System,代码行数:61,代码来源:AnalogMeter.cs

示例5: OffsetTest

        public void OffsetTest(int x, int y)
        {
            Point p1 = new Point(x, y);
            Point p2 = new Point(y, x);

            p1.Offset(p2);

            Assert.Equal(p2.X + p2.Y, p1.X);
            Assert.Equal(p1.X, p1.Y);

            p2.Offset(x, y);
            Assert.Equal(p1, p2);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:13,代码来源:PointTests.cs

示例6: Move

        private void Move(Point p)
        {
            p = _originalForm.PointToScreen(p);
            var activeScr = Screen.FromPoint(p); // get the screen from the point !!

            if (!activeScr.WorkingArea.Contains(p))
            {
                p.X = NormalizeInside(p.X, activeScr.WorkingArea.Left, activeScr.WorkingArea.Right);
                p.Y = NormalizeInside(p.Y, activeScr.WorkingArea.Top, activeScr.WorkingArea.Bottom);
            }

            p.Offset(-_offsetPoint.X, -_offsetPoint.Y);

            // p is the exact location of the frame - so we can play with it
            // to detect the new position acording to different bounds
            _formRect.Location = p; // this is the new positon of the form

            _formOffsetPoint.X = _stickGap + 1; // (more than) maximum gaps
            _formOffsetPoint.Y = _stickGap + 1;

            if (StickToScreen)
                Move_Stick(activeScr.WorkingArea, false);

            // Now try to snap to other windows
            if (StickToOther)
            {
                foreach (Form sw in GlobalStickyWindows)
                {
                    if (sw != _originalForm)
                        Move_Stick(sw.Bounds, true);
                }
            }

            if (_formOffsetPoint.X == _stickGap + 1)
                _formOffsetPoint.X = 0;
            if (_formOffsetPoint.Y == _stickGap + 1)
                _formOffsetPoint.Y = 0;

            _formRect.Offset(_formOffsetPoint);

            _originalForm.Bounds = _formRect;
        }
开发者ID:Type-of-Tool,项目名称:ootd,代码行数:42,代码来源:StickyWindow.cs

示例7: OnNCLButtonDown

        /// <summary>
        ///     Checks where the click was in the NC area and starts move or resize operation
        /// </summary>
        /// <param name="iHitTest"></param>
        /// <param name="point"></param>
        /// <returns></returns>
        private bool OnNCLButtonDown(int iHitTest, Point point)
        {
            _offsetPoint = point;

            switch (iHitTest)
            {
                case UnsafeNativeMethods.HT.HTCAPTION:
                    {
                        // request for move
                        if (StickOnMove)
                        {
                            var pointInApp = _originalForm.PointToClient(Cursor.Position);
                            _offsetPoint.Offset(pointInApp.X, pointInApp.Y);
                            StartMove();
                            return true;
                        }
                        return false; // leave default processing
                    }

                // requests for resize
                case UnsafeNativeMethods.HT.HTTOPLEFT:
                    return StartResize(ResizeDir.Top | ResizeDir.Left);
                case UnsafeNativeMethods.HT.HTTOP:
                    return StartResize(ResizeDir.Top);
                case UnsafeNativeMethods.HT.HTTOPRIGHT:
                    return StartResize(ResizeDir.Top | ResizeDir.Right);
                case UnsafeNativeMethods.HT.HTRIGHT:
                    return StartResize(ResizeDir.Right);
                case UnsafeNativeMethods.HT.HTBOTTOMRIGHT:
                    return StartResize(ResizeDir.Bottom | ResizeDir.Right);
                case UnsafeNativeMethods.HT.HTBOTTOM:
                    return StartResize(ResizeDir.Bottom);
                case UnsafeNativeMethods.HT.HTBOTTOMLEFT:
                    return StartResize(ResizeDir.Bottom | ResizeDir.Left);
                case UnsafeNativeMethods.HT.HTLEFT:
                    return StartResize(ResizeDir.Left);
            }

            return false;
        }
开发者ID:Type-of-Tool,项目名称:ootd,代码行数:46,代码来源:StickyWindow.cs

示例8: SetupHexagonalGrid

        void SetupHexagonalGrid()
        {
            // Make cell regions: we assume cells have only 1 region but that can change in the future
            int l = _numCells;
            int qx, qy;
            int q = (int)(Math.Sqrt (l));
            q = q * 12 / 13;
            if (q<1) q= 1;
            qx=qy=q;
            int qx2 = qx * 4 / 3;

            double stepX = (transform.localScale.y / transform.localScale.x) / qx;
            double stepY = (transform.localScale.x / transform.localScale.y) / qy;

            double halfStepX = stepX*0.5;
            double halfStepY = stepY*0.5;

            Segment [,,] sides = new Segment[qx2,qy,6]; // 0 = left-up, 1 = top, 2 = right-up, 3 = right-down, 4 = down, 5 = left-down
            int c = -1;
            int subdivisions = goodGridCurvature > 0 ? 3: 1;
            for (int j=0;j<qy;j++) {
                for (int k=0;k<qx2;k++) {
                    Point center = new Point((double)k/qx-0.5+halfStepX,(double)j/qy-0.5+halfStepY);
                    center.x -= k *  halfStepX/2;
                    Cell cell = new Cell( (++c).ToString(), new Vector2((float)center.x, (float)center.y));

                    double offsetY = (k % 2==0) ? 0: -halfStepY;

                    Segment leftUp =  (k>0 && offsetY<0) ? sides[k-1, j, 3]: new Segment(center.Offset(-halfStepX, offsetY), center.Offset(-halfStepX/2, halfStepY + offsetY), k==0 || (j==qy-1 && offsetY==0));
                    sides[k, j, 0] = leftUp;

                    Segment top = new Segment(center.Offset(-halfStepX/2, halfStepY + offsetY), center.Offset(halfStepX/2, halfStepY + offsetY), j==qy-1);
                    sides[k, j, 1] = top;

                    Segment rightUp = new Segment(center.Offset(halfStepX/2, halfStepY + offsetY), center.Offset(halfStepX, offsetY), k==qx2-1 || (j==qy-1 && offsetY==0));
                    sides[k, j, 2] = rightUp;

                    Segment rightDown = (j > 0 && k<qx2-1 && offsetY<0) ? sides[k+1,j-1,0]: new Segment(center.Offset(halfStepX, offsetY), center.Offset(halfStepX/2, -halfStepY + offsetY), (j==0 && offsetY<0)|| k==qx2-1);
                    sides[k, j, 3] = rightDown;

                    Segment bottom = j>0 ? sides[k, j-1, 1] : new Segment(center.Offset(halfStepX/2, -halfStepY + offsetY), center.Offset(-halfStepX/2, -halfStepY +offsetY), true);
                    sides[k, j, 4] = bottom;

                    Segment leftDown;
                    if (offsetY<0 && j>0) {
                        leftDown = sides[k-1, j-1, 2];
                    } else if (offsetY==0 && k>0) {
                        leftDown = sides[k-1, j, 2];
                    } else {
                        leftDown = new Segment(center.Offset(-halfStepX/2, -halfStepY+offsetY), center.Offset(-halfStepX, offsetY), true);
                    }
                    sides[k, j, 5] = leftDown;

                    if (j==0) {
            //						leftDown.CropBottom();
            //						bottom.CropBottom();
            //						rightDown.CropBottom();
                    }
                    if (k==qx2-1) {
                        top.CropRight();
                        rightUp.CropRight();
                        rightDown.CropRight();
                        bottom.CropRight();
                    }

                    Region cr = new Region (cell);
                    if (subdivisions>1) {
                        if (!top.deleted) cr.segments.AddRange (top.Subdivide(subdivisions, _gridCurvature));
                        if (!rightUp.deleted) cr.segments.AddRange (rightUp.Subdivide(subdivisions, _gridCurvature));
                        if (!rightDown.deleted) cr.segments.AddRange (rightDown.Subdivide(subdivisions, _gridCurvature));
                        if (!bottom.deleted) cr.segments.AddRange (bottom.Subdivide(subdivisions, _gridCurvature));
                        if (!leftDown.deleted) cr.segments.AddRange (leftDown.Subdivide(subdivisions, _gridCurvature));
                        if (!leftUp.deleted) cr.segments.AddRange (leftUp.Subdivide(subdivisions, _gridCurvature));
                    } else {
                        if (!top.deleted) cr.segments.Add (top);
                        if (!rightUp.deleted) cr.segments.Add (rightUp);
                        if (!rightDown.deleted) cr.segments.Add (rightDown);
                        if (!bottom.deleted) cr.segments.Add (bottom);
                        if (!leftDown.deleted) cr.segments.Add (leftDown);
                        if (!leftUp.deleted) cr.segments.Add (leftUp);
                    }
                    Connector connector = new Connector();
                    connector.AddRange(cr.segments);
                    cr.polygon = connector.ToPolygon(); // FromLargestLineStrip();
                    if (cr.polygon!=null) {
                        cell.region = cr;
                        cells.Add (cell);
                    }
                }
            }
        }
开发者ID:TPSAncient,项目名称:TurnBasedStrategyUnity,代码行数:91,代码来源:TGSPrivate.cs

示例9: SetupBoxGrid

        void SetupBoxGrid(bool strictQuads)
        {
            // Make cell regions: we assume cells have only 1 region but that can change in the future
            int l = _numCells;
            int qx, qy;
            int q = (int)(Math.Sqrt (l));
            if (strictQuads) {
                qx=qy=q;
            } else {
                qx=l;
                qy=1;
                if (q<1) q=1;
                if ( (int)(q*q) != l) { // not squared
                    if (!GetTwoFactors(l, out qx, out qy)) {
                        // if number > 10 and it's prime, reduce by one so we can avoid ugly accordian grids
                        if (l>10) GetTwoFactors(l-1, out qx, out qy);
                    }
                } else {
                    qx = qy = q;
                }
            }
            double stepX = (transform.localScale.y / transform.localScale.x) / qx;
            double stepY = (transform.localScale.x / transform.localScale.y) / qy;

            double halfStepX = stepX*0.5;
            double halfStepY = stepY*0.5;

            Segment [,,] sides = new Segment[qx,qy,4]; // 0 = left, 1 = top, 2 = right, 3 = bottom
            int c = -1;
            int subdivisions = goodGridCurvature > 0 ? 3: 1;
            for (int k=0;k<qx;k++) {
                for (int j=0;j<qy;j++) {
                    Point center = new Point((double)k/qx-0.5+halfStepX,(double)j/qy-0.5+halfStepY);
                    Cell cell = new Cell( (++c).ToString(), new Vector2((float)center.x, (float)center.y));

                    Segment left = k>0 ? sides[k-1, j, 2] : new Segment(center.Offset(-halfStepX, -halfStepY), center.Offset(-halfStepX, halfStepY), true);
                    sides[k, j, 0] = left;

                    Segment top = new Segment(center.Offset(-halfStepX, halfStepY), center.Offset(halfStepX, halfStepY), j==qy-1);
                    sides[k, j, 1] = top;

                    Segment right = new Segment(center.Offset(halfStepX, halfStepY), center.Offset(halfStepX, -halfStepY), k==qx-1);
                    sides[k, j, 2] = right;

                    Segment bottom = j>0 ? sides[k, j-1, 1] : new Segment(center.Offset(halfStepX, -halfStepY), center.Offset(-halfStepX, -halfStepY), true);
                    sides[k, j, 3] = bottom;

                    Region cr = new Region (cell);
                    if (subdivisions>1) {
                        cr.segments.AddRange (top.Subdivide(subdivisions, _gridCurvature));
                        cr.segments.AddRange (right.Subdivide(subdivisions, _gridCurvature));
                        cr.segments.AddRange (bottom.Subdivide(subdivisions, _gridCurvature));
                        cr.segments.AddRange (left.Subdivide(subdivisions, _gridCurvature));
                    } else {
                        cr.segments.Add (top);
                        cr.segments.Add (right);
                        cr.segments.Add (bottom);
                        cr.segments.Add (left);
                    }
                    Connector connector = new Connector();
                    connector.AddRange(cr.segments);
                    cr.polygon = connector.ToPolygon(); // FromLargestLineStrip();
                    if (cr.polygon!=null) {
                        cell.region = cr;
                        cells.Add (cell);
                    }
                }
            }
        }
开发者ID:TPSAncient,项目名称:TurnBasedStrategyUnity,代码行数:69,代码来源:TGSPrivate.cs

示例10: HitImageTestAt

            private bool HitImageTestAt(Point p, ListViewItem item)
            {
                Rectangle rcItem = item.GetBounds(ItemBoundsPortion.Entire);
                GraphicsUnit units = GraphicsUnit.Point;
                if (item.ImageList != null)
                {
                    Image img = item.ImageList.Images[0];
                    RectangleF rcImageF = img.GetBounds(ref units);
                    Rectangle rcImage = Rectangle.Round(rcImageF);

                    rcImage.Width += item.IndentCount + item.Position.X;
                    p.Offset(rcItem.Left, -rcItem.Top);

                    if (rcImage.Contains(p))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                return false;
            }
开发者ID:unforgiven512,项目名称:kpenhancedlistview,代码行数:24,代码来源:InlineEditing.cs

示例11: OffsetPolar

 public static Point OffsetPolar(Point o, double th, double dist)
 {
     int dx = MathEx.Round(dist*Math.Cos(th));
     int dy = MathEx.Round(dist*Math.Sin(th));
     o.Offset(dx,dy);
     return o;
 }
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:7,代码来源:Geometry.cs

示例12: OnLayout

                protected override void OnLayout(LayoutEventArgs levent)
                {
                    // set the size and location for close and auto-hide buttons
                    Rectangle rectCaption = ClientRectangle;
                    int buttonWidth = ImageCloseEnabled.Width;
                    int buttonHeight = ImageCloseEnabled.Height;
                    int height = rectCaption.Height - ButtonGapTop - ButtonGapBottom;
                    if (buttonHeight < height)
                    {
                        buttonWidth = buttonWidth * (height / buttonHeight);
                        buttonHeight = height;
                    }

                    m_buttonClose.SuspendLayout();
                    m_buttonAutoHide.SuspendLayout();
                    m_buttonOptions.SuspendLayout();

                    Size buttonSize = new Size(buttonWidth, buttonHeight);
                    m_buttonAutoHide.Size = buttonSize;
                    m_buttonClose.Size = buttonSize;
                    m_buttonOptions.Size = buttonSize;

                    int x = rectCaption.X + rectCaption.Width - 1 - ButtonGapRight - m_buttonClose.Width;
                    int y = rectCaption.Y + ButtonGapTop;
                    Point point = new Point(x, y);
                    m_buttonClose.Location = point;
                    point.Offset(- (m_buttonAutoHide.Width + ButtonGapBetween), 0);
                    m_buttonAutoHide.Location = point;
                    point.Offset(- (m_buttonOptions.Width + ButtonGapBetween), 0);
                    m_buttonOptions.Location = point;

                    m_buttonClose.ResumeLayout();
                    m_buttonAutoHide.ResumeLayout();
                    m_buttonOptions.ResumeLayout();
                    base.OnLayout(levent);
                }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:36,代码来源:DockPaneCaptionFromBase.cs


注:本文中的Point.Offset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。