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


C# Graphics.DrawEllipse方法代码示例

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


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

示例1: Run

        public static void Run()
        {
            // ExStart:DrawingEllipse
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages();

            // Creates an instance of FileStream
            using (FileStream stream = new FileStream(dataDir + "DrawingEllipse_out.bmp", FileMode.Create))
            {
                // Create an instance of BmpOptions and set its various properties
                BmpOptions saveOptions = new BmpOptions();
                saveOptions.BitsPerPixel = 32;
                saveOptions.Source = new StreamSource(stream);

                // Create an instance of Image
                using (Image image = Image.Create(saveOptions, 100, 100))
                {
                    // Create and initialize an instance of Graphics class and Clear Graphics surface                    
                    Graphics graphic = new Graphics(image);
                    graphic.Clear(Color.Yellow);

                    // Draw a dotted ellipse shape by specifying the Pen object having red color and a surrounding Rectangle
                    graphic.DrawEllipse(new Pen(Color.Red), new Rectangle(30, 10, 40, 80));

                    // Draw a continuous ellipse shape by specifying the Pen object having solid brush with blue color and a surrounding Rectangle
                    graphic.DrawEllipse(new Pen(new SolidBrush(Color.Blue)), new Rectangle(10, 30, 80, 40));
                    image.Save();
                }
                stream.Close();
            }
            // ExEnd:DrawingEllipse
        }
开发者ID:aspose-imaging,项目名称:Aspose.Imaging-for-.NET,代码行数:32,代码来源:DrawingEllipse.cs

示例2: Run

        public static void Run()
        {
            // ExStart:DrawingUsingGraphics
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages() + "SampleImage_out.bmp";

            // Create an instance of BmpOptions and set its various properties
            BmpOptions imageOptions = new BmpOptions();
            imageOptions.BitsPerPixel = 24;

            // Create an instance of FileCreateSource and assign it to Source property 
            imageOptions.Source = new FileCreateSource(dataDir, false);
            using (var image =  Image.Create(imageOptions, 500, 500))
            {
                var graphics = new Graphics(image);

                // Clear the image surface with white color and Create and initialize a Pen object with blue color
                graphics.Clear(Color.White);                
                var pen = new Pen(Color.Blue);

                // Draw Ellipse by defining the bounding rectangle of width 150 and height 100 also Draw a polygon using the LinearGradientBrush
                graphics.DrawEllipse(pen, new Rectangle(10, 10, 150, 100));
                using (var linearGradientBrush = new LinearGradientBrush(image.Bounds, Color.Red, Color.White, 45f))
                {
                    graphics.FillPolygon(linearGradientBrush, new[] { new Point(200, 200), new Point(400, 200), new Point(250, 350) });
                }
                image.Save();
            }
            // ExEnd:DrawingUsingGraphics
        }
开发者ID:aspose-imaging,项目名称:Aspose.Imaging-for-.NET,代码行数:30,代码来源:DrawingUsingGraphics.cs

示例3: Draw

 public override void Draw(Graphics gr)
 {
     if (Ready)
     {
         gr.DrawEllipse(Pens.Green, Left, Top, Right, Bottom);
     }
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例4: DrawNode

	/// <summary>
	/// Draws the node using GDI+.
	/// </summary>
	/// <param name="graphics">GDI+ Graphics surface.</param>
	/// <param name="bounds">The bounds in which to draw the node.</param>
	public override void DrawNode(Graphics graphics, Rectangle bounds) {
		graphics.FillEllipse(mFill, bounds);
		graphics.DrawEllipse(mStroke, bounds);
	}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:9,代码来源:Node.cs

示例5: Draw

    /// <summary>
    /// Dessiner l'automate dans un Panel.
    /// </summary>
    /// <param name="DrawPanel">Le panel ou on va dessiner l'automate</param>
    /// <param name="fix">La methode de deplacement des etats dans le dessin
    /// true pour des emplacements fixes</param>
    public void Draw(System.Windows.Forms.Panel DrawPanel, bool fix)
    {
        Random Ran = new Random();

        Dessin = DrawPanel.CreateGraphics();
        AutoImage = new Bitmap(DrawPanel.Width, DrawPanel.Height);
        grImage = Graphics.FromImage(AutoImage);

        SolidBrush pinceau = new SolidBrush(Color.Blue);
        Pen myPen = new Pen(Color.Blue, 2);
        Font myfont = new Font("Verdana", 8, FontStyle.Bold);

        DrawPanel.Refresh();
        //Dessin.PixelOffsetMode = PixelOffsetMode.HighQuality;
        Dessin.SmoothingMode = SmoothingMode.AntiAlias;
        grImage.SmoothingMode = SmoothingMode.AntiAlias;

        Pen inipen = new Pen(Color.Coral, 5);
        inipen.CustomEndCap = new AdjustableArrowCap(3, 3, false);

        if (!DessinChanged)
            if (fix)
            {
                myPointArray = new Point[10];
                int[] TabX = new int[8];
                for (int i = 0; i < 8; i++)
                {
                    TabX[i] = (int)i * ((DrawPanel.Width - 40) / 7);
                }
                int[] TabY = new int[5];
                for (int i = 0; i < 5; i++)
                {
                    TabY[i] = (int)i * ((DrawPanel.Height - 28) / 4);
                }

                #region myPointArray
                myPointArray[0] = new Point(TabX[4], TabY[0]);
                myPointArray[1] = new Point(TabX[0], TabY[2]);
                myPointArray[2] = new Point(TabX[7], TabY[2]);
                myPointArray[3] = new Point(TabX[5], TabY[3]);
                myPointArray[4] = new Point(TabX[5], TabY[1]);
                myPointArray[5] = new Point(TabX[2], TabY[3]);
                myPointArray[6] = new Point(TabX[3], TabY[0]);
                myPointArray[7] = new Point(TabX[4], TabY[4]);
                myPointArray[8] = new Point(TabX[2], TabY[1]);
                myPointArray[9] = new Point(TabX[3], TabY[4]);
                #endregion

            }
            else
            {
                myPointArray = new Point[this.S];
                //les restes sont calculés
                double alpha = (Math.PI * 2) / this.S;
                for (int i = 0; i < this.S; i++)
                {
                    myPointArray[i] = new Point((int)((Math.Cos((i - 1) * alpha) * (DrawPanel.Width / 2.75)) + DrawPanel.Width / 2.2), (int)((Math.Sin((i - 1) * alpha) * 90) + 100));

                }

            }

        if (this.S > 10)
            DrawPanel.BackColor = Color.Red;
        for (int i = 0; (i < this.S); i++)
        {
            Point p = myPointArray[i];
            Dessin.DrawEllipse(myPen, p.X, p.Y, 30, 30);
            grImage.DrawEllipse(myPen, p.X, p.Y, 30, 30);

            if (this.S0 == i) //etat ititial
            {

                Dessin.DrawLine(inipen, p.X - 40, p.Y + 5, p.X - 10, p.Y + 10);
                grImage.DrawLine(inipen, p.X - 40, p.Y + 5, p.X - 10, p.Y + 10);
            }
            if (this.F.Contains(i)) //etat final
            {
                grImage.DrawEllipse(myPen, p.X + 2, p.Y + 2, 30 - 4, 30 - 4);
                Dessin.DrawEllipse(myPen, p.X + 2, p.Y + 2, 30 - 4, 30 - 4);
            }

            for (int j = 0; (j < this.S) & (j < 10); j++)
            {

                String CsTran = "";
                if (this.getType() != TYPE.Gfa)
                    foreach (char car in this.X)
                    {
                        if (this.getType() == TYPE.Dfa)
                        {
                            if (((Dfa)this).getInstruction(i, car) == j)
                            {
                                CsTran += ((CsTran.Length == 0) ? (car.ToString()) : ("/" + car.ToString()));
//.........这里部分代码省略.........
开发者ID:sohaibafifi,项目名称:automata,代码行数:101,代码来源:Automata.cs

示例6: Draw

 public override void Draw(Graphics graphics)
 {
     foreach (var s in selected)
                 graphics.DrawEllipse(Pens.Yellow,
                     view.WorldToScreenX(s.Position.X - s.Radius) + 1,
                     view.WorldToScreenY(s.Position.Y - s.Radius) + 1,
                     s.Radius * 2 * view.zoom - 2,
                     s.Radius * 2 * view.zoom - 2);
 }
开发者ID:Keldyn,项目名称:BattleOfTheClans,代码行数:9,代码来源:View.cs

示例7: Draw

 public override void Draw(Graphics Canvas)
 {
     Pen pen = new Pen(Color.Black);
     Canvas.DrawEllipse(pen, pts[0].X, pts[0].Y, this.size, this.size);
 }
开发者ID:YannickMeijer,项目名称:Lab4,代码行数:5,代码来源:Circle.cs

示例8: Render

 public override void Render(Graphics gr, int iScale)
 {
     gr.FillEllipse(new SolidBrush(m_Color), m_iXStart * iScale, m_iYStart * iScale, m_iWidth * iScale, m_iHeight * iScale);
     if (m_iBorderThickness > 0)
         gr.DrawEllipse(new Pen(m_BorderColor, m_iBorderThickness), m_iXStart * iScale, m_iYStart * iScale, m_iWidth * iScale, m_iHeight * iScale);
 }
开发者ID:NigelColpitts,项目名称:GDIDrawer,代码行数:6,代码来源:CDrawer.cs

示例9: Draw

 public override void Draw(Graphics e)
 {
     e.DrawEllipse(new Pen(Color.Black), Rect);
 }
开发者ID:HeaHDeRTaJIeC,项目名称:OOP-OSiSP-Projects,代码行数:4,代码来源:ELLIPSES.cs

示例10: draw

 public void draw(Graphics g)
 {
     lock (bmp)
     {
         Pen redpen = new Pen(Color.Red, 5);
         for (int i = 0; i < NUM_OF_POINTS; i++)
         {
             int[] point = applyTransformation(redTestPoints[i, 0], redTestPoints[i, 1]);
             if (point[0] < 0 || point[1] < 0 ||
                 point[0] > bmp.Width || point[1] > bmp.Height)
             {
                 continue;
             }
             g.DrawEllipse(redpen, (float)point[0], (float)point[1], 1f, 1f);
         }
         //Console.WriteLine(fitness);
     }
 }
开发者ID:adesproject,项目名称:ADES,代码行数:18,代码来源:Processors.cs

示例11: drawEllipse

 public override void drawEllipse(Point location, int diameter, Graphics canvas)
 {
     Pen pen = new Pen(Color.Black);
     canvas.DrawEllipse(pen, location.X, location.Y, diameter, diameter);
 }
开发者ID:RobinSikkens,项目名称:MSO-Lab-4,代码行数:5,代码来源:DrawCSharp.cs

示例12: OnPaint

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        G = e.Graphics;
        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

        G.Clear(BackColor);
        G.SmoothingMode = SmoothingMode.AntiAlias;

        GP1 = new GraphicsPath();
        GP1.AddEllipse(0, 2, Height - 5, Height - 5);

        PB1 = new PathGradientBrush(GP1);
        PB1.CenterColor = Color.FromArgb(50, 50, 50);
        PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
        PB1.FocusScales = new PointF(0.3f, 0.3f);

        G.FillPath(PB1, GP1);

        G.DrawEllipse(P1, 0, 2, Height - 5, Height - 5);
        G.DrawEllipse(P2, 1, 3, Height - 7, Height - 7);

        if (_Checked)
        {
            G.FillEllipse(Brushes.Black, 6, 8, Height - 15, Height - 15);
            G.FillEllipse(Brushes.White, 5, 7, Height - 15, Height - 15);
        }

        SZ1 = G.MeasureString(Text, Font);
        PT1 = new PointF(Height - 3, Height / 2 - SZ1.Height / 2);

        G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
        G.DrawString(Text, Font, Brushes.White, PT1);
    }
开发者ID:massimoca,项目名称:Wedit,代码行数:33,代码来源:Theme.cs


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