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


C# Brush.GetBrush方法代码示例

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


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

示例1: DrawRectangle

 public void DrawRectangle(Rect frame, Pen pen = null, Brush brush = null)
 {
     if (brush != null) {
         graphics.FillRectangle (brush.GetBrush (frame), Conversions.GetRectangleF (frame));
     }
     if (pen != null) {
         var r = Conversions.GetRectangleF (frame);
         graphics.DrawRectangle (pen.GetPen (), r.X, r.Y, r.Width, r.Height);
     }
 }
开发者ID:sami1971,项目名称:NGraphics,代码行数:10,代码来源:SystemDrawingPlatform.cs

示例2: DrawPath

        public void DrawPath(IEnumerable<PathOp> ops, Pen pen = null, Brush brush = null)
        {
            using (var path = new GraphicsPath ()) {

                var bb = new BoundingBoxBuilder ();

                var position = Point.Zero;

                foreach (var op in ops) {
                    var mt = op as MoveTo;
                    if (mt != null) {
                        var p = mt.Point;
                        position = p;
                        bb.Add (p);
                        continue;
                    }
                    var lt = op as LineTo;
                    if (lt != null) {
                        var p = lt.Point;
                        path.AddLine (Conversions.GetPointF (position), Conversions.GetPointF (p));
                        position = p;
                        bb.Add (p);
                        continue;
                    }
                    var at = op as ArcTo;
                    if (at != null) {
                        var p = at.Point;
                        path.AddLine (Conversions.GetPointF (position), Conversions.GetPointF (p));
                        position = p;
                        bb.Add (p);
                        continue;
                    }
                    var ct = op as CurveTo;
                    if (ct != null) {
                        var p = ct.Point;
                        var c1 = ct.Control1;
                        var c2 = ct.Control2;
                        path.AddBezier (Conversions.GetPointF (position), Conversions.GetPointF (c1),
                            Conversions.GetPointF (c2), Conversions.GetPointF (p));
                        position = p;
                        bb.Add (p);
                        bb.Add (c1);
                        bb.Add (c2);
                        continue;
                    }
                    var cp = op as ClosePath;
                    if (cp != null) {
                        path.CloseFigure ();
                        continue;
                    }

                    throw new NotSupportedException ("Path Op " + op);
                }

                var frame = bb.BoundingBox;
                if (brush != null) {
                    graphics.FillPath (brush.GetBrush (frame), path);
                }
                if (pen != null) {
                    var r = Conversions.GetRectangleF (frame);
                    graphics.DrawPath (pen.GetPen (), path);
                }
            }
        }
开发者ID:sami1971,项目名称:NGraphics,代码行数:64,代码来源:SystemDrawingPlatform.cs

示例3: DrawRectangle

		public void DrawRectangle (Rect frame, Size corner, Pen pen = null, Brush brush = null)
		{
			if (corner.Width > 0 || corner.Height > 0) {
				using (var path = new GraphicsPath ()) {
					var xdia = corner.Width * 2;
					var ydia = corner.Height * 2;
					if(xdia > frame.Width)    xdia = frame.Width;
					if(ydia > frame.Height)   ydia = frame.Height;

					// define a corner 
					var Corner = Conversions.GetRectangleF (frame);

					path.AddArc (Corner, 180, 90);    

					// top right
					Corner.X += (float)(frame.Width - xdia);
					path.AddArc (Corner, 270, 90);    
    
					// bottom right
					Corner.Y += (float)(frame.Height - ydia);
					path.AddArc (Corner,   0, 90);    
    
					// bottom left
					Corner.X -= (float)(frame.Width - xdia);
					path.AddArc (Corner,  90, 90);

					// end path
					path.CloseFigure ();

					if (brush != null) {
						graphics.FillPath (brush.GetBrush (frame), path);
					}
					if (pen != null) {
						graphics.DrawPath (pen.GetPen (), path);
					}
				}
			}
			else {
				if (brush != null) {
					graphics.FillRectangle (brush.GetBrush (frame), Conversions.GetRectangleF (frame));
				}
				if (pen != null) {
					var r = Conversions.GetRectangleF (frame);
					graphics.DrawRectangle (pen.GetPen (), r.X, r.Y, r.Width, r.Height);
				}
			}
		}
开发者ID:stevetsang,项目名称:NGraphics,代码行数:47,代码来源:SystemDrawingPlatform.cs

示例4: DrawEllipse

 public void DrawEllipse(Rect frame, Pen pen = null, Brush brush = null)
 {
     if (brush != null) {
         graphics.FillEllipse (brush.GetBrush (frame), Conversions.GetRectangleF (frame));
     }
     if (pen != null) {
         graphics.DrawEllipse (pen.GetPen (), Conversions.GetRectangleF (frame));
     }
 }
开发者ID:sami1971,项目名称:NGraphics,代码行数:9,代码来源:SystemDrawingPlatform.cs

示例5: SelectBrush

	// Select a brush into the toolkit graphics object.
	private void SelectBrush(Brush brush)
			{
				if(brush == null)
				{
					throw new ArgumentNullException("brush");
				}
				if(graphics == null)
				{
					throw new ObjectDisposedException("graphics");
				}
				IToolkitBrush tbrush = brush.GetBrush(graphics.Toolkit);
				tbrush.Select(graphics);
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:14,代码来源:Graphics.cs


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