예제 #1
0
        /// <summary>
        /// Draw a circle, by capturing 2 clicks to define the diameter.
        /// </summary>
        /// <param name="e"></param>
        private void CreateCircle(MouseEventArgs e)
        {
            if (clicknumber == 0)
            {
                one         = new PointF(e.X, e.Y);
                clicknumber = 1;
            }
            else
            {
                two         = new PointF(e.X, e.Y);
                clicknumber = 0;
                Graphics g        = this.CreateGraphics();
                Pen      blackpen = new Pen(Color.Black);

                Circle aShape = new Circle(one, two);
                activeShapes.Add(aShape);
                aShape.Draw(g);
            }
            RefreshDrawings();
        }
예제 #2
0
파일: Program.cs 프로젝트: Randray/Homework
        static void Main(string[] args)
        {
            //Shape shape = new Shape();
            Shape circle = new Circle();

            circle.Draw();

            List <Shape> shapes = new List <Shape>();

            // use polymorphis to store objects
            shapes.Add(new Circle());
            shapes.Add(new Square());
            shapes.Add(new Circle());
            shapes.Add(new Square());

            Console.WriteLine("Loop through all drawing objects in a list:");
            foreach (Shape shape in shapes)
            {
                shape.Draw(); // "Draw Circle!" "Draw Square!" ...
            }
        }