public static Inflate ( Rectangle rect, int x, int y ) : Rectangle | ||
rect | Rectangle | |
x | int | |
y | int | |
Résultat | Rectangle |
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(); }
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); }
/// <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; }
/// <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); }
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; }
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); }
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); } } }
private void roundButton_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { if (!roundButtons) { return; } System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); // Set a new rectangle to the same size as the button's // ClientRectangle property. System.Drawing.Rectangle newRectangle = (sender as Button).ClientRectangle; // Decrease the size of the rectangle. newRectangle.Inflate(-5, -5); // Draw the button's border. e.Graphics.DrawEllipse(System.Drawing.Pens.Gray, newRectangle); // Increase the size of the rectangle to include the border. newRectangle.Inflate(1, 1); // Create a circle within the new rectangle. buttonPath.AddEllipse(newRectangle); // Set the button's Region property to the newly created // circle region. (sender as Button).Region = new Region(buttonPath); }
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); }
// This method will change the square button to a circular button by // creating a new circle-shaped GraphicsPath object and setting it // to the RoundButton objects region. private void ButtonLogin_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); // Set a new rectangle to the same size as the button's // ClientRectangle property. System.Drawing.Rectangle newRectangle = buttonLogin.ClientRectangle; // Decrease the size of the rectangle. newRectangle.Inflate(-10, -10); // Draw the button's border. e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle); // Increase the size of the rectangle to include the border. newRectangle.Inflate(1, 1); // Create a circle within the new rectangle. buttonPath.AddEllipse(newRectangle); // Set the button's Region property to the newly created // circle region. buttonLogin.Region = new System.Drawing.Region(buttonPath); }
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); } } }
private void Exit_Paint(object sender, PaintEventArgs e) { System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); // Set a new rectangle to the same size as the button's // ClientRectangle property. System.Drawing.Rectangle newRectangle = Exit.ClientRectangle; // Decrease the size of the rectangle. newRectangle.Inflate(0, 0); // Draw the button's border. e.Graphics.DrawEllipse(System.Drawing.Pens.Transparent, newRectangle); // Increase the size of the rectangle to include the border. newRectangle.Inflate(0, 0); // Create a circle within the new rectangle. buttonPath.AddEllipse(newRectangle); // Set the button's Region property to the newly created // circle region. Exit.Region = new System.Drawing.Region(buttonPath); }
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); }
public void cutBitmapShow(int index) { #region 截图显示下一个 try { string tFilePath = ConfigurationManager.AppSettings["FtpPath"] + selectListView.Items[index].SubItems[2].Text + selectListView.Items[index].SubItems[3].Text; int Zoom = int.Parse(ConfigurationManager.AppSettings["Zoom"]); //if (!File.Exists(tFilePath)) { Bitmap resBitmap = null; string[] reg = selectListView.Items[index].SubItems[4].Text.Split(','); DRectangle rect = new DRectangle( Convert.ToInt32(double.Parse(reg[0])), Convert.ToInt32(double.Parse(reg[1])), Convert.ToInt32(double.Parse(reg[2])), Convert.ToInt32(double.Parse(reg[3]))); DRectangle oldRect = rect; if (selectListView.Items[index].SubItems[1].Text == "0") // 正面 { //Bitmap drawBitmap = Utils.DrawRect(bitmapFront, rect, lvList.Items[index].SubItems[7].Text); rect.Inflate(Zoom, Zoom); resBitmap = Utils.BitmapCut(bitmapFront, rect);//.Save(tFilePath); twoSidesPcb.BeginInvoke((Action)(() => { twoSidesPcb.pictureBoxDraw(true, rect); })); } else if (selectListView.Items[index].SubItems[1].Text == "1") // 背面 { //Bitmap drawBitmap = Utils.DrawRect(bitmapBack, rect, lvList.Items[index].SubItems[7].Text); rect.Inflate(Zoom, Zoom); resBitmap = Utils.BitmapCut(bitmapBack, rect);//.Save(tFilePath); twoSidesPcb.BeginInvoke((Action)(() => { twoSidesPcb.pictureBoxDraw(false, rect); })); } DRectangle newRect = new DRectangle(oldRect.X - rect.X - oldRect.Width / 2, oldRect.Y - rect.Y - oldRect.Height / 2, oldRect.Width, oldRect.Height); //resBitmap.Save(tFilePath); partOfPcb.BeginInvoke((Action)(() => { try { partOfPcb.showImgThread(resBitmap, newRect, selectListView.Items[index].SubItems[7].Text); } catch (Exception er) { } })); } } catch (Exception er) { } #endregion }
}//构造开始键图形 private void Stop_Paint(object sender, PaintEventArgs e) { System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); System.Drawing.Rectangle newRectangle = Stop.ClientRectangle; newRectangle.Inflate(-10, -10); e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle); newRectangle.Inflate(1, 1); buttonPath.AddEllipse(newRectangle); Stop.Region = new System.Drawing.Region(buttonPath); }//构造停止键图形
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; } }
protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); System.Drawing.Rectangle newRectangle = this.ClientRectangle; newRectangle.Inflate(-5, -10); pe.Graphics.DrawEllipse(_pen, newRectangle); newRectangle.Inflate(1, 1); buttonPath.AddEllipse(newRectangle); this.Region = new System.Drawing.Region(buttonPath); }
private static void ToNearCircleP(object sender, PaintEventArgs e) { PictureBox btn = sender as PictureBox; System.Drawing.Drawing2D.GraphicsPath btnPath = new System.Drawing.Drawing2D.GraphicsPath(); System.Drawing.Rectangle newRectangle = btn.ClientRectangle; newRectangle.Inflate(-1, -1); e.Graphics.DrawEllipse(System.Drawing.Pens.BlanchedAlmond, newRectangle); newRectangle.Inflate(-1, -1); btnPath.AddEllipse(newRectangle); btn.Region = new System.Drawing.Region(btnPath); }
private void button1_Paint(object sender, PaintEventArgs e) { Button btn = sender as Button; System.Drawing.Drawing2D.GraphicsPath btnPath = new System.Drawing.Drawing2D.GraphicsPath(); System.Drawing.Rectangle newRectangle = btn.ClientRectangle; newRectangle.Inflate(-2, -1); e.Graphics.DrawEllipse(System.Drawing.Pens.BlanchedAlmond, newRectangle); newRectangle.Inflate(-2, -4); btnPath.AddEllipse(newRectangle); btn.Region = new System.Drawing.Region(btnPath); }
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; }
/// <summary> /// Refreshes the shape /// </summary> public override void Invalidate() { if (Site == null) { return; } if (Connectors == null) { return; } // Invalidate the shape mRectangle, pay attention on scroll position and zoom RectangleF r = this.Rectangle; r.Inflate(+3, +3); // padding for selection frame. System.Drawing.Rectangle r2 = System.Drawing.Rectangle.Round(r); r2.Offset(Site.AutoScrollPosition.X, Site.AutoScrollPosition.Y); r2 = Site.ZoomRectangle(r2); r2.Inflate(2, 2); Site.InvalidateRectangle(r2); // Invalidate each connector foreach (Connector c in Connectors) { c.Invalidate(); if (Tracker != null) { foreach (Connection n in c.Connections) { n.Invalidate(); } } } // Invalidate tracker if (Tracker != null) { RectangleF a = Tracker.Grip(new Point(-1, -1)); RectangleF b = Tracker.Grip(new Point(+1, +1)); r2 = System.Drawing.Rectangle.Round(RectangleF.Union(a, b)); r2.Offset(Site.AutoScrollPosition.X, Site.AutoScrollPosition.Y); r2 = Site.ZoomRectangle(r2); r2.Inflate(2, 2); Site.InvalidateRectangle(r2); } }
protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { try { string s = ((string)value); if (string.IsNullOrWhiteSpace(s)) { return; } string[] values = s.Split(':'); if (values.Length != 3) { return; } float.TryParse(values[0], out float low); float.TryParse(values[1], out float mid); float.TryParse(values[2], out float max); float lowPercent = low / max; float midPercent = mid / max; // Draws the cell grid base.Paint(g, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground)); cellBounds.Inflate(-2, -2); if (midPercent > 0.0) { g.FillRectangle(SystemBrushes.GradientInactiveCaption, cellBounds.X, cellBounds.Y, midPercent * cellBounds.Width, cellBounds.Height); } if (lowPercent > 0.0) { cellBounds.Inflate(-1, -1); // Draw the progress bar and the text g.FillRectangle(SystemBrushes.ActiveCaption, cellBounds.X, cellBounds.Y, lowPercent * cellBounds.Width, cellBounds.Height); //g.DrawString(progressVal.ToString() + "%", cellStyle.Font, foreColorBrush, cellBounds.X + (cellBounds.Width / 2) - 5, cellBounds.Y + 2); } //else //{ // // draw the text // if (this.DataGridView.CurrentRow.Index == rowIndex) // g.DrawString(progressVal.ToString() + "%", cellStyle.Font, new SolidBrush(cellStyle.SelectionForeColor), cellBounds.X + 6, cellBounds.Y + 2); // else // g.DrawString(progressVal.ToString() + "%", cellStyle.Font, foreColorBrush, cellBounds.X + 6, cellBounds.Y + 2); //} } catch /*(Exception e) */ { } }
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; }
public override void Draw(CGRect rect) { var g = Graphics.FromCurrentContext (); // NSView does not have a background color so we just use Clear to white here g.Clear (Color.White); CGRect ClientRectangle = rect; var rectangle = new Rectangle ((int)ClientRectangle.X, (int)ClientRectangle.Y, (int)ClientRectangle.Width, (int)ClientRectangle.Height); drawingRectangle = new Rectangle (rectangle.Location, rectangle.Size); drawingRectangle.Inflate (-offset, -offset); //Draw ClientRectangle and drawingRectangle using Pen: g.DrawRectangle (Pens.Red, rectangle); 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: var aPen = new Pen (Color.Green, 3); g.DrawLine (aPen, Point2D (new CGPoint (3, 2)), Point2D (new CGPoint (6, 7))); g.PageUnit = GraphicsUnit.Inch; ClientRectangle = new CGRect(0.5f,0.5f, 1.5f, 1.5f); aPen.Width = 1 / g.DpiX; g.DrawRectangle (aPen, (float)ClientRectangle.X, (float)ClientRectangle.Y, (float)ClientRectangle.Width, (float)ClientRectangle.Height); aPen.Dispose(); g.Dispose(); }
public static void PaindCircleWithUpArrows(Graphics g, Rectangle rect, float thickness, Color color) { using (Pen pen = new Pen(color, thickness)) { g.DrawEllipse(pen, rect); rect.Inflate(1, 1); int x = rect.Width; int y = rect.Height; Point p1 = new Point(); Point p2 = new Point(); p1.X = (3*x)/8; p1.Y = y/2; p2.X = x/2; p2.Y = y/4; g.DrawLine(pen, p1, p2); p1.X = (5*x)/8; p1.Y = y/2; g.DrawLine(pen, p2, p1); p1.X = (3*x)/8; p1.Y = (3*y)/4; p2.X = x/2; p2.Y = y/2; g.DrawLine(pen, p1, p2); p1.X = (5*x)/8; p1.Y = 3*y/4; g.DrawLine(pen, p2, p1); } }
public static void Frame3D(Graphics graphics, Rectangle rc, Color topColor, Color bottomColor, int width) { if(graphics == null) throw new ArgumentNullException("graphics"); Pen pen = new Pen(topColor, 1); pen.Width = 1; while(width > 0) { width--; pen.Color = topColor; Point[] top_pnts = { new Point(rc.Left, rc.Bottom), new Point(rc.Left, rc.Top), new Point(rc.Right, rc.Top) }; graphics.DrawLines(pen, top_pnts); pen.Color = bottomColor; Point[] bottom_pnts = { new Point(rc.Right, rc.Top), new Point(rc.Right, rc.Bottom), new Point(rc.Left, rc.Bottom) }; graphics.DrawLines(pen, bottom_pnts); rc.Inflate(-1, -1); } pen.Dispose(); }
protected virtual Rectangle AddApron(Rectangle rect, int apronRadius, Rectangle maxBounds) { rect.Inflate(apronRadius, apronRadius); rect.Intersect(maxBounds); return rect; }
public override void Draw(RectangleF dirtyRect) { Graphics g = new Graphics(); var ClientRectangle = new Rectangle((int)dirtyRect.X, (int)dirtyRect.Y, (int)dirtyRect.Width, (int)dirtyRect.Height); // Calculate the location and size of the drawing area // Within which we want to draw the graphics: //Rectangle ChartArea = ClientRectangle; Rectangle ChartArea = new Rectangle(50, 50, ClientRectangle.Width - 70, ClientRectangle.Height - 70); g.DrawRectangle(Pens.LightCoral, ChartArea); PlotArea = new Rectangle(ChartArea.Location, ChartArea.Size); PlotArea.Inflate(-offset, -offset); //Draw ClientRectangle and PlotArea using pen: g.DrawRectangle(Pens.Black, PlotArea); // Generate Sine and Cosine data points to plot: PointF[] pt1 = new PointF[nPoints]; PointF[] pt2 = new PointF[nPoints]; for (int i = 0; i < nPoints; i++) { pt1[i] = new PointF(i / 5.0f, (float)Math.Sin(i/5.0f)); pt2[i] = new PointF(i / 5.0f, (float)Math.Cos(i/5.0f)); } for (int i = 1; i < nPoints; i++) { g.DrawLine(Pens.Blue, Point2D(pt1[i - 1]), Point2D(pt1[i])); g.DrawLine(Pens.Red, Point2D(pt2[i - 1]), Point2D(pt2[i])); } g.Dispose(); }
protected void DrawSelectionHandle(RenderInfo info, Point point) { var bounds = new Rectangle(point.X - 4, point.Y - 4, 8, 8); info.Graphics.FillRectangle(Brushes.Gray, bounds); bounds.Inflate(-1, -1); info.Graphics.FillRectangle(Brushes.White, bounds); }
protected override void OnPaint(PaintEventArgs e) { System.Drawing.Rectangle rect = ClientRectangle; Graphics g = e.Graphics; ProgressBarRenderer.DrawHorizontalBar(g, rect); rect.Inflate(-3, -3); if (Value > 0) { // As we doing this ourselves we need to draw the chunks on the progress bar System.Drawing.Rectangle clip = new System.Drawing.Rectangle(rect.X, rect.Y, (int)Math.Round(((float)Value / Maximum) * rect.Width), rect.Height); ProgressBarRenderer.DrawHorizontalChunks(g, clip); } // Set the Display text (Either a % amount or our custom text string text = DisplayStyle == ProgressBarDisplayText.Percentage ? Value.ToString() + '%' : CustomText; using (System.Drawing.Font f = new System.Drawing.Font(FontFamily.GenericSerif, 10)) { SizeF len = g.MeasureString(text, f); // Calculate the location of the text (the middle of progress bar) Point location = new Point(Convert.ToInt32((rect.Width / 2) - (len.Width / 2)) + 20, Convert.ToInt32((rect.Height / 2) - (len.Height / 2)) + 3); // Draw the custom text g.DrawString(text, f, Brushes.Black, location); } }
private static void DrawContent(Graphics g, Rectangle rect, string title, string body) { if (!string.IsNullOrEmpty(title)) { using (Font titleFont = new Font(FontFamily.GenericSansSerif, 18.0f, FontStyle.Bold)) { g.DrawString(title, titleFont, Brushes.Black, rect); //Update the rect to position the body text. SizeF titleSize = g.MeasureString(title, titleFont, rect.Width); int titleHeight = (int)titleSize.Height + 1; rect.Offset(0, titleHeight); rect.Height -= titleHeight; } } if (!string.IsNullOrEmpty(body)) { using (Font bodyFont = new Font(FontFamily.GenericSerif, 12.0f, FontStyle.Regular)) { rect.Inflate(-2, 0); g.DrawString(body, bodyFont, Brushes.Black, rect); } } }
protected void DrawCheckBackground3DLite(PaintEventArgs e, Rectangle bounds, Color checkColor, Color checkBackground, ButtonBaseAdapter.ColorData colors, bool disabledColors) { Graphics graphics = e.Graphics; Color control = checkBackground; if (!this.Control.Enabled && disabledColors) { control = SystemColors.Control; } using (Brush brush = new SolidBrush(control)) { using (Pen pen = new Pen(colors.buttonShadow)) { using (Pen pen2 = new Pen(colors.buttonFace)) { using (Pen pen3 = new Pen(colors.highlight)) { bounds.Width--; bounds.Height--; graphics.DrawPie(pen, bounds, 136f, 88f); graphics.DrawPie(pen, bounds, 226f, 88f); graphics.DrawPie(pen3, bounds, 316f, 88f); graphics.DrawPie(pen3, bounds, 46f, 88f); bounds.Inflate(-1, -1); graphics.FillEllipse(brush, bounds); graphics.DrawEllipse(pen2, bounds); } } } } }
protected void DrawCheckBackgroundFlat(PaintEventArgs e, Rectangle bounds, Color borderColor, Color checkBackground, bool disabledColors) { Color field = checkBackground; Color border = borderColor; if (!Control.Enabled && disabledColors) { border = ControlPaint.ContrastControlDark; field = SystemColors.Control; } float scale = GetDpiScaleRatio(e.Graphics); using( WindowsGraphics wg = WindowsGraphics.FromGraphics(e.Graphics) ) { using( WindowsPen borderPen = new WindowsPen(wg.DeviceContext, border) ) { using( WindowsBrush fieldBrush = new WindowsSolidBrush(wg.DeviceContext, field) ) { // for Dev10 525537, in high DPI mode when we draw ellipse as three rectantles, // the quality of ellipse is poor. Draw it directly as ellipse if(scale > 1.1) { bounds.Width--; bounds.Height--; wg.DrawAndFillEllipse(borderPen, fieldBrush, bounds); bounds.Inflate(-1, -1); } else { DrawAndFillEllipse(wg, borderPen, fieldBrush, bounds); } } } } }
/// <summary> /// LAYOUT DRAWING /// </summary> protected override void Layout() { base.Layout(); rec0 = GH_Convert.ToRectangle(Bounds); rec0.Height += 5; System.Drawing.Rectangle rec1 = rec0; rec1.Width = rec0.Width / 2; rec1.Y = rec0.Bottom - 5; rec1.Height = 5; rec1.Inflate(0, 0); System.Drawing.Rectangle rec2 = rec0; if (rec0.Width % 2 == 0) { rec2.X = rec0.Right - rec0.Width / 2; rec2.Width = rec0.Width / 2; } else { rec2.X = -1 + rec0.Right - rec0.Width / 2; rec2.Width = 1 + rec0.Width / 2; } rec2.Y = rec0.Bottom - 5; rec2.Height = 5; rec2.Inflate(0, 0); Bounds = rec0; ButtonBounds = rec1; ButtonBounds2 = rec2; }
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); }
private void Form1_Layout(object sender, LayoutEventArgs e) { Rect = ClientRectangle; Rect.Inflate(-10, -10); StrSize = string.Format("폭 = {0}, 높이 = {1}", Rect.Width, Rect.Height); Invalidate(); }
private static void InfateRect(ref Rectangle rect) { int x= int.Parse(Console.ReadLine()); int y =int.Parse(Console.ReadLine()); rect.Inflate(x, y); Console.WriteLine(rect); }
private void button2_Paint(object sender, PaintEventArgs e) { Button button = sender as Button; int j = 0; for (int i = 0; i < B.Length; i++) { if (B[i].Name == button.Name) { j = i; } } MessageBox.Show(j.ToString()); System.Drawing.Rectangle newRectangle = button.ClientRectangle; newRectangle.Inflate(-10, -10); e.Graphics.FillEllipse(new SolidBrush(C[j]), newRectangle); if (selected[j] == 1) { e.Graphics.DrawEllipse(new Pen(C[j], 2), newRectangle); } GraphicsPath buttonPath = new GraphicsPath(); buttonPath.AddEllipse(newRectangle); button.Region = new System.Drawing.Region(buttonPath); }
public virtual void DrawSelectionBackground(Graphics dc, Rectangle nodeRect, Node node) { if (m_owner.NodesSelection.Contains(node) || m_owner.FocusedNode == node) { if (!Application.RenderWithVisualStyles) { // have to fill the solid background only before the node is painted dc.FillRectangle(SystemBrushes.FromSystemColor(SystemColors.Highlight), nodeRect); } else { // have to draw the transparent background after the node is painted VisualStyleItemBackground.Style style = VisualStyleItemBackground.Style.Normal; if (m_owner.Focused == false) style = VisualStyleItemBackground.Style.Inactive; VisualStyleItemBackground rendere = new VisualStyleItemBackground(style); rendere.DrawBackground(m_owner, dc, nodeRect); } } if (m_owner.Focused && (m_owner.FocusedNode == node)) { nodeRect.Height += 1; nodeRect.Inflate(-1,-1); ControlPaint.DrawFocusRectangle(dc, nodeRect); } }
protected void DrawCheckBackground3DLite(PaintEventArgs e, Rectangle bounds, Color checkColor, Color checkBackground, ColorData colors, bool disabledColors) { Graphics g = e.Graphics; Color field = checkBackground; if (!Control.Enabled && disabledColors) { field = SystemColors.Control; } using (Brush fieldBrush = new SolidBrush(field)) { using (Pen dark = new Pen(colors.buttonShadow), light = new Pen(colors.buttonFace), lightlight = new Pen(colors.highlight)) { bounds.Width--; bounds.Height--; // fall a little short of SW, NW, NE, SE because corners come out nasty g.DrawPie(dark, bounds, (float)(135 + 1), (float)(90 - 2)); g.DrawPie(dark, bounds, (float)(225 + 1), (float)(90 - 2)); g.DrawPie(lightlight, bounds, (float)(315 + 1), (float)(90 - 2)); g.DrawPie(lightlight, bounds, (float)(45 + 1), (float)(90 - 2)); bounds.Inflate(-1, -1); g.FillEllipse(fieldBrush, bounds); g.DrawEllipse(light, bounds); } } }
// find cities nearest to center within 3 pixel radius private void menuItemMapSearchNearest_Click(object sender, System.EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; System.Drawing.Rectangle rect = mapControl1.Bounds; System.Drawing.Point pt = new System.Drawing.Point(rect.Left, rect.Top); pt.X += rect.Width / 2; pt.Y += rect.Height / 2; SearchInfo si = MapInfo.Mapping.SearchInfoFactory.SearchNearest(_map, pt, 3); IResultSetFeatureCollection fc = _catalog.Search("uscty_1k", si); rect.X = pt.X; rect.Y = pt.Y; rect.Width = 0; rect.Height = 0; rect.Inflate(3, 3); // show search geometry on screen for visual confirmation MapInfo.Geometry.MultiPolygon p = MapInfo.Mapping.SearchInfoFactory.CreateScreenRect(_map, rect); ShowSearchGeometry(p); SelectFeatureCollection(fc); } finally { Cursor.Current = Cursors.Default; } }
private void DrawContent(Graphics graphics, Rectangle rect) { using (LinearGradientBrush brush = new LinearGradientBrush(new Point(0, 0), new Point(rect.Width, rect.Height), Color.White, Color.LightGreen)) { graphics.FillRectangle(brush, rect); } if (!string.IsNullOrEmpty(_title)) { using (Font titleFont = new Font(FontFamily.GenericSansSerif, 18.0f, FontStyle.Bold)) { graphics.DrawString(_title, titleFont, Brushes.Black, rect); // Update the rect to position the body text SizeF titleSize = graphics.MeasureString(_title, titleFont, rect.Width); int titleHeight = (int)titleSize.Height + 1; rect.Offset(0, titleHeight); rect.Height -= titleHeight; } } if (!string.IsNullOrEmpty(_description)) { using (Font bodyFont = new Font(FontFamily.GenericSerif, 12.0f, FontStyle.Regular)) { rect.Inflate(-2, 0); graphics.DrawString(_description, bodyFont, Brushes.Black, rect); } } }
///<summary> ///Default constructor ///</summary> public SimpleShapeBase() : base() { mTextRectangle = Rectangle; mTextRectangle.Inflate(-TextRectangleInflation, -TextRectangleInflation); }
protected override void OnPaint(PaintEventArgs e) { const int inset = 2; using (Image offscreenImage = new Bitmap(this.Width, this.Height)) { using (Graphics offscreen = Graphics.FromImage(offscreenImage)) { Rectangle rect = new Rectangle(0, 0, this.Width, this.Height); if (ProgressBarRenderer.IsSupported) ProgressBarRenderer.DrawHorizontalBar(offscreen, rect); rect.Inflate(new Size(-inset, -inset)); rect.Width = (int)(rect.Width * ((double)this.Value / this.Maximum)); if (rect.Width == 0) rect.Width = 1; LinearGradientBrush brush = new LinearGradientBrush(rect, this.BackColor, this.ForeColor, LinearGradientMode.Vertical); offscreen.FillRectangle(brush, inset, inset, rect.Width, rect.Height); e.Graphics.DrawImage(offscreenImage, 0, 0); offscreenImage.Dispose(); } } }
public override void DrawButton(System.Drawing.Graphics g, System.Drawing.Rectangle rect, System.Windows.Forms.ButtonState buttonState, Syncfusion.Windows.Forms.Grid.GridStyleInfo style) { ControlPaint.DrawButton(g, rect, buttonState); // Icon rect.Inflate(-3, -3); Syncfusion.Drawing.BrushPaint.FillRectangle(g, rect, new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.PathEllipse, Color.Black, Color.Wheat)); }
static private Image CreateDropDownButtonImage() { System.Drawing.Rectangle rect = new System.Drawing.Rectangle(System.Drawing.Point.Empty, new Size(24, 24)); Bitmap bmp = new Bitmap(rect.Width, rect.Height); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; using (System.Drawing.Brush brush = new System.Drawing.SolidBrush(Color.Transparent)) { g.FillRectangle(brush, rect); } using (Pen pen = new Pen(Color.White, 2f)) { pen.StartCap = System.Drawing.Drawing2D.LineCap.Round; pen.EndCap = System.Drawing.Drawing2D.LineCap.Round; rect.Inflate(-2, -2); g.DrawEllipse(pen, rect); rect.Y += 1; int dx = -5; int dy = -7; rect.Inflate(dx, dy); System.Drawing.Point p1, p2; p1 = new System.Drawing.Point(rect.X, rect.Y); p2 = new System.Drawing.Point(rect.X + (rect.Width / 2), rect.Bottom); g.DrawLine(pen, p1, p2); p1 = new System.Drawing.Point(rect.Right, rect.Y); p2 = new System.Drawing.Point(rect.X + (rect.Width / 2), rect.Bottom); g.DrawLine(pen, p1, p2); } return(bmp); }
public void OnPaintTest2(IRenderEventArgs e) { Graphics g = ((GdiSurface)e.Surface).Graphics; SD.Drawing2D.Matrix save = g.Transform; g.Transform = Camera.Matrix.ToGdi(); Rectangle smaller = new Rectangle(start, new Size(50, 20)); Rectangle bigger = new Rectangle(start, new Size(55, 25)); Rectangle rect3 = new Rectangle(start, new Size(10, 10)); g.DrawRectangle(rectPen, smaller); g.DrawRectangle(rectPen, bigger); smaller.Inflate(-5, -5); bigger.Inflate(5, 5); //region.MakeEmpty (); region.MakeEmpty(); invPath.Reset(); invPath.FillMode = FillMode.Alternate; smaller.Intersect(bigger); //region.Intersect (smaller); //invPath.StartFigure (); invPath.AddRectangle(bigger); //invPath.CloseFigure(); //invPath.StartFigure(); invPath.AddRectangle(smaller); //invPath.CloseFigure(); // this is to simulage g.Clip, as it has the bounds-rectangle: region.Union(invPath.GetBounds()); region.Intersect(invPath); Region saveRegion = g.Clip; g.Clip = region; g.DrawPath(pathPen, invPath); //g.FillPath (regionBrush, invPath); g.FillRegion(regionBrush, g.Clip); if (!region.IsVisible(rect3)) { int x = 1; } //g.FillRegion (clipregionBrush, g.Clip); g.Transform = save; g.Clip = saveRegion; }
public override void OnPaint(IRenderEventArgs e) { Graphics g = ((GdiSurface)e.Surface).Graphics; SD.Drawing2D.Matrix save = g.Transform; g.Transform = Camera.Matrix.ToGdi(); Rectangle smaller = new Rectangle(start, new Size(50, 20)); Rectangle bigger = new Rectangle(start, new Size(55, 25)); g.DrawRectangle(rectPen, smaller); g.DrawRectangle(rectPen, bigger); smaller.Inflate(-5, -5); bigger.Inflate(5, 5); Rectangle[] pathRects = { Rectangle.FromLTRB(bigger.Left, bigger.Top, bigger.Right, smaller.Top), Rectangle.FromLTRB(bigger.Left, smaller.Bottom, bigger.Right, bigger.Bottom), Rectangle.FromLTRB(bigger.Left, smaller.Top, smaller.Left, smaller.Bottom), Rectangle.FromLTRB(smaller.Right, smaller.Top, bigger.Right, smaller.Bottom) }; Region clipRegion = new Region(); clipRegion.MakeInfinite(); clipRegion.Intersect( Rectangle.FromLTRB(bigger.Left, bigger.Top, bigger.Right, smaller.Top)); clipRegion.Union( Rectangle.FromLTRB(bigger.Left, smaller.Bottom, bigger.Right, bigger.Bottom)); clipRegion.Union( Rectangle.FromLTRB(bigger.Left, smaller.Top, smaller.Left, smaller.Bottom)); clipRegion.Union( Rectangle.FromLTRB(smaller.Right, smaller.Top, bigger.Right, smaller.Bottom)); bool isVisible = false; RectangleF testRect = Rectangle.Inflate(smaller, -1, -1); isVisible = clipRegion.IsVisible(testRect); if (isVisible) { clipRegion.MakeInfinite(); } invPath.Reset(); invPath.FillMode = FillMode.Alternate; invPath.AddRectangles(pathRects); g.DrawPath(pathPen, invPath); g.FillPath(regionBrush, invPath); }
protected override void Layout() { base.Layout(); System.Drawing.Rectangle rec0 = GH_Convert.ToRectangle(Bounds); rec0.Height += 22; System.Drawing.Rectangle rec1 = rec0; rec1.Y = rec1.Bottom - 22; rec1.Height = 22; rec1.Inflate(-2, -2); Bounds = rec0; ButtonBounds = rec1; }
/// <summary> /// Draws the frame selection if Selected property is true. /// </summary> /// <param name="document">Informations transferred from DrawingPanel.</param> /// <param name="e">PaintEventArgs.</param> protected override void DrawSelection(IDocument document, PaintEventArgs e) { if (!Shape.Visible || !IsValidGeometric(Shape.Geometric)) { return; } System.Drawing.Rectangle outside = System.Drawing.Rectangle.Round(Shape.Geometric.GetBounds()); System.Drawing.Rectangle inside = outside; outside.Inflate(GrabberDimension / 2, GrabberDimension / 2); inside.Inflate(-GrabberDimension / 2, -GrabberDimension / 2); ControlPaint.DrawSelectionFrame(e.Graphics, true, outside, inside, document.DrawingControl.BackColor); }
protected override void Layout() { base.Layout(); System.Drawing.Rectangle componentRect = GH_Convert.ToRectangle(Bounds); componentRect.Height += buttonHeight; System.Drawing.Rectangle buttonRect = componentRect; buttonRect.Y = buttonRect.Bottom - buttonHeight; buttonRect.Height = buttonHeight; buttonRect.Inflate(-3, -3); // Shrink button bounds for cleaner insert Bounds = componentRect; ButtonBounds = buttonRect; }
protected override void OnPaint(PaintEventArgs e) { System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); // Set a new rectangle to the same size as the button's // ClientRectangle property. System.Drawing.Rectangle newRectangle = this.ClientRectangle; // Increase the size of the rectangle to include the border. newRectangle.Inflate(1, 1); // Set the button's Region property to the newly created // circle region. this.Region = new System.Drawing.Region(awesomium.CreateRoundRect(newRectangle, 10, AwesomiumBase.RectangleCorners.All)); base.OnPaint(e); }
internal static void DrawDropShadow(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, int radius, System.Drawing.Color color) { graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; using (System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(color.A / 4, color.R, color.G, color.B))) { for (int i = 0; i < 4; i++) { bounds.Inflate(-1, -1); using (System.Drawing.Drawing2D.GraphicsPath graphicsPath = Skybound.VisualTips.Rendering.VisualTipRenderer.CreateRoundRectPath(bounds, radius, Skybound.VisualTips.Rendering.VisualTipRenderer.BorderCorners.All)) { graphics.FillPath(brush, graphicsPath); } } } graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; }
internal void DrawControl(System.Drawing.Graphics g) { System.Drawing.Brush brush; if (!Visible) { return; } System.Drawing.Rectangle rectangle1 = ClientRectangle; System.Drawing.Rectangle rectangle2 = DisplayRectangle; if (mBackColor == System.Drawing.Color.Transparent) { brush = new System.Drawing.SolidBrush(Parent.BackColor); } else { brush = new System.Drawing.SolidBrush(mBackColor); } g.FillRectangle(brush, rectangle1); brush.Dispose(); System.Drawing.Size size = System.Windows.Forms.SystemInformation.Border3DSize; int i1 = size.Width; System.Drawing.Pen pen = new System.Drawing.Pen(_BorderColor); rectangle2.Inflate(i1, i1); g.DrawRectangle(pen, rectangle2); pen.Dispose(); for (int i2 = 0; i2 < TabCount; i2++) { DrawTab(g, TabPages[i2], i2); } if (SelectedTab != null) { System.Windows.Forms.TabPage tabPage = SelectedTab; //tabPage.BackColor; pen = new System.Drawing.Pen(_TagPageSelectedColor); rectangle2.Offset(1, 1); rectangle2.Width -= 2; rectangle2.Height -= 2; g.DrawRectangle(pen, rectangle2); rectangle2.Width--; rectangle2.Height--; g.DrawRectangle(pen, rectangle2); pen.Dispose(); } }
private void bandedGridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { System.Drawing.Rectangle r = e.Bounds; Brush ellipseBrush = Brushes.DimGray; e.Graphics.DrawRectangle(new Pen(ellipseBrush, 0.5f), r); r.Width -= 12; e.Appearance.DrawString(e.Cache, e.DisplayText, r); e.Handled = true; if (bandedGridView1.IsEditing && bandedGridView1.FocusedColumn == e.Column && bandedGridView1.FocusedRowHandle == e.RowHandle) { System.Drawing.Rectangle rect = e.Bounds; rect.Inflate(new Size(1, 1)); e.Graphics.FillRectangle(Brushes.Red, rect); e.Handled = true; } }
/// <summary> /// 渲染控件边框 /// </summary> /// <param name="g">绘图画面</param> /// <param name="TabArea">绘制的区域</param> public virtual void RenderTabPanelBorder(System.Drawing.Graphics g, System.Drawing.Rectangle TabArea) { Pen border1 = new Pen(Color.FromArgb(19, 28, 37)); //Pen border1 = new Pen(Color.FromArgb(0,255,0)); g.DrawRectangle(border1, TabArea); border1.Dispose(); //内边框 Pen border2 = new Pen(Color.FromArgb(91, 125, 170)); //Pen border2 = new Pen(Color.FromArgb(255,0,0)); TabArea.Inflate(-1, -1); g.DrawRectangle(border2, TabArea); //g.DrawRectangle(border2,tabArea.X+1,tabArea.Y+1,tabArea.Width-3,tabArea.Height-3); border2.Dispose(); }
/// <summary> /// Calculates the rectangular region used for text display. /// </summary> /// <returns>returns the rectangular region for the text display</returns> private System.Drawing.Rectangle GetTextDestinationRect() { System.Drawing.Rectangle ImageRect = GetImageDestinationRect(); System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, 0, 0); switch (this.ImageAlign) { case System.Drawing.ContentAlignment.BottomCenter: rect = new System.Drawing.Rectangle(0, 0, this.Width, ImageRect.Top); break; case System.Drawing.ContentAlignment.BottomLeft: rect = new System.Drawing.Rectangle(0, 0, this.Width, ImageRect.Top); break; case System.Drawing.ContentAlignment.BottomRight: rect = new System.Drawing.Rectangle(0, 0, this.Width, ImageRect.Top); break; case System.Drawing.ContentAlignment.MiddleCenter: rect = new System.Drawing.Rectangle(0, ImageRect.Bottom, this.Width, this.Height - ImageRect.Bottom); break; case System.Drawing.ContentAlignment.MiddleLeft: rect = new System.Drawing.Rectangle(ImageRect.Right, 0, this.Width - ImageRect.Right, this.Height); break; case System.Drawing.ContentAlignment.MiddleRight: rect = new System.Drawing.Rectangle(0, 0, ImageRect.Left, this.Height); break; case System.Drawing.ContentAlignment.TopCenter: rect = new System.Drawing.Rectangle(0, ImageRect.Bottom, this.Width, this.Height - ImageRect.Bottom); break; case System.Drawing.ContentAlignment.TopLeft: rect = new System.Drawing.Rectangle(0, ImageRect.Bottom, this.Width, this.Height - ImageRect.Bottom); break; case System.Drawing.ContentAlignment.TopRight: rect = new System.Drawing.Rectangle(0, ImageRect.Bottom, this.Width, this.Height - ImageRect.Bottom); break; } rect.Inflate(-this.Padding, -this.Padding); return(rect); }
protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); System.Drawing.Rectangle WordCloud = new System.Drawing.Rectangle(ClientRectangle.Location, ClientRectangle.Size); WordCloud.Y = ControlTop; WordCloud.Height -= ControlTop; WordCloud.Inflate(-1, -1); m_WordCloud.Location = WordCloud.Location; m_WordCloud.Size = WordCloud.Size; Win32.RemoveBorder(m_WordCloud.Handle); Win32.RemoveClientEdge(m_WordCloud.Handle); Invalidate(true); }
public static double GetInkInside(Stroke s) { double numIntersections = 0; int numPoints = s.GetPoints().Length; System.Drawing.Rectangle rect1 = s.GetBoundingBox(); rect1.Inflate(rect1.Width / 5, rect1.Height / 5); StrokeIntersection[] intersections1 = s.GetRectangleIntersections(rect1); foreach (StrokeIntersection intersection in intersections1) { int beginIndex = (intersection.BeginIndex != -1 ? (int)intersection.BeginIndex : 0); int endIndex = (intersection.EndIndex != -1 ? (int)intersection.EndIndex : numPoints - 1); numIntersections += (endIndex - beginIndex + 1); } return(numIntersections); }
private void buttonDecimal_Paint(object sender, PaintEventArgs e) { try { System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); System.Drawing.Rectangle newRectangle = buttonDecimal.ClientRectangle; newRectangle.Inflate(0, 0); buttonPath = CreateRoundedRectanglePath(newRectangle); Pen pen = new Pen(Brushes.Black); pen.Width = 2.0F; pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; e.Graphics.DrawPath(pen, buttonPath); buttonDecimal.Region = new System.Drawing.Region(buttonPath); } catch (Exception err) { ConsoleWriteLine(err.ToString()); } }