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

namespace EX2
{
    public partial class Form1 : Form
    {
        string ObjectName;
        public Form1()
        {
            InitializeComponent();
        }

        private void آوردنبهجلوToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ObjectName == "pictureBox1")
                pictureBox1.BringToFront();
            else if (ObjectName == "pictureBox2")
                pictureBox2.BringToFront();
            else if (ObjectName == "pictureBox3")
                pictureBox3.BringToFront();
        }


   

        private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
        {
            ObjectName = "pictureBox3";
        }

        private void pictureBox2_MouseDown(object sender, MouseEventArgs e)
        {
            ObjectName = "pictureBox2";
        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            ObjectName = "pictureBox1";
        }

        private void فرستادنبهعقبToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ObjectName == "pictureBox1")
                pictureBox1.SendToBack();
            else if (ObjectName == "pictureBox2")
                pictureBox2.SendToBack();
            else if (ObjectName == "pictureBox3")
                pictureBox3.SendToBack();
        }

    }
}
