/// <summary> /// Renders a label to the map. /// </summary> /// <param name="g">Graphics reference</param> /// <param name="LabelPoint">Label placement</param> /// <param name="Offset">Offset of label in screen coordinates</param> /// <param name="font">Font used for rendering</param> /// <param name="forecolor">Font forecolor</param> /// <param name="backcolor">Background color</param> /// <param name="halo">Color of halo</param> /// <param name="rotation">Text rotation in degrees</param> /// <param name="text">Text to render</param> /// <param name="map">Map reference</param> public static void DrawLabel(System.Drawing.Graphics g, System.Drawing.PointF LabelPoint, System.Drawing.PointF Offset, System.Drawing.Font font, System.Drawing.Color forecolor, System.Drawing.Brush backcolor, System.Drawing.Pen halo, float rotation, string text, SharpMap.Map map) { System.Drawing.SizeF fontSize = g.MeasureString(text, font); //Calculate the size of the text LabelPoint.X += Offset.X; LabelPoint.Y += Offset.Y; //add label offset if (rotation != 0 && rotation != float.NaN) { g.TranslateTransform(LabelPoint.X, LabelPoint.Y); g.RotateTransform(rotation); g.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2); if (backcolor != null && backcolor != System.Drawing.Brushes.Transparent) g.FillRectangle(backcolor, 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddString(text, font.FontFamily, (int)font.Style, font.Size, new System.Drawing.Point(0, 0), null); if (halo != null) g.DrawPath(halo, path); g.FillPath(new System.Drawing.SolidBrush(forecolor), path); //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0); g.Transform = map.MapTransform; } else { if (backcolor != null && backcolor != System.Drawing.Brushes.Transparent) g.FillRectangle(backcolor, LabelPoint.X, LabelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddString(text, font.FontFamily, (int)font.Style, font.Size, LabelPoint, null); if (halo != null) g.DrawPath(halo, path); g.FillPath(new System.Drawing.SolidBrush(forecolor), path); //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y); } }
// 圆角代码 public void Round(System.Drawing.Region region) { // ----------------------------------------------------------------------------------------------- // 已经是.net提供给我们的最容易的改窗体的属性了(以前要自己调API) System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath(); int x = 0; int y = 0; int thisWidth = this.Width; int thisHeight = this.Height; int angle = _Radius; if (angle > 0) { System.Drawing.Graphics g = CreateGraphics(); oPath.AddArc(x, y, angle, angle, 180, 90); // 左上角 oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90); // 右上角 oPath.AddArc(thisWidth - angle, thisHeight - angle, angle, angle, 0, 90); // 右下角 oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90); // 左下角 oPath.CloseAllFigures(); Region = new System.Drawing.Region(oPath); } // ----------------------------------------------------------------------------------------------- else { oPath.AddLine(x + angle, y, thisWidth - angle, y); // 顶端 oPath.AddLine(thisWidth, y + angle, thisWidth, thisHeight - angle); // 右边 oPath.AddLine(thisWidth - angle, thisHeight, x + angle, thisHeight); // 底边 oPath.AddLine(x, y + angle, x, thisHeight - angle); // 左边 oPath.CloseAllFigures(); Region = new System.Drawing.Region(oPath); } }
protected override void WndProc(ref Message m) { base.WndProc(ref m); switch (m.Msg) { case 0xf: Graphics g = this.CreateGraphics(); g.FillRectangle(BorderBrush, this.ClientRectangle); //Create the path for the arrow System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath(); PointF TopLeft = new PointF(this.Width - 13, (this.Height - 5) / 2); PointF TopRight = new PointF(this.Width - 6, (this.Height - 5) / 2); PointF Bottom = new PointF(this.Width - 9, (this.Height + 2) / 2); pth.AddLine(TopLeft, TopRight); pth.AddLine(TopRight, Bottom); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; //Draw the arrow g.FillPath(new SolidBrush(Color.White), pth); break; default: break; } }
private void DrawFilledPath(SeriesBase series, System.Drawing.Pen pen,System.Drawing.Brush brush) { var path = new System.Drawing.Drawing2D.GraphicsPath(); if (series is AreaSeries) { path.StartFigure(); AreaSeries areaSeries = series as AreaSeries; var points = areaSeries.AreaPoints; var pointCount = areaSeries.AreaPoints.Count; for (int i = 0; i < pointCount - 1; i++) { System.Drawing.PointF startPoint = points[i].AsDrawingPointF(); System.Drawing.PointF endPoint = points[i + 1].AsDrawingPointF(); path.AddLine(startPoint, endPoint); } path.CloseAllFigures(); switch (RenderingMode) { case RenderingMode.GDIRendering: GDIGraphics.FillPath(brush, path); break; case RenderingMode.Default: break; case RenderingMode.WritableBitmap: WritableBitmapGraphics.FillPath(brush, path); break; default: break; } } }
public BBControl(int X, int Y, int dx, int dy) { InitializeComponent(); this.Location = new Point(X, Y); Random rannd = new Random(); this.dx = dx; this.dy = dy; while (dy == 0) { this.dy = rannd.Next(-50, 50); } while (dx == 0) { this.dx = rannd.Next(-50, 50); } Color color = Color.FromArgb(rannd.Next(255), rannd.Next(255), rannd.Next(255)); while (color == Color.White) { color = Color.FromArgb(rannd.Next(255), rannd.Next(255), rannd.Next(255)); } this.BackColor = color; this.Width = 2 * rannd.Next(2, 25); this.Height = this.Width; System.Drawing.Drawing2D.GraphicsPath Button_Path = new System.Drawing.Drawing2D.GraphicsPath(); Button_Path.AddEllipse(0, 0, this.Width, this.Height); Region Button_Region = new Region(Button_Path); this.Region = Button_Region; thread = new Thread(DoWork); thread.Start(); }
/// <summary> /// Repaints the form with cool background and stuff /// </summary> /// <param name="graph">The graphics object to paint to, the element will be drawn to 0,0</param> override public void Paint(Graphics graph) { //Draws Rectangular Shapes if (Shape == ModelShapes.Arrow) { _arrowPath = new System.Drawing.Drawing2D.GraphicsPath(); //Draws the basic shape Pen arrowPen; if (Highlight < 1) arrowPen = new Pen(Color.Cyan, 3F); else arrowPen = new Pen(Color.Black, 3F); //Draws the curved arrow Point[] lineArray = new Point[4]; lineArray[0] = new Point(_startPoint.X, _startPoint.Y); lineArray[1] = new Point(_startPoint.X - ((_startPoint.X - _stopPoint.X) / 3), _startPoint.Y); lineArray[2] = new Point(_stopPoint.X - ((_stopPoint.X - _startPoint.X) / 3), _stopPoint.Y); lineArray[3] = new Point(_stopPoint.X, _stopPoint.Y); graph.DrawBeziers(arrowPen, lineArray); _arrowPath.AddBeziers(lineArray); _arrowPath.Flatten(); //Draws the arrow head Point[] arrowArray = new Point[3]; arrowArray[0] = _stopPoint; arrowArray[1] = new Point(_stopPoint.X - (5 * Math.Sign(_stopPoint.X - _startPoint.X)),_stopPoint.Y - 2); arrowArray[2] = new Point(_stopPoint.X - (5 * Math.Sign(_stopPoint.X - _startPoint.X)), _stopPoint.Y + 2); graph.DrawPolygon(arrowPen,arrowArray); //Garbage collection arrowPen.Dispose(); } }
//Chnage Facing Direction CFD private void btnCFD_Paint(object sender, PaintEventArgs e) { System.Drawing.Drawing2D.GraphicsPath myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath(); myGraphicsPath.AddEllipse(new Rectangle(0, 0, 100, 100)); btnCFD.Size = new System.Drawing.Size(100, 100); btnCFD.Region = new Region(myGraphicsPath); }
public frmLogin() { InitializeComponent(); foreach (Button btn in this.Controls.OfType<Button>()) {//this will controll all button inside form btn.FlatStyle = FlatStyle.Standard; btn.ForeColor = Color.Black; btn.BackColor = Color.White; } foreach (TextBox txtbox in this.Controls.OfType<TextBox>()) {//this will controll all textbox inside form txtbox.BorderStyle = BorderStyle.None; } //background this.BackgroundImage = Properties.Resources.bg; this.BackgroundImageLayout = ImageLayout.Stretch; 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; }
/// <summary> /// Draw curves on graphics with transform and given pen /// </summary> static void DrawCurves( Graphics graphics, List<PointF[]> curves, System.Drawing.Drawing2D.Matrix transform, Pen pen) { foreach( PointF[] curve in curves ) { System.Drawing.Drawing2D.GraphicsPath gPath = new System.Drawing.Drawing2D.GraphicsPath(); if( curve.Length == 0 ) { break; } if( curve.Length == 1 ) { gPath.AddArc( new RectangleF( curve[0], new SizeF( 0.5f, 0.5f ) ), 0.0f, (float) Math.PI ); } else { gPath.AddLines( curve ); } if( transform != null ) gPath.Transform( transform ); graphics.DrawPath( pen, gPath ); } }
private void Form1_Load(object sender, EventArgs e) { // Cut the form System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddPolygon(new Point[] { new Point(0, 0), new Point(0, this.Height), new Point(this.Width, 0) }); Region myRegion = new Region(myPath); this.Region = myRegion; }
public Form1(String ime, PocetnaForma pf) { InitializeComponent(); igracIme = ime; this.igraci = pf.igraci; fruits = new List<Fruit>(); toolStripStatusLabel1.Text = ""; this.DoubleBuffered = true; selected = false; pf = new PocetnaForma(); this.pf = pf; i1 = new Igrac(igracIme); timer1.Start(); timer2.Start(); //za kopceto da bide okruglo i bez border System.Drawing.Drawing2D.GraphicsPath ag = new System.Drawing.Drawing2D.GraphicsPath(); ag.AddArc(0, 0, button1.Width, button1.Height, 0, 360); button1.Region = new Region(ag); button1.TabStop = false; button1.FlatStyle = FlatStyle.Flat; button1.FlatAppearance.BorderSize = 0; //za play kopceto System.Drawing.Drawing2D.GraphicsPath ag1 = new System.Drawing.Drawing2D.GraphicsPath(); ag1.AddArc(0, 0, button2.Width, button2.Height, 0, 360); button2.Region = new Region(ag1); button2.TabStop = false; button2.FlatStyle = FlatStyle.Flat; button2.FlatAppearance.BorderSize = 0; }
public Form1() { InitializeComponent(); saveLogs("InitializeComponent"); cookies = ReadCookiesFromDisk("cookies.dat"); if ((!check()) && (Properties.Settings.Default.email != "") && (Properties.Settings.Default.password != "")) { if (!auth()) resultLabel.Text = "Error authentication"; } Microsoft.Win32.RegistryKey readKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\ETS2MP"); if (readKey != null) { regInstallLocation = (string)readKey.GetValue("InstallLocation"); regInstallDir = (string)readKey.GetValue("InstallDir"); } else { saveLogs("Game not found!"); } System.Drawing.Drawing2D.GraphicsPath Button_Path = new System.Drawing.Drawing2D.GraphicsPath(); Button_Path.AddEllipse(0, 0, btnPlay.Width, btnPlay.Height); System.Drawing.Region Button_Region = new System.Drawing.Region(Button_Path); this.btnPlay.Region = Button_Region; }
/// <summary> /// 绘制圆角 /// </summary> /// <param name="g"></param> /// <param name="p"></param> /// <param name="X"></param> /// <param name="Y"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="radius"></param> public static void DrawRoundRect(Graphics g, Pen p, Brush brush,float X, float Y, float width, float height, float radius) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddLine(X + radius, Y, X + width - (radius * 2), Y); gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90); gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2)); gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90); gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height); gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90); gp.AddLine(X, Y + height - (radius * 2), X, Y + radius); gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90); gp.CloseFigure(); g.DrawPath(p, gp); g.FillPath(brush, gp); gp.Dispose(); }
private System.Drawing.Drawing2D.GraphicsPath GetPath(int index) { System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.Reset(); Rectangle rect = this.GetTabRect(index); if (index == 0) { path.AddLine(rect.Left + 1, rect.Bottom + 1, rect.Left + rect.Height, rect.Top + 2); path.AddLine(rect.Left + rect.Height + 4, rect.Top, rect.Right - 3, rect.Top); path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1); } else { if (index == this.SelectedIndex) { path.AddLine(rect.Left + 5 - rect.Height, rect.Bottom + 1, rect.Left + 4, rect.Top + 2); path.AddLine(rect.Left + 8, rect.Top, rect.Right - 3, rect.Top); path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1); path.AddLine(rect.Right - 1, rect.Bottom + 1, rect.Left + 5 - rect.Height, rect.Bottom + 1); } else { path.AddLine(rect.Left, rect.Top + 6, rect.Left + 4, rect.Top + 2); path.AddLine(rect.Left + 8, rect.Top, rect.Right - 3, rect.Top); path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1); path.AddLine(rect.Right - 1, rect.Bottom + 1, rect.Left, rect.Bottom + 1); } } return path; }
public void TestPathPointSymbolizer() { var fdt = CreatingData.CreatePointFeatureDataTableFromArrays( CreatingData.GetRandomOrdinates(50, -180, 180), CreatingData.GetRandomOrdinates(50, -90, 90), null); var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt); var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider); var pps = SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateSquare(new System.Drawing.Pen(System.Drawing.Color.Red, 2), new System.Drawing.SolidBrush( System.Drawing.Color.DodgerBlue), 20); layer.Style.PointSymbolizer = pps; var map = new SharpMap.Map(new System.Drawing.Size(720, 360)); map.Layers.Add(layer); map.ZoomToExtents(); map.GetMap().Save("PathPointSymbolizer1.bmp"); pps.Rotation = -30; map.GetMap().Save("PathPointSymbolizer2.bmp"); pps.Rotation = 0f; pps.Offset = new System.Drawing.PointF(4, 4); map.GetMap().Save("PathPointSymbolizer3.bmp"); var gpTriangle1 = new System.Drawing.Drawing2D.GraphicsPath(); gpTriangle1.AddPolygon(new [] { new System.Drawing.Point(0, 0), new System.Drawing.Point(5, 10), new System.Drawing.Point(10, 0), new System.Drawing.Point(0, 0), }); var gpTriangle2 = new System.Drawing.Drawing2D.GraphicsPath(); gpTriangle2.AddPolygon(new[] { new System.Drawing.Point(0, 0), new System.Drawing.Point(-5, -10), new System.Drawing.Point(-10, 0), new System.Drawing.Point(0, 0), }); pps = new SharpMap.Rendering.Symbolizer.PathPointSymbolizer(new[] { new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition { Path = gpTriangle1, Line = new System.Drawing.Pen( System.Drawing.Color.Red, 2), Fill = new System.Drawing.SolidBrush( System.Drawing.Color.DodgerBlue) }, new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition { Path = gpTriangle2, Line = new System.Drawing.Pen( System.Drawing.Color.DodgerBlue, 2), Fill = new System.Drawing.SolidBrush( System.Drawing.Color.Red) } }){ Rotation = 45 }; layer.Style.PointSymbolizer = pps; map.GetMap().Save("PathPointSymbolizer4.bmp"); pps.Rotation = 180; map.GetMap().Save("PathPointSymbolizer5.bmp"); }
protected override void OnPaint(PaintEventArgs pevent) { this.Size = new Size(50, 50); System.Drawing.Drawing2D.GraphicsPath aCircle = new System.Drawing.Drawing2D.GraphicsPath(); aCircle.AddEllipse(new System.Drawing.RectangleF(0, 0, 50, 50)); this.Region = new Region(aCircle); base.OnPaint(pevent); }
private void frmLogginpass_Load(object sender, EventArgs e) { lblUsuario.Text = nombreUser; System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddEllipse(0, 0, pbImgPerfil.Width - 3, pbImgPerfil.Height - 3); Region rg = new Region(gp); pbImgPerfil.Region = rg; }
/// <summary> /// Renders a LineString to the map. /// </summary> /// <param name="g">Graphics reference</param> /// <param name="line">LineString to render</param> /// <param name="pen">Pen style used for rendering</param> /// <param name="map">Map reference</param> public static void DrawLineString(System.Drawing.Graphics g, Geometries.LineString line, System.Drawing.Pen pen, SharpMap.Map map) { if (line.Vertices.Count > 1) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddLines(line.TransformToImage(map)); g.DrawPath(pen, gp); } }
private void frmLogin_Load(object sender, EventArgs e) { //Creating circle path FillRoleCombo(); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddEllipse(0, 0, 400, 400); this.Region = new Region(path); }
public static System.Drawing.Drawing2D.GraphicsPath DrawRoundRect(int x, int y, int width, int height, int radius) { System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddArc(x, y, radius, radius, 180f, 90f); path.AddArc(width - radius, y, radius, radius, 270f, 90f); path.AddArc(width - radius, height - radius, radius, radius, 0f, 90f); path.AddArc(x, height - radius, radius, radius, 90f, 90f); path.CloseAllFigures(); return path; }
public void DrawHover(Graphics graphics, Rectangle bounds, double hoverDone) { using (Bitmap b = new Bitmap(mBackgroundImage, bounds.Size)) graphics.DrawImage(b, bounds.Location); var path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddPie(bounds.X, bounds.Y, bounds.Width, bounds.Height, -90f, (float) (360 * hoverDone)); graphics.SetClip(path); using (Bitmap b = new Bitmap(mImage, bounds.Size)) graphics.DrawImage(b, bounds.Location); graphics.ResetClip(); }
void L_Message_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; //画渐变色 System.Drawing.Drawing2D.LinearGradientBrush lgb = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 0), new Point(0, L_Message.Height), Color.FromArgb(20, Color.White), Color.FromArgb(0, Color.FromArgb(80, 95, 103))); System.Drawing.Drawing2D.GraphicsPath gp = GetRoundedRectPath(new Rectangle(new Point(0, 0), L_Message.Size), 5); g.FillPath(lgb, gp); //g.Clear(Color.FromArgb(63,63,63)); //g.DrawString(TEXT, new Font("宋体", 11f), Brushes.White, Point.Empty); //g.DrawLine(new Pen(Theme.ThemeColorBG, 2), 0, L_Message.Height - 1, L_Message.Width, L_Message.Height - 1); g.DrawRectangle(new Pen(Color.FromArgb(47, 56, 61)), 0, 0, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 1); }
public void TabControl7_GetTabRegion(object sender, Thinksea.Windows.Forms.MdiTabControl.TabControl.GetTabRegionEventArgs e) { System.Drawing.Drawing2D.GraphicsPath x = new System.Drawing.Drawing2D.GraphicsPath(); x.AddArc(new Rectangle(0, 0, e.TabWidth, e.TabHeight * 2 / 3), 0, -180); x.Flatten(); System.Drawing.Point[] temp_array = e.Points; Array.Resize(ref temp_array, x.PointCount); e.Points = temp_array; for (int i = 0; i <= x.PointCount - 1; i++) { e.Points[i] = new Point(System.Convert.ToInt32(x.PathPoints[i].X), System.Convert.ToInt32(x.PathPoints[i].Y)); } }
public static void BordesRedondeados(Button b) { Rectangle r = new Rectangle(0, 0, b.Width, b.Height); System.Drawing.Drawing2D.GraphicsPath button = new System.Drawing.Drawing2D.GraphicsPath(); int d = 10; // VARIABLE CONTROL PARA N CONTORNO REDONDEADO DE BOTONES button.AddArc(r.X, r.Y, d, d, 180, 90); button.AddArc(r.X + r.Width - d, r.Y, d, d, 270, 90); button.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0, 90); button.AddArc(r.X, r.Y + r.Height - d, d, d, 90, 90); b.Region = new Region(button); }
public void OvalKenar()// Oval kenarlı PİCTURBOX İÇİN GÖRÜNTÜ AYARLARI { Rectangle r = new Rectangle(0, 0, pictureBoxKisiFotosu.Width, pictureBoxKisiFotosu.Height); System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); int d = 172; gp.AddArc(r.X, r.Y, d, d, 180, 90); gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270, 90); gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0, 90); gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90, 90); pictureBoxKisiFotosu.Region = new Region(gp); }//// OvalKenar() end
public FieldButton() { //set triangle for button shape triangle = new Point[3] { new Point(0, 0), new Point(100, 0), new Point(50, 86) }; //set up shape and add triangle shape = new System.Drawing.Drawing2D.GraphicsPath(); shape.AddPolygon(triangle); //set default background this.BackColor = Color.Black; InitializeComponent(); }
void DrawRoundRect(Graphics g, Brush b, int x, int y, int w, int h, int r) { System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddArc(x, y, r + r, r + r, 180, 90); path.AddLine(x + r, y, x + w - r, y); path.AddArc(x + w - 2 * r, y, 2 * r, 2 * r, 270, 90); path.AddLine(x + w, y + r, x + w, y + h - r); path.AddArc(x + w - 2 * r, y + h - 2 * r, r + r, r + r, 0, 91); path.AddLine(x + r, y + h, x + w - r, y + h); path.AddArc(x, y + h - 2 * r, 2 * r, 2 * r, 90, 91); path.CloseFigure(); g.FillPath(b, path); }
public void DrawHover(Graphics graphics, Rectangle bounds, double hoverDone) { using (Bitmap b = new Bitmap(mBackgroundImage, bounds.Size)) graphics.DrawImage(b, bounds.Location); var path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddPie(bounds.X, bounds.Y, bounds.Width, bounds.Height, -90f, (float)(360 * hoverDone)); graphics.SetClip(path); using (Bitmap b = new Bitmap(mImage, bounds.Size)) graphics.DrawImage(b, bounds.Location); graphics.ResetClip(); }
private void button1_Click(object sender, EventArgs e) { Rectangle r = new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height); System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); int d = 50; gp.AddArc(r.X, r.Y, d, d, 180, 90); gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270, 90); gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0, 90); gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90, 90); pictureBox1.Region = new Region(gp); }
static void DrawRoundedRectangle(Graphics g, Pen p, int x, int y, int w, int h, int rx, int ry) { System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddArc(x, y, rx + rx, ry + ry, 180, 90); path.AddLine(x + rx, y, x + w - rx, y); path.AddArc(x + w - 2 * rx, y, 2 * rx, 2 * ry, 270, 90); path.AddLine(x + w, y + ry, x + w, y + h - ry); path.AddArc(x + w - 2 * rx, y + h - 2 * ry, rx + rx, ry + ry, 0, 91); path.AddLine(x + rx, y + h, x + w - rx, y + h); path.AddArc(x, y + h - 2 * ry, 2 * rx, 2 * ry, 90, 91); path.CloseFigure(); g.DrawPath(p, path); }
private void rectangleShape2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { Point mouseDownLocation = new Point(e.X + rectangleShape2.Left, e.Y + rectangleShape2.Top); // Clear the previous line. mousePath.Dispose(); mousePath = new System.Drawing.Drawing2D.GraphicsPath(); rectangleShape2.Invalidate(); // Add a line to the graphics path. mousePath.AddLine(mouseDownLocation, mouseDownLocation); }
private void Form1_Load(object sender, EventArgs e) { System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddPolygon(new Point[] { new Point(0, 0), new Point(0, this.Height), new Point(this.Width, 0) }); Region myRegion = new Region(myPath); this.Region = myRegion; }
public void DrawPath(System.Drawing.Pen pen, System.Drawing.Drawing2D.GraphicsPath path) { if (pen.Color != Color.Empty) { VPathGroup group = null; if (!_result.TryGetValue(pen.Color, out group)) { group = new VPathGroup(pen.Color); _result.Add(pen.Color, group); } group.PathList.Add(_transformator.TransformPath(path)); } }
/// <summary> /// 未知方法,(现已废弃,替代方法 PointInPolygon) /// </summary> /// <param name="point"></param> /// <param name="pointColl"></param> /// <returns></returns> public static bool IsVisible_GraphicsPath(Point point, List <Point> pointColl) { System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); List <System.Drawing.Point> pathPoints = new List <System.Drawing.Point>(); foreach (var pathPoint in pointColl) { pathPoints.Add(new System.Drawing.Point((int)Math.Round(pathPoint.X), (int)Math.Round(pathPoint.Y))); } path.AddPolygon(pathPoints.ToArray()); path.CloseFigure(); return(path.IsVisible(new System.Drawing.Point((int)Math.Round(point.X), (int)Math.Round(point.Y)))); }
private System.Drawing.Drawing2D.GraphicsPath getWindowDecorationsPath() { RectangleF clientArea = new RectangleF(this.containerControl.Location, this.containerControl.Size); float titleHeight = 25; float border = 5; var gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddRectangle(new RectangleF(clientArea.X - 1, clientArea.Y - 1, clientArea.Width + 1, clientArea.Height + 1)); gp.AddRectangle(new RectangleF(clientArea.X - border - 1, clientArea.Y - titleHeight - 1, clientArea.Width + 2 * border + 1, clientArea.Height + titleHeight + border + 1)); return(gp); }
private void draw(object sender, EventArgs e) { using (Graphics graphics = Graphics.FromImage(bitmap)) { graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; graphics.FillRectangle(new SolidBrush(color), new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height)); System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath(); graphicsPath.AddString(textBox2.Text, font.FontFamily, (int)FontStyle.Regular, (int)numericUpDown4.Value, new Point((int)numericUpDown1.Value, (int)numericUpDown2.Value), StringFormat.GenericDefault); graphics.FillPath(Brushes.White, graphicsPath); graphics.DrawPath(new Pen(Color.Black, (int)numericUpDown3.Value), graphicsPath); } pictureBox1.Image = bitmap; }
private void ImproveFlashesButtons() { System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddEllipse(0, 0, 12, 12); Region myRegion = new Region(myPath); PictureBox[] pictureBoxes = { pictureBox3, pictureBox8, pictureBox9, pictureBox19, pictureBox22, pictureBox11 }; for (int i = 0; i < pictureBoxes.Length; i++) { pictureBoxes[i].Region = myRegion; pictureBoxes[i].BackColor = Color.Yellow; } }
public void Render(LittleSharpRenderEngine engine, Graphics graphics, ILineString line, ILineStyle style) { if (line == null || style == null) return; System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); //TODO: Does not seems to add a single long line, but multiple line segments gp.AddLines(RenderUtil.CoordToPoint(line.Coordinates)); if (style.Outlines != null) foreach(IOutline linestyle in style.Outlines) RenderUtil.RenderOutline(engine, graphics, gp, linestyle); }
private void makeRoundPictureCorners() { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddEllipse(0, 0, picBlackBall.Width - 1, picBlackBall.Height - 1); Region rg = new Region(gp); picBlackBall.Region = rg; System.Drawing.Drawing2D.GraphicsPath gp2 = new System.Drawing.Drawing2D.GraphicsPath(); gp2.AddEllipse(0, 0, picRedball.Width - 1, picRedball.Height - 1); Region rg2 = new Region(gp2); picRedball.Region = rg2; }
private void ImproveMollyButtons() { System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddEllipse(0, 0, 12, 12); Region myRegion = new Region(myPath); PictureBox[] pictureBoxes = { pictureBox5, pictureBox6, pictureBox10, pictureBox20, pictureBox30, pictureBox31, pictureBox32, pictureBox34 }; for (int i = 0; i < pictureBoxes.Length; i++) { pictureBoxes[i].Region = myRegion; pictureBoxes[i].BackColor = Color.Red; } }
//Rounded Controls private static void SetRoundedShape(Control control, int radius) { System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddLine(radius, 0, control.Width - radius, 0); path.AddArc(control.Width - radius, 0, radius, radius, 270, 90); path.AddLine(control.Width, radius, control.Width, control.Height - radius); path.AddArc(control.Width - radius, control.Height - radius, radius, radius, 0, 90); path.AddLine(control.Width - radius, control.Height, radius, control.Height); path.AddArc(0, control.Height - radius, radius, radius, 90, 90); path.AddLine(0, control.Height - radius, 0, radius); path.AddArc(0, 0, radius, radius, 180, 90); control.Region = new System.Drawing.Region(path); }
public void Rounded() { Rectangle r = new Rectangle(0, 0, pictureBox2.Width, pictureBox2.Height); System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); int d = 55; gp.AddArc(r.X, r.Y, d, d, 180, 90); gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270, 90); gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0, 90); gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90, 90); pictureBox2.Region = new Region(gp); }
private void ImproveWallbangsButtons() { System.Drawing.Drawing2D.GraphicsPath myPath = new System.Drawing.Drawing2D.GraphicsPath(); myPath.AddEllipse(0, 0, 12, 12); Region myRegion = new Region(myPath); PictureBox[] pictureBoxes = { pictureBox35, pictureBox36, pictureBox37, pictureBox38, pictureBox39, pictureBox40, pictureBox41, pictureBox42, pictureBox43 }; for (int i = 0; i < pictureBoxes.Length; i++) { pictureBoxes[i].Region = myRegion; pictureBoxes[i].BackColor = Color.Black; } }
public static void BorderRedondoButton(Button b) { Rectangle r = new Rectangle(0, 0, b.Width, b.Height); System.Drawing.Drawing2D.GraphicsPath button = new System.Drawing.Drawing2D.GraphicsPath(); int d = 10; button.AddArc(r.X, r.Y, d, d, 180, 90); button.AddArc(r.X + r.Width - d, r.Y, d, d, 280, 90); button.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0, 90); button.AddArc(r.X, r.Y + r.Height - d, d, d, 90, 90); b.Region = new Region(button); }
/// <summary> /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.AddToGraphicsPath (System.Drawing.Drawing2D.GraphicsPath, bool)"/> /// </summary> /// <param name="path"></param> /// <param name="forward"></param> public override void AddToGraphicsPath(System.Drawing.Drawing2D.GraphicsPath path, bool forward) { if (forward) { path.AddArc((float)(Center.x - Radius), (float)(Center.y - Radius), (float)(2 * Radius), (float)(2 * Radius), (float)(start.Degree), (float)(sweep.Degree)); } else { path.AddArc((float)(Center.x - Radius), (float)(Center.y - Radius), (float)(2 * Radius), (float)(2 * Radius), (float)((start + sweep).Degree), (float)(-sweep.Degree)); } }
public override bool HitTest(System.Drawing.Point pt) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix(); System.Drawing.Pen myPen = new System.Drawing.Pen(this.m_lineColor, (float)this.m_lineWidth + 2); float X = (float)this.X; float Y = (float)this.Y; gp.AddLine(X, Y, X + m_Size.Width, Y + m_Size.Height); myMatrix.RotateAt((float)this.m_Rotation, new System.Drawing.PointF(X, Y), System.Drawing.Drawing2D.MatrixOrder.Append); gp.Transform(myMatrix); return(gp.IsOutlineVisible(pt, myPen)); }
private void btnguide_Click(object sender, EventArgs e) { System.Drawing.Drawing2D.GraphicsPath aCircle = new System.Drawing.Drawing2D.GraphicsPath(); aCircle.AddEllipse(new Rectangle(0, 0, 50, 50)); btnNavigateFind.Region = new Region(aCircle); panelNavigate.Location = new Point(0, 0); panelNavigate.Visible = true; tbxEnd.Text = lblScene.Text; lbxS = lbxNavigate; btnSide.Visible = false; lbxNavigate.Visible = false; lbxSearchBar.Visible = false; }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿 g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddEllipse(0, 0, this.Width, this.Height); this.Region = new Region(path); }
void paintPanelTopBorder() { if (CurrentMenu != null) { Graphics g = Graphics.FromHwnd(panelContent.Handle); Pen borderPen = new Pen(Color.FromArgb(190, 190, 190), 1); Pen backgroundPen = new Pen(panelContent.BackColor, 1); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); g.DrawLine(borderPen, new Point(0, 0), new Point(CurrentMenu.Location.X + 1, 0)); g.DrawLine(backgroundPen, new Point(CurrentMenu.Location.X + 1, 0), new Point(CurrentMenu.Location.X + CurrentMenu.Width - 1, 0)); g.DrawLine(borderPen, new Point(CurrentMenu.Location.X + CurrentMenu.Width - 1, 0), new Point(Width, 0)); } }
public ucAccount(int AccountID) { InitializeComponent(); this.AccountID = AccountID; Photo = pictureBox_photo; About = richTextBox_about; Add = button_add; System.Drawing.Drawing2D.GraphicsPath gPath = new System.Drawing.Drawing2D.GraphicsPath(); gPath.AddEllipse(Photo.DisplayRectangle); Photo.Region = new Region(gPath); }
private void ToweringInferno_Load(object sender, EventArgs e) { CheckForIllegalCrossThreadCalls = false; try { IPHostEntry ipHost = Dns.GetHostEntry(Dns.GetHostName()); IPAddress ipAddr = IPAddress.Parse("192.168.0.3"); //AQUI SE ESTABLECE LA IP DEL SERVER localEndPoint = new IPEndPoint(ipAddr, 50000); //AQUI SE ESTABLECE EL PUERTO DEL SERVER sender2 = new Socket(ipAddr.AddressFamily, SocketType.Stream, ProtocolType.Tcp); sender2.Connect(localEndPoint); } catch { } Thread t = new Thread(RecibeMensajes); t.Start(); int[] arreglo = { 31, 22, 27, 44, 43, 45, 4, 10 }; int[] arreglo2 = { 45, 52, 11, 17, 28, 48, 2, 40 }; Rectangle r = new Rectangle(0, 0, panel3.Width, panel3.Height); System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); int d = 50; gp.AddEllipse(new Rectangle(0, 2, 370, 370)); panel3.Region = new Region(gp); Rectangle r2 = new Rectangle(0, 0, panel1.Width, panel1.Height); System.Drawing.Drawing2D.GraphicsPath gp2 = new System.Drawing.Drawing2D.GraphicsPath(); gp2.AddEllipse(new Rectangle(0, 2, 370, 370)); panel1.Region = new Region(gp2); Rectangle r3 = new Rectangle(0, 0, pictureBox9.Width, pictureBox9.Height); System.Drawing.Drawing2D.GraphicsPath gp3 = new System.Drawing.Drawing2D.GraphicsPath(); gp3.AddEllipse(new Rectangle(0, 0, 370, 370)); pictureBox9.Region = new Region(gp3); this.WindowState = FormWindowState.Maximized; timer1 = new System.Windows.Forms.Timer(); timer1.Tick += new EventHandler(timer1_Tick); timer1.Interval = 1000; // 1 second timer1.Start(); timee.Text = counter.ToString(); }
private void Panel_DoubleClick(object sender, EventArgs e) { string tag = (sender as PictureBox).Tag.ToString(); string[] namesArray = tag.Split('*'); List <string> namesList = new List <string>(namesArray.Length); namesList.AddRange(namesArray); Program.TagName = namesList[4]; Program.SizeInPX = Convert.ToInt32(namesList[3]); IdDetectorAeditar = Convert.ToInt32(namesList[1]); Program.Identificador = namesList[2]; Program.Gdispositivo = namesList[5]; Program.GtipoDispositivo = namesList[6]; Program.Gfigura = namesList[7]; NameZoneForm form = new NameZoneForm(); form.ShowDialog(); if (Program.TagName != "") { (sender as PictureBox).Tag = namesList[0] + "*" + IdDetectorAeditar + "*" + Program.Identificador + "*" + Program.SizeInPX.ToString() + "*" + Program.TagName + "*" + Program.Gdispositivo + "*" + Program.GtipoDispositivo + "*" + Program.Gfigura; if (Program.Gfigura == "Círculo") { (sender as PictureBox).Region = null; (sender as PictureBox).Size = new Size(Program.SizeInPX, Program.SizeInPX); var path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddEllipse(0, 0, Program.SizeInPX, Program.SizeInPX); (sender as PictureBox).Region = new Region(path); (sender as PictureBox).Image = null; (sender as PictureBox).Image = Properties.Resources.cuadroVerde; } else { (sender as PictureBox).Region = null; (sender as PictureBox).Size = new Size(Program.SizeInPX, Program.SizeInPX); if (Program.Gfigura == "Letra P") { (sender as PictureBox).Image = null; (sender as PictureBox).Image = Properties.Resources.transLetraPverde; } else { (sender as PictureBox).Image = null; (sender as PictureBox).Image = Properties.Resources.cuadroVerde; } } } }
private void button2_Click(object sender, EventArgs e) { foreach (Control c in this.Controls) { if (c.GetType() == typeof(Panel)) { foreach (Label a in c.Controls) { var path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddEllipse(0, 0, a.Width, a.Height); a.Region = new Region(path); } } } try { int aux = Int32.Parse(txtnum.Text); int i = 0; if (aux < 8 && aux >= 0) { foreach (Panel A in painel) { A.Visible = false; } foreach (Panel A in painel) { if (i == aux) { break; } A.Visible = true; i++; } } else { MessageBox.Show("Vai dar não meu parceiro"); } txtnum.Text = " "; } catch { MessageBox.Show("Digite um Valor válido"); } }
private void DrawBorder(Graphics graphics) { var rectangleCloseButton = new Rectangle(Width - titleBarThickness - 1, 0, titleBarThickness, titleBarThickness); var rectangleMinimizeButton = new Rectangle(Width - titleBarThickness * 2, 0, titleBarThickness, titleBarThickness); var pLeftUp1 = new Point(0, 0); var pLeftUp2 = new Point(thickness, thickness); var pRightUp1 = new Point(Width, 0); var pRightUp2 = new Point(Width - thickness, thickness); var pLeftDown1 = new Point(0, Height); var pLeftDown2 = new Point(thickness, Height - thickness); var pRightDown1 = new Point(Width, Height); var pRightDown2 = new Point(Width - thickness, Height - thickness); //UP var pathUp = new System.Drawing.Drawing2D.GraphicsPath(); pathUp.AddLines(new[] { pLeftUp1, new Point(0, titleBarThickness), new Point(Width, titleBarThickness), pRightUp1 }); //Left var pathLeft = new System.Drawing.Drawing2D.GraphicsPath(); pathLeft.AddLines(new[] { pLeftUp1, pLeftUp2, pLeftDown2, pLeftDown1 }); //Bottom var pathBottom = new System.Drawing.Drawing2D.GraphicsPath(); pathBottom.AddLines(new[] { pLeftDown1, pLeftDown2, pRightDown2, pRightDown1 }); //Right var pathRight = new System.Drawing.Drawing2D.GraphicsPath(); pathRight.AddLines(new[] { pRightDown1, pRightDown2, pRightUp2, pRightUp1 }); //External Up graphics.SetClip(pathUp); graphics.DrawLine(PenBorder, pLeftUp1, pRightUp1); //External Left graphics.SetClip(pathLeft); graphics.DrawLine(PenBorder, pLeftUp1, pLeftDown1); //External Bottom graphics.SetClip(pathBottom); graphics.DrawLine(PenBorder, pLeftDown1, pRightDown1); //External Right graphics.SetClip(pathRight); graphics.DrawLine(PenBorder, pRightUp1, pRightDown1); graphics.ResetClip(); }
public Form1() { InitializeComponent(); _points = new List<Point> { new Point(10, 10), new Point(200, 10), new Point(200, 200) }; _path = new System.Drawing.Drawing2D.GraphicsPath(); _rectangles = new List<Rectangle>(); }
public static void DrawRoundedRectangle(Graphics gfx, Rectangle Bounds, int CornerRadius, Pen DrawPen, Color FillColor) { System.Drawing.Drawing2D.GraphicsPath gfxPath = new System.Drawing.Drawing2D.GraphicsPath(); DrawPen.EndCap = DrawPen.StartCap = System.Drawing.Drawing2D.LineCap.Round; gfxPath.AddArc(Bounds.X, Bounds.Y, CornerRadius, CornerRadius, 180, 90); gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y, CornerRadius, CornerRadius, 270, 90); gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90); gfxPath.AddArc(Bounds.X, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90); gfxPath.AddLine(Bounds.X, Bounds.Y + Bounds.Height - CornerRadius, Bounds.X, Bounds.Y + CornerRadius / 2); gfx.FillPath(new SolidBrush(FillColor), gfxPath); gfx.DrawPath(DrawPen, gfxPath); }
public void Render(LittleSharpRenderEngine engine, Graphics graphics, IPolygon polygon, IAreaStyle style) { if (polygon == null || style == null) return; System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddPolygon(RenderUtil.CoordToPoint(polygon.Shell.Coordinates)); foreach (ILinearRing l in polygon.Holes) gp.AddPolygon(RenderUtil.CoordToPoint(l.Coordinates)); gp.CloseFigure(); if (style.Fill != null) RenderUtil.RenderFill(engine, graphics, gp, style.Fill); if (style.Outline != null) RenderUtil.RenderOutline(engine, graphics, gp, style.Outline); }
public void Draw(int hDC, int x, int y) { this._graphics = Graphics.FromHdc((IntPtr)hDC); System.Drawing.Drawing2D.GraphicsPath oSysmbolOutPath = new System.Drawing.Drawing2D.GraphicsPath(); if (this._graphics != null && this._symbolFont != null) { this._graphics.TranslateTransform(1f, 1f); this._graphics.DrawString(new string(((char)this._symbolIndex), 1), this._symbolFont, new SolidBrush(this._symbolColor), (float)x, (float)y); this._graphics.DrawString(this._extendedInfos, new Font(this._extendedInfosFont.Name, (float)this._extendedInfosFontSize), new SolidBrush(this._extentedInfosColor), (float)x, (float)y); this._graphics.RotateTransform((float)this._rotation); } this._graphics.Dispose(); }
/// <summary> /// takes in a parsed path and returns a list of points that can be used to draw the path /// </summary> /// <returns>The drawing points.</returns> /// <param name="segments">Segments.</param> public Vector2[] getDrawingPoints( List<SvgPathSegment> segments, float flatness = 3 ) { var path = new System.Drawing.Drawing2D.GraphicsPath(); for( var j = 0; j < segments.Count; j++ ) { var segment = segments[j]; if( segment is SvgMoveToSegment ) { path.StartFigure(); } else if( segment is SvgCubicCurveSegment ) { var cubicSegment = segment as SvgCubicCurveSegment; path.AddBezier( toDrawPoint( segment.start ), toDrawPoint( cubicSegment.firstCtrlPoint ), toDrawPoint( cubicSegment.secondCtrlPoint ), toDrawPoint( segment.end ) ); } else if( segment is SvgClosePathSegment ) { // important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure. if( path.PointCount > 0 && !path.PathPoints[0].Equals( path.PathPoints[path.PathPoints.Length - 1] ) ) { var i = path.PathTypes.Length - 1; while( i >= 0 && path.PathTypes[i] > 0 ) i--; if( i < 0 ) i = 0; path.AddLine( path.PathPoints[path.PathPoints.Length - 1], path.PathPoints[i] ); } path.CloseFigure(); } else if( segment is SvgLineSegment ) { path.AddLine( toDrawPoint( segment.start ), toDrawPoint( segment.end ) ); } else if( segment is SvgQuadraticCurveSegment ) { var quadSegment = segment as SvgQuadraticCurveSegment; path.AddBezier( toDrawPoint( segment.start ), toDrawPoint( quadSegment.firstCtrlPoint ), toDrawPoint( quadSegment.secondCtrlPoint ), toDrawPoint( segment.end ) ); } else { Debug.warn( "unknown type in getDrawingPoints" ); } } path.Flatten( new System.Drawing.Drawing2D.Matrix(), flatness ); return System.Array.ConvertAll( path.PathPoints, i => new Vector2( i.X, i.Y ) ); }
/// <summary> /// Constructor /// </summary> /// <param name="points">points of the polygon</param> /// <param name="rType">Range Type</param> public RangePolygon(PointF[] points, RANGETYPE rType,int id) { this.rangeType = rType; this.polygonPoints = points; if(rType == RANGETYPE.TOP) { fillColor=Color.FromArgb(15,0,255,0); } else { fillColor=Color.FromArgb(15,255,0,0); } this.polygonID = id; graphicsPath = new System.Drawing.Drawing2D.GraphicsPath(); graphicsPath.AddPolygon(polygonPoints); }