예제 #1
0
 /// <summary>
 /// 更新<c>showStr</c>和<c>ShowBox.Text</c>值
 /// </summary>
 /// <permission cref="showStr">更新该成员的值</permission>
 /// <param name="str">要更新的字符串</param>
 private void UpdateStrAndBox(string str)
 {
     ShowBox.Focus();
     if (showStr == "0" && str != ".")
     {
         showStr = str;
     }
     else
     {
         showStr += str;
     }
     ShowBox.Text = showStr;
     ShowBox.Select(ShowBox.Text.Length, 0);
     ShowBox.ScrollToCaret();
 }
예제 #2
0
 /// <summary>
 /// 按钮C点击事件
 /// </summary>
 /// <param name="sender">事件源</param>
 /// <param name="e">不包含事件数据的对象</param>
 private void Btnc_Click(object sender, EventArgs e)
 {
     ShowBox.Focus();
     if (showStr == string.Empty)
     {
         ShowBox.Text = "0";
         ShowBox.Select(ShowBox.Text.Length, 0);
         ShowBox.ScrollToCaret();
         return;
     }
     showStr = showStr.Substring(0, showStr.Length - 1);
     if (string.Equals(showStr, string.Empty))
     {
         showStr = "0";
     }
     ShowBox.Text = showStr;
     ShowBox.Select(ShowBox.Text.Length, 0);
     ShowBox.ScrollToCaret();
 }
예제 #3
0
 /// <summary>
 /// 按钮Enter点击事件
 /// </summary>
 /// <param name="sender">事件源</param>
 /// <param name="e">不包含事件数据的对象</param>
 private void Btnenter_Click(object sender, EventArgs e)
 {
     ShowBox.Focus();
     if (showStr.IndexOfAny(new char[] { '+', '-', '*', '/' }) == -1)
     {
         return;
     }
     try
     {
         double result = Calculation.GetCalculation().Result(showStr);
         showStr      = string.Empty;
         ShowBox.Text = result.ToString();
         ShowBox.Select(ShowBox.Text.Length, 0);
         ShowBox.ScrollToCaret();
     }
     catch (Exception)
     {
         return;
     }
 }