public static Inflate ( Rectangle rect, int x, int y ) : Rectangle | ||
rect | Rectangle | |
x | int | |
y | int | |
return | 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); }
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); } } }
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; }
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); } } }
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); }
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); }
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 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; } }
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; }
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; }
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); }
///<summary> ///Default constructor ///</summary> public SimpleShapeBase() : base() { mTextRectangle = Rectangle; mTextRectangle.Inflate(-TextRectangleInflation, -TextRectangleInflation); }
private void Form1_Layout(object sender, LayoutEventArgs e) { Rect = ClientRectangle; Rect.Inflate(-10, -10); StrSize = string.Format("폭 = {0}, 높이 = {1}", Rect.Width, Rect.Height); Invalidate(); }
protected virtual Rectangle AddApron(Rectangle rect, int apronRadius, Rectangle maxBounds) { rect.Inflate(apronRadius, apronRadius); rect.Intersect(maxBounds); return rect; }
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 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); } } } } }
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); } }
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); }
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(); }
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); } }
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); } } }
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); }
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); } } } } }
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); } } }
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(); } } }