本文整理汇总了C#中System.Drawing.Rectangle.RectangleOffset方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.RectangleOffset方法的具体用法?C# Rectangle.RectangleOffset怎么用?C# Rectangle.RectangleOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Rectangle
的用法示例。
在下文中一共展示了Rectangle.RectangleOffset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScreenRegionForm
public ScreenRegionForm(Rectangle regionRectangle)
{
InitializeComponent();
borderRectangle = regionRectangle.RectangleOffset(1);
borderRectangle0Based = new Rectangle(0, 0, borderRectangle.Width, borderRectangle.Height);
Location = borderRectangle.Location;
Size = new Size(borderRectangle.Width, borderRectangle.Height + pInfo.Height);
pInfo.Location = new Point(Width - pInfo.Width, Height - pInfo.Height);
Region region = new Region(ClientRectangle);
region.Exclude(borderRectangle0Based.RectangleOffset(-1));
region.Exclude(new Rectangle(0, pInfo.Location.Y, pInfo.Location.X, pInfo.Height));
Region = region;
Timer = new Stopwatch();
}
示例2: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawImage(ToastImage, 1, 1, ToastImage.Width, ToastImage.Height);
if (!string.IsNullOrEmpty(ToastText))
{
Rectangle textRect = new Rectangle(0, 0, e.ClipRectangle.Width, 40);
using (SolidBrush brush = new SolidBrush(Color.FromArgb(150, 255, 255, 255)))
{
g.FillRectangle(brush, textRect);
}
using (Font font = new Font("Arial", 10))
{
g.DrawString(ToastText, font, Brushes.Black, textRect.RectangleOffset(-3));
}
}
g.DrawRectangleProper(Pens.Black, e.ClipRectangle);
}
示例3: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle rect = e.ClipRectangle;
if (ToastImage != null)
{
g.DrawImage(ToastImage, 1, 1, ToastImage.Width, ToastImage.Height);
if (mouseInside && !string.IsNullOrEmpty(ToastURL))
{
Rectangle textRect = new Rectangle(0, 0, rect.Width, 40);
using (SolidBrush brush = new SolidBrush(Color.FromArgb(150, 255, 255, 255)))
{
g.FillRectangle(brush, textRect);
}
g.DrawString(ToastURL, textFont, Brushes.Black, textRect.RectangleOffset(-urlPadding));
}
}
else if (!string.IsNullOrEmpty(ToastText))
{
using (LinearGradientBrush brush = new LinearGradientBrush(rect, Color.FromArgb(80, 80, 80), Color.FromArgb(50, 50, 50), LinearGradientMode.Vertical))
{
g.FillRectangle(brush, rect);
}
Rectangle textRect = new Rectangle(textPadding, textPadding, textRenderSize.Width + 2, textRenderSize.Height + 2);
g.DrawString(ToastText, textFont, Brushes.Black, textRect);
g.DrawString(ToastText, textFont, Brushes.White, textRect.LocationOffset(1));
}
g.DrawRectangleProper(Pens.Black, rect);
}
示例4: DrawTips
private void DrawTips(Graphics g)
{
int offset = 10;
int padding = 3;
string tipText;
if (isDrawingMode)
{
tipText = "Ctrl: Region mode ░ Shift: Pen color ░ Mouse wheel: Pen size ░ Space: Fullscreen capture";
}
else
{
tipText = "Ctrl: Drawing mode ░ Space: Fullscreen capture";
}
Size textSize = g.MeasureString(tipText, tipFont).ToSize();
int rectWidth = textSize.Width + padding * 2;
int rectHeight = textSize.Height + padding * 2;
Rectangle primaryScreenBounds = CaptureHelpers.GetPrimaryScreenBounds0Based();
Rectangle textRectangle = new Rectangle(primaryScreenBounds.X + (primaryScreenBounds.Width / 2) - (rectWidth / 2), offset, rectWidth, rectHeight);
if (textRectangle.RectangleOffset(10).Contains(CurrentMousePosition0Based))
{
textRectangle.Y = primaryScreenBounds.Height - rectHeight - offset;
}
using (Brush brush = new SolidBrush(Color.FromArgb(175, Color.White)))
using (Pen pen = new Pen(Color.FromArgb(175, Color.Black)))
{
g.DrawRoundedRectangle(brush, pen, textRectangle, 5);
}
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
{
g.DrawString(tipText, tipFont, Brushes.Black, textRectangle, sf);
}
}
示例5: DrawDropImage
private Bitmap DrawDropImage(int size)
{
Bitmap bmp = new Bitmap(size, size);
Rectangle rect = new Rectangle(0, 0, size, size);
using (Graphics g = Graphics.FromImage(bmp))
{
g.FillRectangle(Brushes.CornflowerBlue, rect);
g.DrawRectangleProper(Pens.Black, rect);
using (Pen pen = new Pen(Color.WhiteSmoke, 5) { Alignment = PenAlignment.Inset })
{
g.DrawRectangleProper(pen, rect.RectangleOffset(-1));
}
string text = "Drop\nhere";
using (Font font = new Font("Arial", 20, FontStyle.Bold))
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
{
g.DrawString(text, font, Brushes.Black, rect.LocationOffset(1), sf);
g.DrawString(text, font, Brushes.White, rect, sf);
}
}
return bmp;
}
示例6: DrawInfo
private void DrawInfo(Graphics g)
{
string text = "FPS: " + FPS;
SizeF textSize = g.MeasureString(text, textFont);
int offset = 30;
Rectangle primaryScreenBounds = CaptureHelpers.GetPrimaryScreenBounds0Based();
Rectangle textRectangle = new Rectangle(primaryScreenBounds.X + offset, primaryScreenBounds.Y + offset, (int)textSize.Width, (int)textSize.Height);
if (textRectangle.RectangleOffset(10).Contains(InputManager.MousePosition0Based))
{
textRectangle.Y = primaryScreenBounds.Height - textRectangle.Height - offset;
}
ImageHelpers.DrawTextWithOutline(g, text, textRectangle.Location, textFont, Color.White, Color.Black);
}