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


C# GraphicsPath.AddRectangle方法代码示例

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


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

示例1: Form1_Paint

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            using (Graphics g = e.Graphics)
            {
                GraphicsPath path = new GraphicsPath();

                path.AddLine(20, 20, 170, 20);
                path.AddLine(20, 20, 20, 100);
                // рисуем новую фигуру
                path.StartFigure();
                path.AddLine(240, 140, 240, 50);
                path.AddLine(240, 140, 80, 140);
                path.AddRectangle(new Rectangle(30, 30, 200, 100));
                // локальное преобразование траектории
                //Matrix X = new Matrix();
                //X.RotateAt(45, new PointF(60.0f, 100.0f));
                //path.Transform(X);
                // рисуем  path
                Pen redPen = new Pen(Color.Red, 2);
                g.FillPath(new SolidBrush(Color.Bisque), path);
                g.DrawPath(redPen, path);

            }

        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:25,代码来源:Form1.cs

示例2: CalculateGraphicsPathFromBitmap

		// From http://edu.cnzz.cn/show_3281.html
		public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap, Color colorTransparent) 
		{ 
			GraphicsPath graphicsPath = new GraphicsPath(); 
			if (colorTransparent == Color.Empty)
				colorTransparent = bitmap.GetPixel(0, 0); 

			for(int row = 0; row < bitmap.Height; row ++) 
			{ 
				int colOpaquePixel = 0;
				for(int col = 0; col < bitmap.Width; col ++) 
				{ 
					if(bitmap.GetPixel(col, row) != colorTransparent) 
					{ 
						colOpaquePixel = col; 
						int colNext = col; 
						for(colNext = colOpaquePixel; colNext < bitmap.Width; colNext ++) 
							if(bitmap.GetPixel(colNext, row) == colorTransparent) 
								break;
 
						graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1)); 
						col = colNext; 
					} 
				} 
			} 
			return graphicsPath; 
		} 
开发者ID:hanistory,项目名称:hasuite,代码行数:27,代码来源:DrawHelper.cs

示例3: RenderFrameByCenter

        protected override void RenderFrameByCenter(PaintEventArgs e, Rectangle r)
        {
            Graphics g = e.Graphics;

            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddRectangle(GaugeFrame.Bounds);

                using (PathGradientBrush br = new PathGradientBrush(path))
                {
                    br.CenterPoint = GaugeFrame.Center;
                    br.CenterColor = GaugeFrame.FrameColor.Start;
                    br.SurroundColors = new Color[] { GaugeFrame.FrameColor.End };

                    br.SetSigmaBellShape(GaugeFrame.FrameSigmaFocus, GaugeFrame.FrameSigmaScale);

                    g.FillRectangle(br, GaugeFrame.Bounds);
                }

                path.AddRectangle(r);

                using (PathGradientBrush br = new PathGradientBrush(path))
                {
                    br.CenterPoint = GaugeFrame.Center;
                    br.CenterColor = GaugeFrame.FrameColor.End;
                    br.SurroundColors = new Color[] { GaugeFrame.FrameColor.Start };

                    g.FillRectangle(br, r);
                }
            }

            RenderFrameBorder(g, GaugeFrame.Bounds);
        }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:33,代码来源:GaugeFrameRectangularRenderer.cs

示例4: pictureBox2_Paint

 private void pictureBox2_Paint(object sender, PaintEventArgs e)
 {
     if (this.pointStart.HasValue && this.pointEnd.HasValue)
     {
         var path = new GraphicsPath(FillMode.Alternate);
         path.AddRectangle(new Rectangle(0, 0, e.ClipRectangle.Width, e.ClipRectangle.Height));
         path.AddRectangle(CreateRectangle(this.pointStart.Value, this.pointEnd.Value));
         e.Graphics.FillPath(grayBrush, path);
     }
 }
开发者ID:lavn0,项目名称:ShadowHighlightImageEditor,代码行数:10,代码来源:MainForm.cs

示例5: Draw

 public void Draw(Point cur)
 {
     switch (sh)
     {
         case Shape.pencil:
             g.DrawLine(pen, prev, cur);
             prev = cur;
             break;
         case Shape.rectangle:
             path = new GraphicsPath();
             if (prev.X > cur.X)
             {
                 if (prev.Y > cur.Y)
                     path.AddRectangle(new Rectangle(cur.X, cur.Y, prev.X - cur.X, prev.Y - cur.Y));
                 if (prev.Y < cur.Y)
                     path.AddRectangle(new Rectangle(cur.X, prev.Y, prev.X - cur.X, cur.Y - prev.Y));
             }
             else
             {
                 if ((prev.Y < cur.Y))
                     path.AddRectangle(new Rectangle(prev.X, prev.Y, cur.X - prev.X, cur.Y - prev.Y));
                 else
                     path.AddRectangle(new Rectangle(prev.X, cur.Y, cur.X - prev.X, prev.Y - cur.Y));
             }
             break;
         case Shape.circle:
             path = new GraphicsPath();
             path.AddEllipse(new Rectangle(prev.X, prev.Y, cur.X - prev.X, cur.Y - prev.Y));
             break;                   
         case Shape.line:
             path = new GraphicsPath();
             path.AddLine(prev, cur);
             break;                    
         case Shape.triangle:
             path = new GraphicsPath();
             Point[] pp = new Point[3];
             pp[0] = prev;
             pp[1] = cur;
             pp[2] = new Point(cur.X - 2 * (cur.X - prev.X), cur.Y);
             path.AddPolygon(pp);
             break;
         case Shape.erasor:
             path = null;
             g.DrawLine(er, prev, cur);
             prev = cur;
             break;
         default:
             break;
     }
     picture.Refresh();
 }
开发者ID:Otegenovaalt,项目名称:Altynay,代码行数:51,代码来源:Drawer.cs

示例6: GetGraphicsPath

 public override GraphicsPath GetGraphicsPath(int left, int top)
 {
     GraphicsPath p = new GraphicsPath();
     Rectangle r = new Rectangle(left, top, Width, Height);
     p.AddRectangle(r);
     return p;
 }
开发者ID:hzsydy,项目名称:Ccao-big-homework,代码行数:7,代码来源:MyRectangle.cs

示例7: GeneratePath

		protected override GraphicsPath GeneratePath()
		{
			GraphicsPath path = new GraphicsPath();
			path.AddRectangle(new Rectangle(
			  Location.X, Location.Y, Size.Width, Size.Height));
			return path;
		}
开发者ID:ehershey,项目名称:development,代码行数:7,代码来源:Shapes.cs

示例8: ConfigrationForm

        /// <summary>
        /// コンストラクタ
        /// </summary>
        public ConfigrationForm()
        {
            InitializeComponent();
            // label8
            //自分自身のバージョン情報を取得する
            System.Diagnostics.FileVersionInfo ver =
                System.Diagnostics.FileVersionInfo.GetVersionInfo(
                System.Reflection.Assembly.GetExecutingAssembly().Location);
            this.label8.Text = ver.ProductName + " version " + ver.ProductVersion + "\nCopyright © 2014 Real Pot Systems (TAKUBON). All right reserved.";

            // バッテリーの有無でラベルのdisableにする
            // バッテリーの有無
            if ((SystemInformation.PowerStatus.BatteryChargeStatus & BatteryChargeStatus.NoSystemBattery) == BatteryChargeStatus.NoSystemBattery)
            {
                this._Battery.Enabled = false;
                this.label2.Enabled = false;
            }
            // パスを設定して、右上のボタンだけにする
            m_path = new GraphicsPath();
            m_path.FillMode = FillMode.Winding;
            m_path.AddRectangle(new Rectangle(this.Width - 42, 0, 36, 36));
            this.Region = new Region(m_path);
            this.SetPostion(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.WorkingArea.Top);
            SetButtonText();
        }
开发者ID:RealPotSystems,项目名称:vGamePad,代码行数:28,代码来源:ConfigrationForm.cs

示例9: RotateImg

        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;
        }
开发者ID:CheViana,项目名称:ImageServer,代码行数:32,代码来源:RotatedProcessor.cs

示例10: Form1_Paint

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            using (Graphics g = e.Graphics)
            {
                // Создаем траекторию
                GraphicsPath path = new GraphicsPath();
                Rectangle rect = new Rectangle(20, 20, 150, 150);
                path.AddRectangle(rect);
                // Создаем градиентную кисть
                PathGradientBrush pgBrush =
                    new PathGradientBrush(path.PathPoints);
                // Уснинавливаем цвета кисти
                pgBrush.CenterColor = Color.Red;
                pgBrush.SurroundColors = new Color[] { Color.Blue };
                // Создаем объект Matrix
                Matrix X = new Matrix();
                // Translate
                X.Translate(30.0f, 10.0f, MatrixOrder.Append);
                // Rotate
                X.Rotate(10.0f, MatrixOrder.Append);
                // Scale
                X.Scale(1.2f, 1.0f, MatrixOrder.Append);
                // Shear
                X.Shear(.2f, 0.03f, MatrixOrder.Prepend);
                // Применяем преобразование к траектории и кисти
                path.Transform(X);
                pgBrush.Transform = X;
                // Выполняем визуализацию
                g.FillPath(pgBrush, path);
            }

        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:32,代码来源:Form1.cs

示例11: ctor_GraphicsPath

		public void ctor_GraphicsPath () {
			GraphicsPath path = new GraphicsPath ();
			path.AddRectangle (rect);
			Region r1 = new Region (path);
			r1.Xor (r);
			Assert.IsTrue (r1.IsEmpty (t.Graphics));
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:Region.cs

示例12: Contains

 //是否圖形包含的座標
 public override bool Contains(Point point)
 {
     GraphicsPath path = new GraphicsPath();
     path.FillMode = FillMode.Winding;
     path.AddRectangle(new System.Drawing.Rectangle(TopLeft.X, TopLeft.Y, AbsoluteSize.X, AbsoluteSize.Y));
     return path.IsVisible(point.X, point.Y);
 }
开发者ID:lohas1107,项目名称:painter,代码行数:8,代码来源:Rectangle.cs

示例13: GetImageGraphicsPath

        private GraphicsPath GetImageGraphicsPath()
        {
            Bitmap bitmap = new Bitmap(_Cell.GetInfoImage());
            GraphicsPath graphicsPath = new GraphicsPath();

            Color colorTransparent = bitmap.GetPixel(0, 0);

            for (int row = 0; row < bitmap.Height; row++)
            {
                for (int col = 0; col < bitmap.Width; col++)
                {
                    if (bitmap.GetPixel(col, row) != colorTransparent)
                    {
                        int colOpaquePixel = col;
                        int colNext;

                        for (colNext = colOpaquePixel; colNext < bitmap.Width; colNext++)
                        {
                            if (bitmap.GetPixel(colNext, row) == colorTransparent)
                                break;
                        }

                        graphicsPath.AddRectangle(new Rectangle(colOpaquePixel,
                                                   row, colNext - colOpaquePixel, 1));

                        col = colNext;
                    }
                }
            }

            return (graphicsPath);
        }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:32,代码来源:CellInfoWindow.cs

示例14: DrawYourSelf

        /// <summary>
        /// Изчертава правоъгълника.
        /// </summary>
        /// <param name="graphics"></param>
        public override void DrawYourSelf(Graphics graphics)
        {
            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(new RectangleF(Location, ModelSize));
            path.Transform(this.TMatrix.TransformationMatrix);
            /**
             * Създава се Pen, който изчертава контура, като използва
             * цвят и дебелина (определят се от конструктора)
             **/
            Pen pen = new Pen(this.BorderColor, this.BorderWidth);
            /*
             * Създава се SolidBrush, която изпълва фигурата, като използва
             * цвят (определя се от конструктора)
             */
            SolidBrush brush = new SolidBrush(this.FillColor);
            /*
               * Функция на namespace System.Drawing.Drawing2D
               * Изпълва контура на елипсата чрез SolidBrush
              */
            if (IS_FILLED)
            {
                graphics.FillPath(brush, path);
            }
            /*
             * Функция на namespace System.Drawing.Drawing2D
             * Изчертава контура на елипсата чрез Pen
            */
            graphics.DrawPath(pen, path);

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

示例15: OnPaint

            protected override void OnPaint(PaintEventArgs e)
            {
                base.OnPaint(e);

                Rectangle rect = ClientRectangle;

                if (Dock == DockStyle.Left || Dock == DockStyle.Right)
                {
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddRectangle(rect);
                        using (PathGradientBrush brush = new PathGradientBrush(path) { CenterColor = Color.FromArgb(0xFF, 204, 206, 219), SurroundColors = new[] { SystemColors.Control } })
                        {
                            e.Graphics.FillRectangle(brush, rect.X + Measures.SplitterSize / 2 - 1, rect.Y,
                                Measures.SplitterSize / 3, rect.Height);
                        }
                    }
                }
                else
                {
                    if (Dock == DockStyle.Top || Dock == DockStyle.Bottom)
                    {
                        using (SolidBrush brush = new SolidBrush(Color.FromArgb(0xFF, 204, 206, 219)))
                        {
                            e.Graphics.FillRectangle(brush, rect.X, rect.Y,
                                rect.Width, Measures.SplitterSize);
                        }
                    }
                }
            }
开发者ID:GamehubDev,项目名称:Nin_Online_Unity,代码行数:30,代码来源:VS2012LightDockWindow.cs


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