private void OperationPlus_Click(object sender, EventArgs e)
 {
     Increase();
     InfoBox.Clear();
     InfoBox.Text = "RgA: ";
     RgCBox.Clear();
     for (int i = 0; i < RgABox.Text.Length; i++)
     {
         InfoBox.Text = InfoBox.Text + RgABox.Text[i];
         if (i == 0)
         {
             InfoBox.Text = InfoBox.Text + ',';
         }
     }
     InfoBox.Text = InfoBox.Text + "\r\n";
     InfoBox.Text = InfoBox.Text + "RgB: ";
     for (int i = 0; i < RgBBox.Text.Length; i++)
     {
         InfoBox.Text = InfoBox.Text + RgBBox.Text[i];
         if (i == 0)
         {
             InfoBox.Text = InfoBox.Text + ',';
         }
     }
     InfoBox.Text = InfoBox.Text + "\r\n";
     InfoBox.Text = InfoBox.Text + "Operation +" + "\r\n" + "\r\n";
     Calculations.Copy(RgABox.Text);
     Calculations.Copy(RgBBox.Text);
     int[] check = new int[16] {
         1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
     };
     if ((Calculations.rg_a[0] == 1) && (!Equals(Calculations.rg_a, check)))
     {
         Calculations.Inverse(Calculations.rg_a);
     }
     if ((Calculations.rg_b[0] == 1) && (!Equals(Calculations.rg_b, check)))
     {
         Calculations.Inverse(Calculations.rg_b);
     }
     Plus();
     if (!Calculations.overflow)
     {
         for (int i = 0; i < 16; i++)
         {
             RgCBox.Text = RgCBox.Text + Convert.ToString(Calculations.rg_c[i]);
             if (i == 0)
             {
                 RgCBox.Text = RgCBox.Text + ',';
             }
         }
     }
     else
     {
         InfoBox.Text = InfoBox.Text + "Возникло переполнение!";
     }
 }
Beispiel #2
0
 private void OperationPlus_Click(object sender, EventArgs e)
 {
     Increase();
     InfoBox.Clear();
     InfoBox.Text = "RgA: ";
     RgCBox.Clear();
     for (int i = 0; i < RgABox.Text.Length; i++)
     {
         InfoBox.Text = InfoBox.Text + RgABox.Text[i];
         if (i == 0)
         {
             InfoBox.Text = InfoBox.Text + ',';
         }
     }
     InfoBox.Text = InfoBox.Text + "\r\n";
     InfoBox.Text = InfoBox.Text + "RgB: ";
     for (int i = 0; i < RgBBox.Text.Length; i++)
     {
         InfoBox.Text = InfoBox.Text + RgBBox.Text[i];
         if (i == 0)
         {
             InfoBox.Text = InfoBox.Text + ',';
         }
     }
     InfoBox.Text = InfoBox.Text + "\r\n";
     InfoBox.Text = InfoBox.Text + "Operation +" + "\r\n" + "\r\n";
     Calculations.Copy(RgABox.Text);
     Calculations.Copy(RgBBox.Text);
     //Для модифицированного кода
     if (Calculations.rg_a[1] == 1)
     {
         Calculations.rg_a[0] = 1;
     }
     else
     {
         Calculations.rg_a[0] = 0;
     }
     if (Calculations.rg_b[1] == 1)
     {
         Calculations.rg_b[0] = 1;
     }
     else
     {
         Calculations.rg_b[0] = 0;
     }
     InfoBox.Text = InfoBox.Text + "Обратный модифицированный код:" + "\r\n";
     for (int i = 0; i < Calculations.rg_a.Length; i++)
     {
         InfoBox.Text = InfoBox.Text + Convert.ToString(Calculations.rg_a[i]);
         if (i == 1)
         {
             InfoBox.Text = InfoBox.Text + ',';
         }
     }
     InfoBox.Text = InfoBox.Text + "\r\n";
     for (int i = 0; i < Calculations.rg_b.Length; i++)
     {
         InfoBox.Text = InfoBox.Text + Convert.ToString(Calculations.rg_b[i]);
         if (i == 1)
         {
             InfoBox.Text = InfoBox.Text + ',';
         }
     }
     InfoBox.Text = InfoBox.Text + "\r\n" + "\r\n";
     //Концовка модифицированного кода
     int[] check = new int[17] {
         1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
     };
     if ((Calculations.rg_a[0] == 1) && (!Equals(Calculations.rg_a, check)))
     {
         Calculations.Inverse(Calculations.rg_a);
     }
     if ((Calculations.rg_b[0] == 1) && (!Equals(Calculations.rg_b, check)))
     {
         Calculations.Inverse(Calculations.rg_b);
     }
     Plus();
     if (!Calculations.not_right)
     {
         for (int i = 1; i < 17; i++)
         {
             RgCBox.Text = RgCBox.Text + Convert.ToString(Calculations.rg_c[i]);
             if (i == 1)
             {
                 RgCBox.Text = RgCBox.Text + ',';
             }
         }
     }
     else
     {
         InfoBox.Text = InfoBox.Text + "Возникло переполнение!";
     }
 }