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


C# GraphicsPath.AddEllipse方法代码示例

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


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

示例1: RenderEllipseGlass

        public static void RenderEllipseGlass(Graphics g, Rectangle ownerRect, GlassPosition position,
            float positionFactor, Color glassColor, int alphaCenter, int alphaSurround)
        {
            if (!(positionFactor > 0 && positionFactor < 1))
                throw new ArgumentException("positionFactor must be between 0 and 1, but not include 0 and 1. ",
                    "positionFactor");

            ownerRect.Height--;
            ownerRect.Width--;

            if (ownerRect.Width < 1 || ownerRect.Height < 1)
                return;

            using (GraphicsPath gp = new GraphicsPath())
            {
                gp.AddEllipse(ownerRect);
                using (PathGradientBrush pb = new PathGradientBrush(gp))
                {
                    pb.CenterPoint = GetEllipseGlassCenterPoint(ownerRect, position, positionFactor);
                    pb.CenterColor = Color.FromArgb(alphaCenter, glassColor);
                    pb.SurroundColors = new Color[] { Color.FromArgb(alphaSurround, glassColor) };
                    using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias))
                    {
                        g.FillPath(pb, gp);
                    }
                }
            }
        }
开发者ID:webxiaohua,项目名称:SmartControls,代码行数:28,代码来源:GlassPainter.cs

示例2: GenerateCapsule

		private static GraphicsPath GenerateCapsule( this Graphics graphics, RectangleF rectangle ) {
			float diameter;
			RectangleF arc;
			GraphicsPath path = new GraphicsPath();

			try {
				if( rectangle.Width > rectangle.Height ) {
					diameter = rectangle.Height;
					SizeF sizeF = new SizeF( diameter, diameter );
					arc = new RectangleF( rectangle.Location, sizeF );
					path.AddArc( arc, 90, 180 );
					arc.X = rectangle.Right - diameter;
					path.AddArc( arc, 270, 180 );
				} else if( rectangle.Width < rectangle.Height ) {
					diameter = rectangle.Width;
					SizeF sizeF = new SizeF( diameter, diameter );
					arc = new RectangleF( rectangle.Location, sizeF );
					path.AddArc( arc, 180, 180 );
					arc.Y = rectangle.Bottom - diameter;
					path.AddArc( arc, 0, 180 );
				} else
					path.AddEllipse( rectangle );
			} catch { path.AddEllipse( rectangle ); } finally { path.CloseFigure(); }
			return path;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:25,代码来源:GraphicsExtension.cs

示例3: DrawYourSelf

        /// <summary>
        /// Изчертава елипсите.
        /// </summary>
        /// <param name="graphics"></param>
        public override void DrawYourSelf(Graphics graphics)
        {
            GraphicsPath path = new GraphicsPath();
            path.StartFigure();
            path.AddEllipse(Location.X + ModelSize.Width / 3, Location.Y + ModelSize.Height / 3, ModelSize.Width / 3, ModelSize.Height / 3);
            path.CloseFigure();
            path.StartFigure();
            path.AddLine(Location.X + (ModelSize.Width * 2) / 3, Location.Y + ModelSize.Height / 2, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 2);
            path.CloseFigure();
            path.AddEllipse(new RectangleF(Location, ModelSize));
            path.CloseFigure();
            path.Transform(this.TMatrix.TransformationMatrix);

            /*
             * Създава се Pen, който изчертава контура, като използва
             * цвят и дебелина (определят се от конструктора)
             */
            Pen pen = new Pen(this.BorderColor, this.BorderWidth);
            // Правим същото, но за запълването
            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }
            graphics.DrawPath(pen, path);
            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:35,代码来源:ConnectedEllipses.cs

示例4: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            GraphicsPath path = new GraphicsPath();
            path.AddEllipse(0, 0, this.Width, this.Height);

            path.AddEllipse(100, 100, 100, 100);

            this.Region = new Region(path);
        }
开发者ID:alperkonuralp,项目名称:WinFormOrnekleri,代码行数:9,代码来源:Form1.cs

示例5: Form1

        public Form1()
        {
            InitializeComponent();
            Path = new GraphicsPath();

            Path.FillMode = FillMode.Winding;
            Path.AddEllipse(50, 30, 100, 100);
            Path.AddEllipse(20, 95, 160, 140);

            Region Rgn = new Region(Path);
            Region = Rgn;
        }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:12,代码来源:Form1.cs

示例6: SetBackground

        void SetBackground(Color color)
        {
            Bitmap bmp_image = new Bitmap(Canvas.Width, Canvas.Height);
            Graphics g = Graphics.FromImage(bmp_image);
            g.SmoothingMode = SmoothingMode.AntiAlias;

            int rect_width = 1120;

            for (int i = 0; i < 360; i += 36)
            {
                g.FillPie(new SolidBrush(Color.Black), new Rectangle(center.X - (int)rect_width / 2, center.Y - (int)rect_width / 2, (int)rect_width, (int)rect_width), i, 18);
            }

            GraphicsPath gp = new GraphicsPath();

            gp.AddEllipse(center.X - rect_width / 2 - 40, center.Y - rect_width / 2, rect_width, rect_width);
            gp.CloseFigure();

            PathGradientBrush pgb = new PathGradientBrush(gp);
            pgb.CenterColor = Color.FromArgb(220, /*152, 35, 149*/color);
            pgb.SurroundColors = new Color[] { Color.FromArgb(30, Color.White) };
            g.FillPath(pgb, gp);

            Canvas.BackgroundImage = bmp_image;
        }
开发者ID:fredddy123,项目名称:Round-Arkanoid,代码行数:25,代码来源:MainWindow.cs

示例7: CreateEllipse

 ///<summary>
 /// Creates a <see cref="PathPointSymbolizer"/> that renders ellipses.
 ///</summary>
 ///<param name="line">The pen to outline the ellipse</param>
 ///<param name="fill">the brush to fill the ellipse</param>
 ///<param name="a">The x-axis radius of the ellipse</param>
 ///<param name="b">The x-axis radius of the ellipse</param>
 ///<returns>The PathPointSymbolizer object</returns>
 public static PathPointSymbolizer CreateEllipse(Pen line, Brush fill, float a, float b)
 {
     GraphicsPath path = new GraphicsPath();
     path.AddEllipse(0, 0, a, b);
     return new PathPointSymbolizer(
         new[] { new PathDefinition { Line = line, Fill = fill, Path = path } });
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:15,代码来源:PathPointSymbolizer.cs

示例8: GetGraphicsPath

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

示例9: ClickableAt

        public override bool ClickableAt(int x, int y)
        {
            Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
            int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS) + 10;
            Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);

            // If we clicked inside the rectangle and it's visible we are clickable at.
            if (!Color.Transparent.Equals(fillColor))
            {
                if (Contains(x, y))
                {
                    return true;
                }
            }

            // check the rest of the lines
            if (lineThickness > 0)
            {
                using (Pen pen = new Pen(Color.White, lineThickness))
                {
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddEllipse(rect);
                        return path.IsOutlineVisible(x, y, pen);
                    }
                }
            }
            else
            {
                return false;
            }
        }
开发者ID:modulexcite,项目名称:ShareX_Google_Code,代码行数:32,代码来源:EllipseContainer.cs

示例10: DrawBreakpoint

    /// <summary>
    /// Draws a breakpoint icon in the margin.
    /// </summary>
    /// <param name="g">The <see cref="Graphics"/> context.</param>
    /// <param name="rectangle">The bounding rectangle.</param>
    /// <param name="isEnabled"><c>true</c> if enabled..</param>
    /// <param name="willBeHit"><c>true</c> if it will be hit.</param>
    public static void DrawBreakpoint(Graphics g, Rectangle rectangle, bool isEnabled, bool willBeHit)
    {
      int diameter = Math.Min(rectangle.Width - 4, rectangle.Height);
      Rectangle rect = new Rectangle(2, rectangle.Y + (rectangle.Height - diameter) / 2, diameter, diameter);

      using (GraphicsPath path = new GraphicsPath())
      {
        path.AddEllipse(rect);
        using (PathGradientBrush pthGrBrush = new PathGradientBrush(path))
        {
          pthGrBrush.CenterPoint = new PointF(rect.Left + rect.Width / 3, rect.Top + rect.Height / 3);
          pthGrBrush.CenterColor = Color.MistyRose;
          Color[] colors = { willBeHit ? Color.Firebrick : Color.Olive };
          pthGrBrush.SurroundColors = colors;

          if (isEnabled)
          {
            g.FillEllipse(pthGrBrush, rect);
          }
          else
          {
            g.FillEllipse(SystemBrushes.Control, rect);
            using (Pen pen = new Pen(pthGrBrush))
            {
              g.DrawEllipse(pen, new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2));
            }
          }
        }
      }
    }
开发者ID:Finarch,项目名称:DigitalRune.Windows.TextEditor,代码行数:37,代码来源:BookmarkRenderer.cs

示例11: ContainsPoint

        /// <summary>
        /// Проверяет попадание точки в фигуру
        /// </summary>
        /// <param name="p"></param>
        /// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
        public override int ContainsPoint(Point p)
        {
            if (this.IsSelected)
            {
                for (int i = 1; i <= KeyPoints.Length; i++)
                {
                    if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
                        return i;
                }
            }

            var path = new GraphicsPath();
            Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);

            Rectangle rect = NormalRectToSquare(PaintHelper.NormalizeRect(StartPoint, EndPoint));
            path.AddEllipse(rect);
            path.Widen(pen);

            Region region = new Region(path);
            pen.Dispose();
            if(region.IsVisible(p))
                return 0;

            Point center = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
            double radius = rect.Width / 2;
            float dx = p.X - center.X;
            float dy = p.Y - center.Y;
            if (Math.Sqrt(dx * dx + dy * dy) <= radius)
                return 0;
            return -1;
        }
开发者ID:tsiganoff,项目名称:PFSOFT_Test,代码行数:36,代码来源:Circle.cs

示例12: StripImage

        private static Bitmap StripImage(Bitmap bitmap)
        {
            var result = bitmap.Clone() as Bitmap;

            if (result == null)
            {
                return null;
            }

            var g = Graphics.FromImage(result);

            using (Brush br = new SolidBrush(Color.Black))
            {
                g.FillRectangle(br, 0, 0, bitmap.Width, bitmap.Height);
            }

            var path = new GraphicsPath();
            var offsetX = (float)(bitmap.Width * 0.85);
            var offsetY = (float)(bitmap.Height * 0.85);

            path.AddEllipse(offsetX, offsetY, bitmap.Width - 2 * offsetX, bitmap.Width - 2 * offsetY);
            g.SetClip(path);
            g.DrawImage(bitmap, 0, 0);

            return result;
        }
开发者ID:reekroo,项目名称:PatternRecognition,代码行数:26,代码来源:CirclesExtractor.cs

示例13: OnPaint

 // Draw the new button.
 protected override void OnPaint(PaintEventArgs e)
 {
     GraphicsPath grPath = new GraphicsPath();
         grPath.AddEllipse(10, 10, 60, 60);
         this.Region = new System.Drawing.Region(grPath);
         base.OnPaint(e);
 }
开发者ID:vavio,项目名称:Kids-vs-IceCream,代码行数:8,代码来源:RoundButton.cs

示例14: Render

        //
        // GET: /ChartImage/
        public void Render(List<int> a)
        {
            int pieWidth = 400, pieHeight=400;
            using(Bitmap bmp = new Bitmap(ImageWidth, ImageHeight))
            using(Graphics g = Graphics.FromImage(bmp))
            using(Font font = new Font(FontFamily, 1f)){
                g.Clear(BackgroundColor);

                GraphicsPath path = new GraphicsPath();
                //return Content(a.Count().ToString());
                if (a[0]==0){
                    //TODO: add text that chart is empty.
                    SolidBrush p = new SolidBrush(ColorTranslator.FromHtml("#40BF40"));
                    path.AddEllipse((ImageWidth - pieWidth) / 2, (ImageHeight - pieHeight) / 2, pieWidth, pieHeight);
                    g.FillPath(p, path);
                }

                g.Flush();
                Response.ContentType = "image/png";
                using(var memoryStream = new MemoryStream()){
                    bmp.Save(memoryStream, ImageFormat.Png);
                    memoryStream.WriteTo(Response.OutputStream);
                }
            }
        }
开发者ID:j-burrows,项目名称:listit,代码行数:27,代码来源:ChartImageController.cs

示例15: GeneratePath

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


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