using System;
using System.Drawing;
using System.Windows.Forms;

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

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "Picture Files (*.jpg)|*.jpg|All Files (*.*)|*.*";
            openFileDialog1.FileName = string.Empty;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
                pictureBox1.Load(openFileDialog1.FileName);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (pictureBox1.Image != null && textBox1.Text != string.Empty)
            {
                Bitmap image1 = new Bitmap(pictureBox1.Image);

                Graphics graph1 = Graphics.FromImage(image1);

                graph1.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

                string wmString = textBox1.Text.Trim();

                Font font1 = new Font("Tahoma", 14, FontStyle.Bold);

                SolidBrush brush1 = new SolidBrush(Color.Blue);

                Point point1 = new Point(10, 10);

                graph1.DrawString(wmString, font1, brush1, point1);

                pictureBox1.Image = image1;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            saveFileDialog1.FileName = string.Empty;
            saveFileDialog1.Filter = "bmp File (*.bmp)|*.bmp";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                pictureBox1.Image.Save(saveFileDialog1.FileName);
        }
    }
}