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


C# GraphicsPath.AddBezier方法代码示例

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


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

示例1: DrawTab

                public static void DrawTab(Graphics g, Rectangle r, Corners corner, GradientType gradient, Color darkColor, Color lightColor, Color edgeColor, bool closed)
                {
                    //dims
                    Point[] points;
                    GraphicsPath path;
                    Region Region;
                    LinearGradientBrush linearBrush;
                    Brush brush = null;
                    Pen pen;
                    r.Inflate(- 1, - 1);
                    //set brushes
                    switch (gradient)
                    {
                        case GradientType.Flat:
                            brush = new SolidBrush(darkColor);
                            break;
                        case GradientType.Linear:
                            brush = new LinearGradientBrush(r, darkColor, lightColor, LinearGradientMode.Vertical);
                            break;
                        case GradientType.Bell:
                            linearBrush = new LinearGradientBrush(r, darkColor, lightColor, LinearGradientMode.Vertical);
                            linearBrush.SetSigmaBellShape((float) (0.17F), (float) (0.67F));
                            brush = linearBrush;
                            break;
                    }
                    pen = new pen(edgeColor, 1);
                    //generic points
                    points = new Point[12] {new Point(r.Left, r.Bottom), new Point(r.Left, r.Bottom - bshift), new Point(r.Left, r.Top + bshift), new Point(r.Left, r.Top), new Point(r.Left + bshift, r.Top), new Point(r.Right - bshift, r.Top), new Point(r.Right, r.Top), new Point(r.Right, r.Top + bshift), new Point(r.Right, r.Bottom - bshift), new Point(r.Right, r.Bottom), new Point(r.Right - bshift, r.Bottom), new Point(r.Left + bshift, r.Bottom)};

                    path = new GraphicsPath();
                    switch (corner)
                    {
                        case Corners.LeftBottom:
                            path.AddLine(points[3], points[1]);
                            path.AddBezier(points[1], points[0], points[0], points[11]);
                            path.AddLine(points[11], points[9]);
                            path.AddLine(points[9], points[6]);
                            path.AddLine(points[6], points[3]);
                            Region = new Region(path);
                            g.FillRegion(brush, Region);
                            g.DrawLine(pen, points[3], points[1]);
                            g.DrawBezier(pen, points[1], points[0], points[0], points[11]);
                            g.DrawLine(pen, points[11], points[9]);
                            g.DrawLine(pen, points[9], points[6]);
                            if (closed)
                            {
                                g.DrawLine(pen, points[6], points[3]);
                            }
                            break;
                        case Corners.LeftTop:
                            path.AddLine(points[0], points[2]);
                            path.AddBezier(points[2], points[3], points[3], points[4]);
                            path.AddLine(points[4], points[6]);
                            path.AddLine(points[6], points[9]);
                            path.AddLine(points[9], points[0]);
                            Region = new Region(path);
                            g.FillRegion(brush, Region);
                            g.DrawLine(pen, points[0], points[2]);
                            g.DrawBezier(pen, points[2], points[3], points[3], points[4]);
                            g.DrawLine(pen, points[4], points[6]);
                            g.DrawLine(pen, points[6], points[9]);
                            if (closed)
                            {
                                g.DrawLine(pen, points[9], points[0]);
                            }
                            break;
                        case Corners.Bottom:

                            path.AddLine(points[1], points[3]);
                            path.AddBezier(points[1], points[0], points[0], points[11]);
                            path.AddLine(points[11], points[10]);
                            path.AddBezier(points[10], points[9], points[9], points[8]);
                            path.AddLine(points[8], points[6]);
                            path.AddLine(points[6], points[3]);
                            Region = new Region(path);
                            g.FillRegion(brush, Region);

                            g.DrawLine(pen, points[1], points[3]);
                            g.DrawBezier(pen, points[1], points[0], points[0], points[11]);
                            g.DrawLine(pen, points[11], points[10]);
                            g.DrawBezier(pen, points[10], points[9], points[9], points[8]);
                            g.DrawLine(pen, points[8], points[6]);

                            if (closed)
                            {
                                g.DrawLine(pen, points[6], points[3]);
                            }

                            break;

                        case Corners.Top:
                            path.AddLine(points[0], points[2]);
                            path.AddBezier(points[2], points[3], points[3], points[4]);
                            path.AddLine(points[4], points[5]);
                            path.AddBezier(points[5], points[6], points[6], points[7]);
                            path.AddLine(points[7], points[9]);
                            path.AddLine(points[9], points[0]);
                            Region = new Region(path);
                            g.FillRegion(brush, Region);

//.........这里部分代码省略.........
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:101,代码来源:DrawHelper.cs

示例2: RoundRect

 private GraphicsPath RoundRect(RectangleF r, float r1, float r2, float r3, float r4)
 {
     float x = r.X, y = r.Y, w = r.Width, h = r.Height;
     GraphicsPath rr = new GraphicsPath();
     rr.AddBezier(x, y + r1, x, y, x + r1, y, x + r1, y);
     rr.AddLine(x + r1, y, x + w - r2, y);
     rr.AddBezier(x + w - r2, y, x + w, y, x + w, y + r2, x + w, y + r2);
     rr.AddLine(x + w, y + r2, x + w, y + h - r3);
     rr.AddBezier(x + w, y + h - r3, x + w, y + h, x + w - r3, y + h, x + w - r3, y + h);
     rr.AddLine(x + w - r3, y + h, x + r4, y + h);
     rr.AddBezier(x + r4, y + h, x, y + h, x, y + h - r4, x, y + h - r4);
     rr.AddLine(x, y + h - r4, x, y + r1);
     return rr;
 }
开发者ID:RobertFurer,项目名称:Picasso23,代码行数:14,代码来源:VistaButton.cs


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