public static Image GetRegionImage(Image surfaceImage, GraphicsPath regionFillPath, GraphicsPath regionDrawPath, SurfaceOptions options) { if (regionFillPath != null) { Image img; Rectangle regionArea = Rectangle.Round(regionFillPath.GetBounds()); Rectangle screenRectangle = CaptureHelpers.GetScreenBounds0Based(); Rectangle newRegionArea = Rectangle.Intersect(regionArea, screenRectangle); using (GraphicsPath gp = (GraphicsPath)regionFillPath.Clone()) { MoveGraphicsPath(gp, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y)); img = ImageHelpers.CropImage(surfaceImage, newRegionArea, gp); if (options.DrawBorder) { GraphicsPath gpOutline = regionDrawPath ?? regionFillPath; using (GraphicsPath gp2 = (GraphicsPath)gpOutline.Clone()) { MoveGraphicsPath(gp2, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y)); img = ImageHelpers.DrawOutline(img, gp2); } } } return img; } return null; }
public static Bitmap KiRotate(Bitmap bmp, float angle, Color bkColor) { PixelFormat pf; int w = bmp.Width + 2; int h = bmp.Height + 2; if (bkColor == Color.Transparent) { pf = PixelFormat.Format32bppArgb; } else { pf = bmp.PixelFormat; } Bitmap tmp = new Bitmap(w, h, pf); Graphics g = Graphics.FromImage(tmp); g.Clear(bkColor); g.DrawImageUnscaled(bmp, 1, 1); g.Dispose(); GraphicsPath path = new GraphicsPath(); path.AddRectangle(new RectangleF(0f, 0f, (float)w, (float)h)); Matrix mtrx = new Matrix(); mtrx.Rotate(angle); RectangleF rct = path.GetBounds(mtrx); Bitmap dst = new Bitmap((int)rct.Width, (int)rct.Height, pf); g = Graphics.FromImage(dst); g.Clear(bkColor); g.TranslateTransform(-rct.X, -rct.Y); g.RotateTransform(angle); g.InterpolationMode = InterpolationMode.HighQualityBilinear; g.DrawImageUnscaled(tmp, 0, 0); g.Dispose(); tmp.Dispose(); return dst; }
public OutlinedStringSurface( String str, Font font, Brush brush, Pen outlinePen, StringFormat stringFormat) { Contract.Requires(str != null); Contract.Requires(font != null); Contract.Requires(brush != null); Contract.Requires(outlinePen != null); _brush = brush; _outlinePen = outlinePen; // グラフィックスパスの生成 _path = new GraphicsPath(); _path.AddString( str, font.FontFamily, (int)font.Style, font.Size, new Point(0, 0), stringFormat); // サイズを取得する var rect = _path.GetBounds(); Size = rect.Size.ToSize(); // 描画時にマージンがなくなるように平行移動 var matrix = new Matrix(1, 0, 0, 1, -rect.Left, -rect.Top); _path.Transform(matrix); // 描画位置を(0, 0)で記憶 matrix.Reset(); _matrix = matrix; }
void Initialize(GraphicsPath path, WrapMode wrapMode, bool initColors, bool calcCenter) { _texturePath = path; _wrapMode = wrapMode; _rectangle = path.GetBounds(); if (initColors) { _centerColor = Color.Black; _surroundColors = new Color []{ Color.White }; } Bitmap texture = new Bitmap( (int)_rectangle.Width, (int)_rectangle.Height ); Graphics g = Graphics.FromImage( texture ); PointF [] pathPoints = path.PathPoints; if (calcCenter) { for (int i=0; i < pathPoints.Length; i++) { _center.X += pathPoints[i].X; _center.Y += pathPoints[i].Y; } _center.X /= pathPoints.Length; _center.Y /= pathPoints.Length; } int outerColor = 0; DrawSector( g, CenterPoint, pathPoints[pathPoints.Length-1], pathPoints[0], CenterColor, SurroundColors[outerColor] ); for(int i=0; i < pathPoints.Length - 1; i++) { if (outerColor < SurroundColors.Length - 1) outerColor++; DrawSector( g, CenterPoint, pathPoints[i], pathPoints[i+1], CenterColor, SurroundColors[outerColor] ); } _nativeObject = new TextureBrush( texture ); }
public static Image ApplyRegionPathToImage(Image backgroundImage, GraphicsPath regionFillPath, RegionCaptureOptions options) { if (backgroundImage != null && regionFillPath != null) { Image img; Rectangle regionArea = Rectangle.Round(regionFillPath.GetBounds()); Rectangle screenRectangle = CaptureHelpers.GetScreenBounds0Based(); Rectangle newRegionArea = Rectangle.Intersect(regionArea, screenRectangle); using (GraphicsPath gp = (GraphicsPath)regionFillPath.Clone()) { using (Matrix matrix = new Matrix()) { gp.CloseFigure(); matrix.Translate(-Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y)); gp.Transform(matrix); } img = ImageHelpers.CropImage(backgroundImage, newRegionArea, gp); } return img; } return null; }
public Bitmap RotateImg(Bitmap bmp, float angle) { var bkColor = Color.White; int w = bmp.Width; int h = bmp.Height; PixelFormat pf; pf = bkColor == Color.Transparent ? PixelFormat.Format32bppArgb : bmp.PixelFormat; Bitmap tempImg = new Bitmap(w, h, pf); Graphics g = Graphics.FromImage(tempImg); g.Clear(bkColor); g.DrawImageUnscaled(bmp, 1, 1); g.Dispose(); GraphicsPath path = new GraphicsPath(); path.AddRectangle(new RectangleF(0f, 0f, w, h)); Matrix mtrx = new Matrix(); //Using System.Drawing.Drawing2D.Matrix class mtrx.Rotate(angle); RectangleF rct = path.GetBounds(mtrx); Bitmap newImg = new Bitmap(Convert.ToInt32(rct.Width), Convert.ToInt32(rct.Height), pf); g = Graphics.FromImage(newImg); g.Clear(bkColor); g.TranslateTransform(-rct.X, -rct.Y); g.RotateTransform(angle); g.InterpolationMode = InterpolationMode.HighQualityBilinear; g.DrawImageUnscaled(tempImg, 0, 0); g.Dispose(); tempImg.Dispose(); return newImg; }
public override RectangleF ReturnBounds() { GraphicsPath path = new GraphicsPath(); path.AddBezier(pointOne, pointTwo, pointTree, pointFour); path.Transform(this.TMatrix.TransformationMatrix); return path.GetBounds(); }
public override RectangleF ReturnBounds() { GraphicsPath path = new GraphicsPath(); path.AddRectangle(new RectangleF(Location.X, Location.Y, ModelSize.Width, ModelSize.Width)); path.Transform(this.TMatrix.TransformationMatrix); return path.GetBounds(); }
public override RectangleF ReturnBounds() { GraphicsPath path = new GraphicsPath(); path.AddEllipse(Location.X, Location.Y, 5, 5); path.Transform(this.TMatrix.TransformationMatrix); return path.GetBounds(); }
private void Form2_Paint(object sender, PaintEventArgs e) { //패스 그래디언트 Point[] pts = { new Point(100, 0), new Point(0, 100), new Point(200, 100) }; PathGradientBrush B = new PathGradientBrush(pts, WrapMode.Tile); e.Graphics.FillRectangle(B, ClientRectangle); //패스 그래디언트 끝 //패스변형 GraphicsPath Path = new GraphicsPath(); Path.AddString("한글", new FontFamily("궁서"), 0, 100, new Point(10, 30), new StringFormat()); //확장 후 외곽선 그리기 Path.Widen(new Pen(Color.Black, 3)); e.Graphics.DrawPath(Pens.Black, Path); //확장 후 채우기 Path.Widen(new Pen(Color.Blue, 3)); e.Graphics.DrawPath(Pens.Black, Path); //곡선 펴기 Path.Flatten(new Matrix(), 12f); e.Graphics.DrawPath(Pens.Black, Path); //회전 Matrix M = new Matrix(); M.Rotate(-10); Path.Transform(M); e.Graphics.FillPath(Brushes.Blue, Path); //휘기 RectangleF R = Path.GetBounds(); PointF[] arPoint = new PointF[4]; arPoint[0] = new PointF(R.Left, R.Top + 30); arPoint[1] = new PointF(R.Right, R.Top - 10); arPoint[2] = new PointF(R.Left + 10, R.Bottom - 10); arPoint[3] = new PointF(R.Right + 30, R.Bottom + 30); Path.Warp(arPoint, R); e.Graphics.FillPath(Brushes.Blue, Path); //클리핑 //graphicspath path= new graphicspath(); //path.fillmode = fillmode.winding; //path.addellipse(50, 10, 100, 80); //path.addellipse(20, 45, 160, 120); //e.graphics.fillpath(brushes.white, path); //e.graphics.setclip(path); //for (int y = 0; y < bottom; y+= 20) //{ // string str = "눈사람의 모양의클리핑 영역에 글자를 쓴것입니다"; // e.graphics.drawstring(str, font, brushes.blue, 0, y); //} //클리핑 끝 }
public override RectangleF ReturnBounds() { Point[] points = (Point[])pointsList.ToArray(typeof(Point)); GraphicsPath path = new GraphicsPath(); path.AddCurve(points,1); path.Transform(this.TMatrix.TransformationMatrix); return path.GetBounds(); }
/// <summary> /// Fills the specified <paramref name="path"/> either with a gradient background or a solid one. /// </summary> /// <param name="g">The <see cref="Graphics"/> object used to draw.</param> /// <param name="path">The <see cref="GraphicsPath"/> to fill.</param> /// <param name="colorStart">The start color.</param> /// <param name="colorEnd">The end color if drawing a gradient background.</param> /// <param name="mode">The <see cref="LinearGradientMode"/> to use.</param> /// <exception cref="ArgumentNullException">If <paramref name="path"/> is null.</exception> public static void FillBackground( Graphics g, GraphicsPath path, Color colorStart, Color colorEnd, LinearGradientMode? mode) { if (path == null) { throw new ArgumentNullException("path", "parameter 'path' cannot be null."); } RectangleF rect = path.GetBounds(); if (!CheckParams(g, path.GetBounds()) || colorStart == Color.Empty) { return; } if (colorEnd == Color.Empty) { if (colorStart != Color.Transparent) { using (SolidBrush brush = new SolidBrush(colorStart)) { g.FillPath(brush, path); } } } else { rect.Height += 2; rect.Y--; using (LinearGradientBrush brush = new LinearGradientBrush( rect, colorStart, colorEnd, mode.GetValueOrDefault(LinearGradientMode.Vertical))) { g.FillPath(brush, path); } } }
public bool HitTest(Rectangle r) { GraphicsPath gp = new GraphicsPath(); Matrix mtx = new Matrix(); gp.AddRectangle(new Rectangle(el.Location.X, el.Location.Y, el.Size.Width, el.Size.Height)); gp.Transform(mtx); Rectangle retGp = Rectangle.Round(gp.GetBounds()); return r.Contains (retGp); }
public Button(int x, int y, int sx, int sy, string str, short key,int mode) { this.rect = new Rectangle(x, y, sx, sy); this.name = str; this.key = key; this.mode = mode; this.p = new Point(); p.X = sx / 2 + x; p.Y = sy / 2 + y - 8; GraphicsPath path = new GraphicsPath(); path.AddString(str, deffont.FontFamily, (int)deffont.Style, deffont.Size,new PointF(0,0), null); RectangleF r=path.GetBounds(); p.X -= (int)r.Width-4; }
public void Draw(KalikoImage image) { var graphics = image.Graphics; var graphicsPath = new GraphicsPath(); var stringFormat = new StringFormat { Alignment = Alignment, LineAlignment = VerticalAlignment }; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; if (Font == null) { Font = image.Font ?? new Font("Arial", 32, FontStyle.Bold, GraphicsUnit.Pixel); } if (TargetArea == Rectangle.Empty) { TargetArea = new Rectangle(0, 0, image.Width, image.Height); } if (Point == Point.Empty) { graphicsPath.AddString(Text, Font.FontFamily, (int)Font.Style, Font.Size, TargetArea, stringFormat); } else { graphicsPath.AddString(Text, Font.FontFamily, (int)Font.Style, Font.Size, Point, stringFormat); } if (Rotation != 0) { var rotationTransform = new Matrix(1, 0, 0, 1, 0, 0); var bounds = graphicsPath.GetBounds(); rotationTransform.RotateAt(Rotation, new PointF(bounds.X + (bounds.Width / 2f), bounds.Y + (bounds.Height / 2f))); graphicsPath.Transform(rotationTransform); } if (TextShadow != null) { DrawShadow(graphics, graphicsPath); } if (Outline > 0) { var pen = new Pen(OutlineColor, Outline) { LineJoin = LineJoin.Round }; graphics.DrawPath(pen, graphicsPath); } if (TextBrush == null) { TextBrush = new SolidBrush(TextColor); } graphics.FillPath(TextBrush, graphicsPath); }
bool Dalssoft.DiagramNet.IController.HitTest(Rectangle r) { GraphicsPath gp = new GraphicsPath(); Matrix mtx = new Matrix(); Point elLocation = el.Location; Size elSize = el.Size; gp.AddRectangle(new Rectangle(elLocation.X, elLocation.Y, elSize.Width, elSize.Height)); gp.Transform(mtx); Rectangle retGp = Rectangle.Round(gp.GetBounds()); return r.Contains (retGp); }
public void SetPosition(float x, float y, int nWidth) { float nSideLength = (float)((float)nWidth * Tan30); m_HexagonPoints[0] = new Point((int)Math.Floor(x - (float)(nWidth / 2)), (int)Math.Floor(y - (nSideLength / 2))-1); m_HexagonPoints[1] = new Point((int)Math.Floor((float)x), (int)Math.Floor(y - (float)(nWidth / 2))-1); m_HexagonPoints[2] = new Point((int)Math.Floor(x + (float)(nWidth / 2)), (int)Math.Floor(y - (nSideLength / 2))-1); m_HexagonPoints[3] = new Point((int)Math.Floor(x + (float)(nWidth / 2)), (int)Math.Floor(y + (nSideLength / 2)) + 1); m_HexagonPoints[4] = new Point((int)Math.Floor((float)x), (int)Math.Floor(y + (float)(nWidth / 2)) + 1); m_HexagonPoints[5] = new Point((int)Math.Floor(x - (float)(nWidth / 2)), (int)Math.Floor(y + (nSideLength / 2)) + 1); GraphicsPath path = new GraphicsPath(); path.AddPolygon(m_HexagonPoints); m_Bounds = Rectangle.Round(path.GetBounds()); m_Bounds.Inflate(2, 2); }
public override RectangleF ReturnBounds() { 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); return path.GetBounds(); }
public static Bitmap CreateFillPolygon(Device d, GraphicsPath path, Brush brush) { RectangleF rectF = path.GetBounds(); System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix(); m.Translate(-rectF.X, -rectF.Y); path.Transform(m); AGT_TextureResource gdi = new AGT_TextureResource(rectF.Width, rectF.Height); if (gdi != null) { Graphics g = gdi.GetGraphics(); if (g != null) { g.FillPath(brush, path); return gdi.ToBitmap(); } } return null; }
private void Form1_Paint(object sender, PaintEventArgs e) { GraphicsPath Path = new GraphicsPath(); Path.AddString("한글", new FontFamily("궁서"), 0, 100, new Point(10, 30), new StringFormat()); /* 확장 후 외곽선 그리기 Path.Widen(new Pen(Color.Black, 3)); e.Graphics.DrawPath(Pens.Black, Path); //*/ /* 확장 후 채우기 Path.Widen(new Pen(Color.Black, 3)); e.Graphics.FillPath(Brushes.Blue, Path); //*/ /* 곡선 펴기 Path.Flatten(new Matrix(), 12f); e.Graphics.DrawPath(Pens.Black, Path); //*/ /* 회전 Matrix M = new Matrix(); M.Rotate(-10); Path.Transform(M); e.Graphics.FillPath(Brushes.Blue, Path); //*/ //* 휘기 RectangleF R = Path.GetBounds(); PointF[] arPoint = new PointF[4]; arPoint[0] = new PointF(R.Left, R.Top + 30); arPoint[1] = new PointF(R.Right, R.Top - 10); arPoint[2] = new PointF(R.Left + 10, R.Bottom - 10); arPoint[3] = new PointF(R.Right + 30, R.Bottom + 30); Path.Warp(arPoint, R); e.Graphics.FillPath(Brushes.Blue, Path); //*/ }
public void GetBounds(Graphics g) { // Create path number 1 and a Pen for drawing. GraphicsPath myPath = new GraphicsPath(); Pen pathPen = new Pen(Color.Black, 1); // Add an Ellipse to the path and Draw it (circle in start // position). myPath.AddEllipse(20, 20, 100, 100); g.DrawPath(pathPen, myPath); // Get the path bounds for Path number 1 and draw them. RectangleF boundRect = myPath.GetBounds(); g.DrawRectangle(new Pen(Color.Red, 1), boundRect.X, boundRect.Y, boundRect.Height, boundRect.Width); // Create a second graphics path and a wider Pen. GraphicsPath myPath2 = new GraphicsPath(); Pen pathPen2 = new Pen(Color.Black, 10); // Create a new ellipse with a width of 10. myPath2.AddEllipse(150, 20, 100, 100); myPath2.Widen(pathPen2); g.FillPath(Brushes.Black, myPath2); // Get the second path bounds. RectangleF boundRect2 = myPath2.GetBounds(); // Draw the bounding rectangle. g.DrawRectangle(new Pen(Color.Red, 1), boundRect2.X, boundRect2.Y, boundRect2.Height, boundRect2.Width); }
/// <summary> /// Rotate the image by angle degrees, with bkColor as new background /// Uses some magic with the translatetransform and pixel2d :P WOW! /// </summary> /// <param name="bmp">the image to be rotated</param> /// <param name="angle">the angle to rotate by</param> /// <param name="bkColor">background color for new background pixels</param> /// <returns>bmp rotated by angle degrees</returns> public static Bitmap RotateImg(Bitmap bmp, float angle, Color bkColor) { int w = bmp.Width; int h = bmp.Height; System.Drawing.Imaging.PixelFormat pf = default(System.Drawing.Imaging.PixelFormat); if (bkColor == Color.Transparent) { pf = System.Drawing.Imaging.PixelFormat.Format32bppArgb; } else { pf = bmp.PixelFormat; } Bitmap tempImg = new Bitmap(w, h, pf); Graphics g = Graphics.FromImage(tempImg); g.Clear(bkColor); g.DrawImageUnscaled(bmp, 1, 1); g.Dispose(); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddRectangle(new RectangleF(0f, 0f, w, h)); System.Drawing.Drawing2D.Matrix mtrx = new System.Drawing.Drawing2D.Matrix(); mtrx.Rotate(angle); RectangleF rct = path.GetBounds(mtrx); Bitmap newImg = new Bitmap(Convert.ToInt32(rct.Width), Convert.ToInt32(rct.Height), pf); g = Graphics.FromImage(newImg); g.Clear(bkColor); g.TranslateTransform(-rct.X, -rct.Y); g.RotateTransform(angle); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear; g.DrawImageUnscaled(tempImg, 0, 0); g.Dispose(); tempImg.Dispose(); return(newImg); }
private static void DrawInk(GraphicsPath p, InkPressureFeedbackMode m, Size s, Graphics g) { RectangleF PathBounds = p.GetBounds(); //get the bounds of the path and compute the square scale transform float ds = 0.8f * Math.Min(s.Width / PathBounds.Width, s.Height / PathBounds.Height); GraphicsState OriginalGraphicsState = g.Save(); g.TranslateTransform(s.Width >> 1, s.Height >> 1); g.ScaleTransform(ds, -ds); switch (m) { case InkPressureFeedbackMode.Size: g.FillEllipse(Brushes.Black, new Rectangle(-800, -800, 1600, 1600)); break; case InkPressureFeedbackMode.Width: g.DrawLine(new Pen(Color.Black, 500f), new Point(-500, 0), new Point(500, 0)); break; case InkPressureFeedbackMode.None: case InkPressureFeedbackMode.Color: default: GraphicsPath InkRegion = new GraphicsPath(); //upper-left triangular clip region to fake "ink" InkRegion.AddPolygon(new Point[] { Point.Empty, new Point(s.Width, 0), new Point(0, s.Height) }); Matrix InverseTransform = g.Transform; InverseTransform.Invert(); InkRegion.Transform(InverseTransform); g.IntersectClip(new Region(InkRegion)); g.DrawPath(new Pen(Color.Blue, 4 / ds), p); break; } g.Restore(OriginalGraphicsState); }
public static Bitmap ImageRotateAll(Bitmap btmp, float anglert, Color bgColor) { int wdth = btmp.Width; int hght = btmp.Height; PixelFormat pixfmt = default(PixelFormat); if (bgColor == Color.Transparent) { pixfmt = PixelFormat.Format32bppArgb; } else { pixfmt = btmp.PixelFormat; } Bitmap tempImage = new Bitmap(wdth, hght, pixfmt); Graphics gr = Graphics.FromImage(tempImage); gr.Clear(bgColor); gr.DrawImageUnscaled(btmp, 1, 1); gr.Dispose(); GraphicsPath path = new GraphicsPath(); path.AddRectangle(new RectangleF(0f, 0f, wdth, hght)); Matrix mtrx = new Matrix(); mtrx.Rotate(anglert); RectangleF rect = path.GetBounds(mtrx); Bitmap newImage = new Bitmap(Convert.ToInt32(rect.Width), Convert.ToInt32(rect.Height), pixfmt); gr = Graphics.FromImage(newImage); gr.Clear(bgColor); gr.TranslateTransform(-rect.X, -rect.Y); gr.RotateTransform(anglert); gr.InterpolationMode = InterpolationMode.HighQualityBilinear; gr.DrawImageUnscaled(tempImage, 0, 0); gr.Dispose(); tempImage.Dispose(); return newImage; }
private void DrawCustomStyle(PaintEventArgs e) { this.BackColor = Color.FromArgb(43, 43, 45); e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; Rectangle r = new Rectangle(0, 0, this.Width, this.Height); contentRectangle = r; #region Parent RoundedRect System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); int d = this.Height; 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); this.Region = new Region(gp); Color c = this.Parent != null ? this.Parent.BackColor : Color.White; e.Graphics.DrawPath(new Pen(c, 2f), gp); #endregion Point p1 = new Point(r.Width / 4, r.Y); Point p2 = new Point(r.X + (r.Width / 4 + r.Width / 2), r.Y); #region inner Rounded Rectangle Rectangle r2 = new Rectangle(p1.X, this.Height / 2 - (r.Height / 8), p2.X - p1.X, r.Height / 6); System.Drawing.Drawing2D.GraphicsPath gp2 = new System.Drawing.Drawing2D.GraphicsPath(); d = this.Height / 6; gp2.AddArc(r2.X, r2.Y, d, d, 180, 90); gp2.AddArc(r2.X + r2.Width - d, r2.Y, d, d, 270, 90); gp2.AddArc(r2.X + r2.Width - d, r2.Y + r2.Height - d, d, d, 0, 90); gp2.AddArc(r2.X, r2.Y + r2.Height - d, d, d, 90, 90); RectangleF irp = gp2.GetBounds(); staticInnerRect = new RectangleF(irp.X, irp.Y, irp.Width, irp.Height); if (!isMouseMoved) { if (this.ToggleState == ToggleButtonState.ON) { tPadx = (int)staticInnerRect.Right - 20; } else { tPadx = (int)staticInnerRect.X; } } custInnerRect = new RectangleF(tPadx, irp.Y, irp.Width, irp.Height); #endregion e.Graphics.DrawPath(new Pen(Color.FromArgb(64, 64, 64), 2f), gp2); using (LinearGradientBrush brs = new LinearGradientBrush(gp2.GetBounds(), Color.FromArgb(19, 19, 19), Color.FromArgb(64, 64, 64), LinearGradientMode.Vertical)) { e.Graphics.FillPath(brs, gp2); e.Graphics.DrawString(this.InActiveText, Font, Brushes.Gray, new Point(r.X + 10, (int)gp2.GetBounds().Y)); e.Graphics.DrawString(this.ActiveText, Font, Brushes.Gray, new Point((int)gp2.GetBounds().Right + 10, (int)gp2.GetBounds().Y)); } #region center shape Point cp1 = new Point((int)custInnerRect.X + 12, (int)irp.Y - 9); Point cp2 = new Point((int)custInnerRect.X - 2, (int)irp.Y); Point cp3 = new Point((int)custInnerRect.X + 3, (int)irp.Bottom + 7); Point cp4 = new Point((int)custInnerRect.X + 20, (int)irp.Bottom + 7); Point cp5 = new Point((int)custInnerRect.X + 24, (int)irp.Y); Point[] centerPoints = new Point[] { cp1, cp2, cp3, cp4, cp5 }; e.Graphics.DrawPolygon(Pens.Black, centerPoints); using (LinearGradientBrush brs = new LinearGradientBrush(cp1, cp3, Color.Gray, Color.Black)) { e.Graphics.FillPolygon(brs, centerPoints); } int x1 = cp3.X + (cp4.X - cp3.X) / 4; if (this.ToggleState == ToggleButtonState.OFF) { e.Graphics.FillEllipse(new SolidBrush(this.InActiveColor), x1, (cp2.Y), 10, 10); } else { e.Graphics.FillEllipse(new SolidBrush(this.ActiveColor), x1, (cp2.Y), 10, 10); } #endregion }
private const int MinItemRadialAngle = 18; // Minimum space in angles that can be occupied by single item. 18 gives 20 items on radial menu. public override void RecalcSize() { if (_RecalcSizeInProgress) return; // Prevent re-entrancy _RecalcSizeInProgress = true; try { DisposeSubItemsInfo(); m_Rect = new Rectangle(0, 0, _Diameter, _Diameter); //this.WidthInternal = _Diameter; //this.HeightInternal = _Diameter; Rectangle bounds = new Rectangle(this.LeftInternal, this.TopInternal, _Diameter, _Diameter); bounds.Width--; bounds.Height--; Rectangle radialMenuBounds = bounds; Rectangle centerBounds = bounds; centerBounds.Inflate(-((_Diameter - _CenterButtonDiameter) / 2 + 1), -((_Diameter - _CenterButtonDiameter) / 2 + 1)); if (_MenuType == eRadialMenuType.Segment) { bounds.Inflate(-_SubMenuEdgeWidth, -_SubMenuEdgeWidth); bounds.Inflate(-_SubMenuEdgeItemSpacing, -_SubMenuEdgeItemSpacing); } SubItemsCollection displayCollection = GetDisplayCollection(); int visibleCount = GetVisibleItemsCount(displayCollection); if (visibleCount > 0) { int maxItemRadialAngle = _MaxItemRadialAngle; if (maxItemRadialAngle == 0) maxItemRadialAngle = 180; int itemPieAngle = Math.Max(MinItemRadialAngle, Math.Min(maxItemRadialAngle, 360 / visibleCount)); if (itemPieAngle > _MaxItemPieAngle) itemPieAngle = _MaxItemPieAngle; // Single item can consume at most half of the circle int currentAngle = -90 - itemPieAngle / 2; _SubItemsInfo = new RadialSubItemInfo[displayCollection.Count]; for (int i = 0; i < displayCollection.Count; i++) { BaseItem item = displayCollection[i]; if (!item.Visible) continue; RadialMenuItem menuItem = item as RadialMenuItem; if (menuItem != null) { menuItem.RecalcSize(); GraphicsPath path = new GraphicsPath(); path.AddArc(bounds, currentAngle, itemPieAngle); Rectangle cb = centerBounds; cb.Inflate(4, 4); path.AddArc(cb, currentAngle + itemPieAngle, -itemPieAngle); path.CloseAllFigures(); menuItem.DisplayPath = path; menuItem.OutterBounds = bounds; menuItem.CenterBounds = centerBounds; menuItem.ItemAngle = currentAngle; menuItem.ItemPieAngle = itemPieAngle; menuItem.Bounds = Rectangle.Round(path.GetBounds()); } else { item.RecalcSize(); // Position item along the imaginary inner circle Rectangle innerCircle = bounds; innerCircle.Width -= item.WidthInternal; innerCircle.Height -= item.HeightInternal; if (innerCircle.Width < centerBounds.Width) innerCircle.Inflate((centerBounds.Width - innerCircle.Width) / 2, 0); if (innerCircle.Height < centerBounds.Height) innerCircle.Inflate(0, (centerBounds.Height - innerCircle.Height) / 2); Point p = new Point(innerCircle.X + (int)((innerCircle.Width / 2) * Math.Cos((currentAngle + itemPieAngle / 2) * (Math.PI / 180))), innerCircle.Y + (int)((innerCircle.Height / 2) * Math.Sin((currentAngle + itemPieAngle / 2) * (Math.PI / 180)))); p.Offset(innerCircle.Width / 2, innerCircle.Height / 2); item.TopInternal = p.Y; item.LeftInternal = p.X; } if (item != null && AnyVisibleSubItems(item)) { Rectangle outerBounds = bounds; outerBounds.Inflate(_SubMenuEdgeItemSpacing, _SubMenuEdgeItemSpacing); GraphicsPath subPath = new GraphicsPath(); int expandAngle = currentAngle + 1; int expandPieAngle = itemPieAngle - 1; subPath.AddArc(outerBounds, expandAngle, expandPieAngle); subPath.AddArc(radialMenuBounds, expandAngle + expandPieAngle, -expandPieAngle); subPath.CloseAllFigures(); Rectangle signPathBounds = radialMenuBounds; signPathBounds.Inflate(-4, -4); Point p = new Point(signPathBounds.X + (int)((signPathBounds.Width / 2) * Math.Cos((currentAngle + itemPieAngle / 2) * (Math.PI / 180))), signPathBounds.Y + (int)((signPathBounds.Height / 2) * Math.Sin((currentAngle + itemPieAngle / 2) * (Math.PI / 180)))); p.Offset(signPathBounds.Width / 2, signPathBounds.Height / 2); GraphicsPath signPath = UIGraphics.GetTrianglePath(new Point(-6, -6), 12, eTriangleDirection.Right); Matrix m = new Matrix(); if (currentAngle + itemPieAngle / 2 != 0) { m.Rotate(currentAngle + itemPieAngle / 2); m.Translate(p.X, p.Y, MatrixOrder.Append); } else m.Translate(p.X, p.Y); signPath.Transform(m); _SubItemsInfo[i] = new RadialSubItemInfo(subPath, signPath, currentAngle, itemPieAngle); } currentAngle += itemPieAngle; item.Displayed = true; } } } finally { _RecalcSizeInProgress = false; } base.RecalcSize(); }
private void DrawTabFocusIndicator(GraphicsPath tabpath, int index, Graphics graphics) { if (this._FocusTrack && this._TabControl.Focused && index == this._TabControl.SelectedIndex) { Brush focusBrush = null; RectangleF pathRect = tabpath.GetBounds(); Rectangle focusRect = Rectangle.Empty; switch (this._TabControl.Alignment) { case TabAlignment.Top: focusRect = new Rectangle((int)pathRect.X, (int)pathRect.Y, (int)pathRect.Width, 4); focusBrush = new LinearGradientBrush(focusRect, this._FocusColor, SystemColors.Window, LinearGradientMode.Vertical); break; case TabAlignment.Bottom: focusRect = new Rectangle((int)pathRect.X, (int)pathRect.Bottom - 4, (int)pathRect.Width, 4); focusBrush = new LinearGradientBrush(focusRect, SystemColors.ControlLight, this._FocusColor, LinearGradientMode.Vertical); break; case TabAlignment.Left: focusRect = new Rectangle((int)pathRect.X, (int)pathRect.Y, 4, (int)pathRect.Height); focusBrush = new LinearGradientBrush(focusRect, this._FocusColor, SystemColors.ControlLight, LinearGradientMode.Horizontal); break; case TabAlignment.Right: focusRect = new Rectangle((int)pathRect.Right - 4, (int)pathRect.Y, 4, (int)pathRect.Height); focusBrush = new LinearGradientBrush(focusRect, SystemColors.ControlLight, this._FocusColor, LinearGradientMode.Horizontal); break; } // Ensure the focus stip does not go outside the tab Region focusRegion = new Region(focusRect); focusRegion.Intersect(tabpath); graphics.FillRegion(focusBrush, focusRegion); focusRegion.Dispose(); focusBrush.Dispose(); } }
public void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons, Dictionary<Kill, KillDisplayDetails> dicKills, List<BattlemapRoundChange> lstRounds, KillDisplayColours colours, Dictionary<int, Color> teamColours) { GraphicsPath gpTimelineOutline = new GraphicsPath(); gpTimelineOutline.AddLines(new Point[] { new Point(5, 0), new Point(0, 5), new Point(0, 15), new Point((int)g.ClipBounds.Width - 280, 15), new Point((int)g.ClipBounds.Width - 280, 5), new Point((int)g.ClipBounds.Width - 275, 0) }); //gpTimelineOutline.AddLine(new Point(this.m_mtsSeek.SeekerPosition, 15), new Point((int)g.ClipBounds.Width - 280, 15)); //gpTimelineOutline.AddLines(new Point[] { new Point(235, (int)g.ClipBounds.Height - 55), new Point(230, (int)g.ClipBounds.Height - 50), new Point(230, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 50), new Point((int)g.ClipBounds.Width - 45, (int)g.ClipBounds.Height - 55) }); gpTimelineOutline.Widen(this.m_pOneWidth); this.ObjectPath = gpTimelineOutline; RectangleF recBounds = gpTimelineOutline.GetBounds(); recBounds.Height += 50.0F; this.HotSpot = recBounds; //string strMouseOverKillList = String.Empty; float flMouseOffsetX = 0.0F; bool blRoundChanged = false; MapTextBlock timeList = new MapTextBlock(); foreach (BattlemapRoundChange RoundChange in new List<BattlemapRoundChange>(lstRounds)) { float flOffsetXs = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - RoundChange.ChangeTime.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F); RectangleF recChangePosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F); if (flOffsetXs >= 0.0F) { GraphicsPath gpChangeTime = new GraphicsPath(); gpChangeTime.AddLine(new PointF(flOffsetXs, 5), new PointF(flOffsetXs, 12)); gpChangeTime.Widen(this.m_pOneWidth); this.DrawBwShape(g, gpChangeTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue); gpChangeTime.Dispose(); if (recChangePosition.Contains(new PointF(pntMouseLocation.X, pntMouseLocation.Y)) == true) { //strMouseOverKillList += String.Format("Round change {0}\r\n", RoundChange.Map.PublicLevelName); timeList.Strings.Add(new MapTextBlockString(String.Format("Round change {0}", RoundChange.Map.PublicLevelName), Color.Pink, true)); blRoundChanged = true; flMouseOffsetX = flOffsetXs; //flMouseOffsetX = flOffsetXs; } } } foreach (KeyValuePair<Kill, KillDisplayDetails> kvpKill in new Dictionary<Kill, KillDisplayDetails>(dicKills)) { float flOffsetXs = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - kvpKill.Key.TimeOfDeath.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F); RectangleF recKillPosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F); if (recKillPosition.Contains(new PointF(pntMouseLocation.X + 5.0F, pntMouseLocation.Y)) == true) { GraphicsPath gpKillTime = new GraphicsPath(); gpKillTime.AddLine(new PointF(flOffsetXs, 10), new PointF(flOffsetXs, 12)); gpKillTime.Widen(this.m_pOneWidth); this.DrawBwShape(g, gpKillTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue); gpKillTime.Dispose(); Color killerColour = Color.White; Color victimColour = Color.White; if (colours == KillDisplayColours.EnemyColours) { killerColour = ControlPaint.Light(Color.SeaGreen); victimColour = ControlPaint.LightLight(Color.Black); } else if (colours == KillDisplayColours.TeamColours) { if (teamColours.ContainsKey(kvpKill.Key.Killer.TeamID) == true && teamColours.ContainsKey(kvpKill.Key.Victim.TeamID) == true) { killerColour = ControlPaint.Light(teamColours[kvpKill.Key.Killer.TeamID]); victimColour = ControlPaint.Light(teamColours[kvpKill.Key.Victim.TeamID]); } } if (kvpKill.Key.Killer.ClanTag.Length > 0) { timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Killer.ClanTag), killerColour, false)); } timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Killer.SoldierName, killerColour, false)); timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.DamageType), Color.WhiteSmoke, false)); if (kvpKill.Key.Victim.ClanTag.Length > 0) { timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Victim.ClanTag), victimColour, false)); } timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Victim.SoldierName, victimColour, true)); flMouseOffsetX = flOffsetXs; } } if (timeList.Strings.Count > 0) { RectangleF recText = timeList.GetBounds(); PointF timeListOffset = new PointF(pntDrawOffset.X + flMouseOffsetX - recText.Width / 2.0F, pntDrawOffset.Y - recText.Height); if (timeListOffset.X + recText.Width > g.ClipBounds.Width) { timeListOffset.X = g.ClipBounds.Width - recText.Width; } timeList.Draw(g, timeListOffset, pntMouseLocation, mbButtons); } base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons); this.m_mtsSeek.ButtonOpacity = this.TimelineOpacity; this.m_mtsSeek.SeekerBounds = recBounds; this.m_mtsSeek.Draw(g, new PointF(pntDrawOffset.X, pntDrawOffset.Y + 13.0F), pntMouseLocation, mbButtons); timeList.Dispose(); }
private void DrawFinger( Graphics g, Rectangle rect, int value, float radius) { int addAngle = _fingerThickness; PointF centerPoint = new PointF((Width - 1) / 2.0f, (Height - 1) / 2.0f); double startAngle = ((float)value * FingerPerAngle - addAngle) / 180 * Math.PI; double endAngle = ((float)value * FingerPerAngle) / 180 * Math.PI; PointF pointStart = new PointF( centerPoint.X + radius * (float)Math.Cos(startAngle), centerPoint.Y + radius * (float)Math.Sin(startAngle)); PointF pointEnd = new PointF( centerPoint.X + radius * (float)Math.Cos(endAngle), centerPoint.Y + radius * (float)Math.Sin(endAngle)); using (GraphicsPath path = new GraphicsPath()) { path.AddLine(centerPoint, pointStart); path.AddArc(rect, value * FingerPerAngle - addAngle, addAngle); path.AddLine(pointEnd, centerPoint); using (LinearGradientBrush brush = new LinearGradientBrush( path.GetBounds(), Color.FromArgb(20, _fingerColor), _fingerColor, value * FingerPerAngle + 90)) { g.FillPath(brush, path); } } }
/// <summary> /// Draw the this <see cref="CurveItem"/> to the specified <see cref="Graphics"/> /// device using the specified smoothing property (<see cref="ZedGraph.Line.SmoothTension"/>). /// The routine draws the line segments and the area fill (if any, see <see cref="FillType"/>; /// the symbols are drawn by the <see cref="Symbol.Draw"/> method. This method /// is normally only called by the Draw method of the /// <see cref="CurveItem"/> object. Note that the <see cref="StepType"/> property /// is ignored for smooth lines (e.g., when <see cref="ZedGraph.Line.IsSmooth"/> is true). /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="LineItem"/> representing this /// curve.</param> public void DrawSmoothFilledCurve( Graphics g, GraphPane pane, CurveItem curve, float scaleFactor ) { Line source = this; if ( curve.IsSelected ) source = Selection.Line; PointF[] arrPoints; int count; IPointList points = curve.Points; if ( this.IsVisible && !this.Color.IsEmpty && points != null && BuildPointsArray( pane, curve, out arrPoints, out count ) && count > 2 ) { float tension = _isSmooth ? _smoothTension : 0f; // Fill the curve if needed if ( this.Fill.IsVisible ) { Axis yAxis = curve.GetYAxis( pane ); using ( GraphicsPath path = new GraphicsPath( FillMode.Winding ) ) { path.AddCurve( arrPoints, 0, count - 2, tension ); double yMin = yAxis._scale._min < 0 ? 0.0 : yAxis._scale._min; CloseCurve( pane, curve, arrPoints, count, yMin, path ); RectangleF rect = path.GetBounds(); using ( Brush brush = source._fill.MakeBrush( rect ) ) { if ( pane.LineType == LineType.Stack && yAxis.Scale._min < 0 && this.IsFirstLine( pane, curve ) ) { float zeroPix = yAxis.Scale.Transform( 0 ); RectangleF tRect = pane.Chart._rect; tRect.Height = zeroPix - tRect.Top; if ( tRect.Height > 0 ) { Region reg = g.Clip; g.SetClip( tRect ); g.FillPath( brush, path ); g.SetClip( pane.Chart._rect ); } } else g.FillPath( brush, path ); //brush.Dispose(); } // restore the zero line if needed (since the fill tends to cover it up) yAxis.FixZeroLine( g, pane, scaleFactor, rect.Left, rect.Right ); } } // If it's a smooth curve, go ahead and render the path. Otherwise, use the // standard drawcurve method just in case there are missing values. if ( _isSmooth ) { using ( Pen pen = GetPen( pane, scaleFactor ) ) { // Stroke the curve g.DrawCurve( pen, arrPoints, 0, count - 2, tension ); //pen.Dispose(); } } else DrawCurve( g, pane, curve, scaleFactor ); } }
private void DrawCursor() { _lower = 0f; float bandpassOffset; var bandpassWidth = 0f; var cursorWidth = Math.Max((_filterBandwidth + _filterOffset) * _xIncrement, 2); var xCarrier = (float) ClientRectangle.Width / 2 + (_frequency - _displayCenterFrequency) * _xIncrement; switch (_bandType) { case BandType.Upper: bandpassOffset = _filterOffset * _xIncrement; bandpassWidth = cursorWidth - bandpassOffset; _lower = xCarrier + bandpassOffset; break; case BandType.Lower: bandpassOffset = _filterOffset * _xIncrement; bandpassWidth = cursorWidth - bandpassOffset; _lower = xCarrier - bandpassOffset - bandpassWidth; break; case BandType.Center: _lower = xCarrier - cursorWidth / 2; bandpassWidth = cursorWidth; break; } _upper = _lower + bandpassWidth; using (var transparentBackground = new SolidBrush(Color.FromArgb(80, Color.DarkGray))) using (var redPen = new Pen(Color.Red)) using (var graphics = Graphics.FromImage(_buffer)) using (var fontFamily = new FontFamily("Arial")) using (var path = new GraphicsPath()) using (var outlinePen = new Pen(Color.Black)) { if (_enableFilter && cursorWidth < ClientRectangle.Width) { var carrierPen = redPen; carrierPen.Width = CarrierPenWidth; graphics.FillRectangle(transparentBackground, (int) _lower + 1, 0, (int) bandpassWidth, ClientRectangle.Height); if (xCarrier >= AxisMargin && xCarrier <= ClientRectangle.Width - AxisMargin) { graphics.DrawLine(carrierPen, xCarrier, 0f, xCarrier, ClientRectangle.Height); } } if (_markPeaks && _spectrumWidth > 0) { var windowSize = (int) bandpassWidth; windowSize = Math.Max(windowSize, 10); windowSize = Math.Min(windowSize, _scaledSpectrum.Length); PeakDetector.GetPeaks(_scaledSpectrum, _peaks, windowSize); var yIncrement = (ClientRectangle.Height - 2 * AxisMargin) / (float) byte.MaxValue; for (var i = 0; i < _peaks.Length; i++) { if (_peaks[i]) { var y = (int) (ClientRectangle.Height - AxisMargin - _scaledSpectrum[i] * yIncrement); var x = i + AxisMargin; graphics.DrawEllipse(Pens.Yellow, x - 5, y - 5, 10, 10); } } } if (_hotTrackNeeded && _trackingX >= AxisMargin && _trackingX <= ClientRectangle.Width - AxisMargin && _trackingY >= AxisMargin && _trackingY <= ClientRectangle.Height - AxisMargin) { if (_scaledSpectrum != null && !_changingFrequency && !_changingCenterFrequency && !_changingBandwidth) { var index = _trackingX - AxisMargin; if (_useSnap) { // Todo: snap the index } if (index > 0 && index < _scaledSpectrum.Length) { graphics.DrawLine(redPen, _trackingX, 0, _trackingX, ClientRectangle.Height); } } string fstring; if (_changingFrequency) { fstring = "VFO = " + GetFrequencyDisplay(_frequency); } else if (_changingBandwidth) { fstring = "BW = " + GetFrequencyDisplay(_filterBandwidth); } else if (_changingCenterFrequency) { fstring = "Center Freq. = " + GetFrequencyDisplay(_centerFrequency); } else { fstring = string.Format("{0}\r\n{1:0.##}dB", GetFrequencyDisplay(_trackingFrequency), _trackingPower); } path.AddString(fstring, fontFamily, (int)FontStyle.Regular, TrackingFontSize, Point.Empty, StringFormat.GenericTypographic); var stringSize = path.GetBounds(); var currentCursor = Cursor.Current; var xOffset = _trackingX + 15.0f; var yOffset = _trackingY + (currentCursor == null ? DefaultCursorHeight : currentCursor.Size.Height) - 8.0f; xOffset = Math.Min(xOffset, ClientRectangle.Width - stringSize.Width - 5); yOffset = Math.Min(yOffset, ClientRectangle.Height - stringSize.Height - 5); path.Reset(); path.AddString(fstring, fontFamily, (int)FontStyle.Regular, TrackingFontSize, new Point((int)xOffset, (int)yOffset), StringFormat.GenericTypographic); var smoothingMode = graphics.SmoothingMode; var interpolationMode = graphics.InterpolationMode; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; outlinePen.Width = 2; graphics.DrawPath(outlinePen, path); graphics.FillPath(Brushes.White, path); graphics.SmoothingMode = smoothingMode; graphics.InterpolationMode = interpolationMode; } } }
private Rectangle GetTabImageRect(GraphicsPath tabBorderPath) { Rectangle imageRect = new Rectangle(); RectangleF rect = tabBorderPath.GetBounds(); // Make it shorter or thinner to fit the height or width because of the padding added to the tab for painting switch (this.Alignment) { case TabAlignment.Top: rect.Y += 4; rect.Height -= 6; break; case TabAlignment.Bottom: rect.Y += 2; rect.Height -= 6; break; case TabAlignment.Left: rect.X += 4; rect.Width -= 6; break; case TabAlignment.Right: rect.X += 2; rect.Width -= 6; break; } // Ensure image is fully visible if (this.Alignment <= TabAlignment.Bottom) { if ((this._StyleProvider.ImageAlign & NativeMethods.AnyLeftAlign) != ((ContentAlignment) 0)){ imageRect = new Rectangle((int)rect.X, (int)rect.Y + (int)Math.Floor((double)((int)rect.Height - 16)/2), 16, 16); while (!tabBorderPath.IsVisible(imageRect.X, imageRect.Y)) { imageRect.X += 1; } imageRect.X += 4; } else if ((this._StyleProvider.ImageAlign & NativeMethods.AnyCenterAlign) != ((ContentAlignment) 0)){ imageRect = new Rectangle((int)rect.X + (int)Math.Floor((double)(((int)rect.Right - (int)rect.X - (int)rect.Height + 2)/2)), (int)rect.Y + (int)Math.Floor((double)((int)rect.Height - 16)/2), 16, 16); } else { imageRect = new Rectangle((int)rect.Right, (int)rect.Y + (int)Math.Floor((double)((int)rect.Height - 16)/2), 16, 16); while (!tabBorderPath.IsVisible(imageRect.Right, imageRect.Y)) { imageRect.X -= 1; } imageRect.X -= 4; // Move it in further to allow for the tab closer if (this._StyleProvider.ShowTabCloser && !this.RightToLeftLayout){ imageRect.X -= 10; } } } else { if ((this._StyleProvider.ImageAlign & NativeMethods.AnyLeftAlign) != ((ContentAlignment) 0)){ imageRect = new Rectangle((int)rect.X + (int)Math.Floor((double)((int)rect.Width - 16)/2), (int)rect.Y, 16, 16); while (!tabBorderPath.IsVisible(imageRect.X, imageRect.Y)) { imageRect.Y += 1; } imageRect.Y += 4; } else if ((this._StyleProvider.ImageAlign & NativeMethods.AnyCenterAlign) != ((ContentAlignment) 0)){ imageRect = new Rectangle((int)rect.X + (int)Math.Floor((double)((int)rect.Width - 16)/2), (int)rect.Y + (int)Math.Floor((double)(((int)rect.Bottom - (int)rect.Y - (int)rect.Width + 2)/2)), 16, 16); } else { imageRect = new Rectangle((int)rect.X + (int)Math.Floor((double)((int)rect.Width - 16)/2), (int)rect.Bottom , 16, 16); while (!tabBorderPath.IsVisible(imageRect.X, imageRect.Bottom)) { imageRect.Y -= 1; } imageRect.Y -= 4; // Move it in further to allow for the tab closer if (this._StyleProvider.ShowTabCloser && !this.RightToLeftLayout){ imageRect.Y -= 10; } } } return imageRect; }
/// <summary>This method will paint the group title.</summary> /// <param name="g">The paint event graphics object.</param> private void PaintGroupText(System.Drawing.Graphics g) { //Check if string has something------------- if (this.Text == string.Empty) { return; } //------------------------------------------ //Set Graphics smoothing mode to Anit-Alias-- g.SmoothingMode = SmoothingMode.AntiAlias; //------------------------------------------- //Declare Variables------------------ SizeF StringSize = g.MeasureString(this.Text, this.Font); Size StringSize2 = StringSize.ToSize(); if (this.GroupImage != null) { StringSize2.Width += 18; } int ArcWidth = this.RoundCorners; int ArcHeight = this.RoundCorners; int ArcX1 = 20; int ArcX2 = (StringSize2.Width + 34) - (ArcWidth + 1); int ArcY1 = 0; int ArcY2 = 24 - (ArcHeight + 1); if (this.TitleStyle == TitleStyles.XPStyle) { ArcX1 = 0; ArcX2 = this.Width - (ArcWidth + 1); ArcY1 = 0; ArcY2 = 24 - (ArcHeight + 1); } System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); System.Drawing.Brush BorderBrush = new SolidBrush(this.BorderColor); System.Drawing.Pen BorderPen = new Pen(BorderBrush, this.BorderThickness); System.Drawing.Drawing2D.LinearGradientBrush BackgroundGradientBrush = null; System.Drawing.Brush BackgroundBrush = null;//(this.PaintGroupBox) ? new LinearGradientBrush(this.CustomGroupBoxColor) : new SolidBrush(this.BackgroundColor); System.Drawing.SolidBrush TextColorBrush = new SolidBrush(this.TitleTextColor); System.Drawing.SolidBrush ShadowBrush = null; System.Drawing.Drawing2D.GraphicsPath ShadowPath = null; //----------------------------------- //Check if shadow is needed---------- if (this.ShadowControl) { ShadowBrush = new SolidBrush(this.ShadowColor); ShadowPath = new System.Drawing.Drawing2D.GraphicsPath(); ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle); // Top Left ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY1 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle); //Top Right ShadowPath.AddArc(ArcX2 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle); //Bottom Right ShadowPath.AddArc(ArcX1 + (this.ShadowThickness - 1), ArcY2 + (this.ShadowThickness - 1), ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle); //Bottom Left ShadowPath.CloseAllFigures(); //Paint Rounded Rectangle------------ g.FillPath(ShadowBrush, ShadowPath); //----------------------------------- } //----------------------------------- //Create Rounded Rectangle Path------ path.AddArc(ArcX1, ArcY1, ArcWidth, ArcHeight, 180, GroupBoxConstants.SweepAngle); // Top Left path.AddArc(ArcX2, ArcY1, ArcWidth, ArcHeight, 270, GroupBoxConstants.SweepAngle); //Top Right path.AddArc(ArcX2, ArcY2, ArcWidth, ArcHeight, 360, GroupBoxConstants.SweepAngle); //Bottom Right path.AddArc(ArcX1, ArcY2, ArcWidth, ArcHeight, 90, GroupBoxConstants.SweepAngle); //Bottom Left path.CloseAllFigures(); //----------------------------------- //Check if Gradient Mode is enabled-- if (this.PaintGroupBox) { //Paint Rounded Rectangle------------ BackgroundGradientBrush = new LinearGradientBrush(path.GetBounds(), this.TitileGradientColors.Color1, this.TitileGradientColors.Color2, (LinearGradientMode)this.BackgroundGradientMode); g.FillPath(BackgroundGradientBrush, path); //----------------------------------- } else { if (this.BackgroundGradientMode == GroupBoxGradientMode.None) { //Paint Rounded Rectangle------------ BackgroundBrush = new SolidBrush(this.BackColor); g.FillPath(BackgroundBrush, path); //----------------------------------- } else { BackgroundGradientBrush = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), this.GradientColors.Color1, this.GradientColors.Color2, (LinearGradientMode)this.BackgroundGradientMode); //Paint Rounded Rectangle------------ g.FillPath(BackgroundGradientBrush, path); //----------------------------------- } } //----------------------------------- //Paint Borded----------------------- g.DrawPath(BorderPen, path); //----------------------------------- //Paint Text------------------------- int CustomStringWidth = (this.GroupImage != null) ? 44 : 28; g.DrawString(this.Text, this.Font, TextColorBrush, CustomStringWidth, 5); //----------------------------------- //Draw GroupImage if there is one---- if (this.GroupImage != null) { g.DrawImage(this.GroupImage, 28, 4, 16, 16); } //----------------------------------- //Destroy Graphic Objects------------ if (path != null) { path.Dispose(); } if (BorderBrush != null) { BorderBrush.Dispose(); } if (BorderPen != null) { BorderPen.Dispose(); } if (BackgroundGradientBrush != null) { BackgroundGradientBrush.Dispose(); } if (BackgroundBrush != null) { BackgroundBrush.Dispose(); } if (TextColorBrush != null) { TextColorBrush.Dispose(); } if (ShadowBrush != null) { ShadowBrush.Dispose(); } if (ShadowPath != null) { ShadowPath.Dispose(); } //----------------------------------- }
public Stack <Point> FindPath(Point from, Point to) { var pfGrid = new int[WAM_WIDTH][]; for (var i = 0; i < WAM_WIDTH; i++) { pfGrid[i] = new int[WAM_HEIGHT]; Array.Fill(pfGrid[i], -1); } // Correct start & end position from = GetNearestWamPoint(from); to = GetNearestWamPoint(to); var workQueue = new Queue <Point>(); var notFound = true; pfGrid[from.X][from.Y] = 0; var curPoint = from; while (notFound) { if (curPoint == to) { notFound = false; } else { var n = pfGrid[curPoint.X][curPoint.Y] + 2; --curPoint.Y; if (curPoint.X >= 0 && curPoint.X < WAM_WIDTH && curPoint.Y >= 0 && curPoint.Y < WAM_HEIGHT && pfGrid[curPoint.X][curPoint.Y] == -1 && _wamData[curPoint.X][curPoint.Y]) { pfGrid[curPoint.X][curPoint.Y] = n; workQueue.Enqueue(curPoint); } ++curPoint.X; ++curPoint.Y; if (curPoint.X >= 0 && curPoint.X < WAM_WIDTH && curPoint.Y >= 0 && curPoint.Y < WAM_HEIGHT && pfGrid[curPoint.X][curPoint.Y] == -1 && _wamData[curPoint.X][curPoint.Y]) { pfGrid[curPoint.X][curPoint.Y] = n; workQueue.Enqueue(curPoint); } ++curPoint.Y; if (--curPoint.X >= 0 && curPoint.X < WAM_WIDTH && curPoint.Y >= 0 && curPoint.Y < WAM_HEIGHT && pfGrid[curPoint.X][curPoint.Y] == -1 && _wamData[curPoint.X][curPoint.Y]) { pfGrid[curPoint.X][curPoint.Y] = n; workQueue.Enqueue(curPoint); } --curPoint.Y; if (--curPoint.X >= 0 && curPoint.X < WAM_WIDTH && curPoint.Y >= 0 && curPoint.Y < WAM_HEIGHT && pfGrid[curPoint.X][curPoint.Y] == -1 && _wamData[curPoint.X][curPoint.Y]) { pfGrid[curPoint.X][curPoint.Y] = n; workQueue.Enqueue(curPoint); } ++n; --curPoint.Y; if (curPoint.X >= 0 && curPoint.X < WAM_WIDTH && curPoint.Y >= 0 && curPoint.Y < WAM_HEIGHT && pfGrid[curPoint.X][curPoint.Y] == -1 && _wamData[curPoint.X][curPoint.Y]) { pfGrid[curPoint.X][curPoint.Y] = n; workQueue.Enqueue(curPoint); } ++curPoint.X; if (++curPoint.X >= 0 && curPoint.X < WAM_WIDTH && curPoint.Y >= 0 && curPoint.Y < WAM_HEIGHT && pfGrid[curPoint.X][curPoint.Y] == -1 && _wamData[curPoint.X][curPoint.Y]) { pfGrid[curPoint.X][curPoint.Y] = n; workQueue.Enqueue(curPoint); } ++curPoint.Y; ++curPoint.Y; if (curPoint.X >= 0 && curPoint.X < WAM_WIDTH && curPoint.Y >= 0 && curPoint.Y < WAM_HEIGHT && pfGrid[curPoint.X][curPoint.Y] == -1 && _wamData[curPoint.X][curPoint.Y]) { pfGrid[curPoint.X][curPoint.Y] = n; workQueue.Enqueue(curPoint); } --curPoint.X; if (--curPoint.X < 0 || curPoint.X >= WAM_WIDTH || curPoint.Y < 0 || curPoint.Y >= WAM_HEIGHT || pfGrid[curPoint.X][curPoint.Y] != -1 || !_wamData[curPoint.X][curPoint.Y]) { continue; } pfGrid[curPoint.X][curPoint.Y] = n; workQueue.Enqueue(curPoint); } } var deltaX = 0; var deltaY = 0; var resultPoints = new Stack <Point>(); while (from.X != to.X || from.Y != to.Y) { curPoint = to; var n = pfGrid[curPoint.X][curPoint.Y]; var dX = 0; var dY = 0; --curPoint.Y; if (curPoint.X >= 0 && curPoint.X < 800 && curPoint.Y >= 0 && curPoint.Y < 600 && pfGrid[curPoint.X][curPoint.Y] != -1 && pfGrid[curPoint.X][curPoint.Y] < n) { n = pfGrid[curPoint.X][curPoint.Y]; dX = 0; dY = -1; } ++curPoint.X; ++curPoint.Y; if (curPoint.X >= 0 && curPoint.X < 800 && curPoint.Y >= 0 && curPoint.Y < 600 && pfGrid[curPoint.X][curPoint.Y] != -1 && pfGrid[curPoint.X][curPoint.Y] < n) { n = pfGrid[curPoint.X][curPoint.Y]; dX = 1; dY = 0; } ++curPoint.Y; if (--curPoint.X >= 0 && curPoint.X < 800 && curPoint.Y >= 0 && curPoint.Y < 600 && pfGrid[curPoint.X][curPoint.Y] != -1 && pfGrid[curPoint.X][curPoint.Y] < n) { n = pfGrid[curPoint.X][curPoint.Y]; dX = 0; dY = 1; } --curPoint.Y; if (--curPoint.X >= 0 && curPoint.X < 800 && curPoint.Y >= 0 && curPoint.Y < 600 && pfGrid[curPoint.X][curPoint.Y] != -1 && pfGrid[curPoint.X][curPoint.Y] < n) { n = pfGrid[curPoint.X][curPoint.Y]; dX = -1; dY = 0; } --curPoint.Y; if (curPoint.X >= 0 && curPoint.X < 800 && curPoint.Y >= 0 && curPoint.Y < 600 && pfGrid[curPoint.X][curPoint.Y] != -1 && pfGrid[curPoint.X][curPoint.Y] < n) { n = pfGrid[curPoint.X][curPoint.Y]; dX = -1; dY = -1; } ++curPoint.X; if (++curPoint.X >= 0 && curPoint.X < 800 && curPoint.Y >= 0 && curPoint.Y < 600 && pfGrid[curPoint.X][curPoint.Y] != -1 && pfGrid[curPoint.X][curPoint.Y] < n) { n = pfGrid[curPoint.X][curPoint.Y]; dX = 1; dY = -1; } ++curPoint.Y; ++curPoint.Y; if (curPoint.X >= 0 && curPoint.X < 800 && curPoint.Y >= 0 && curPoint.Y < 600 && pfGrid[curPoint.X][curPoint.Y] != -1 && pfGrid[curPoint.X][curPoint.Y] < n) { n = pfGrid[curPoint.X][curPoint.Y]; dX = 1; dY = 1; } --curPoint.X; if (--curPoint.X >= 0 && curPoint.X < 800 && curPoint.Y >= 0 && curPoint.Y < 600 && pfGrid[curPoint.X][curPoint.Y] != -1 && pfGrid[curPoint.X][curPoint.Y] < n) { n = pfGrid[curPoint.X][curPoint.Y]; dX = -1; dY = 1; } if (dX != deltaX || dY != deltaY) { resultPoints.Push(to); deltaX = dX; deltaY = dY; } to.X += dX; to.Y += dY; } if (resultPoints.Count == 0) { resultPoints.Push(from); } var stackSize = -1; while (stackSize != resultPoints.Count) { stackSize = resultPoints.Count; for (var i = 2; i < resultPoints.Count; ++i) { from.X = resultPoints.ElementAt(i - 2).X; from.Y = resultPoints.ElementAt(i - 2).Y; deltaX = resultPoints.ElementAt(i - 1).X; deltaY = resultPoints.ElementAt(i - 1).Y; to.X = resultPoints.ElementAt(i).X; to.Y = resultPoints.ElementAt(i).Y; var directPath = new System.Drawing.Drawing2D.GraphicsPath(); directPath.AddLine(new System.Drawing.Point(from.X, from.Y), new System.Drawing.Point(to.X, to.Y)); var lineBounds = directPath.GetBounds(); var line2d = new Line2D(new Point2D(from.X, from.Y), new Point2D(to.X, to.Y)); notFound = true; for (curPoint.X = (int)lineBounds.X; curPoint.X < lineBounds.X + lineBounds.Width; ++curPoint.X) { for (curPoint.Y = (int)lineBounds.Y; curPoint.Y < lineBounds.Y + lineBounds.Height; ++curPoint.Y) { if (line2d.LineTo(new Point2D(curPoint.X, curPoint.Y), true).Length < 0.8) { notFound = (notFound && _wamData[curPoint.X][curPoint.Y]); } } } if (notFound) { resultPoints = resultPoints.Where((source, index) => index != i - 1) as Stack <Point>; } } } return(resultPoints); }
private static void CalculateLabelAroundOnLineString(SharpMap.Geometries.LineString line, ref BaseLabel label, Map map, System.Drawing.Graphics g, System.Drawing.SizeF textSize) { IList <SharpMap.Geometries.Point> sPoints = line.Vertices; // only get point in enverlop of map Collection <System.Drawing.PointF> colPoint = new Collection <System.Drawing.PointF>(); bool bCheckStarted = false; for (int j = 0; j < sPoints.Count; j++) { if (map.Envelope.Grow(map.PixelSize * 10).Contains(sPoints[j])) { //points[j] = map.WorldToImage(sPoints[j]); colPoint.Add(map.WorldToImage(sPoints[j])); bCheckStarted = true; } else if (bCheckStarted == true) { // fix bug curved line out of map in center segment of line break; } } if (colPoint.Count > 1) { label.TextOnPathLabel = new SharpMap.Rendering.TextOnPath(); switch (label.Style.HorizontalAlignment) { case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left: label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Left; break; case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Right: label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Right; break; case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center: label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center; break; default: label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center; break; } switch (label.Style.VerticalAlignment) { case SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Bottom: label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.UnderPath; break; case SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Top: label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.OverPath; break; case SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Middle: label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.CenterPath; break; default: label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.CenterPath; break; } int idxStartPath = 0; int numberPoint = colPoint.Count; // start Optimzes Path points int step = 100; if (colPoint.Count >= step * 2) { numberPoint = step * 2;; switch (label.Style.HorizontalAlignment) { case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left: //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Left; idxStartPath = 0; break; case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Right: //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Right; idxStartPath = colPoint.Count - step; break; case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center: //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center; idxStartPath = (int)colPoint.Count / 2 - step; break; default: //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center; idxStartPath = (int)colPoint.Count / 2 - step; break; } } // end optimize path point System.Drawing.PointF[] points = new System.Drawing.PointF[numberPoint]; int count = 0; if (colPoint[0].X <= colPoint[colPoint.Count - 1].X) { for (int l = idxStartPath; l < numberPoint + idxStartPath; l++) { points[count] = colPoint[l]; count++; } } else { //reverse the path for (int k = numberPoint - 1 + idxStartPath; k >= idxStartPath; k--) { points[count] = colPoint[k]; count++; } } //get text size in page units ie pixels float textheight = label.Style.Font.Size; switch (label.Style.Font.Unit) { case System.Drawing.GraphicsUnit.Display: textheight = textheight * g.DpiY / 75; break; case System.Drawing.GraphicsUnit.Document: textheight = textheight * g.DpiY / 300; break; case System.Drawing.GraphicsUnit.Inch: textheight = textheight * g.DpiY; break; case System.Drawing.GraphicsUnit.Millimeter: textheight = (float)(textheight / 25.4 * g.DpiY); break; case System.Drawing.GraphicsUnit.Pixel: //do nothing break; case System.Drawing.GraphicsUnit.Point: textheight = textheight * g.DpiY / 72; break; } System.Drawing.Font topFont = new System.Drawing.Font(label.Style.Font.FontFamily, textheight, label.Style.Font.Style); // System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddLines(points); label.TextOnPathLabel.PathColorTop = System.Drawing.Color.Transparent; label.TextOnPathLabel.Text = label.Text; label.TextOnPathLabel.LetterSpacePercentage = 90; label.TextOnPathLabel.FillColorTop = new System.Drawing.SolidBrush(label.Style.ForeColor); label.TextOnPathLabel.Font = topFont; label.TextOnPathLabel.PathDataTop = path.PathData; label.TextOnPathLabel.Graphics = g; //label.TextOnPathLabel.ShowPath=true; //label.TextOnPathLabel.PathColorTop = System.Drawing.Color.YellowGreen; if (label.Style.Halo != null) { label.TextOnPathLabel.ColorHalo = label.Style.Halo; } else { label.TextOnPathLabel.ColorHalo = null;// new System.Drawing.Pen(label.Style.ForeColor, (float)0.5); } path.Dispose(); // MeasureString to get region label.TextOnPathLabel.MeasureString = true; label.TextOnPathLabel.DrawTextOnPath(); label.TextOnPathLabel.MeasureString = false; // Get Region label for CollissionDetection here. System.Drawing.Drawing2D.GraphicsPath pathRegion = new System.Drawing.Drawing2D.GraphicsPath(); if (label.TextOnPathLabel.RegionList.Count > 0) { //int idxCenter = (int)label.TextOnPathLabel.PointsText.Count / 2; //System.Drawing.Drawing2D.Matrix rotationMatrix = g.Transform.Clone();// new Matrix(); //rotationMatrix.RotateAt(label.TextOnPathLabel.Angles[idxCenter], label.TextOnPathLabel.PointsText[idxCenter]); //if (label.TextOnPathLabel.PointsTextUp.Count > 0) //{ // for (int up = label.TextOnPathLabel.PointsTextUp.Count - 1; up >= 0; up--) // { // label.TextOnPathLabel.PointsText.Add(label.TextOnPathLabel.PointsTextUp[up]); // } //} pathRegion.AddRectangles(label.TextOnPathLabel.RegionList.ToArray()); // get box for detect colission here label.Box = new LabelBox(pathRegion.GetBounds()); //g.FillRectangle(System.Drawing.Brushes.YellowGreen, label.Box); } pathRegion.Dispose(); } }