private void panel_topo_Paint(object sender, PaintEventArgs e) { GraphicsPath PastaGrafica = new GraphicsPath(); PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, 1, panel_topo.Size.Width, panel_topo.Size.Height)); //Arredondar canto superior esquerdo PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, 1, 10, 10)); PastaGrafica.AddPie(1, 1, 20, 20, 180, 90); //Arredondar canto superior direito PastaGrafica.AddRectangle(new System.Drawing.Rectangle(panel_topo.Width - 12, 1, 12, 13)); PastaGrafica.AddPie(panel_topo.Width - 24, 1, 24, 26, 270, 90); //Arredondar canto inferior esquerdo PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, panel_topo.Height - 10, 10, 10)); PastaGrafica.AddPie(1, panel_topo.Height - 20, 20, 20, 90, 90); //Arredondar canto inferior direito PastaGrafica.AddRectangle(new System.Drawing.Rectangle(panel_topo.Width - 12, panel_topo.Height - 13, 13, 13)); PastaGrafica.AddPie(panel_topo.Width - 24, panel_topo.Height - 26, 24, 26, 0, 90); PastaGrafica.SetMarkers(); panel_topo.Region = new Region(PastaGrafica); }
private void FillRegion() { GraphicsPath path = new GraphicsPath(); path.AddEllipse(0, 0, Width, Height); switch (_movement) { case MovementWay.Right: path.AddPie(0, 0, Width, Height, 310, 100); break; case MovementWay.Left: path.AddPie(0, 0, Width, Height, 130, 100); break; case MovementWay.Up: path.AddPie(0, 0, Width, Height, 220, 100); break; case MovementWay.Down: path.AddPie(0, 0, Width, Height, 40, 100); break; } Region = new Region(path); }
public void ArredondaCantosdoForm() { using (GraphicsPath PastaGrafica = new GraphicsPath()) { PastaGrafica.AddRectangle(new Rectangle(1, 1, Size.Width, Size.Height)); //Arredondar canto superior esquerdo PastaGrafica.AddRectangle(new Rectangle(1, 1, 10, 10)); PastaGrafica.AddPie(1, 1, 20, 20, 180, 90); //Arredondar canto superior direito PastaGrafica.AddRectangle(new Rectangle(Width - 12, 1, 12, 13)); PastaGrafica.AddPie(Width - 24, 1, 24, 26, 270, 90); //Arredondar canto inferior esquerdo PastaGrafica.AddRectangle(new Rectangle(1, Height - 10, 10, 10)); PastaGrafica.AddPie(1, Height - 20, 20, 20, 90, 90); //Arredondar canto inferior direito PastaGrafica.AddRectangle(new Rectangle(Width - 12, Height - 13, 13, 13)); PastaGrafica.AddPie(Width - 24, Height - 26, 24, 26, 0, 90); PastaGrafica.SetMarkers(); Region = new Region(PastaGrafica); }; }
private void Frm_Checkout_Load(object sender, EventArgs e) { GraphicsPath PastaGrafica = new GraphicsPath(); PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, 1, this.Size.Width, this.Size.Height)); //Arredondar canto superior esquerdo PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, 1, 10, 10)); PastaGrafica.AddPie(1, 1, 20, 20, 180, 90); //Arredondar canto superior direito PastaGrafica.AddRectangle(new System.Drawing.Rectangle(this.Width - 12, 1, 12, 13)); PastaGrafica.AddPie(this.Width - 24, 1, 24, 26, 270, 90); //Arredondar canto inferior esquerdo PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, this.Height - 10, 10, 10)); PastaGrafica.AddPie(1, this.Height - 20, 20, 20, 90, 90); //Arredondar canto inferior direito PastaGrafica.AddRectangle(new System.Drawing.Rectangle(this.Width - 12, this.Height - 13, 13, 13)); PastaGrafica.AddPie(this.Width - 24, this.Height - 26, 24, 26, 0, 90); PastaGrafica.SetMarkers(); this.Region = new Region(PastaGrafica); }
private void SetFormDesigh() { // フォームの境界線、タイトルバーを無しに設定 this.FormBorderStyle = FormBorderStyle.None; // フォームの角を丸くする var radius = 40; var diameter = radius * 2; var gp = new GraphicsPath(); // 左上 gp.AddPie(0, 0, diameter, diameter, 180, 90); // 右上 gp.AddPie(this.Width - diameter, 0, diameter, diameter, 270, 90); // 左下 gp.AddPie(0, this.Height - diameter, diameter, diameter, 90, 90); // 右下 gp.AddPie(this.Width - diameter, this.Height - diameter, diameter, diameter, 0, 90); // 中央 gp.AddRectangle(new Rectangle(radius, 0, this.Width - diameter, this.Height)); // 左 gp.AddRectangle(new Rectangle(0, radius, radius, this.Height - diameter)); // 右 gp.AddRectangle(new Rectangle(this.Width - radius, radius, radius, this.Height - diameter)); this.Region = new Region(gp); }
public GraphicsPath graphicsPath(TextBox txt) { GraphicsPath gp = new GraphicsPath(); gp.AddRectangle(new System.Drawing.Rectangle(1, 1, txt.Size.Width, txt.Size.Height)); //Arredondar canto superior esquerdo gp.AddRectangle(new System.Drawing.Rectangle(1, 1, 10, 10)); gp.AddPie(1, 1, 20, 20, 180, 90); //Arredondar canto superior direito gp.AddRectangle(new System.Drawing.Rectangle(txt.Width - 12, 1, 12, 13)); gp.AddPie(txt.Width - 24, 1, 24, 26, 270, 90); //Arredondar canto inferior esquerdo gp.AddRectangle(new System.Drawing.Rectangle(1, txt.Height - 10, 10, 10)); gp.AddPie(1, txt.Height - 20, 20, 20, 90, 90); //Arredondar canto inferior direito gp.AddRectangle(new System.Drawing.Rectangle(txt.Width - 12, txt.Height - 13, 13, 13)); gp.AddPie(txt.Width - 24, txt.Height - 26, 24, 26, 0, 90); gp.SetMarkers(); return(gp); }
private void FillRegion() { GraphicsPath path = new GraphicsPath(); path.AddEllipse(0, 0, this.Width, this.Height); switch (_Movement) { case MovementWay.Right: path.AddPie(0, 0, this.Width, this.Height, 310, 100); break; case MovementWay.Left: path.AddPie(0, 0, this.Width, this.Height, 130, 100); break; case MovementWay.Up: path.AddPie(0, 0, this.Width, this.Height, 220, 100); break; case MovementWay.Down: path.AddPie(0, 0, this.Width, this.Height, 40, 100); break; } this.Region = new System.Drawing.Region(path); }
private void panel1_Paint(object sender, PaintEventArgs e) { GraphicsPath PastaGrafica = new GraphicsPath(); PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, 1, panel1.Size.Width, panel1.Height)); //Arredondar canto superior esquerdo PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, 1, 10, 10)); PastaGrafica.AddPie(1, 1, 20, 20, 180, 90); //Arredondar canto superior direito PastaGrafica.AddRectangle(new System.Drawing.Rectangle(panel1.Width - 12, 1, 12, 13)); PastaGrafica.AddPie(panel1.Width - 24, 1, 24, 26, 270, 90); //Arredondar canto inferior esquerdo PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, panel1.Height - 10, 10, 10)); PastaGrafica.AddPie(1, panel1.Height - 20, 20, 20, 90, 90); //Arredondar canto inferior direito PastaGrafica.AddRectangle(new System.Drawing.Rectangle(panel1.Width - 12, panel1.Height - 13, 13, 13)); PastaGrafica.AddPie(panel1.Width - 24, panel1.Height - 26, 24, 26, 0, 90); PastaGrafica.SetMarkers(); panel1.Region = new Region(PastaGrafica); using (LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle, Color.Orange, Color.Black, 90F)) { e.Graphics.FillRectangle(brush, this.ClientRectangle); } }
private void CreateSweepGradient(ColorBlend blend) { GraphicsPath path = new GraphicsPath(); //Point[] points = new Point[] { // new Point(0, 0), new Point(AnimationConfig.Width, 0), // new Point(AnimationConfig.Width, AnimationConfig.Height), new Point(0, AnimationConfig.Height) //}; //path.AddPolygon(points); //PathGradientBrush tempBrush = new PathGradientBrush(path); //tempBrush.CenterPoint = new PointF(AnimationConfig.Width / 2, AnimationConfig.Height); //tempBrush.CenterColor = Color.Red; //tempBrush.SurroundColors = new Color[]{Color.Pink, Color.Blue, Color.Yellow, Color.Cyan}; path.AddPie(0, 0, AnimationConfig.Width, AnimationConfig.Height, 0, 45); path.AddPie(0, 0, AnimationConfig.Width, AnimationConfig.Height, 0, -45); PathGradientBrush tempBrush = new PathGradientBrush(path); tempBrush.CenterPoint = new PointF(AnimationConfig.Width / 2, AnimationConfig.Height / 2); tempBrush.CenterColor = Color.Red; tempBrush.SurroundColors = new Color[] { Color.Blue, Color.Yellow }; brush = tempBrush; pen = new Pen(brush); }
public void ArredondaCantosdoForm() { GraphicsPath PastaGrafica = new GraphicsPath(); PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, 1, this.Size.Width, this.Size.Height)); //Arredondar canto superior esquerdo PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, 1, 10, 10)); PastaGrafica.AddPie(1, 1, 20, 20, 180, 90); //Arredondar canto superior direito PastaGrafica.AddRectangle(new System.Drawing.Rectangle(this.Width - 12, 1, 12, 13)); PastaGrafica.AddPie(this.Width - 14, 1, 24, 26, 270, 90); //Arredondar canto inferior esquerdo PastaGrafica.AddRectangle(new System.Drawing.Rectangle(1, this.Height - 10, 10, 10)); PastaGrafica.AddPie(1, this.Height - 10, 20, 20, 90, 90); //Arredondar canto inferior direito PastaGrafica.AddRectangle(new System.Drawing.Rectangle(this.Width - 12, this.Height - 13, 13, 13)); PastaGrafica.AddPie(this.Width - 14, this.Height - 26, 24, 26, 0, 90); PastaGrafica.SetMarkers(); this.Region = new Region(PastaGrafica); }
protected override void PreRendering(Graphics targetGraphics) { base.PreRendering(targetGraphics); var path = new GraphicsPath(); float angle = ValueAsFloat * 360; path.AddPie(0, 0, Width, Height, -90, angle); path.AddPie(Width * .085f, Height * .085f, Width * .83f, Height * .83f, -90, angle); targetGraphics.FillPath(new SolidBrush(ForeColor), path); }
private void PictureBox1_Paint(object sender, PaintEventArgs e) { Graphics figure = e.Graphics; figure.DrawEllipse(Pens.Black, centerX - R1, centerY - R1, D1, D1); figure.DrawEllipse(Pens.Black, centerX - R2, centerY - R2, D2, D2); figure.DrawEllipse(Pens.Black, centerX - R2, centerY, D1, D1); Pen lineX = new Pen(Color.Black, 2) { CustomEndCap = new AdjustableArrowCap(5, 5) }, lineY = new Pen(Color.Black, 2) { CustomEndCap = new AdjustableArrowCap(5, 5) }, lineDiag = new Pen(Color.Black, 2), lineStrih = new Pen(Color.Black, 2); figure.DrawLine(lineX, 50, centerY, pictureBox1.Width - 50, centerY); figure.DrawLine(lineY, centerX, pictureBox1.Height - 50, centerX, 50); figure.DrawLine(lineDiag, centerX - R2, centerY + R2, centerX + R2 + 10, centerY - R2 - 10); lineStrih.DashStyle = DashStyle.Dash; figure.DrawLine(lineStrih, centerX, centerY - R2, centerX + R2, centerY - R2); figure.DrawLine(lineStrih, centerX + R2, centerY, centerX + R2, centerY - R2); figure.FillEllipse(Brushes.Black, centerX - R1 - 5, centerY - 5, 10, 10); figure.FillEllipse(Brushes.Black, centerX - 5, centerY + R1 - 5, 10, 10); figure.FillEllipse(Brushes.Black, centerX + R2 - 5, centerY - 5, 10, 10); figure.FillEllipse(Brushes.Black, centerX + R2 - 5, centerY - R2 - 5, 10, 10); GraphicsPath gp1 = new GraphicsPath(); gp1.AddPie(centerX - R2, centerY - R2, D2, D2, 270, 45); gp1.AddPie(centerX - R1, centerY - R1, D1, D1, 270, 45); Region r1 = new Region(gp1); GraphicsPath gp2 = new GraphicsPath(); gp2.AddPie(centerX - R2, centerY, D1, D1, -45, 180); GraphicsPath gp3 = new GraphicsPath(); gp3.AddPie(centerX - R2, centerY - R2, D2, D2, 90, 45); gp3.AddEllipse(centerX - R1, centerY - R1, D1, D1); Region r2 = new Region(gp2); Region r3 = new Region(gp3); r2.Intersect(r3); figure.FillRegion(br1, r1); figure.FillRegion(br2, r2); }
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.PixelOffsetMode = PixelOffsetMode.HighQuality; //soundIcon is 16x16 Rectangle rpie = new Rectangle(2, 0, 12, 12); Rectangle rrect = new Rectangle(0, 4, 4, 4); GraphicsPath soundPath = new GraphicsPath(FillMode.Winding); soundPath.AddPie(rpie, 90, 180); soundPath.AddRectangle(rrect); g.FillPath(BrushNormal, soundPath); Matrix mTransform = new Matrix(); mTransform.Translate(Width - 20, 0); soundPath.Transform(mTransform); g.FillPath(BrushNormal, soundPath); GraphicsPath trackPath = new GraphicsPath(FillMode.Winding); trackPath.AddPie(18, 5, BAR_THICKNESS + 1, BAR_THICKNESS, 90, 180); trackPath.AddRectangle(new Rectangle(20, 5, Width - 50, BAR_THICKNESS)); trackPath.AddPie(Width - 32, 5, BAR_THICKNESS, BAR_THICKNESS, 270, 180); g.FillPath(BrushNormal, trackPath); /* Draw Trackball ====*==== */ int barLength = Width - 32 - 18; CircleRect.X = ((fPosition * barLength) / 100) + 18; g.FillEllipse(BrushCircle, CircleRect); g.DrawEllipse(CircleStroke, CircleRect); if (inClientArea) { g.FillRectangle(BrushNormal, VolumeTextRect); g.DrawString(fPosition.ToString(), Font, BrushCircle, VolumeTextRect, VolumeTextFormat); } g.PixelOffsetMode = PixelOffsetMode.Default; g.DrawLine(CircleStroke, Width - 10, 4, Width - 10, 8); g.DrawLine(CircleStroke, Width - 8, 2, Width - 8, 10); base.OnPaint(e); }
public static void RoundShape(this Control ctl, float CirRay = 14f) { var gr = new GraphicsPath(); gr.AddPie(0, 0, CirRay, CirRay, 180f, 90f); gr.AddPie(ctl.Width - CirRay, 0, CirRay, CirRay, 270f, 90f); gr.AddPie(0, ctl.Height - CirRay, CirRay, CirRay, 90f, 90f); gr.AddPie(ctl.Width - CirRay, ctl.Height - CirRay, CirRay, CirRay, 0f, 90f); gr.AddRectangle(new Rectangle((int)CirRay / 2, 0, (int)(ctl.Width - CirRay), (int)ctl.Height)); gr.AddRectangle(new Rectangle(0, (int)CirRay / 2, (int)CirRay / 2, (int)(ctl.Height - CirRay))); gr.AddRectangle(new Rectangle((int)(ctl.Width - CirRay / 2), (int)CirRay / 2, (int)CirRay / 2, (int)(ctl.Height - CirRay))); ctl.Region = new Region(gr); }
static private GraphicsPath Pie() { GraphicsPath path = new GraphicsPath(); path.AddPie(20, 20, 200, 200, 60, 120); return(path); }
protected override void DrawFillGradient(PaintArgs p, Rectangle rect, Point[] points) { GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddPie(rect, (float)this.StartAngle, (float)this.SweepAngle); p.Graphics.FillGradientPath(rect, graphicsPath, base.GradientStartColor, base.GradientStopColor, base.ModeAngle, 1f, false); }
public void Method23(PaintEventArgs e) { Graphics myGraphics = e.Graphics; // <snippet23> SolidBrush mySolidBrush = new SolidBrush(Color.Aqua); GraphicsPath myGraphicsPath = new GraphicsPath(); Point[] myPointArray = { new Point(15, 20), new Point(20, 40), new Point(50, 30) }; FontFamily myFontFamily = new FontFamily("Times New Roman"); PointF myPointF = new PointF(50, 20); StringFormat myStringFormat = new StringFormat(); myGraphicsPath.AddArc(0, 0, 30, 20, -90, 180); myGraphicsPath.AddCurve(myPointArray); myGraphicsPath.AddString("a string in a path", myFontFamily, 0, 24, myPointF, myStringFormat); myGraphicsPath.AddPie(230, 10, 40, 40, 40, 110); myGraphics.FillPath(mySolidBrush, myGraphicsPath); myGraphics.DrawPath(myPen, myGraphicsPath); // </snippet23> }
public void Method103(PaintEventArgs e) { Graphics myGraphics = e.Graphics; // <snippet103> GraphicsPath myGraphicsPath = new GraphicsPath(); Point[] myPointArray = { new Point(5, 30), new Point(20, 40), new Point(50, 30) }; FontFamily myFontFamily = new FontFamily("Times New Roman"); PointF myPointF = new PointF(50, 20); StringFormat myStringFormat = new StringFormat(); myGraphicsPath.AddArc(0, 0, 30, 20, -90, 180); myGraphicsPath.StartFigure(); myGraphicsPath.AddCurve(myPointArray); myGraphicsPath.AddString("a string in a path", myFontFamily, 0, 24, myPointF, myStringFormat); myGraphicsPath.AddPie(230, 10, 40, 40, 40, 110); myGraphics.DrawPath(myPen, myGraphicsPath); // </snippet103> }
public override void Create() { base.Create(); GraphicsPath.StartFigure(); GraphicsPath.AddPie(X1, Y1, Width, Height, startAngle, sweepAngle); GraphicsPath.CloseFigure(); }
public override GraphicsPath GetGraphicsPath(int left, int top) { GraphicsPath p = new GraphicsPath(); p.AddPie(left, top, Width, Height, StartAngle, SweepAngle); return(p); }
/// <summary> /// Constructs all GraphicsPaths which represent every face of the slice. /// These GraphicsPaths are centered at (0,0), and a transform is applied to the Graphics /// object which draws the GraphicsPaths. /// </summary> private void ConstructPaths() { SizeF offset = OffsetSize; // create the bottom face bottomFace = new GraphicsPath(); bottomFace.AddPie(offset.Width - Control.Style.EllipseWidth, offset.Height - Control.Style.EllipseHeight, 2 * Control.Style.EllipseWidth, 2 * Control.Style.EllipseHeight, (float)(TransformedStartAngle * 180 / Math.PI), (float)(TransformedSweepAngle * 180 / Math.PI)); // create the top face topFace = new GraphicsPath(); topFace.AddPie(offset.Width - Control.Style.EllipseWidth, -Control.Style.VisualThickness + offset.Height - Control.Style.EllipseHeight, 2 * Control.Style.EllipseWidth, 2 * Control.Style.EllipseHeight, (float)(TransformedStartAngle * 180 / Math.PI), (float)(TransformedSweepAngle * 180 / Math.PI)); // create the interior start face if it is visible if (StartAngle >= Math.PI / 2 && StartAngle <= 3 * Math.PI / 2) { startFace = CreateInteriorFace(StartAngle, out startFaceEdges); } else { startFace = null; } // create the interior end face if it is visible if (EndAngle >= 3 * Math.PI / 2 || EndAngle <= Math.PI / 2) { endFace = CreateInteriorFace(EndAngle, out endFaceEdges); } else { endFace = null; } // create the exterior face exteriorFace = CreateExteriorFace(out exteriorFaceEdges); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; g.Clear(this.BackColor); GraphicsPath gp1 = new GraphicsPath(); GraphicsPath gp2 = new GraphicsPath(); float xInnerPos = -innerRadius / 2f + this.Width / 2f; float yInnerPos = -innerRadius / 2f + this.Height / 2f; float xOuterPos = -outerRadius / 2f + this.Width / 2f; float yOuterPos = -outerRadius / 2f + this.Height / 2f; if (innerRadius != 0.0) { gp1.AddPie(xInnerPos, yInnerPos, innerRadius, innerRadius, startAngle, sweepAngle); } gp2.AddPie(xOuterPos, yOuterPos, outerRadius, outerRadius, startAngle, sweepAngle); Region rg1 = new System.Drawing.Region(gp1); Region rg2 = new System.Drawing.Region(gp2); g.DrawPath(Pens.Transparent, gp1); g.DrawPath(Pens.Transparent, gp2); rg1.Xor(rg2); g.FillRegion(Brushes.Black, rg1); this.Region = rg1; }
public bool DrawGraphicPathClipDrawingArea(Graphics graphics, Rectangle clientAreaOfForm, string pictureToUseBg) { int rectangleX = clientAreaOfForm.Width; int rectangleY = clientAreaOfForm.Height; GraphicsPath graphicsPath = new GraphicsPath(); Rectangle boundaryOfForm = new Rectangle(0, 0, rectangleX, rectangleY); graphicsPath.AddPie(boundaryOfForm, 40, 370); graphics.SetClip(graphicsPath); Pen pen = new Pen(Color.Blue, 10); try { graphics.DrawImage(Image.FromFile(pictureToUseBg), boundaryOfForm); } catch { return(false); } graphics.DrawPath(pen, graphicsPath); return(true); }
public override void SetDimension(int Width, int Height) { base.SetDimension(Width, Height); // save refeence to old ones Bitmap oldBitmap = Image; Graphics oldGraphics = g; // create new ones Image = new Bitmap(Width, Height); g = Graphics.FromImage(Image); GraphicsPath gpath = new GraphicsPath(); gpath.AddPie(0, 0, Width, Height, 0, 360); gpath.CloseFigure(); g.Clip = new Region(gpath); // let outer world release the old one RaiseImageChanged(); // cleanup old ones oldBitmap.Dispose(); oldGraphics.Dispose(); }
public Form1() { InitializeComponent(); Graphics g = CreateGraphics(); Rectangle r = this.ClientRectangle; GraphicsPath path = new GraphicsPath(); path.AddPie(r, 50, 50); this.Region = new Region(path); this.BackColor = Color.DarkRed; Rectangle bRect = button1.ClientRectangle; bRect.Inflate(-5, -5); path.AddEllipse(bRect); button1.Region = new Region(path); button1.FlatStyle = FlatStyle.Popup; button1.BackColor = Color.Red; button1.Click += Button1_Click; button1.MouseEnter += Button1_MouseEnter; button1.MouseLeave += Button1_MouseLeave; }
/// <summary> /// Draws the filled arc. /// </summary> /// <param name="grp">The GRP.</param> /// <param name="color">The color.</param> /// <param name="startAngle">The start angle.</param> private void DrawFilledArc(Graphics grp, Color color, int startAngle) { grp.SmoothingMode = smoothing; Rectangle main = this.ClientRectangle; // If there is no region to be drawn, then this method terminates itself if (main.Width - (2 * this._ringThickness) < 1 || main.Height - (2 * this._ringThickness) <= 1) { return; } // Calculates the region that will be filled GraphicsPath outerPath = new GraphicsPath(); outerPath.AddPie(main, startAngle, this.PieAngle); Rectangle sub = new Rectangle(main.X + this._ringThickness, main.Y + this._ringThickness, main.Width - (2 * this._ringThickness), main.Height - (2 * this._ringThickness)); GraphicsPath innerPath = new GraphicsPath(); innerPath.AddPie(sub, startAngle - 1, this.PieAngle + 2); System.Drawing.Region mainRegion = new Region(outerPath); System.Drawing.Region subRegion = new Region(innerPath); mainRegion.Exclude(subRegion); // Fill that region grp.FillRegion(new SolidBrush(color), mainRegion); }
public static void FillSector(this RenderTarget renderTarget, RawVector2 pos, float radius, Color color, float angleStart, float angleEnd) { PointF[] pathPoints; using (GraphicsPath path = new GraphicsPath()) { radius *= 2f; path.AddPie(pos.X - (radius / 2f), pos.Y - (radius / 2f), radius, radius, angleStart, angleEnd); path.Flatten(); pathPoints = path.PathPoints; path.Dispose(); } using (SharpDX.Direct2D1.Factory factory = renderTarget.Factory) { PathGeometry geometry = new PathGeometry(factory); if (pathPoints.Length > 1) { GeometrySink sink = geometry.Open(); sink.SetSegmentFlags(PathSegment.ForceRoundLineJoin); sink.BeginFigure(new RawVector2(pathPoints[0].X, pathPoints[0].Y), FigureBegin.Filled); for (int i = 1; i < pathPoints.Length; i++) { sink.AddLine(new RawVector2(pathPoints[i].X, pathPoints[i].Y)); } sink.EndFigure(FigureEnd.Closed); sink.Close(); sink.Dispose(); } SolidColorBrush brush = new SolidColorBrush(renderTarget, color.ToRawColor4(1f)); renderTarget.FillGeometry(geometry, brush); brush.Dispose(); geometry.Dispose(); } }
private void Render() { // bkGroundPath1 = new GraphicsPath(); // bkGroundPath2 = new GraphicsPath(); // valuePath = new GraphicsPath(); // freGroundPath = new GraphicsPath(); bkGroundPath1.Reset(); bkGroundPath2.Reset(); valuePath.Reset(); freGroundPath.Reset(); bkGroundPath1.AddPie(new Rectangle(0, 0, size, size), 0, 360); //just in case... if (sliceCount == 0) { sliceCount = 12; } float sliceAngle = 360 / sliceCount; float sweepAngle = sliceAngle - 5; for (int i = 0; i < sliceCount; i++) { if (value != i) { valuePath.AddPie(0, 0, size, size, i * sliceAngle, sweepAngle); } } bkGroundPath2.AddPie( (size / 2 - size * blockRatio), (size / 2 - size * blockRatio), (blockRatio * 2 * size), (blockRatio * 2 * size), 0, 360); freGroundPath.AddPie(new Rectangle(0, 0, size, size), value * sliceAngle, sweepAngle); Invalidate(); }
private void UpdateHitRegion() { if (boundingBox.Size == Size.Empty) { return; } try { using (GraphicsPath path = new GraphicsPath()) { path.AddPie(boundingBox, start, sweep); if (hitRegion != null) { hitRegion.Dispose(); } hitRegion = new Region(path); } } catch (Exception) { log.DebugFormat("Error while computing hit region of angle helper."); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; g.Clear(this.BackColor); GraphicsPath gp1 = new GraphicsPath(); GraphicsPath gp2 = new GraphicsPath(); gp1.AddPie(0, 0, this.Width, this.Height, 0, 90); gp2.AddPie(this.Width / 4f, this.Height / 4f, this.Width / 2f, this.Height / 2f, 0, 90); Region rg1 = new System.Drawing.Region(gp1); Region rg2 = new System.Drawing.Region(gp2); g.DrawPath(Pens.Transparent, gp1); g.DrawPath(Pens.Transparent, gp2); rg1.Xor(rg2); g.FillRegion(Brushes.Black, rg1); this.Region = rg1; }