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.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.