本文整理匯總了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);
}