Arc Pie Demo : Pie « 2D Graphics « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » 2D Graphics » PieScreenshots 
Arc Pie Demo
Arc Pie Demo

/*
GDI+ Programming in C# and VB .NET
by Nick Symmonds

Publisher: Apress
ISBN: 159059035X
*/
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace MIsc2D_c
{
    /// <summary>
    /// Summary description for MIsc2D.
    /// </summary>
    public class MIsc2D : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.ListBox listBox1;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public MIsc2D()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Disposebool disposing )
        {
            ifdisposing )
            {
                if (components != null
                {
                    components.Dispose();
                }
            }
            base.Disposedisposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
      this.label1 = new System.Windows.Forms.Label();
      this.label2 = new System.Windows.Forms.Label();
      this.label3 = new System.Windows.Forms.Label();
      this.listBox1 = new System.Windows.Forms.ListBox();
      this.SuspendLayout();
      // 
      // label1
      // 
      this.label1.Location = new System.Drawing.Point(40280);
      this.label1.Name = "label1";
      this.label1.Size = new System.Drawing.Size(16016);
      this.label1.TabIndex = 0;
      // 
      // label2
      // 
      this.label2.Location = new System.Drawing.Point(40296);
      this.label2.Name = "label2";
      this.label2.Size = new System.Drawing.Size(16016);
      this.label2.TabIndex = 1;
      // 
      // label3
      // 
      this.label3.Location = new System.Drawing.Point(40312);
      this.label3.Name = "label3";
      this.label3.Size = new System.Drawing.Size(16016);
      this.label3.TabIndex = 2;
      // 
      // listBox1
      // 
      this.listBox1.Location = new System.Drawing.Point(24200);
      this.listBox1.Name = "listBox1";
      this.listBox1.Size = new System.Drawing.Size(19269);
      this.listBox1.TabIndex = 3;
      // 
      // MIsc2D
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(513);
      this.ClientSize = new System.Drawing.Size(292373);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                  this.listBox1,
                                                                  this.label3,
                                                                  this.label2,
                                                                  this.label1});
      this.Name = "MIsc2D";
      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
      this.Text = "MIsc2D";
      this.Load += new System.EventHandler(this.MIsc2D_Load);
      this.ResumeLayout(false);

    }
        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() 
        {
            Application.Run(new MIsc2D());
        }

    private void MIsc2D_Load(object sender, System.EventArgs e)
    {
    
    }

    protected override void OnPaint(PaintEventArgs e)
    {
      Graphics G = e.Graphics;

      GraphicsPath p = new  GraphicsPath();
      PointF[] pts = new PointF(50,  50),
                       new PointF(15025),
                       new PointF(20050)};
      p.AddCurve(pts);
      p.AddRectangle(new Rectangle(60605050));
      p.AddPie(1001008080035);
      G.DrawPath(Pens.Black,p);

      GraphicsPathIterator iter = new GraphicsPathIterator(p);
      label1.Text = "Num pts in path = " + iter.Count.ToString();
      label2.Text = "Num subpaths in path = " + iter.SubpathCount.ToString();
      label3.Text = "Path has curve = " + iter.HasCurve().ToString();

      int StartIndex;
      int EndIndex;
      int i;
      bool IsClosed; 
      // Rewind the Iterator.
      iter.Rewind();
      // List the Subpaths.
      for(i=0;i<iter.SubpathCount;i++) {
        iter.NextSubpath(out StartIndex, out EndIndex, out IsClosed);
        listBox1.Items.Add("Start: " + StartIndex.ToString() +
                           "  End: " + EndIndex.ToString() +
                           "  IsClosed: " + IsClosed.ToString());
      }

    }
    }
}



           
       
Related examples in the same category
1.Draw a pieDraw a pie
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.