using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2
{
   public partial class Form1 : Form
   {
      public Form1()
      {
         InitializeComponent();
      }

      private void button1_Click(object sender, EventArgs e)
      {
         using (Graphics g = this.CreateGraphics())
         {
            using (Pen p = new Pen(Color.Purple))
            {
               g.DrawLine(p, new Point(1, 1), new Point(this.Width, this.Height));
            }
         }
      }

      private void button2_Click(object sender, EventArgs e)
      {
         string text = "Witaj GDI+";
         using (Graphics g = this.CreateGraphics())
         {
            using (Font textFont = new Font("Agency FB", 18))
            {
               using (SolidBrush textBrush = new SolidBrush(Color.DarkRed))
               {
                  StringFormat drawFormat = new StringFormat();
                  g.DrawString(text, textFont, textBrush, 1.0f, 1.0f, drawFormat);
               }
            }
         }
      }

      private void button2_Paint(object sender, PaintEventArgs e)
      {

      }

      private void Form1_Paint(object sender, PaintEventArgs e)
      {

      }

      protected override void OnPaint(PaintEventArgs e)
      {
         base.OnPaint(e);
         using (Graphics g = this.CreateGraphics())
         {
            using (Font textFont = new Font("Arial", 18))
            {
               using (SolidBrush textBrush = new SolidBrush(Color.Black))
               {
                  g.DrawString("Zawsze odrysowywane", textFont, textBrush, 1.0f,
                    (float)this.Height / 2);
               }
            }
         }
      }

   }
}