private void Form1_Paint(object sender, PaintEventArgs e)

        {

            Graphics g = e.Graphics;

            g.DrawString("這是一组同心圆", this.Font, Brushes.Black, 10, 20);

             Pen p1 = new Pen(Color.Red);

             Pen p2 = new Pen(Color.Purple);

             Pen p3 = new Pen(Color.Blue);

             Pen p4 = new Pen(Color.Green);

             g.DrawEllipse(p1, 120-80, 120-80,80*2, 80*2);

             g.DrawEllipse(p2, 120 - 60, 120 - 60, 60 * 2, 60 * 2);

             g.DrawEllipse(p3, 120 - 40, 120 - 40, 40 * 2, 40 * 2);

             g.DrawEllipse(p4, 120 - 20, 120 -20, 20 * 2, 20 * 2);

 

 

        }

 

        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)

        {

            Graphics g = e.Graphics;

            g.DrawString("這是一组同心圆", this.Font, Brushes.Black, 10, 20);

            Pen p1 = new Pen(Color.Red);

            Pen p2 = new Pen(Color.Purple);

            Pen p3 = new Pen(Color.Blue);

            Pen p4 = new Pen(Color.Green);

            g.DrawEllipse(p1, 120 - 80, 120 - 80, 80 * 2, 80 * 2);

            g.DrawEllipse(p2, 120 - 60, 120 - 60, 60 * 2, 60 * 2);

            g.DrawEllipse(p3, 120 - 40, 120 - 40, 40 * 2, 40 * 2);

            g.DrawEllipse(p4, 120 - 20, 120 - 20, 20 * 2, 20 * 2);

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            PrintDialog p = new PrintDialog();

            p.Document = printDocument1;

            DialogResult result = p.ShowDialog();

            if (result == DialogResult.OK )

            {

                printDocument1.Print();

            }          

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

            printPreviewDialog1.Document = printDocument1;

            printPreviewDialog1.Show();

        }

 

        private void button3_Click(object sender, EventArgs e)

        {

            pageSetupDialog1.Document = printDocument1;

            pageSetupDialog1.ShowDialog();

        }

創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()