Advertisement
MarkDev

Untitled

Apr 7th, 2021
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.63 KB | None | 0 0
  1. private void btnGradient_Click(object sender, EventArgs e)
  2.         {
  3.             if (egoldsGoogleTextBox1.Text == "" || egoldsGoogleTextBox2.Text == "" || egoldsGoogleTextBox3.Text == "")
  4.             {
  5.                 MessageBox.Show("Пожалуйста введите значение во все поля!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  6.             }
  7.             else
  8.             {
  9.                 Random rnd = new Random();
  10.                 int x = Convert.ToInt32(egoldsGoogleTextBox1.Text);
  11.                
  12.                 double nach = Convert.ToDouble(egoldsGoogleTextBox2.Text);
  13.                 double end = Convert.ToDouble(egoldsGoogleTextBox3.Text);
  14.                 double razn = (end - nach) * 10;
  15.                 double integ = 785;
  16.  
  17.                 if (nach > end)
  18.                 {
  19.                     MessageBox.Show("Пожалуйста введите корректные значения диапазона!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  20.                 }
  21.                 else if (nach < 0)
  22.                 {
  23.                     MessageBox.Show("Пожалуйста введите корректные значения диапазона!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  24.                 }
  25.                 else
  26.                 {
  27.                     label3.Visible = true;
  28.                     label9.Visible = true;
  29.                     listBox1.Visible = true;
  30.                     label6.Visible = true;
  31.                     listBox2.Visible = true;
  32.                     pictureBox2.Visible = true;
  33.                     yt_Button2.Visible = true;
  34.                     yt_Button3.Visible = true;
  35.                     label11.Visible = true;
  36.                     label12.Visible = true;
  37.  
  38.  
  39.                     listBox1.Items.Clear();
  40.                     listBox2.Items.Clear();
  41.  
  42.  
  43.                     double chet = nach;
  44.  
  45.                     double[] mass = new double[1000];
  46.  
  47.                     mass[0] = nach;
  48.                     listBox1.Items.Add(mass[0].ToString("F1"));
  49.  
  50.                     for (int i = 1; i < razn + 1; i++)
  51.                     {
  52.                         chet = chet + 0.1;
  53.                         mass[i] = chet;
  54.                         listBox1.Items.Add(mass[i].ToString("F1"));
  55.                     }
  56.  
  57.                     if (egoldsGoogleTextBox8.Visible == true)
  58.                     {
  59.                         if (egoldsGoogleTextBox8.Text == "")
  60.                         {
  61.                             MessageBox.Show("Пожалуйста введите значения во все поля!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  62.                         }
  63.                         else
  64.                         {
  65.                             integ = Convert.ToDouble(egoldsGoogleTextBox8.Text);
  66.                         }
  67.                     }
  68.  
  69.                     if (egoldsGoogleTextBox4.Visible == true | egoldsGoogleTextBox5.Visible == true)
  70.                     {
  71.                         if (egoldsGoogleTextBox4.Text == "" || egoldsGoogleTextBox5.Text == "" || egoldsGoogleTextBox6.Text == "" || egoldsGoogleTextBox7.Text == "")
  72.                         {
  73.                             MessageBox.Show("Пожалуйста введите значения во все поля!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  74.                         }
  75.                         else
  76.                         {
  77.                             double x1 = Convert.ToDouble(egoldsGoogleTextBox4.Text);
  78.                             double x2 = Convert.ToDouble(egoldsGoogleTextBox5.Text);
  79.                             double c1 = Convert.ToDouble(egoldsGoogleTextBox6.Text);
  80.                             double c2 = Convert.ToDouble(egoldsGoogleTextBox7.Text);
  81.  
  82.  
  83.                             double rand = 0;
  84.                             rand += mass[rnd.Next(0, (int)razn)];
  85.  
  86.                             double r1 = x1 + (x2 - x1) * rand;
  87.                             double r2 = c1 + (c2 - c1) * rand;
  88.  
  89.                             label4.Text = ($"R1 = {x1} + ({x2} - {x1})*{rand.ToString("F1")}");
  90.                             label5.Text = ($"R1 = {r1.ToString("F1")}");
  91.  
  92.                             label8.Text = ($"R2 = {c1} + ({c2} - {c1})*{rand.ToString("F1")}");
  93.                             label7.Text = ($"R2 = {r2.ToString("F1")}");
  94.  
  95.                             label10.Text = ($"y = {integ}");
  96.  
  97.                             int h = 0;
  98.                             int t = 0;
  99.  
  100.                             if (integ > r2)
  101.                             {
  102.                                 for (int i = 0; i < x; i++)
  103.                                 {
  104.                                     h++;
  105.                                     t++;
  106.                                     listBox2.Items.Add($"N1 = {h} | N2 = {t} | y = {integ}");
  107.                                 }
  108.                                 label2.Text = $"Значение интеграла больше чем R2 | {r2.ToString("F1")} <> {integ}";
  109.                             }
  110.                             else
  111.                             {
  112.                                 for (int i = 0; i < x; i++)
  113.                                 {
  114.                                     h++;
  115.                                     listBox2.Items.Add($"N1 = {h} | y = {integ}");
  116.                                 }
  117.                                 label2.Text = $"Значение интеграла меньше чем R2 | {r2.ToString("F1")} <> {integ}";
  118.                             }
  119.                         }
  120.                     }
  121.                     else
  122.                     {
  123.                         double rand = 0;
  124.                         rand += mass[rnd.Next(0, (int)razn)];
  125.  
  126.                         double r1 = 10 + (5 - 10) * rand;
  127.                         double r2 = 0 + (210 - 0) * rand;
  128.  
  129.                         label4.Text = ($"R1 = 10 + (5 - 10)*{rand.ToString("F1")}");
  130.                         label5.Text = ($"R1 = {r1.ToString("F1")}");
  131.  
  132.                         label8.Text = ($"R2 = 0 + (210 - 0)*{rand.ToString("F1")}");
  133.                         label7.Text = ($"R2 = {r2.ToString("F1")}");
  134.  
  135.                         label10.Text = ($"y = {integ}");
  136.  
  137.                         int h = 0;
  138.                         int t = 0;
  139.  
  140.                         if (integ > r2)
  141.                         {
  142.                             for (int i = 0; i < x; i++)
  143.                             {
  144.                                 h++;
  145.                                 t++;
  146.                                 listBox2.Items.Add($"N1 = {h} | N2 = {t} | y = {integ}");
  147.                             }
  148.                             label2.Text = $"Значение интеграла больше чем R2 | {r2.ToString("F1")} <> {integ}";
  149.                         }
  150.                         else
  151.                         {
  152.                             for (int i = 0; i < x; i++)
  153.                             {
  154.                                 h++;
  155.                                 listBox2.Items.Add($"N1 = {h} | y = {integ}");
  156.                             }
  157.                             label2.Text = $"Значение интеграла меньше чем R2 | {r2.ToString("F1")} <> {integ}";
  158.                         }
  159.                     }
  160.                 }              
  161.             }
  162.         }
  163.  
  164.         private void yt_Button1_Click(object sender, EventArgs e)
  165.         {
  166.             if (cmbStyle.Visible == false)
  167.             {
  168.                 cmbStyle.Visible = true;
  169.             }
  170.             else
  171.             {
  172.                 cmbStyle.Visible = false;
  173.             }
  174.         }
  175.  
  176.         private void yt_Button2_Click(object sender, EventArgs e)
  177.         {
  178.             if (egoldsGoogleTextBox4.Visible == false)
  179.             {
  180.                 egoldsGoogleTextBox4.Visible = true;
  181.                 egoldsGoogleTextBox5.Visible = true;
  182.                 egoldsGoogleTextBox6.Visible = true;
  183.                 egoldsGoogleTextBox7.Visible = true;
  184.             }
  185.             else
  186.             {
  187.                 egoldsGoogleTextBox4.Visible = false;
  188.                 egoldsGoogleTextBox5.Visible = false;
  189.                 egoldsGoogleTextBox6.Visible = false;
  190.                 egoldsGoogleTextBox7.Visible = false;
  191.             }
  192.         }
  193.  
  194.         private void yt_Button3_Click(object sender, EventArgs e)
  195.         {
  196.             if (egoldsGoogleTextBox8.Visible == false)
  197.             {
  198.                 egoldsGoogleTextBox8.Visible = true;
  199.             }
  200.             else
  201.             {
  202.                 egoldsGoogleTextBox8.Visible = false;
  203.             }
  204.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement