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 WindowsFormsApplication15
{
    public partial class frm_riazi : Form
    {
        public frm_riazi()
        {
            InitializeComponent();
        }


        int num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0, num6 = 0, num7 = 0, num8 = 0, num9 = 0, num10 = 0, num11 = 0, num12 = 0;
        public int scr = 0;

        Frm_Message Ms = new Frm_Message();
         


        private void rectangleShape1_Click(object sender, EventArgs e)
        {

        }

        private void frm_riazi_Load(object sender, EventArgs e)
        {

            int halat = 0;



            Random objRandom = new Random();
           num1 = objRandom.Next(1, 30);
           num2 = objRandom.Next(1, 30);
           num3 = objRandom.Next(1, 30);

           num4 = num1 + num2 + num3;

           num5 = objRandom.Next(1, 30);
           num6 = objRandom.Next(1, 30);
           num7 = objRandom.Next(1, 30);

           num8 = num5 + num6 + num7;

           num9 = num1 + num5 ;
           num10 = num2 + num6;
           num11 = num3 + num7;
           num12 = num4 + num8;


//''''''''''''''''''''''''''''''''''''''''''''''''

    

          halat = objRandom.Next(3);

          switch (halat)
          {

              case 0 :

           adad1.Text = Convert.ToString(num1);
           adad1.Enabled = true;
           adad1.Text = "";


           adad2.Text = Convert.ToString(num2);
           adad2.Enabled = false;

           adad3.Text = Convert.ToString(num3);
           adad3.Enabled = false;
           

           adad4.Text = Convert.ToString(num4);
           adad4.Enabled = false;
          

           adad5.Text = Convert.ToString(num5);
           adad5.Enabled = false;
           
           adad6.Text = Convert.ToString(num6);
           adad6.Enabled = true;
           adad6.Text = "";

           adad7.Text = Convert.ToString(num7);
           adad7.Enabled = false;
           
           adad8.Text = Convert.ToString(num8);
           adad8.Enabled = true;
           adad8.Text = "";
         
           adad9.Text = Convert.ToString(num9);
           adad9.Enabled = false;


           adad10.Text = Convert.ToString(num10);
           adad10.Enabled = false;

           adad11.Text = Convert.ToString(num11);
           adad11.Enabled = true;
           adad11.Text = "";

           adad12.Text = Convert.ToString(num12);
           adad12.Enabled = false;
        
           break;



              case 1:

           adad1.Text = Convert.ToString(num1);
           adad1.Enabled = false;


           adad2.Text = Convert.ToString(num2);
           adad2.Enabled = true;
           adad2.Text = "";

           adad3.Text = Convert.ToString(num3);
           adad3.Enabled = false;


           adad4.Text = Convert.ToString(num4);
           adad4.Enabled = false;


           adad5.Text = Convert.ToString(num5);
           adad5.Enabled = true;
           adad5.Text = "";

           adad6.Text = Convert.ToString(num6);
           adad6.Enabled = false;
           

           adad7.Text = Convert.ToString(num7);
           adad7.Enabled = true;
           adad7.Text = "";

           adad8.Text = Convert.ToString(num8);
           adad8.Enabled = false;

           adad9.Text = Convert.ToString(num9);
           adad9.Enabled = false;


           adad10.Text = Convert.ToString(num10);
           adad10.Enabled = true;
           adad10.Text = "";

           adad11.Text = Convert.ToString(num11);
           adad11.Enabled = false;
           

           adad12.Text = Convert.ToString(num12);
           adad12.Enabled = false;

           break;




              case 2:

           adad1.Text = Convert.ToString(num1);
           adad1.Enabled = false;


           adad2.Text = Convert.ToString(num2);
           adad2.Enabled = false;


           adad3.Text = Convert.ToString(num3);
           adad3.Enabled = true;
           adad3.Text = "";

           adad4.Text = Convert.ToString(num4);
           adad4.Enabled = false;


           adad5.Text = Convert.ToString(num5);
           adad5.Enabled = false;

           adad6.Text = Convert.ToString(num6);
           adad6.Enabled = false;


           adad7.Text = Convert.ToString(num7);
           adad7.Enabled = false;

           adad8.Text = Convert.ToString(num8);
           adad8.Enabled = true;
           adad8.Text = "";

           adad9.Text = Convert.ToString(num9);
           adad9.Enabled = true;
           adad9.Text = "";

           adad10.Text = Convert.ToString(num10);
           adad10.Enabled = false;

           adad11.Text = Convert.ToString(num11);
           adad11.Enabled = false;


           adad12.Text = Convert.ToString(num12);
           adad12.Enabled = true;
           adad12.Text = "";

           break;

          }








        }

        private void button1_Click(object sender, EventArgs e)
        {



            timer1.Enabled = false;



             if (Convert.ToString(num1) == adad1.Text & Convert.ToString(num2) == adad2.Text & Convert.ToString(num3) == adad3.Text & Convert.ToString(num4) == adad4.Text & Convert.ToString(num5) == adad5.Text & Convert.ToString(num6) == adad6.Text & Convert.ToString(num7) == adad7.Text & Convert.ToString(num8) == adad8.Text & Convert.ToString(num9) == adad9.Text & Convert.ToString(num10) == adad10.Text & Convert.ToString(num11) == adad11.Text & Convert.ToString(num12) == adad12.Text)
             {

                 scr = 1;

                 Ms.label2.Visible = true;
                 Ms.label3.Visible = true;
                 Ms.label4.Visible = true;
                 Ms.label5.Visible = false;
                 Ms.label1.Text = "شما برنده شدید";
                 Ms.label1.ForeColor = Color.LightGreen;
                 Ms.label2.Text = "1";
                 Ms.ShowDialog();
                 this.Close();

              


             }

             else
             {
                 Ms.label2.Visible = false;
                 Ms.label3.Visible = false;
                 Ms.label4.Visible = false;
                 Ms.label5.Visible = true;
                 Ms.label1.Text = "شما باختید";
                 Ms.label1.ForeColor = Color.Red;
                 Ms.label5.Text = "در محاسبات شما اشتباه وجود داشت";
                 Ms.ShowDialog();
                 this.Close();

             }


        
          

              
            











        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (Convert.ToInt32( label18.Text ) > 0)
            {
                label18.Text = Convert.ToString(Convert.ToUInt32(label18.Text) - 1);

            }

            else if (Convert.ToInt32(label18.Text) == 0)
            {

                timer1.Enabled = false;


                if (Convert.ToString(num1) == adad1.Text & Convert.ToString(num2) == adad2.Text & Convert.ToString(num3) == adad3.Text & Convert.ToString(num4) == adad4.Text & Convert.ToString(num5) == adad5.Text & Convert.ToString(num6) == adad6.Text & Convert.ToString(num7) == adad7.Text & Convert.ToString(num8) == adad8.Text & Convert.ToString(num9) == adad9.Text & Convert.ToString(num10) == adad10.Text & Convert.ToString(num11) == adad11.Text & Convert.ToString(num12) == adad12.Text)
                {

                    scr = 1;

                    Ms.label2.Visible = true;
                    Ms.label3.Visible = true;
                    Ms.label4.Visible = true;
                    Ms.label5.Visible = false;
                    Ms.label1.Text = "شما برنده شدید";
                    Ms.label1.ForeColor = Color.LightGreen;
                    Ms.label2.Text = "1";
                    Ms.ShowDialog();
                    this.Close();




                }

                else
                {
                    Ms.label2.Visible = false;
                    Ms.label3.Visible = false;
                    Ms.label4.Visible = false;
                    Ms.label5.Visible = true;
                    Ms.label1.Text = "شما باختید";
                    Ms.label1.ForeColor = Color.Red;
                    Ms.label5.Text = "زمان شما به اتمام رسید";
                    Ms.ShowDialog();
                    this.Close();

                }
           
            }
        }

      
    }
}
