public static void RenderEllipseGlass(Graphics g, Rectangle ownerRect, GlassPosition position, float positionFactor, Color glassColor, int alphaCenter, int alphaSurround) { if (!(positionFactor > 0 && positionFactor < 1)) throw new ArgumentException("positionFactor must be between 0 and 1, but not include 0 and 1. ", "positionFactor"); ownerRect.Height--; ownerRect.Width--; if (ownerRect.Width < 1 || ownerRect.Height < 1) return; using (GraphicsPath gp = new GraphicsPath()) { gp.AddEllipse(ownerRect); using (PathGradientBrush pb = new PathGradientBrush(gp)) { pb.CenterPoint = GetEllipseGlassCenterPoint(ownerRect, position, positionFactor); pb.CenterColor = Color.FromArgb(alphaCenter, glassColor); pb.SurroundColors = new Color[] { Color.FromArgb(alphaSurround, glassColor) }; using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias)) { g.FillPath(pb, gp); } } } }
private static GraphicsPath GenerateCapsule( this Graphics graphics, RectangleF rectangle ) { float diameter; RectangleF arc; GraphicsPath path = new GraphicsPath(); try { if( rectangle.Width > rectangle.Height ) { diameter = rectangle.Height; SizeF sizeF = new SizeF( diameter, diameter ); arc = new RectangleF( rectangle.Location, sizeF ); path.AddArc( arc, 90, 180 ); arc.X = rectangle.Right - diameter; path.AddArc( arc, 270, 180 ); } else if( rectangle.Width < rectangle.Height ) { diameter = rectangle.Width; SizeF sizeF = new SizeF( diameter, diameter ); arc = new RectangleF( rectangle.Location, sizeF ); path.AddArc( arc, 180, 180 ); arc.Y = rectangle.Bottom - diameter; path.AddArc( arc, 0, 180 ); } else path.AddEllipse( rectangle ); } catch { path.AddEllipse( rectangle ); } finally { path.CloseFigure(); } return path; }
/// <summary> /// Изчертава елипсите. /// </summary> /// <param name="graphics"></param> public override void DrawYourSelf(Graphics graphics) { GraphicsPath path = new GraphicsPath(); path.StartFigure(); path.AddEllipse(Location.X + ModelSize.Width / 3, Location.Y + ModelSize.Height / 3, ModelSize.Width / 3, ModelSize.Height / 3); path.CloseFigure(); path.StartFigure(); path.AddLine(Location.X + (ModelSize.Width * 2) / 3, Location.Y + ModelSize.Height / 2, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 2); path.CloseFigure(); path.AddEllipse(new RectangleF(Location, ModelSize)); path.CloseFigure(); path.Transform(this.TMatrix.TransformationMatrix); /* * Създава се Pen, който изчертава контура, като използва * цвят и дебелина (определят се от конструктора) */ Pen pen = new Pen(this.BorderColor, this.BorderWidth); // Правим същото, но за запълването if (IS_FILLED) { SolidBrush brush = new SolidBrush(this.FillColor); graphics.FillPath(brush, path); } graphics.DrawPath(pen, path); if (this.Selected) { this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds())); this.selectionUnit.DrawYourSelf(graphics); } }
private void Form1_Load(object sender, EventArgs e) { GraphicsPath path = new GraphicsPath(); path.AddEllipse(0, 0, this.Width, this.Height); path.AddEllipse(100, 100, 100, 100); this.Region = new Region(path); }
public Form1() { InitializeComponent(); Path = new GraphicsPath(); Path.FillMode = FillMode.Winding; Path.AddEllipse(50, 30, 100, 100); Path.AddEllipse(20, 95, 160, 140); Region Rgn = new Region(Path); Region = Rgn; }
private GraphicsPath GetCapsule(RectangleF baseRect) { float diameter; RectangleF arc; GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); try { if (baseRect.Width > baseRect.Height) { // return horizontal capsule diameter = baseRect.Height; SizeF sizeF = new SizeF(diameter, diameter); arc = new RectangleF(baseRect.Location, sizeF); path.AddArc(arc, 90, 180); arc.X = baseRect.Right - diameter; path.AddArc(arc, 270, 180); } else if (baseRect.Width < baseRect.Height) { // return vertical capsule diameter = baseRect.Width; SizeF sizeF = new SizeF(diameter, diameter); arc = new RectangleF(baseRect.Location, sizeF); path.AddArc(arc, 180, 180); arc.Y = baseRect.Bottom - diameter; path.AddArc(arc, 0, 180); } else { // return circle path.AddEllipse(baseRect); } } catch (Exception ex) { Console.WriteLine(ex.Message); path.AddEllipse(baseRect); } finally { path.CloseFigure(); } return(path); }
protected override GraphicsPath GeneratePath() { GraphicsPath path = new GraphicsPath(); path.AddEllipse( Location.X, Location.Y, Size.Width, Size.Height); return path; }
public override void DrawYourSelf(Graphics graphics) { GraphicsPath path = new GraphicsPath(); path.StartFigure(); path.AddLine(Location.X, Location.Y + ModelSize.Height / 3, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 3); path.CloseFigure(); path.StartFigure(); path.AddLine(Location.X, Location.Y + (ModelSize.Height / 3) * 2, Location.X + ModelSize.Width, Location.Y + (ModelSize.Height * 2) / 3); path.CloseFigure(); path.AddEllipse(new RectangleF(Location, ModelSize)); path.CloseFigure(); path.Transform(this.TMatrix.TransformationMatrix); Pen pen = new Pen(this.BorderColor, this.BorderWidth); if (IS_FILLED) { SolidBrush brush = new SolidBrush(this.FillColor); graphics.FillPath(brush, path); } graphics.DrawPath(pen, path); if (this.Selected) { this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds())); this.selectionUnit.DrawYourSelf(graphics); } }
private void drawCircle(Point startPoint) { Rectangle rect = new Rectangle(); int width = 100; rect.X = startPoint.X - width / 2; rect.Y = startPoint.Y - width / 2; rect.Width = width; rect.Height = width; this.BackColor = Color.Yellow; this.Opacity = 1; //Graphics g = CreateGraphics(); //g.DrawRectangle(Pens.Yellow, rcScreen); //g.FillRectangle(Brushes.Yellow, rcScreen); //Pen p = new Pen(Color.Yellow, 10); //g.DrawEllipse(p, rect); System.Drawing.Drawing2D.GraphicsPath testPath = new System.Drawing.Drawing2D.GraphicsPath(); testPath.AddEllipse(rect); System.Drawing.Drawing2D.GraphicsPath testPath2 = new System.Drawing.Drawing2D.GraphicsPath(); testPath2.AddEllipse(rect.X + 10, rect.Y + 10, rect.Width - 20, rect.Height - 20); Region region = new Region(rcScreen); region.Intersect(testPath); region.Exclude(testPath2); this.Region = region; }
protected void RoundControl(Control control) { var path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddEllipse(0, 0, control.Width, control.Height); control.Region = new Region(path); }
//檢查是否與圖案有交集 public override bool ContainsInShape(int x, int y) { GraphicsPath path = new GraphicsPath(); path.FillMode = FillMode.Winding; path.AddEllipse(new Rectangle(_locationOfTopPoint.X + _moveingXOffset, _locationOfTopPoint.Y + _moveingYOffset, Wideth, Height)); return path.IsVisible(x, y); }
private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Point[] points = { new Point(5,10) , new Point(23 , 130), new Point(130 , 57) }; GraphicsPath path = new GraphicsPath(); path.StartFigure(); path.AddEllipse(170 , 170 , 100 , 50); g.FillPath(Brushes.Black, path); path.CloseFigure(); path.StartFigure(); path.AddCurve(points , 0.5F); g.FillPath(Brushes.Blue, path); //coords g.TranslateTransform(40, 40); Point A = new Point(0, 0); Point B = new Point(150 , 150); g.DrawLine(new Pen(Brushes.Black, 3), A, B); g.Dispose(); }
// // GET: /ChartImage/ public void Render(List<int> a) { int pieWidth = 400, pieHeight=400; using(Bitmap bmp = new Bitmap(ImageWidth, ImageHeight)) using(Graphics g = Graphics.FromImage(bmp)) using(Font font = new Font(FontFamily, 1f)){ g.Clear(BackgroundColor); GraphicsPath path = new GraphicsPath(); //return Content(a.Count().ToString()); if (a[0]==0){ //TODO: add text that chart is empty. SolidBrush p = new SolidBrush(ColorTranslator.FromHtml("#40BF40")); path.AddEllipse((ImageWidth - pieWidth) / 2, (ImageHeight - pieHeight) / 2, pieWidth, pieHeight); g.FillPath(p, path); } g.Flush(); Response.ContentType = "image/png"; using(var memoryStream = new MemoryStream()){ bmp.Save(memoryStream, ImageFormat.Png); memoryStream.WriteTo(Response.OutputStream); } } }
public override GraphicsPath GetGraphicsPath(int left, int top) { GraphicsPath p = new GraphicsPath(); Rectangle r = new Rectangle(left, top, Width, Height); p.AddEllipse(r); return p; }
private void Utilisateur_Load(object sender, EventArgs e) { ////////////// //this.listUtilisateur.Columns[0].Visible = false; //PictureBox en format Circulaire System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddEllipse(0, 0, photo.Width - 3, photo.Height - 3); Region rg = new Region(gp); photo.Region = rg; // Connection.CONNECTER(); Connection.dtadapter = new SqlDataAdapter("select * from utilisateur", Connection.con); Connection.dtset = new DataSet(); Connection.dtadapter.Fill(Connection.dtset, "utilisateur"); listUtilisateur.DataSource = Connection.dtset.Tables["utilisateur"]; ///DataGrid View Design listUtilisateur.BorderStyle = BorderStyle.None; listUtilisateur.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249); listUtilisateur.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal; listUtilisateur.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise; listUtilisateur.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke; listUtilisateur.BackgroundColor = Color.White; listUtilisateur.EnableHeadersVisualStyles = false; listUtilisateur.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; listUtilisateur.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72); listUtilisateur.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; }
private static Bitmap StripImage(Bitmap bitmap) { var result = bitmap.Clone() as Bitmap; if (result == null) { return null; } var g = Graphics.FromImage(result); using (Brush br = new SolidBrush(Color.Black)) { g.FillRectangle(br, 0, 0, bitmap.Width, bitmap.Height); } var path = new GraphicsPath(); var offsetX = (float)(bitmap.Width * 0.85); var offsetY = (float)(bitmap.Height * 0.85); path.AddEllipse(offsetX, offsetY, bitmap.Width - 2 * offsetX, bitmap.Width - 2 * offsetY); g.SetClip(path); g.DrawImage(bitmap, 0, 0); return result; }
public override bool ClickableAt(int x, int y) { Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height); int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS) + 10; Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR); // If we clicked inside the rectangle and it's visible we are clickable at. if (!Color.Transparent.Equals(fillColor)) { if (Contains(x, y)) { return true; } } // check the rest of the lines if (lineThickness > 0) { using (Pen pen = new Pen(Color.White, lineThickness)) { using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(rect); return path.IsOutlineVisible(x, y, pen); } } } else { return false; } }
private void CustRoundButton_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 = this.ClientRectangle; // Decrease the size of the rectangle. newRectangle.Inflate(-10, -10); // 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(2, 2); //1 1 // Create a circle within the new rectangle. buttonPath.AddEllipse(newRectangle); // Set the button's Region property to the newly created // circle region. this.Region = new System.Drawing.Region(buttonPath); }
public static System.Drawing.Brush GetBrush(this Brush brush, Rect frame) { var cb = brush as SolidBrush; if (cb != null) { return new System.Drawing.SolidBrush (cb.Color.GetColor ()); } var lgb = brush as LinearGradientBrush; if (lgb != null) { var s = lgb.Absolute ? lgb.Start : frame.Position + lgb.Start * frame.Size; var e = lgb.Absolute ? lgb.End : frame.Position + lgb.End * frame.Size; var b = new System.Drawing.Drawing2D.LinearGradientBrush (GetPointF (s), GetPointF (e), System.Drawing.Color.Black, System.Drawing.Color.Black); var bb = BuildBlend (lgb.Stops); if (bb != null) { b.InterpolationColors = bb; } return b; } var rgb = brush as RadialGradientBrush; if (rgb != null) { var r = rgb.GetAbsoluteRadius (frame); var c = rgb.GetAbsoluteCenter (frame); var path = new GraphicsPath (); path.AddEllipse (GetRectangleF (new Rect (c - r, 2 * r))); var b = new PathGradientBrush (path); var bb = BuildBlend (rgb.Stops, true); if (bb != null) { b.InterpolationColors = bb; } return b; } throw new NotImplementedException ("Brush " + brush); }
public override GraphicsPath MakePath() { GraphicsPath path1 = new GraphicsPath(FillMode.Winding); RectangleF ef1 = this.Bounds; path1.AddEllipse(ef1.X, ef1.Y, ef1.Width, ef1.Height); return path1; }
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 RenderFrameByCenter(PaintEventArgs e, Rectangle r) { Graphics g = e.Graphics; using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(GaugeFrame.Bounds); using (PathGradientBrush br = new PathGradientBrush(path)) { br.CenterPoint = GaugeFrame.Center; br.CenterColor = GaugeFrame.FrameColor.Start; br.SurroundColors = new Color[] { GaugeFrame.FrameColor.End }; br.SetSigmaBellShape(GaugeFrame.FrameSigmaFocus, GaugeFrame.FrameSigmaScale); g.FillEllipse(br, GaugeFrame.Bounds); } path.AddEllipse(r); using (PathGradientBrush br = new PathGradientBrush(path)) { br.CenterPoint = GaugeFrame.Center; br.CenterColor = GaugeFrame.FrameColor.End; br.SurroundColors = new Color[] { GaugeFrame.FrameColor.Start }; g.FillEllipse(br, r); } } RenderFrameBorder(g); }
/// <summary> /// Проверяет попадание точки в фигуру /// </summary> /// <param name="p"></param> /// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns> public override int ContainsPoint(Point p) { if (this.IsSelected) { for (int i = 1; i <= KeyPoints.Length; i++) { if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p)) return i; } } var path = new GraphicsPath(); Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness); Rectangle rect = NormalRectToSquare(PaintHelper.NormalizeRect(StartPoint, EndPoint)); path.AddEllipse(rect); path.Widen(pen); Region region = new Region(path); pen.Dispose(); if(region.IsVisible(p)) return 0; Point center = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2); double radius = rect.Width / 2; float dx = p.X - center.X; float dy = p.Y - center.Y; if (Math.Sqrt(dx * dx + dy * dy) <= radius) return 0; return -1; }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddEllipse(0, 0, this.Width, this.Height); this.Region = new Region(path); }
public static void PaintVignette(Graphics g, Rectangle bounds) { Rectangle ellipsebounds = bounds; ellipsebounds.Offset(-ellipsebounds.X, -ellipsebounds.Y); int x = ellipsebounds.Width - (int)Math.Round(.70712 * ellipsebounds.Width); int y = ellipsebounds.Height - (int)Math.Round(.70712 * ellipsebounds.Height); ellipsebounds.Inflate(x, y); using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(ellipsebounds); using (PathGradientBrush brush = new PathGradientBrush(path)) { brush.WrapMode = WrapMode.Tile; brush.CenterColor = Color.FromArgb(0, 0, 0, 0); brush.SurroundColors = new Color[] { Color.FromArgb(255, 0, 0, 0) }; Blend blend = new Blend(); blend.Positions = new float[] { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0F }; blend.Factors = new float[] { 0.0f, 0.5f, 1f, 1f, 1.0f, 1.0f }; brush.Blend = blend; Region oldClip = g.Clip; g.Clip = new Region(bounds); g.FillRectangle(brush, ellipsebounds); g.Clip = oldClip; } } }
public override GraphicsPath Get() { var shape = new GraphicsPath(); var bounds = new Rectangle(this.state.Left, this.state.Top, this.state.Width, this.state.Height); shape.AddEllipse(bounds); return shape; }
private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; //Создаем массив точек Point[] points = { new Point(5, 10), new Point(23, 130), new Point(130, 57)}; GraphicsPath path = new GraphicsPath(); //рисуем первую траекторию path.StartFigure(); path.AddEllipse(170, 170, 100, 50); // заливаем траекторию цветом g.FillPath(Brushes.Aqua, path); //рисуем вторую траекторию path.StartFigure(); path.AddCurve(points, 0.5F); path.AddArc(100, 50, 100, 100, 0, 120); path.AddLine(50, 150, 50, 220); // Закрываем траекторию path.CloseFigure(); //рисуем четвертую траекторию path.StartFigure(); path.AddArc(180, 30, 60, 60, 0, -170); g.DrawPath(new Pen(Color.Blue, 3), path); g.Dispose(); }
private void propertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { PropertyGrid props = (PropertyGrid)s; try { TextBox propTxt = (TextBox)props.SelectedObject; //PropertyCategories propLine = (PropertyCategories)props.SelectedObject; if (propTxt != null) { System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddEllipse(0, 0, propTxt.Width - 1, propTxt.Height - 1); Region myRegion = new Region(myPath); propTxt.Region = myRegion; } } catch { } try { PropertyCategories propLine = (PropertyCategories)props.SelectedObject; reDrawAll(); } catch { } }
public void child_Paint(object sender, PaintEventArgs e) { GraphicsPath path = new GraphicsPath(); path.AddEllipse(this.ClientRectangle); Region region = new Region(path); this.Region = region; }
// The following code example demonstrates how to construct and // use a region. // This example is designed to be used with Windows Forms. // Paste the code to a form and call the FillRegionExcludingPath // method when handling the form's Paint event, passing e as // PaintEventArgs. //<snippet1> private void FillRegionExcludingPath(PaintEventArgs e) { // Create the region using a rectangle. Region myRegion = new Region(new Rectangle(20, 20, 100, 100)); // Create the GraphicsPath. System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); // Add a circle to the graphics path. path.AddEllipse(50, 50, 25, 25); // Exclude the circle from the region. myRegion.Exclude(path); // Retrieve a Graphics object from the form. Graphics formGraphics = e.Graphics; // Fill the region in blue. formGraphics.FillRegion(Brushes.Blue, myRegion); // Dispose of the path and region objects. path.Dispose(); myRegion.Dispose(); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { GraphicsPath grPath = new GraphicsPath(); grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height); this.Region = new System.Drawing.Region(grPath); base.OnPaint(e); }
public ItemStream() { InitializeComponent(); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddEllipse(0, 0, imageItem.Width, imageItem.Height); imageItem.Region = new Region(path); }
/// <summary>Make stop sign</summary> /// <param name="size"></param> /// <returns></returns> private static GraphicsPath MakeStop(Size size) { var stop = new System.Drawing.Drawing2D.GraphicsPath(); stop.AddEllipse(0, 0, size.Width, size.Height); return(stop); }
protected override void OnPaint(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. Rectangle newRectangle = 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. Region = new System.Drawing.Region(buttonPath); base.OnPaint(e); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); GraphicsPath buttonPath = new GraphicsPath(); // Set a new rectangle to the same size as the button's // ClientRectangle property. System.Drawing.Rectangle newRectangle = 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. Region = new System.Drawing.Region(buttonPath); }
// Draw the new button. protected override void OnPaint(PaintEventArgs e) { GraphicsPath grPath = new GraphicsPath(); grPath.AddEllipse(10, 10, 60, 60); this.Region = new System.Drawing.Region(grPath); base.OnPaint(e); }
/// <summary> /// Draws a breakpoint icon in the margin. /// </summary> /// <param name="g">The <see cref="Graphics"/> context.</param> /// <param name="rectangle">The bounding rectangle.</param> /// <param name="isEnabled"><c>true</c> if enabled..</param> /// <param name="willBeHit"><c>true</c> if it will be hit.</param> public static void DrawBreakpoint(Graphics g, Rectangle rectangle, bool isEnabled, bool willBeHit) { int diameter = Math.Min(rectangle.Width - 4, rectangle.Height); Rectangle rect = new Rectangle(2, rectangle.Y + (rectangle.Height - diameter) / 2, diameter, diameter); using (GraphicsPath path = new GraphicsPath()) { path.AddEllipse(rect); using (PathGradientBrush pthGrBrush = new PathGradientBrush(path)) { pthGrBrush.CenterPoint = new PointF(rect.Left + rect.Width / 3, rect.Top + rect.Height / 3); pthGrBrush.CenterColor = Color.MistyRose; Color[] colors = { willBeHit ? Color.Firebrick : Color.Olive }; pthGrBrush.SurroundColors = colors; if (isEnabled) { g.FillEllipse(pthGrBrush, rect); } else { g.FillEllipse(SystemBrushes.Control, rect); using (Pen pen = new Pen(pthGrBrush)) { g.DrawEllipse(pen, new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2)); } } } } }
///<summary> /// Creates a <see cref="PathPointSymbolizer"/> that renders ellipses. ///</summary> ///<param name="line">The pen to outline the ellipse</param> ///<param name="fill">the brush to fill the ellipse</param> ///<param name="a">The x-axis radius of the ellipse</param> ///<param name="b">The x-axis radius of the ellipse</param> ///<returns>The PathPointSymbolizer object</returns> public static PathPointSymbolizer CreateEllipse(Pen line, Brush fill, float a, float b) { GraphicsPath path = new GraphicsPath(); path.AddEllipse(0, 0, a, b); return new PathPointSymbolizer( new[] { new PathDefinition { Line = line, Fill = fill, Path = path } }); }
void SetBackground(Color color) { Bitmap bmp_image = new Bitmap(Canvas.Width, Canvas.Height); Graphics g = Graphics.FromImage(bmp_image); g.SmoothingMode = SmoothingMode.AntiAlias; int rect_width = 1120; for (int i = 0; i < 360; i += 36) { g.FillPie(new SolidBrush(Color.Black), new Rectangle(center.X - (int)rect_width / 2, center.Y - (int)rect_width / 2, (int)rect_width, (int)rect_width), i, 18); } GraphicsPath gp = new GraphicsPath(); gp.AddEllipse(center.X - rect_width / 2 - 40, center.Y - rect_width / 2, rect_width, rect_width); gp.CloseFigure(); PathGradientBrush pgb = new PathGradientBrush(gp); pgb.CenterColor = Color.FromArgb(220, /*152, 35, 149*/color); pgb.SurroundColors = new Color[] { Color.FromArgb(30, Color.White) }; g.FillPath(pgb, gp); Canvas.BackgroundImage = bmp_image; }
private void Form3_Paint(object sender, PaintEventArgs e) { GraphicsPath MYPATH = new GraphicsPath(); // 将椭圆添加到路径对象中 MYPATH.AddEllipse(20, 30, this.Width - 30, this.Height - 40); //使用韩国椭圆构造一个区域,并将此区域作为程序窗体区域 this.Region = new Region(MYPATH); }
private void btnChangeShape_Click(object sender, EventArgs e) { if (hasNormalRegion) { GraphicsPath p = new GraphicsPath(); int bigDiameter = this.ClientSize.Height; int donutWidth = 100; p.AddEllipse(0, 0, bigDiameter, bigDiameter); p.AddEllipse(donutWidth, donutWidth, bigDiameter - (donutWidth * 2), bigDiameter - (donutWidth * 2)); this.Region = new Region(p); } else { this.Region = null; } hasNormalRegion = !hasNormalRegion; }
private void Form1_Load(object sender, EventArgs e) { System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddEllipse(0, 0, this.Width, this.Height); Region myRegion = new Region(myPath); this.Region = myRegion; }
private void CheckImage_Click(object sender, EventArgs e) { System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddEllipse(this.pictureBox1.ClientRectangle); Region reg = new Region(path); this.pictureBox1.Region = reg; }
//============================ Override Events ================================ protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e);//重載paint事件 System.Drawing.Drawing2D.GraphicsPath _path = new System.Drawing.Drawing2D.GraphicsPath(); _path.AddEllipse(new Rectangle(0, 0, 30, 30)); Region = new Region(_path); //改變形狀 e.Graphics.DrawEllipse(new Pen(Color.Maroon, 7), new Rectangle(0, 0, 30, 30)); //畫出外框 }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { GraphicsPath grPath = new GraphicsPath(); grPath.AddEllipse(1, 1, 5, 5); this.Region = new System.Drawing.Region(grPath); base.OnPaint(e); }
private void ProfilePic() { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddEllipse(0, 0, pbProfilePic.Width - 1, pbProfilePic.Height - 1); Region rg = new Region(gp); pbProfilePic.Region = rg; }
private void Form1_Load(object sender, EventArgs e) { System.Drawing.Drawing2D.GraphicsPath Button_Path = new System.Drawing.Drawing2D.GraphicsPath(); Button_Path.AddEllipse(0, 0, this.button1.Width, this.button1.Height); Region Button_Region = new Region(Button_Path); this.button1.Region = Button_Region; }
protected override void OnResize(EventArgs e) { using (var path = new System.Drawing.Drawing2D.GraphicsPath()) { path.AddEllipse(0, 0, this.Width, this.Height); this.Region = new System.Drawing.Region(path); } base.OnResize(e); }
private void ImgView_Load(object sender, EventArgs e) { System.Drawing.Drawing2D.GraphicsPath myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath(); //myGraphicsPath.AddEllipse(new Rectangle(0, 0, 125, 125)); //myGraphicsPath.AddEllipse(new Rectangle(75, 75, 20, 20)); myGraphicsPath.AddEllipse(new Rectangle(2, -30, 96, 94)); //myGraphicsPath.AddEllipse(new Rectangle(145, 75, 20, 20)); this.imgButton1.Region = new Region(myGraphicsPath); }
public static void BordasCirculos(Control obj) { using (GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath()) { gp.AddEllipse(0, 0, obj.Width - 3, obj.Height - 3); Region rg = new Region(gp); obj.Region = rg; } }
private void EditProfile_Load(object sender, EventArgs e) { //PictureBox en format Circulaire System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddEllipse(0, 0, photo.Width - 3, photo.Height - 3); Region rg = new Region(gp); photo.Region = rg; }
protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); using (System.Drawing.Drawing2D.GraphicsPath g = new System.Drawing.Drawing2D.GraphicsPath()) { g.AddEllipse(0, 0, this.Width, this.Height); this.Region = new Region(g); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddEllipse(2, 2, this.Width - 6, this.Height - 6); Graphics g = e.Graphics; g.DrawEllipse(new Pen(Color.Black, 2), 2, 2, Width - 6, Height - 6); Region = new Region(path); }
protected override void OnPaint(PaintEventArgs e) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); System.Drawing.Rectangle r = new Rectangle((int)((size.Width * 101 / 768)), (int)(size.Height * 3 / 576), (int)(size.Width * 568 / 768), (int)(size.Width * 568 / 768)); e.Graphics.DrawEllipse(Pens.Transparent, r);//после нужного вам результата замените - Pens.Transparent gp.AddEllipse(r); Region = new System.Drawing.Region(gp); }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddEllipse(0, 0, pictureBox1.Width - 3, pictureBox1.Height - 3); Region rg = new Region(gp); pictureBox1.Region = rg; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; }
public Region Circle(int width, int height) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddEllipse(0, 0, width - 3, height - 3); //using (var gp = new GraphicsPath()) //{ // gp.AddEllipse(new Rectangle(0, 0, width - 1, height - 1)); return(new Region(gp)); //} }
public int newTextBox() { TextBox txtBox = new TextBox(); try { //txtBox[nNumCurrentTextBox] = new TextBox(); V.Add(new Vertex(txtBox)); } catch { //Array.Resize<TextBox>(ref txtBox, nCurrentSize + nReSize); //nCurrentSize = nCurrentSize + nReSize; //To Do не ресайзится } //int CursorX = Cursor.Position.X; //int CursorY = Cursor.Position.Y; //.Location.X не работает??? а так как сделал не правильно //txtBox[nNumCurrentTextBox].Left = CursorX; //txtBox[nNumCurrentTextBox].Top = CursorY; txtBox.Location = new System.Drawing.Point(Ox, Oy); txtBox.Multiline = true; txtBox.Width = 60; txtBox.Height = 60; txtBox.BackColor = Color.Silver; txtBox.TextAlign = HorizontalAlignment.Center; //To Do по центру надо а тут сверху System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddEllipse(0, 0, txtBox.Width - 1, txtBox.Height - 1); Region myRegion = new Region(myPath); txtBox.Region = myRegion; txtBox.Text = Convert.ToString(nNumCurrentTextBox); // Пропушим себя ещё чтоб знать чо кликать txtBox.MouseDown += delegate(object sender, MouseEventArgs e) { clickVertex(sender, e); }; txtBox.MouseMove += delegate(object sender, MouseEventArgs e) { setMouseMove(sender, e); }; txtBox.MouseUp += delegate(object sender, MouseEventArgs e) { isDragOff(sender, e); }; //txtBox.SizeChanged += delegate(object sender, EventArgs e) //{ reElipse(sender, e); }; txtBox.Parent = sheet; nNumCurrentTextBox++; return(0); }
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); }
public Bunifu.Framework.UI.BunifuThinButton2 AddNewBubble(String txt, String Sender) { Bunifu.Framework.UI.BunifuThinButton2 box = new Bunifu.Framework.UI.BunifuThinButton2(); System.Windows.Forms.Label lbl = new System.Windows.Forms.Label(); System.Windows.Forms.Label lblSender = new System.Windows.Forms.Label(); System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); System.Windows.Forms.PictureBox pb = new System.Windows.Forms.PictureBox(); int[] posX = new int[2]; pb.Image = Image.FromFile(@"D:\Danes\BotHealth\Images\icon.jpg"); lblSender.Text = Sender; lbl.Text = txt; lbl.Font = new Font("Arial", 11, FontStyle.Regular); lblSender.Font = new Font("Arial", 9, FontStyle.Regular); lblSender.ForeColor = Color.DarkSlateGray; lbl.AutoSize = lblSender.AutoSize = true; lblSender.MaximumSize = new Size(300, 15); lbl.MaximumSize = new Size(300, 0); box.Size = new Size(lbl.PreferredSize.Width + 20, lbl.PreferredSize.Height + 20); box.ButtonText = ""; pnlDisplay.Controls.Add(lblSender); pnlDisplay.Controls.Add(lbl); pnlDisplay.Controls.Add(box); if (Sender.ToLower() == "me") { posX[0] = this.Size.Width - box.Size.Width - 40; posX[1] = this.Size.Width - lblSender.Size.Width - 44; box.ActiveFillColor = box.ActiveLineColor = box.IdleFillColor = box.IdleLineColor = lbl.BackColor = Color.SeaGreen; lbl.ForeColor = Color.WhiteSmoke; } else { posX[0] = posX[1] = 50; box.ActiveFillColor = box.ActiveLineColor = box.IdleFillColor = box.IdleLineColor = lbl.BackColor = Color.WhiteSmoke; lbl.ForeColor = Color.SeaGreen; pnlDisplay.Controls.Add(pb); pb.BackColor = Color.GhostWhite; pb.Size = new Size(45, 45); gp.AddEllipse(0, 0, pb.Width - 3, pb.Height - 3); Region rg = new Region(gp); pb.Region = rg; } box.Location = new System.Drawing.Point(posX[0], (n + 10) - pnlDisplay.VerticalScroll.Value); lbl.Location = new System.Drawing.Point(posX[0] + 10, (n + 20) - pnlDisplay.VerticalScroll.Value); lblSender.Location = new System.Drawing.Point(posX[1] + 2, (n) - pnlDisplay.VerticalScroll.Value); pb.Location = new System.Drawing.Point(5, (n - 10) - pnlDisplay.VerticalScroll.Value); n += box.Size.Height + lblSender.Size.Height; for (int i = 1; (i < 3) && (pnlDisplay.VerticalScroll.Maximum != 100); i++) { pnlDisplay.VerticalScroll.Value = pnlDisplay.VerticalScroll.Maximum; } return(box); }
public LedShow() { this.Size = new Size(40, 40); this.BackColor = Color.Transparent; this.BackgroundImageLayout = ImageLayout.Stretch; this.BackgroundImage = Properties.Resources.None; using (System.Drawing.Drawing2D.GraphicsPath g = new System.Drawing.Drawing2D.GraphicsPath()) { g.AddEllipse(0, 0, this.Width, this.Height); this.Region = new Region(g); } }