当前位置: 首页>>代码示例>>C#>>正文


C# GraphicsPath.AddPolygon方法代码示例

本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.AddPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.AddPolygon方法的具体用法?C# GraphicsPath.AddPolygon怎么用?C# GraphicsPath.AddPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Drawing2D.GraphicsPath的用法示例。


在下文中一共展示了GraphicsPath.AddPolygon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawPolygon

        public static void DrawPolygon(Graphics graphics, Polygon pol, Brush brush, Pen pen, IViewport viewport)
        {
            if (pol.ExteriorRing == null) return;
            if (pol.ExteriorRing.Vertices.Count <= 2) return;

            //Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
            var gp = new GraphicsPath();

            //Add the exterior polygon
            var points = GeometryRenderer.WorldToScreenGDI(pol.ExteriorRing, viewport);
            if (points.Length > 2)
                gp.AddPolygon(points);
            //Add the interior polygons (holes)
            foreach (LinearRing linearRing in pol.InteriorRings)
            {
                var interiorPoints = GeometryRenderer.WorldToScreenGDI(linearRing, viewport);
                if (interiorPoints.Length > 2)
                    gp.AddPolygon(interiorPoints);
            }

            if (gp.PointCount == 0) return;

            // Only render inside of polygon if the brush isn't null or isn't transparent
            if (brush != null && brush != Brushes.Transparent)
                graphics.FillPath(brush, gp);
            // Create an outline if a pen style is available
            if (pen != null)
                graphics.DrawPath(pen, gp);
        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:29,代码来源:PolygonRenderer.cs

示例2: GetPolygonGraphicsPath

		/*
		 * GetPolygonGraphicsPath
		 */

		/// <summary>
		/// Gets the <see cref="T:GraphicsPath"/> for the polygon with the specified number of points.
		/// </summary>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <paramref name="vertextCount"/> is less than 3.
		/// </exception>
		public static GraphicsPath GetPolygonGraphicsPath(int vertexCount, Rectangle polygonBounds)
		{
			if (vertexCount < 3)
			{
				throw new ArgumentOutOfRangeException(
					"vertexCount",
					vertexCount,
					Properties.Resources.ArgumentOutOfRange_PolygonPoints
					);
			}

			PointF[] points = new PointF[vertexCount];

			int currentPoint = 0;

			double offset = 360.0 / (double)vertexCount;

			for (double angle = -90; currentPoint < vertexCount; angle += offset)
			{
				points[currentPoint++] = new PointF(
					(float)(polygonBounds.Left + (double)polygonBounds.Width / 2.0 + GetEllipseX(DegToRad(angle), (double)polygonBounds.Width / 2.0)),
					(float)(polygonBounds.Top + (double)polygonBounds.Height / 2.0 + GetEllipseY(DegToRad(angle), (double)polygonBounds.Height / 2.0))
					);
			}

			GraphicsPath gp = new GraphicsPath();
			gp.AddPolygon(points);

			return gp;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:40,代码来源:NuGenControlPaint.Polygons.cs

示例3: RotateImage

        public static Bitmap RotateImage(Image img, float theta)
        {
            Matrix matrix = new Matrix();
            matrix.Translate(img.Width / -2, img.Height / -2, MatrixOrder.Append);
            matrix.RotateAt(theta, new Point(0, 0), MatrixOrder.Append);
            using (GraphicsPath gp = new GraphicsPath())
            {
                gp.AddPolygon(new Point[] { new Point(0, 0), new Point(img.Width, 0), new Point(0, img.Height) });
                gp.Transform(matrix);
                PointF[] pts = gp.PathPoints;

                Rectangle bbox = BoundingBox(img, matrix);
                Bitmap bmpDest = new Bitmap(bbox.Width, bbox.Height);

                using (Graphics gDest = Graphics.FromImage(bmpDest))
                {
                    Matrix mDest = new Matrix();
                    mDest.Translate(bmpDest.Width / 2, bmpDest.Height / 2, MatrixOrder.Append);
                    gDest.Transform = mDest;
                    gDest.CompositingQuality = CompositingQuality.HighQuality;
                    gDest.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    gDest.DrawImage(img, pts);
                    return bmpDest;
                }
            }
        }
开发者ID:dmitriydel,项目名称:sharexmod,代码行数:26,代码来源:GraphicsHelper.cs

示例4: MouseDown

        public override void MouseDown(object sender, MouseEventArgs e) {

            if (e.Button == MouseButtons.Left) {
                isMouseDown = true;
                if (CurrentMarker == null && isBegin) {
                    GMapMarker marker = createMarker(rMap1.FromLocalToLatLng(e.X, e.Y));
                }
            } else if (e.Button == MouseButtons.Right) {
                if (isBegin) {
                    //统计设备
                    if(routes.Markers.Count<2)return;

                    List<PS_gt> gtlist = new List<PS_gt>();
                    List<sd_gt> sdlist = new List<sd_gt>();
                    int bl = 1000000;
                    using (GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath()) {
                        List<PointF> list = new List<PointF>();
                        foreach (PointLatLng pll in routes.Polygons[0].Points) {
                            list.Add(new PointF((float)pll.Lng * bl, (float)pll.Lat * bl));

                        }
                        gp.AddPolygon(list.ToArray());
                        Region r = new Region(gp);
                        
                        foreach (GMapOverlay lay in this.rMap1.Overlays) {
                            if (!lay.IsVisibile|| !(lay is LineOverlay)) continue;
                            LineOverlay lo = lay as LineOverlay;
                            foreach (GMapMarker m in lo.Markers) {
                                if (r.IsVisible(new PointF((float)m.Position.Lng * bl, (float)m.Position.Lat * bl))) {
                                    if(m.Tag is PS_gt)
                                        gtlist.Add(m.Tag as PS_gt);
                                    else if(m.Tag is sd_gt)
                                    {
                                        sdlist.Add(m.Tag as sd_gt);
                                    }
                                }

                            }
                        }
                    }
                    if (gtlist.Count>sdlist.Count)
                    {
                        frmQytj dlg = new frmQytj(gtlist);
                        dlg.StartPosition = FormStartPosition.CenterScreen;

                        dlg.Show(this.rMap1);
                    }
                    else
                    {
                        frmSdtj dlg = new frmSdtj(sdlist);
                        dlg.StartPosition = FormStartPosition.CenterScreen;

                        dlg.Show(this.rMap1);
                    }
                   
                   
                }
                isBegin = false;
            }
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:60,代码来源:OperationTj.cs

示例5: TButton

        public TButton()
            : base()
        {

            Point[] pts = {   new Point(0, _buttonsize / 2 - 1), 
                              new Point(_buttonsize / 2 - 1, 0), 
                              new Point(_buttonsize , _buttonsize / 2 - 1), 
                              new Point(_buttonsize , _buttonsize / 2 + 2),
                              new Point(_buttonsize / 2 + 2, _buttonsize - 1),
                              new Point(_buttonsize / 2 - 1, _buttonsize - 1) };

            GraphicsPath p = new GraphicsPath();
            p.AddPolygon(pts);
            p.CloseFigure();
            p.FillMode = FillMode.Alternate;
            this.Region = new Region(p);

            ImageList = new System.Windows.Forms.ImageList();
            ImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
            ImageList.ImageSize = new System.Drawing.Size(_buttonsize, _buttonsize);


            ImageList.Images.Add(((System.Drawing.Image)(Resource1.ResourceManager.GetObject("diamond1"))));
            ImageList.Images.Add(((System.Drawing.Image)(Resource1.ResourceManager.GetObject("diamond1_down"))));
            ImageIndex = 0;

        }
开发者ID:PKAstro,项目名称:Ascom.Gemini.Telescope,代码行数:27,代码来源:TButton.cs

示例6: DrawYourSelf

        public override void DrawYourSelf(Graphics graphics)
        {
            int i = 0;
            Point[] points = new Point[this.pointsList.Count];//(Point[])pointsList.ToArray(typeof(Point));
            foreach(Point _point in this.pointsList)
            {
                points[i] = _point;
                i++;
            }

            GraphicsPath path = new GraphicsPath();
            path.AddPolygon(points);
            path.Transform(this.TMatrix.TransformationMatrix);

            Pen pen = new Pen(this.BorderColor, this.BorderWidth);

            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }

            graphics.DrawPath(pen, path);

            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:30,代码来源:PolygonShape.cs

示例7: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics myGraphics = e.Graphics;
            Pen myPen = new Pen(Color.Black, 1.0f);
            GraphicsPath gp = new GraphicsPath();
            Matrix RotationTransform;

            float centerX = this.Size.Width / 2f;
            float centerY = this.Size.Height / 2f;

            gp.AddPolygon(new PointF[] {
                new PointF(centerX, centerY - 5),
                new PointF(centerX-5, centerY + 5),
                new PointF(centerX+5, centerY + 5)
            });

            RotationTransform = new Matrix(1, 0, 0, 1, 0, 0); // rotation matrix
            PointF RotationPoint = new PointF(centerX, centerY); // rotation point
            RotationTransform.RotateAt(heading, RotationPoint);
            gp.Transform(RotationTransform);

            myGraphics.FillPath(myPen.Brush, gp);
            myGraphics.DrawPath(myPen, gp);
            myPen.Dispose();
            gp.Dispose();
        }
开发者ID:glocklueng,项目名称:helocamosun,代码行数:27,代码来源:HelicopterIcon.cs

示例8: LinePenStyle

 /// <summary>
 /// Initializes the <see cref="T:LinePenStyle"/> class.
 /// </summary>
 static LinePenStyle()
 {
     Point[] ps = new Point[3] { new Point(-2, 0), new Point(0, 4), new Point(2, 0) };
     GraphicsPath gpath = new GraphicsPath();
     gpath.AddPolygon(ps);
     gpath.CloseAllFigures();
     mGeneralizationCap = new CustomLineCap(null, gpath);
 }
开发者ID:JackWangCUMT,项目名称:mathnet-yttrium,代码行数:11,代码来源:LinePenStyle.cs

示例9: Paint

        public static void Paint( object sender)
        {
            PictureBox pic = ((PictureBox)sender);
            List<Point> list = new List<Point>();
            int width = pic.Width;
            int height = pic.Height;

            //左上
            list.Add(new Point(0, 0));
            list.Add(new Point(0, 0));
            list.Add(new Point(0, 0));
            list.Add(new Point(0, 0));
            list.Add(new Point(0, 0));
            list.Add(new Point(0, 0));
            list.Add(new Point(0, 0));
            list.Add(new Point(0, 0));
            list.Add(new Point(0, 0));
            //右上
            list.Add(new Point(width - 0, 0));
            list.Add(new Point(width - 0, 0));
            list.Add(new Point(width - 0, 0));
            list.Add(new Point(width - 0, 0));
            list.Add(new Point(width - 0, 0));
            list.Add(new Point(width - 0, 0));
            list.Add(new Point(width - 0, 0));
            list.Add(new Point(width - 0, 0));
            list.Add(new Point(width - 0, 0));
            //右下
            list.Add(new Point(width - 0, height - 5));
            list.Add(new Point(width - 1, height - 5));
            list.Add(new Point(width - 1, height - 3));
            list.Add(new Point(width - 2, height - 3));
            list.Add(new Point(width - 2, height - 2));
            list.Add(new Point(width - 3, height - 2));
            list.Add(new Point(width - 3, height - 1));
            list.Add(new Point(width - 5, height - 1));
            list.Add(new Point(width - 5, height - 0));
            //左下
            list.Add(new Point(5, height - 0));
            list.Add(new Point(5, height - 1));
            list.Add(new Point(3, height - 1));
            list.Add(new Point(3, height - 2));
            list.Add(new Point(2, height - 2));
            list.Add(new Point(2, height - 3));
            list.Add(new Point(1, height - 3));
            list.Add(new Point(1, height - 5));
            list.Add(new Point(0, height - 5));

            Point[] points = list.ToArray();

            GraphicsPath shape = new GraphicsPath();
            shape.AddPolygon(points);

            //将窗体的显示区域设为GraphicsPath的实例
            pic.Region = new System.Drawing.Region(shape);
        }
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:56,代码来源:PictureViewdown.cs

示例10: Paint

        public static void Paint( object sender)
        {
            Form form = ((Form)sender);
            List<Point> list = new List<Point>();
            int width = form.Width;
            int height = form.Height;

            //左上
            list.Add(new Point(0, 5));
            list.Add(new Point(1, 5));
            list.Add(new Point(1, 3));
            list.Add(new Point(2, 3));
            list.Add(new Point(2, 2));
            list.Add(new Point(3, 2));
            list.Add(new Point(3, 1));
            list.Add(new Point(5, 1));
            list.Add(new Point(5, 0));
            //右上
            list.Add(new Point(width - 5, 0));
            list.Add(new Point(width - 5, 1));
            list.Add(new Point(width - 3, 1));
            list.Add(new Point(width - 3, 2));
            list.Add(new Point(width - 2, 2));
            list.Add(new Point(width - 2, 3));
            list.Add(new Point(width - 1, 3));
            list.Add(new Point(width - 1, 5));
            list.Add(new Point(width - 0, 5));
            //右下
            list.Add(new Point(width - 0, height - 5));
            list.Add(new Point(width - 1, height - 5));
            list.Add(new Point(width - 1, height - 3));
            list.Add(new Point(width - 2, height - 3));
            list.Add(new Point(width - 2, height - 2));
            list.Add(new Point(width - 3, height - 2));
            list.Add(new Point(width - 3, height - 1));
            list.Add(new Point(width - 5, height - 1));
            list.Add(new Point(width - 5, height - 0));
            //左下
            list.Add(new Point(5, height - 0));
            list.Add(new Point(5, height - 1));
            list.Add(new Point(3, height - 1));
            list.Add(new Point(3, height - 2));
            list.Add(new Point(2, height - 2));
            list.Add(new Point(2, height - 3));
            list.Add(new Point(1, height - 3));
            list.Add(new Point(1, height - 5));
            list.Add(new Point(0, height - 5));

            Point[] points = list.ToArray();

            GraphicsPath shape = new GraphicsPath();
            shape.AddPolygon(points);

            //将窗体的显示区域设为GraphicsPath的实例
            form.Region = new System.Drawing.Region(shape);
        }
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:56,代码来源:FormView.cs

示例11: ReturnBounds

        public override RectangleF ReturnBounds()
        {
            Point[] points = (Point[])pointsList.ToArray(typeof(Point));
            GraphicsPath path = new GraphicsPath();

            path.AddPolygon(points);
            path.Transform(this.TMatrix.TransformationMatrix);

            return  path.GetBounds();
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:10,代码来源:PolygonShape.cs

示例12: Draw

 public void Draw(Graphics g, Color c)
 {
     GraphicsPath path = new GraphicsPath();
     path.AddPolygon(m_HexagonPoints);
     using (SolidBrush brush = new SolidBrush(c))
     {
         g.FillPath(brush, path);
     }
     path.Dispose();
 }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:10,代码来源:CombCell.cs

示例13: FixtureSetUp

		public void FixtureSetUp ()
		{
			bitmap = new Bitmap (10, 10);
			graphic = Graphics.FromImage (bitmap);

			sp1 = new GraphicsPath ();
			sp1.AddPolygon (new Point[4] { new Point (0, 0), new Point (3, 0), new Point (3, 3), new Point (0, 3) });

			sp2 = new GraphicsPath ();
			sp2.AddPolygon (new Point[4] { new Point (2, 2), new Point (5, 2), new Point (5, 5), new Point (2, 5) });
		}
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:RegionDataTest.cs

示例14: Lanes

        static Lanes()
        {
            TopLane = new GraphicsPath();
            TopLane.AddPolygon(_topLane.ToPointF());

            MidLane = new GraphicsPath();
            MidLane.AddPolygon(_midLane.ToPointF());

            BotLane = new GraphicsPath();
            BotLane.AddPolygon(_botLane.ToPointF());
        }
开发者ID:coman3,项目名称:EloBuddy.Addons,代码行数:11,代码来源:Lanes.cs

示例15: UpdatePath

        protected override void UpdatePath()
        {
            if (this.Points == null || this.Points.Length == 0) return;

            InternalPath = new GraphicsPath();
            InternalPath.AddPolygon(this.Points);

            Matrix mtx = new Matrix();
            mtx.RotateAt(this.Rotation, InternalRotationBasePoint);
            InternalPath.Transform(mtx);
        }
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:11,代码来源:ShapePolygon.cs


注:本文中的System.Drawing.Drawing2D.GraphicsPath.AddPolygon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。