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 EX3
{
    public partial class Form1 : Form
    {
        string ObjectName;
        public Form1()
        {
            InitializeComponent();
        }

        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")
                toolPic1BringToFro.PerformClick();
            else if (ObjectName == "pictureBox2")
                toolPic2BringToFro.PerformClick();
            else if (ObjectName == "pictureBox3")
                toolPic3BringToFro.PerformClick();
        }

        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();
        }

        private void ToolstripPic1_Click(object sender, EventArgs e)
        {
            if (ToolstripPic1.Checked == true)
            {
                pictureBox1.Visible = false;
                ToolstripPic1.Checked = false;
            }
            else
            {
                pictureBox1.Visible = true;
                    ToolstripPic1.Checked = true;
            }
            
            }

        private void ToolstripPic2_Click(object sender, EventArgs e)
        {
            if (ToolstripPic2.Checked == true)
            {
                pictureBox2.Visible = false;
                ToolstripPic2.Checked = false;
            }
            else
            {
                pictureBox2.Visible = true;
                ToolstripPic2.Checked = true;
            }
        }

        private void ToolstripPic3_Click(object sender, EventArgs e)
        {
            if (ToolstripPic3.Checked == true)
            {
                pictureBox3.Visible = false;
                ToolstripPic3.Checked = false;
            }
            else
            {
                pictureBox3.Visible = true;
                ToolstripPic3.Checked = true;
            }
        }

        private void toolPic1BringToFro_Click(object sender, EventArgs e)
        {
            pictureBox1.BringToFront();
            toolPic1BringToFro.Checked = true;
            toolPic2BringToFro.Checked = false;
            toolPic3BringToFro.Checked = false;
        }

        private void toolPic2BringToFro_Click(object sender, EventArgs e)
        {
            pictureBox2.BringToFront();
            toolPic1BringToFro.Checked = false;
            toolPic2BringToFro.Checked = true;
            toolPic3BringToFro.Checked = false;
        }

        private void toolPic3BringToFro_Click(object sender, EventArgs e)
        {
            pictureBox3.BringToFront();
            toolPic1BringToFro.Checked = false;
            toolPic2BringToFro.Checked = false;
            toolPic3BringToFro.Checked = true;
        }

       
    }
}
