本文整理汇总了C#中System.Drawing.Rectangle.LocationOffset方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.LocationOffset方法的具体用法?C# Rectangle.LocationOffset怎么用?C# Rectangle.LocationOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Rectangle
的用法示例。
在下文中一共展示了Rectangle.LocationOffset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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.Offset(-1));
}
string text = Resources.DropForm_DrawDropImage_Drop_here;
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;
}
示例2: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle rect = e.ClipRectangle;
if (ToastConfig.Image != null)
{
g.DrawImage(ToastConfig.Image, 1, 1, ToastConfig.Image.Width, ToastConfig.Image.Height);
if (isMouseInside && !string.IsNullOrEmpty(ToastConfig.URL))
{
Rectangle textRect = new Rectangle(0, 0, rect.Width, 40);
using (SolidBrush brush = new SolidBrush(Color.FromArgb(100, 0, 0, 0)))
{
g.FillRectangle(brush, textRect);
}
g.DrawString(ToastConfig.URL, textFont, Brushes.White, textRect.Offset(-urlPadding));
}
}
else if (!string.IsNullOrEmpty(ToastConfig.Text))
{
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(ToastConfig.Text, textFont, Brushes.Black, textRect);
g.DrawString(ToastConfig.Text, textFont, Brushes.White, textRect.LocationOffset(1));
}
g.DrawRectangleProper(Pens.Black, rect);
}