예제 #1
0
        private void Check_LastSymb(object sender, KeyPressEventArgs e)
        {
            char number = e.KeyChar;

            e.Handled = true;
            if (RPN.IsOperand(number) || RPN.IsSpecSymb(number) || Char.IsDigit(number) || number == 8)
            {
                if (textbox.Text != "")
                {
                    char[] txt = textbox.Text.ToCharArray();
                    if (!RPN.IsOperand(txt[txt.Length - 1]))
                    {
                        e.Handled = false;
                    }
                    if (RPN.IsSpecSymb(number) || Char.IsDigit(number))
                    {
                        e.Handled = false;
                    }
                    if (number == 8)
                    {
                        e.Handled = false;
                    }
                }
                else
                {
                    if (Char.IsDigit(number))
                    {
                        e.Handled = false;
                    }
                }
            }
        }
예제 #2
0
        private bool Check_LastSymb(object sender)
        {
            char ch = char.Parse((sender as Button).Tag.ToString());

            if (RPN.IsOperand(ch) || RPN.IsSpecSymb(ch) || Char.IsDigit(ch))
            {
                if (textbox.Text != "")
                {
                    char[] txt = textbox.Text.ToCharArray();
                    if (!RPN.IsOperand(txt[txt.Length - 1]))
                    {
                        return(true);
                    }
                    if (RPN.IsSpecSymb(ch) || Char.IsDigit(ch))
                    {
                        return(true);
                    }
                }
                else
                {
                    if (Char.IsDigit(ch))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #3
0
 private void drob_Click(object sender, EventArgs e)
 {
     if (!CheckLock())
     {
         if (textbox.Text != "")
         {
             bool   check   = true;
             string newText = "";
             char[] src     = textbox.Text.ToCharArray();
             int    pos     = src.Length - 1;
             int    i       = -1;
             for (; pos >= 0; pos--)
             {
                 if (check)
                 {
                     if (!Char.IsDigit(src[pos]) && !RPN.IsSpecSymb(src[pos]))
                     {
                         check = false;
                         i     = pos; break;
                     }
                     if (pos == 0)
                     {
                         check = false;
                         i     = -1;
                     }
                 }
             }
             for (int j = 0; j < src.Length; j++)
             {
                 if (j == 0 && i == -1)
                 {
                     newText += "1/" + src[j];
                 }
                 else
                 {
                     if (j == i)
                     {
                         newText += "1/" + src[j];
                     }
                     else
                     {
                         newText += src[j];
                     }
                 }
             }
             textbox.Text = newText;
         }
         else
         {
             textbox.Text = "1/";
         }
     }
 }