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


C# GraphicsPath.AddRectangles方法代码示例

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


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

示例1: MapTimelineControl

        public MapTimelineControl()
        {
            this.m_mtsSeek = new MapTimelineSeekButton();

            this.TimelineButtons = new List<MapObject>();

            GraphicsPath gpButtonPath = new GraphicsPath();
            gpButtonPath.AddLines(new Point[] { new Point(0, 6), new Point(6, 12), new Point(6, 6), new Point(12, 12), new Point(12, 0), new Point(6, 6), new Point(6, 0), new Point(0, 6) });
            gpButtonPath.CloseFigure();
            MapTimelineControlButton mtbButton = new MapTimelineControlButton(gpButtonPath, MapTimelineControlButtonType.Rewind);
            mtbButton.TimelineControlButtonClicked += new MapTimelineControlButton.TimelineControlButtonClickedHandler(mtbButton_TimelineControlButtonClicked);
            this.TimelineButtons.Add(mtbButton);

            gpButtonPath = new GraphicsPath();
            gpButtonPath.AddRectangles(new Rectangle[] { new Rectangle(0, 0, 4, 12), new Rectangle(8, 0, 4, 12) });
            mtbButton = new MapTimelineControlButton(gpButtonPath, MapTimelineControlButtonType.Pause);
            mtbButton.TimelineControlButtonClicked += new MapTimelineControlButton.TimelineControlButtonClickedHandler(mtbButton_TimelineControlButtonClicked);
            this.TimelineButtons.Add(mtbButton);

            gpButtonPath = new GraphicsPath();
            gpButtonPath.AddLines(new Point[] { new Point(1, 0), new Point(1, 12), new Point(9, 6), new Point(1, 0) });
            gpButtonPath.CloseFigure();
            mtbButton = new MapTimelineControlButton(gpButtonPath, MapTimelineControlButtonType.Play);
            mtbButton.ForegroundColour = Color.LightSeaGreen;
            mtbButton.TimelineControlButtonClicked += new MapTimelineControlButton.TimelineControlButtonClickedHandler(mtbButton_TimelineControlButtonClicked);
            this.TimelineButtons.Add(mtbButton);

            gpButtonPath = new GraphicsPath();
            gpButtonPath.AddLines(new Point[] { new Point(0, 0), new Point(0, 12), new Point(6, 6), new Point(6, 12), new Point(12, 6), new Point(6, 0), new Point(6, 6), new Point(0, 0) });
            gpButtonPath.CloseFigure();
            mtbButton = new MapTimelineControlButton(gpButtonPath, MapTimelineControlButtonType.FastForward);
            mtbButton.TimelineControlButtonClicked += new MapTimelineControlButton.TimelineControlButtonClickedHandler(mtbButton_TimelineControlButtonClicked);
            this.TimelineButtons.Add(mtbButton);

            this.SelectedButtonType = MapTimelineControlButtonType.Play;
            this.m_flControlChangeSpeed = 2.0F;
        }
开发者ID:eaceaser,项目名称:PRoCon,代码行数:37,代码来源:MapTimelineControl.cs

示例2: StartClose_AddRectangles

		public void StartClose_AddRectangles ()
		{
			GraphicsPath path = new GraphicsPath ();
			path.AddLine (1, 1, 2, 2);
			path.AddRectangles (new RectangleF[2] {
				new RectangleF (10, 10, 20, 20),
				new RectangleF (20, 20, 10, 10) });
			path.AddLine (10, 10, 20, 20);
			byte[] types = path.PathTypes;
			// check first types
			Assert.AreEqual (0, types[0], "start/Line");
			Assert.AreEqual (0, types[2], "start/Rectangles");
			// check last types
			Assert.AreEqual (129, types[path.PointCount - 3], "end/Rectangles");
			Assert.AreEqual (0, types[path.PointCount - 2], "start/Line2");
			Assert.AreEqual (1, types[path.PointCount - 1], "end/Line2");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:17,代码来源:GraphicsPathTest.cs

示例3: AddRectangles_SamePoint

		public void AddRectangles_SamePoint ()
		{
			Rectangle r1 = new Rectangle (1, 1, 0, 0);
			Rectangle r2 = new Rectangle (1, 1, 1, 1);
			Rectangle r3 = new Rectangle (1, 2, 1, 1);

			GraphicsPath gp = new GraphicsPath ();
			gp.AddRectangles (new Rectangle[] { r1, r2, r3 });
			Assert.AreEqual (8, gp.PointCount, "1-PointCount");
			// first rect is ignore, then all other 2x4 (8) points are present, no compression
		}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:GraphicsPathTest.cs

示例4: AddRectangles_Two

		public void AddRectangles_Two ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddRectangles (new RectangleF[2] {
				new RectangleF (1f, 1f, 2f, 2f),
				new RectangleF (2f, 2f, 1f, 1f) } );
			RectangleF rect = gp.GetBounds ();
			Assert.AreEqual (1f, rect.X, "Bounds.X");
			Assert.AreEqual (1f, rect.Y, "Bounds.Y");
			Assert.AreEqual (2f, rect.Width, "Bounds.Width");
			Assert.AreEqual (2f, rect.Height, "Bounds.Height");
			// second rectangle is completely within the first one
			CheckRectangle (gp, 8);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:14,代码来源:GraphicsPathTest.cs

示例5: AddRectangles_Float

		public void AddRectangles_Float ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddRectangles (new RectangleF [1] { new RectangleF (1f, 1f, 2f, 2f) });
			CheckRectangle (gp, 4);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:6,代码来源:GraphicsPathTest.cs

示例6: AddRectangles_Float_Empty

		public void AddRectangles_Float_Empty ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddRectangles ( new RectangleF[0]);
			CheckRectangle (gp, 4);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:6,代码来源:GraphicsPathTest.cs

示例7: AddRectangles_Float_Null

		public void AddRectangles_Float_Null ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddRectangles ((RectangleF[]) null);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:5,代码来源:GraphicsPathTest.cs

示例8: AddRectangles_RectangleArr

		public void AddRectangles_RectangleArr()
		{
			path = new GraphicsPath();
			Rectangle [] rectangles = new Rectangle [] {new Rectangle (50, 50, 400, 80),
														new Rectangle (150, 150, 100, 400),
														new Rectangle (0, 0, 200, 480),
														new Rectangle (450, 450, 40, 80)};
			path.AddRectangles (rectangles);

			Assert.AreEqual (16, path.PointCount);
			
			PointF [] expectedPoints = new PointF [] {	new PointF(50f, 50f), 
														new PointF(450f, 50f), 
														new PointF(450f, 130f), 
														new PointF(50f, 130f), 
														new PointF(150f, 150f), 
														new PointF(250f, 150f), 
														new PointF(250f, 550f), 
														new PointF(150f, 550f), 
														new PointF(0f, 0f), 
														new PointF(200f, 0f), 
														new PointF(200f, 480f), 
														new PointF(0f, 480f), 
														new PointF(450f, 450f), 
														new PointF(490f, 450f), 
														new PointF(490f, 530f), 
														new PointF(450f, 530f)};
			
			for(int i = 0; i < path.PointCount; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
			}

			byte [] expectedTypes = new byte [] {	(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath),
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath)};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
			}	

			t.Graphics.DrawPath (p, path);
			t.Show ();
			//t.AssertCompare ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:57,代码来源:GraphicsPath.cs

示例9: Rectangles

		static private GraphicsPath Rectangles ()
		{
			GraphicsPath path = new GraphicsPath ();
			path.AddRectangles (new Rectangle[2] {
				new Rectangle (20, 20, 100, 100),
				new Rectangle (100, 100, 20, 20)
				});
			return path;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:Shapes.cs

示例10: AddRectangles2

        private void AddRectangles2(Graphics g)
        {
            // Adds a pattern of rectangles to a GraphicsPath object.
            GraphicsPath myPath = new GraphicsPath();
            RectangleF[] pathRects =
            {
                new RectangleF(20,20,100,200),
                new RectangleF(40,40,120,220),
                new RectangleF(60,60,240,140)
            };
            myPath.AddRectangles(pathRects);

            // Draw the path to the screen.
            Pen myPen = new Pen(Color.Black, 2);
            g.DrawPath(myPen, myPath);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:16,代码来源:DrawingView.cs

示例11: CalculateLabelAroundOnLineString


//.........这里部分代码省略.........
                            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();
            }

        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:101,代码来源:LabelLayer.cs

示例12: BuildFrame

        /// <summary>
        /// 设置边框控件可视区域
        /// </summary>
        /// <returns></returns>
        private GraphicsPath BuildFrame()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddRectangles(smallRects);

            Rectangle[] rects1 = new Rectangle[8];
            rects1[0] = new Rectangle(linePoints[0], new Size(linePoints[1].X - linePoints[0].X, 1));
            rects1[1] = new Rectangle(linePoints[2], new Size(linePoints[3].X - linePoints[2].X, 1));
            rects1[2] = new Rectangle(linePoints[4], new Size(1, linePoints[5].Y - linePoints[4].Y));
            rects1[3] = new Rectangle(linePoints[6], new Size(1, linePoints[7].Y - linePoints[6].Y));
            rects1[4] = new Rectangle(linePoints[9], new Size(linePoints[8].X - linePoints[9].X, 1));
            rects1[5] = new Rectangle(linePoints[11], new Size(linePoints[10].X - linePoints[11].X, 1));
            rects1[6] = new Rectangle(linePoints[13], new Size(1, linePoints[12].Y - linePoints[13].Y));
            rects1[7] = new Rectangle(linePoints[15], new Size(1, linePoints[14].Y - linePoints[15].Y));

            path.AddRectangles(rects1);

            return path;
        }
开发者ID:wsrf2009,项目名称:KnxUiEditor,代码行数:24,代码来源:FrameControl.cs

示例13: OnPaint

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            Point StartPoint = new Point(0, 0);
            Point EndPoint = new Point(0, this.Height);

            if (_ProgressDirection == ProgressDir.Vertical)
            {
                EndPoint = new Point(this.Width, 0);
            }

            using (GraphicsPath gp = new GraphicsPath())
            {
                Rectangle rec = new Rectangle(0, 0, this.Width, this.Height);
                int rad = Convert.ToInt32(rec.Height / 2.5);
                if (rec.Width < rec.Height)
                    rad = Convert.ToInt32(rec.Width / 2.5);

                using (LinearGradientBrush _BackColorBrush = new LinearGradientBrush(StartPoint, EndPoint, _BackColor, _GradiantColor))
                {
                    _BackColorBrush.Blend = bBlend;
                    if (_RoundedCorners)
                    {
                        gp.AddArc(rec.X, rec.Y, rad, rad, 180, 90);
                        gp.AddArc(rec.Right - (rad), rec.Y, rad, rad, 270, 90);
                        gp.AddArc(rec.Right - (rad), rec.Bottom - (rad), rad, rad, 0, 90);
                        gp.AddArc(rec.X, rec.Bottom - (rad), rad, rad, 90, 90);
                        gp.CloseFigure();
                        e.Graphics.FillPath(_BackColorBrush, gp);
                    }
                    else
                    {
                        e.Graphics.FillRectangle(_BackColorBrush, rec);
                    }
                }

                if (_Value > _Minimum)
                {
                    int lngth = Convert.ToInt32((double)(this.Width / (double)(_Maximum - _Minimum)) * _Value);
                    if (_ProgressDirection == ProgressDir.Vertical)
                    {
                        lngth = Convert.ToInt32((double)(this.Height / (double)(_Maximum - _Minimum)) * _Value);
                        rec.Y = rec.Height - lngth;
                        rec.Height = lngth;
                    }
                    else
                    {
                        rec.Width = lngth;
                    }

                    using (LinearGradientBrush _ProgressBrush = new LinearGradientBrush(StartPoint, EndPoint, _ProgressColor, _GradiantColor))
                    {
                        _ProgressBrush.Blend = bBlend;
                        if (_RoundedCorners)
                        {
                            if (_ProgressDirection == ProgressDir.Horizontal)
                            {
                                rec.Height -= 1;
                            }
                            else
                            {
                                rec.Width -= 1;
                            }

                            using (GraphicsPath gp2 = new GraphicsPath())
                            {
                                gp2.AddArc(rec.X, rec.Y, rad, rad, 180, 90);
                                gp2.AddArc(rec.Right - (rad), rec.Y, rad, rad, 270, 90);
                                gp2.AddArc(rec.Right - (rad), rec.Bottom - (rad), rad, rad, 0, 90);
                                gp2.AddArc(rec.X, rec.Bottom - (rad), rad, rad, 90, 90);
                                gp2.CloseFigure();
                                using (GraphicsPath gp3 = new GraphicsPath())
                                {
                                    using (Region rgn = new Region(gp))
                                    {
                                        rgn.Intersect(gp2);
                                        gp3.AddRectangles(rgn.GetRegionScans(new Matrix()));
                                    }
                                    e.Graphics.FillPath(_ProgressBrush, gp3);
                                }
                            }
                        }
                        else
                        {
                            e.Graphics.FillRectangle(_ProgressBrush, rec);
                        }
                    }
                }

                if (_Image != null)
                {
                    if (_ImageLayout == ImageLayoutType.Stretch)
                    {
                        e.Graphics.DrawImage(_Image, 0, 0, this.Width, this.Height);
                    }
                    else if (_ImageLayout == ImageLayoutType.None)
                    {
                        e.Graphics.DrawImage(_Image, 0, 0);
                    }
                    else
//.........这里部分代码省略.........
开发者ID:anhnnp,项目名称:Nhakhoaso,代码行数:101,代码来源:ProgressBarEX.cs

示例14: AddRectangles_RectangleFArr

		public void AddRectangles_RectangleFArr()
		{
			path = new GraphicsPath();
			RectangleF [] rectangles = new RectangleF [] {	new RectangleF (50.10f, 50.11f, 400.1f, 80.15f),
															new RectangleF (150f, 150.87f, 100.09f, 400.99f),
															new RectangleF (0.123245f, 0.23f, 200.98f, 480.56f),
															new RectangleF (450.3333333333f, 450.6666666f, 40.8f, 80.4f)};
			path.AddRectangles (rectangles);

			Assert.AreEqual (16, path.PointCount);
			
			PointF [] expectedPoints = new PointF [] {	new PointF(50.1f, 50.11f), 
														new PointF(450.2f, 50.11f), 
														new PointF(450.2f, 130.26f), 
														new PointF(50.1f, 130.26f), 
														new PointF(150f, 150.87f), 
														new PointF(250.09f, 150.87f), 
														new PointF(250.09f, 551.86f), 
														new PointF(150f, 551.86f), 
														new PointF(0.123245f, 0.23f), 
														new PointF(201.1032f, 0.23f), 
														new PointF(201.1032f, 480.79f), 
														new PointF(0.123245f, 480.79f), 
														new PointF(450.3333f, 450.6667f), 
														new PointF(491.1333f, 450.6667f), 
														new PointF(491.1333f, 531.0667f), 
														new PointF(450.3333f, 531.0667f)};
			
			for(int i = 0; i < path.PointCount; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
			}

			byte [] expectedTypes = new byte [] {	(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath),
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath)};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
			}	

			t.Graphics.DrawPath (p, path);
			t.Show ();
			//t.AssertCompare ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:57,代码来源:GraphicsPath.cs

示例15: Reverse_Rectangles

		public void Reverse_Rectangles ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				Rectangle[] rects = new Rectangle[] { new Rectangle (1, 2, 3, 4), new Rectangle (5, 6, 7, 8) }; 
				gp.AddRectangles (rects);
				Reverse (gp);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:GraphicsPathTest.cs


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