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


C# Rectangle.Offset方法代码示例

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


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

示例1: AttachObject

    public void AttachObject(int x, int y, GameObject obj, Rectangle redirect)
    {
        ClampTileIndex (ref x, ref y);
        mTiles [x, y].Attachment = obj;

        redirect.Offset (x, y);
        for (var xx = redirect.Left; xx < redirect.Right; xx++)
            for (var yy = redirect.Bottom; yy < redirect.Top; yy++)
                RedirectTile (xx, yy, x, y);
    }
开发者ID:Botyto,项目名称:UnityTown,代码行数:10,代码来源:Iso_Methods.cs

示例2: CalculateButtonTextAndImageLayout

    //The following layout functions were taken from Mono's Windows.Forms 
    //implementation, specifically "ThemeWin32Classic.cs", 
    //then modified to fit the context of this splitButton

    private void CalculateButtonTextAndImageLayout(ref Rectangle content_rect, out Rectangle textRectangle, out Rectangle imageRectangle)
    {
        Size text_size = TextRenderer.MeasureText(Text, Font, content_rect.Size, textFormatFlags);
        Size image_size = Image == null ? Size.Empty : Image.Size;

        textRectangle = Rectangle.Empty;
        imageRectangle = Rectangle.Empty;

        switch (TextImageRelation)
        {
            case TextImageRelation.Overlay:
                // Overlay is easy, text always goes here
                textRectangle = OverlayObjectRect(ref content_rect, ref text_size, TextAlign); // Rectangle.Inflate(content_rect, -4, -4);

                //Offset on Windows 98 style when button is pressed
                if (_state == PushButtonState.Pressed && !Application.RenderWithVisualStyles)
                    textRectangle.Offset(1, 1);

                // Image is dependent on ImageAlign
                if (Image != null)
                    imageRectangle = OverlayObjectRect(ref content_rect, ref image_size, ImageAlign);

                break;
            case TextImageRelation.ImageAboveText:
                content_rect.Inflate(-4, -4);
                LayoutTextAboveOrBelowImage(content_rect, false, text_size, image_size, out textRectangle, out imageRectangle);
                break;
            case TextImageRelation.TextAboveImage:
                content_rect.Inflate(-4, -4);
                LayoutTextAboveOrBelowImage(content_rect, true, text_size, image_size, out textRectangle, out imageRectangle);
                break;
            case TextImageRelation.ImageBeforeText:
                content_rect.Inflate(-4, -4);
                LayoutTextBeforeOrAfterImage(content_rect, false, text_size, image_size, out textRectangle, out imageRectangle);
                break;
            case TextImageRelation.TextBeforeImage:
                content_rect.Inflate(-4, -4);
                LayoutTextBeforeOrAfterImage(content_rect, true, text_size, image_size, out textRectangle, out imageRectangle);
                break;
        }
    }
开发者ID:Vanatrix,项目名称:chummer5a,代码行数:45,代码来源:SplitButton.cs

示例3: OffsetTest

        public void OffsetTest(int x, int y, int width, int height)
        {
            Rectangle r1 = new Rectangle(x, y, width, height);
            Rectangle expectedRect = new Rectangle(x + width, y + height, width, height);
            Point p = new Point(width, height);

            r1.Offset(p);
            Assert.Equal(expectedRect, r1);

            expectedRect.Offset(p);
            r1.Offset(width, height);
            Assert.Equal(expectedRect, r1);
        }
开发者ID:jemmy655,项目名称:corefx,代码行数:13,代码来源:RectangleTests.cs

示例4: PaintTransparentBackground

            protected void PaintTransparentBackground(Graphics g, Rectangle clipRect)
            {
                if (this.Parent != null)
                {
                    clipRect.Offset(this.Location);
                    PaintEventArgs e = new PaintEventArgs(g, clipRect);
                    GraphicsState state = g.Save();
                    g.SmoothingMode = SmoothingMode.HighSpeed;
                    try
                    {
                        g.TranslateTransform(System.Convert.ToSingle(- this.Location.X), System.Convert.ToSingle(- this.Location.Y));
                        this.InvokePaintBackground(this.Parent, e);
                        this.InvokePaint(this.Parent, e);

                    }
                    finally
                    {
                        g.Restore(state);
                        clipRect.Offset(- this.Location.X, - this.Location.Y);
                    }
                }
                else
                {
                    System.Drawing.Drawing2D.LinearGradientBrush backBrush = new System.Drawing.Drawing2D.LinearGradientBrush(this.Bounds, SystemColors.ControlLightLight, SystemColors.ControlLight, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                    g.FillRectangle(backBrush, this.Bounds);
                    backBrush.Dispose();
                }
            }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:28,代码来源:SPTabControl.cs

示例5: _bufferedPainter_PaintVisualState

    /// <summary>
    /// Paints the control (using the Buffered Paint API).
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void _bufferedPainter_PaintVisualState(object sender, BufferedPaintEventArgs<ComboBoxState> e) {
		VisualStyleRenderer r = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);
		r.DrawParentBackground(e.Graphics, ClientRectangle, this);
		
		DrawComboBox(e.Graphics, ClientRectangle, e.State);

		Rectangle itemBounds = new Rectangle(0, 0, Width - 21, Height);
		itemBounds.Inflate(-1, -3);
		itemBounds.Offset(2, 0);

        // draw the item in the editable portion
        DrawItemState state = DrawItemState.ComboBoxEdit;
        if (Focused && ShowFocusCues && !DroppedDown) state |= DrawItemState.Focus;
        if (!Enabled) state |= DrawItemState.Disabled;
        OnDrawItem(new DrawItemEventArgs(e.Graphics, Font, itemBounds, SelectedIndex, state));
    }
开发者ID:BruceNielsen,项目名称:_V4.7-Proxy,代码行数:21,代码来源:GroupedComboBox.cs

示例6: DrawNextBtn

            public override void DrawNextBtn(Graphics g, Rectangle rect, int state, String text)
            {
                StringFormat m_Format = new StringFormat();
                m_Format.Alignment = StringAlignment.Center;
                m_Format.FormatFlags = StringFormatFlags.FitBlackBox;
                m_Format.LineAlignment = StringAlignment.Center;

                g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                using (SolidBrush backBrush = new SolidBrush(BgColor))
                    g.FillRectangle(backBrush, rect);
                using (Pen aPen = new Pen(GridColor))
                    g.DrawLine(aPen, rect.Left, rect.Top, rect.Right, rect.Top);

                rect.Offset(2, 1);

                g.DrawString(text, CellDataBoldFont, SystemBrushes.WindowText, rect, m_Format);

                g.TextRenderingHint = TextRenderingHint.SystemDefault;
            }
开发者ID:AndrianDTR,项目名称:Atlantic,代码行数:20,代码来源:Office12Renderer.cs

示例7: ScreenToFrame

 public override Rectangle ScreenToFrame(Rectangle childRectangle)
 {
     childRectangle.Offset(-titleRectangle.X, -titleRectangle.Y);
     return childRectangle;
 }
开发者ID:tpb3d,项目名称:TPB3D,代码行数:5,代码来源:BaseFrame.cs

示例8: Mode5Draw

    private void Mode5Draw(out Vector2 pos)
    {
        pos = U.RawToScreen (Input.mousePosition);
        var idx = IsoToIndex (pos);

        if (mBuilding == null) {
            mBuilding = new GameObject ("Example Building");
            mBuilding.transform.localScale *= 3f;
            var rend = (SpriteRenderer)mBuilding.AddComponent<SpriteRenderer> ();
            rend.sprite = Resources.Load<Sprite> ("lumber");
            mBuildingMoving = true;
        }

        if (Input.GetMouseButtonDown (0)) {
            var check = new Rectangle (-1, -1, 3, 3);
            check.Offset (idx);
            if (mBuildingMoving && IsFlat (check)) {
                AttachObject (idx.x, idx.y, mBuilding, new Rectangle (-1, -1, 3, 3));
                mBuildingMoving = false;
            } else {
                DetachObject (idx.x, idx.y);
                mBuildingMoving = true;
            }
        }

        if (!mBuildingMoving)
            return;

        mBuilding.transform.position = IndexToIso (idx);
    }
开发者ID:Botyto,项目名称:UnityTown,代码行数:30,代码来源:Iso_Examples.cs


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