本文整理汇总了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);
}
示例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;
}
}
示例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);
}
示例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();
}
}
示例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));
}
示例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;
}
示例7: ScreenToFrame
public override Rectangle ScreenToFrame(Rectangle childRectangle)
{
childRectangle.Offset(-titleRectangle.X, -titleRectangle.Y);
return childRectangle;
}
示例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);
}