Exemple #1
0
 private void Btn6_Click(object sender, EventArgs e)
 {
     if (HistoryTxtBox.Text.Contains('='))
     {
         HistoryTxtBox.Clear();
         ResultTxtBox.Clear();
     }
     if (!(HistoryTxtBox.Text.LastOrDefault() == ')'))
     {
         ResultTxtBox.Text += "6";
     }
 }
Exemple #2
0
 public bool FindResult()
 {
     try
     {
         if (HistoryTxtBox.Text.Contains('='))
         {
             HistoryTxtBox.Clear();
         }
         char sumbol = HistoryTxtBox.Text.Intersect(SumbolArr).LastOrDefault();
         if (HistoryTxtBox.Text.Length == 0 || sumbol == '\0')
         {
             Result = Convert.ToDouble(ResultTxtBox.Text);
         }
         if (ResultTxtBox.Text.Length > 0)
         {
             if (sumbol == '+')
             {
                 Result += Convert.ToDouble(ResultTxtBox.Text);
             }
             if (sumbol == '-')
             {
                 Result -= Convert.ToDouble(ResultTxtBox.Text);
             }
             if (sumbol == '*')
             {
                 if (Result == 0)
                 {
                     Result = 1;
                 }
                 Result *= Convert.ToDouble(ResultTxtBox.Text);
             }
             if (sumbol == '/')
             {
                 if (Convert.ToDouble(ResultTxtBox.Text) == 0)
                 {
                     throw new Exception("Ошибка: Деления на нол!!!");
                 }
                 Result /= Convert.ToDouble(ResultTxtBox.Text);
             }
             return(true);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         ResultTxtBox.Clear();
     }
     return(false);
 }
Exemple #3
0
 private void Btn0_Click(object sender, EventArgs e)
 {
     if (HistoryTxtBox.Text.Contains('='))
     {
         HistoryTxtBox.Clear();
         ResultTxtBox.Clear();
     }
     if (!(HistoryTxtBox.Text.LastOrDefault() == ')'))
     {
         if ((!ResultTxtBox.Text.All(p => p == '0')) || (ResultTxtBox.Text.Length == 0))
         {
             ResultTxtBox.Text += "0";
         }
     }
 }
        private void Predict_Click(object sender, EventArgs e)
        {
            var pred = ss.Predict(SrcTxtBox.Text.ToLower().Trim().Split(' ').ToList());

            ResultTxtBox.Clear();

            int i = 0;

            foreach (var item in pred)
            {
                ResultTxtBox.Text += item + " ";

                i++;
            }
        }
Exemple #5
0
 private void ProtsentBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (ResultTxtBox.Text.Length > 0 && HistoryTxtBox.Text.LastOrDefault() != ')')
         {
             if (HistoryTxtBox.Text.LastOrDefault() == '=')
             {
                 HistoryTxtBox.Clear();
             }
             HistoryTxtBox.Text += $"({ResultTxtBox.Text}%)";
             ResultTxtBox.Text   = (Result * Convert.ToDouble(ResultTxtBox.Text) / 100).ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         ResultTxtBox.Clear();
     }
 }
Exemple #6
0
 private void DevideBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (FindResult())
         {
             if (HistoryTxtBox.Text.LastOrDefault() == ')')
             {
                 HistoryTxtBox.Text += "/";
             }
             else
             {
                 HistoryTxtBox.Text += ResultTxtBox.Text + "/";
             }
             ResultTxtBox.Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         ResultTxtBox.Clear();
     }
 }
Exemple #7
0
 private void ResultBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (FindResult())
         {
             if (HistoryTxtBox.Text.LastOrDefault() == ')')
             {
                 HistoryTxtBox.Text += "=";
             }
             else
             {
                 HistoryTxtBox.Text += ResultTxtBox.Text + "=";
             }
             ResultTxtBox.Text = Result.ToString();
             HistoryListBox.Items.Add(HistoryTxtBox.Text + ResultTxtBox.Text);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         ResultTxtBox.Clear();
     }
 }
Exemple #8
0
 private void CBtn_Click(object sender, EventArgs e)
 {
     ResultTxtBox.Clear();
     HistoryTxtBox.Clear();
     Result = 0;
 }
Exemple #9
0
 private void CEBtn_Click(object sender, EventArgs e)
 {
     ResultTxtBox.Clear();
 }