當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。