本文整理汇总了C#中System.Drawing.Rectangle.Inflate方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Inflate方法的具体用法?C# Rectangle.Inflate怎么用?C# Rectangle.Inflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Inflate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(System.Drawing.RectangleF dirtyRect)
{
var g = new Graphics();
// NSView does not have a background color so we just use Clear to white here
g.Clear(Color.White);
//RectangleF ClientRectangle = this.Bounds;
RectangleF ClientRectangle = dirtyRect;
// Calculate the location and size of the drawing area
// within which we want to draw the graphics:
Rectangle rect = new Rectangle((int)ClientRectangle.X, (int)ClientRectangle.Y,
(int)ClientRectangle.Width, (int)ClientRectangle.Height);
drawingRectangle = new Rectangle(rect.Location, rect.Size);
drawingRectangle.Inflate(-offset, -offset);
//Draw ClientRectangle and drawingRectangle using Pen:
g.DrawRectangle(Pens.Red, rect);
g.DrawRectangle(Pens.Black, drawingRectangle);
// Draw a line from point (3,2) to Point (6, 7)
// using the Pen with a width of 3 pixels:
Pen aPen = new Pen(Color.Green, 3);
g.DrawLine(aPen, Point2D(new PointF(3, 2)),
Point2D(new PointF(6, 7)));
g.PageUnit = GraphicsUnit.Inch;
ClientRectangle = new RectangleF(0.5f,0.5f, 1.5f, 1.5f);
aPen.Width = 1 / g.DpiX;
g.DrawRectangle(aPen, ClientRectangle);
aPen.Dispose();
g.Dispose();
}
示例2: OnPaint
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
//base.OnPaint(e);
Graphics g = e.Graphics;
g.Clear(this.Parent.BackColor);
g.SmoothingMode = SmoothingMode.AntiAlias;
Rectangle rect = new Rectangle(Point.Empty, e.ClipRectangle.Size);
rect.Width -= 1;
rect.Height -= 1;
Color coutBorder;
Color cinnerBorder;
Color cbackgroundTop;
Color cbackgroundBottom;
Color ctext;
if (mouseover)
{
coutBorder = ButtonColor.HoverOutBorder;
cinnerBorder = ButtonColor.HoverInnerBorder;
cbackgroundTop = ButtonColor.HoverBackgroundTop;
cbackgroundBottom = ButtonColor.HoverBackgroundBottom;
ctext = mousedown ? Color.Black : ButtonColor.HoverText;
}
else
{
coutBorder = ButtonColor.OutBorder;
cinnerBorder = ButtonColor.InnerBorder;
cbackgroundTop = ButtonColor.BackgroundTop;
cbackgroundBottom = ButtonColor.BackgroundBottom;
ctext = ButtonColor.Text;
}
using (GraphicsPath path = GraphicsTools.CreateRoundRectangle(rect, 2))
{
using (LinearGradientBrush lgBrush = new LinearGradientBrush(Point.Empty, new Point(rect.Width, rect.Height),
cbackgroundTop, cbackgroundBottom))
{
g.FillPath(lgBrush, path);
}
g.DrawPath(new Pen(coutBorder), path);
rect.Inflate(-1, -1);
using (GraphicsPath path2 = GraphicsTools.CreateRoundRectangle(rect, 2))
{
g.DrawPath(new Pen(cinnerBorder), path2);
}
}
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
g.DrawString(this.Text, this.Font, new SolidBrush(ctext), e.ClipRectangle, sf);
UpdateBounds(this.Location.X, this.Location.Y, this.Width, this.Height, e.ClipRectangle.Width, e.ClipRectangle.Height);
}
示例3: ButtonDragRectangleEventArgs
/// <summary>
/// Initialize a new instance of the ButtonDragRectangleEventArgs class.
/// </summary>
/// <param name="point">Left mouse down point.</param>
public ButtonDragRectangleEventArgs(Point point)
{
_point = point;
_dragRect = new Rectangle(_point, Size.Empty);
_dragRect.Inflate(SystemInformation.DragSize);
_preDragOffset = true;
}
示例4: SimpleShapeBase
/// <summary>
/// Initializes a new instance of the <see cref="T:SimpleShapeBase"/> class.
/// </summary>
/// <param name="model">the <see cref="IModel"/></param>
public SimpleShapeBase(IModel model)
: base(model)
{
mTextRectangle = Rectangle;
mTextRectangle.Inflate(-TextRectangleInflation, -TextRectangleInflation);
}
示例5: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
Rectangle rect = new Rectangle(0, 0, base.ClientSize.Width - 1, base.ClientSize.Height - 1);
using (Pen pen = this.on ? new Pen(Color.FromArgb(0, 0, 128)) : new Pen(Color.FromArgb(59, 97, 156)))
{
g.DrawEllipse(pen, rect);
}
using (Brush brush = this.on ? new SolidBrush(Color.Yellow) : new SolidBrush(Color.White))
{
if (rect.Width > 3 && rect.Height > 3)
{
rect.Inflate(-1, -1);
g.FillEllipse(Brushes.WhiteSmoke, rect);
rect.Inflate(-2, -2);
g.FillEllipse(brush, rect);
}
}
}
示例6: DrawGlyph
public override void DrawGlyph(PaintEventArgs e, Rectangle bounds)
{
int num = Math.Max(0, (bounds.Width - bounds.Height) / 2);
int num2 = Math.Max(0, (bounds.Height - bounds.Width) / 2);
bounds.Inflate(-num, -num2);
if (bounds.Width > bounds.Height)
{
bounds.Width--;
}
if (bounds.Height > bounds.Width)
{
bounds.Height--;
}
bounds.Inflate(-2, -2);
int width = bounds.Width;
int num4 = width / 3;
SmoothingMode smoothingMode = e.Graphics.SmoothingMode;
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
e.Graphics.FillEllipse(Brushes.Red, bounds);
e.Graphics.DrawEllipse(Pens.Maroon, bounds);
using (Pen pen = new Pen(Color.White, (float) Math.Max(2, width / 7)))
{
e.Graphics.DrawLine(pen, (int) (bounds.X + num4), (int) (bounds.Y + num4), (int) (bounds.Right - num4), (int) (bounds.Bottom - num4));
e.Graphics.DrawLine(pen, (int) (bounds.Right - num4), (int) (bounds.Y + num4), (int) (bounds.X + num4), (int) (bounds.Bottom - num4));
}
e.Graphics.SmoothingMode = smoothingMode;
}
示例7: DrawGlyph
public override void DrawGlyph(PaintEventArgs e, Rectangle bounds)
{
if (this.Opacity > 0f)
{
bounds.Inflate(-1, -1);
int width = bounds.Width;
if (bounds.Height > width)
{
bounds.Inflate(0, (width - bounds.Height) / 2);
}
if (this.Opacity == 1f)
{
e.Graphics.DrawImage(this.Bitmap, bounds);
}
else
{
ColorMatrix newColorMatrix = new ColorMatrix {
Matrix33 = this.Opacity
};
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetColorMatrix(newColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
e.Graphics.DrawImage(this.Bitmap, bounds, 0, 0, this.Bitmap.Width, this.Bitmap.Height, GraphicsUnit.Pixel, imageAttr);
}
}
}
示例8: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
Matrix matrix = new Matrix();
base.OnPaint(e);
Pen pen = new Pen( Color.Red, 2 );
Pen penBlack = new Pen(Color.Black, 1);
Brush brush = new SolidBrush(Color.Silver);
Rectangle r = new Rectangle(this.ClientRectangle.Left, this.ClientRectangle.Top, this.ClientRectangle.Width, this.ClientRectangle.Height );
r.Inflate(-1, -1);
if( r.Width % 2 != 0 )
r.Width = r.Width - 1;
if( r.Height % 2 != 0 )
r.Height = r.Height - 1;
Point centerPoint = new Point(r.Width / 2, r.Height / 2);
int diamaeter = this.ClientRectangle.Width;
float radius = diamaeter / 2;
double radians = (rotation-90) * Math.PI / 180;
e.Graphics.FillEllipse(brush, r );
e.Graphics.DrawEllipse(penBlack, r);
r.Inflate(-2, -2);
e.Graphics.Transform = matrix;
e.Graphics.DrawLine(pen, (int)( centerPoint.X * Math.Cos(radians) + centerPoint.X ),
(int)( centerPoint.Y * Math.Sin(radians) + centerPoint.Y ),
centerPoint.X,
centerPoint.Y);
}
示例9: WndProc
protected override void WndProc(ref Message m)
{
if (m.Msg == msg)
{
if (this.before) base.WndProc(ref m);
if (pen2.Color != CON.BackColor) { pen2 = new Pen(CON.BackColor); }
IntPtr hDC = NativeMethods.GetWindowDC(this.Handle);
Graphics g = Graphics.FromHdc(hDC);
Rectangle bounds = new Rectangle(0, 0, this.CON.Size.Width - 1, this.CON.Size.Height - 1);
g.DrawRectangle(pen, bounds);
bounds.Inflate(-1, -1);
g.DrawRectangle(pen2, bounds);
bounds.Inflate(-1, -1);
g.DrawRectangle(pen2, bounds);
NativeMethods.ReleaseDC(this.Handle, hDC);
g.Dispose();
m.Result = (IntPtr)1;
if (!this.after) return;
}
base.WndProc(ref m);
}
示例10: Draw
internal static void Draw(ActivityDesignerPaintEventArgs e, Rectangle bounds)
{
bounds.Inflate(-1, -1);
e.Graphics.FillEllipse(Brushes.White, bounds);
e.Graphics.DrawEllipse(e.AmbientTheme.SelectionForegroundPen, bounds);
bounds.Inflate(-1, -1);
e.Graphics.FillEllipse(e.AmbientTheme.SelectionForegroundBrush, bounds);
}
示例11: Draw
public virtual void Draw (Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor) {
bool is_themecolor = backColor.ToArgb () == ThemeEngine.Current.ColorControl.ToArgb () || backColor == Color.Empty ? true : false;
CPColor cpcolor = is_themecolor ? CPColor.Empty : ResPool.GetCPColor (backColor);
Pen pen;
switch (state) {
case ButtonThemeState.Normal:
case ButtonThemeState.Entered:
case ButtonThemeState.Disabled:
pen = is_themecolor ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
g.DrawLine (pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom - 2);
g.DrawLine (pen, bounds.X + 1, bounds.Y, bounds.Right - 2, bounds.Y);
pen = is_themecolor ? SystemPens.Control : ResPool.GetPen (backColor);
g.DrawLine (pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Bottom - 3);
g.DrawLine (pen, bounds.X + 2, bounds.Y + 1, bounds.Right - 3, bounds.Y + 1);
pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
g.DrawLine (pen, bounds.X + 1, bounds.Bottom - 2, bounds.Right - 2, bounds.Bottom - 2);
g.DrawLine (pen, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 3);
pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
g.DrawLine (pen, bounds.X, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
g.DrawLine (pen, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 2);
break;
case ButtonThemeState.Pressed:
g.DrawRectangle (ResPool.GetPen (foreColor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
bounds.Inflate (-1, -1);
pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
g.DrawRectangle (pen, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
break;
case ButtonThemeState.Default:
g.DrawRectangle (ResPool.GetPen (foreColor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
bounds.Inflate (-1, -1);
pen = is_themecolor ? SystemPens.ControlLightLight : ResPool.GetPen (cpcolor.LightLight);
g.DrawLine (pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom - 2);
g.DrawLine (pen, bounds.X + 1, bounds.Y, bounds.Right - 2, bounds.Y);
pen = is_themecolor ? SystemPens.Control : ResPool.GetPen (backColor);
g.DrawLine (pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Bottom - 3);
g.DrawLine (pen, bounds.X + 2, bounds.Y + 1, bounds.Right - 3, bounds.Y + 1);
pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen (cpcolor.Dark);
g.DrawLine (pen, bounds.X + 1, bounds.Bottom - 2, bounds.Right - 2, bounds.Bottom - 2);
g.DrawLine (pen, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 3);
pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetPen (cpcolor.DarkDark);
g.DrawLine (pen, bounds.X, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
g.DrawLine (pen, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 2);
break;
}
}
示例12: DrawGlyph
public override void DrawGlyph(PaintEventArgs e, Rectangle bounds)
{
GraphicsPath path;
int num = Math.Max(0, (bounds.Width - bounds.Height) / 2);
int num2 = Math.Max(0, (bounds.Height - bounds.Width) / 2);
bounds.Inflate(-num, -num2);
if ((bounds.Width % 2) == 1)
{
bounds.Width--;
}
if ((bounds.Height % 2) == 1)
{
bounds.Height--;
}
if (bounds.Width > bounds.Height)
{
bounds.Width = bounds.Height;
}
if (bounds.Height > bounds.Width)
{
bounds.Height = bounds.Width;
}
bounds.Inflate(-2, -2);
int width = bounds.Width;
int num4 = width / 3;
int num5 = width / 4;
int num6 = bounds.X + (bounds.Width / 2);
float x = bounds.X + (0.5f * (bounds.Width + 3));
float num8 = x - 3f;
SmoothingMode smoothingMode = e.Graphics.SmoothingMode;
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
using (path = new GraphicsPath())
{
Point[] points = new Point[] { new Point(bounds.Left + num4, bounds.Bottom), new Point(bounds.Right - num4, bounds.Bottom), new Point(bounds.Right, bounds.Bottom - num4), new Point(bounds.Right, bounds.Top + num4), new Point(bounds.Right - num4, bounds.Top), new Point(bounds.Left + num4, bounds.Top), new Point(bounds.Left, bounds.Top + num4), new Point(bounds.Left, bounds.Bottom - num4) };
path.AddLines(points);
path.CloseAllFigures();
e.Graphics.FillPath(Brushes.Red, path);
e.Graphics.DrawPath(Pens.DarkGray, path);
}
using (path = new GraphicsPath())
{
PointF[] tfArray = new PointF[] { new PointF(num8, (float) ((bounds.Top + num5) - 1)), new PointF(x, (float) ((bounds.Top + num5) - 1)), new PointF(num6 + 1.2f, (-0.5f + bounds.Top) + ((bounds.Height * 2f) / 3f)), new PointF(num6 - 1.2f, (-0.5f + bounds.Top) + ((bounds.Height * 2f) / 3f)) };
path.AddLines(tfArray);
path.CloseAllFigures();
e.Graphics.FillPath(Brushes.White, path);
}
RectangleF rect = new RectangleF((float) num6, (float) (bounds.Bottom - num5), 0f, 0f);
rect.Inflate(1.5f, 1.5f);
e.Graphics.FillEllipse(Brushes.White, rect);
e.Graphics.SmoothingMode = smoothingMode;
}
示例13: GenerateItemImage
public static Bitmap GenerateItemImage(string text, Color color, int width, int height, Font font)
{
//Debug.WriteLine("GenerateItemImage");
Rectangle rc = new Rectangle(0, 0, width, height);
Bitmap itemImage = new Bitmap(rc.Width, rc.Height);
/// Create button
rc.Inflate(-3, -3);
GraphicsPath path1 = GetPath(rc, 10);
rc.Inflate(0, 6);
LinearGradientBrush br1 = new LinearGradientBrush(rc, color, Color.White, LinearGradientMode.Vertical);
rc.Inflate(0, -6);
/// Create shadow
Rectangle rc2 = rc;
rc2.Offset(8, 8);
GraphicsPath path2 = GetPath(rc2, 20);
PathGradientBrush br2 = new PathGradientBrush(path2);
br2.CenterColor = ControlPaint.DarkDark(Color.Silver);
br2.SurroundColors = new Color[] { Color.White };
/// Create bubble
Rectangle rc3 = rc;
rc3.Inflate(-15, -rc.Height / 3);
rc3.Y = rc3.Y - 2;
//rc3.Height = rc3.Height;
GraphicsPath path3 = GetPath(rc3, rc3.Height);
LinearGradientBrush br3 = new LinearGradientBrush(rc3, Color.FromArgb(255, Color.White), Color.FromArgb(0, Color.White), LinearGradientMode.Vertical);
itemImage = new Bitmap(width - 2, height);
Graphics g = Graphics.FromImage(itemImage);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.FillPath(br2, path2);
g.FillPath(br1, path1);
g.FillPath(br3, path3);
//SizeF size = g.MeasureString(text, font);
//int fontHeight = (int)size.Height + 5;
//g.DrawString(
// text,
// font,
// Brushes.Black,
// new RectangleF((rc.Width - size.Width) / 2, 2, width, fontHeight));
return itemImage;
}
示例14: GetActionBounds
private Rectangle GetActionBounds(int actionIndex)
{
Rectangle destination = new Rectangle(Point.Empty, base.ParentView.ViewPortSize);
DynamicAction action = this.actions[actionIndex];
destination.Inflate(-action.DockMargin.Width, -action.DockMargin.Height);
return new Rectangle(ActivityDesignerPaint.GetRectangleFromAlignment(action.DockAlignment, destination, action.Bounds.Size).Location, action.Bounds.Size);
}
示例15: Form1_Layout
private void Form1_Layout(object sender, LayoutEventArgs e)
{
Rect = ClientRectangle;
Rect.Inflate(-10, -10);
StrSize = string.Format("폭 = {0}, 높이 = {1}", Rect.Width, Rect.Height);
Invalidate();
}