コード例 #1
0
        private void arithmitic_click(object sender, EventArgs e)
        {
            Button num = (Button)sender;

            if (txtNumbers.Text.Contains("∞"))
            {
                txtNumbers.Clear();
            }
            if (prevnum != 0)
            {
                if (num.Text == "sqrt")
                {
                    prevnum = Math.Sqrt(double.Parse(txtNumbers.Text));
                }
                if (num.Text == "1/x")
                {
                    prevnum = Convert.ToDouble(1.0 / Convert.ToDouble(txtNumbers.Text));
                }
                if (num.Text == "%")
                {
                    prevnum = Convert.ToDouble(txtNumbers.Text) / 100;
                }
                Button21.PerformClick();
                operation         = num.Text;
                operation_pressed = true;
            }
            else if (num.Text == "sqrt")
            {
                prevnum         = Math.Sqrt(double.Parse(txtNumbers.Text));
                txtNumbers.Text = prevnum.ToString();
            }
            else if (num.Text == "1/x")
            {
                prevnum         = Convert.ToDouble(1.0 / Convert.ToDouble(txtNumbers.Text));
                txtNumbers.Text = prevnum.ToString();
            }
            else if (num.Text == "%")
            {
                prevnum         = Convert.ToDouble(txtNumbers.Text) / 100;
                txtNumbers.Text = prevnum.ToString();
            }
            else
            {
                operation         = num.Text;
                prevnum           = double.Parse(txtNumbers.Text);
                txtNumbers.Text   = "0";
                operation_pressed = true;
            }
        }
コード例 #2
0
        public MessageBoxResult Show(string text, string caption, MessageBoxButton buttonType, MessageBoxImage iconType, Int32 defaultButton)
        {
            Description = text;
            //this.Title = caption;

            MessageBoxButtons _buttonType = (MessageBoxButtons)buttonType;
            MessageBoxIcon    _iconType   = MessageBoxIcon.None;

            if (iconType == MessageBoxImage.None)
            {
                _iconType = MessageBoxIcon.None;
            }
            else if (iconType == MessageBoxImage.Error)
            {
                _iconType = MessageBoxIcon.Error;
            }
            else if (iconType == MessageBoxImage.Hand)
            {
                _iconType = MessageBoxIcon.Hand;
            }
            else if (iconType == MessageBoxImage.Stop)
            {
                _iconType = MessageBoxIcon.Stop;
            }
            else if (iconType == MessageBoxImage.Question)
            {
                _iconType = MessageBoxIcon.Question;
            }
            else if (iconType == MessageBoxImage.Exclamation)
            {
                _iconType = MessageBoxIcon.Exclamation;
            }
            else if (iconType == MessageBoxImage.Warning)
            {
                _iconType = MessageBoxIcon.Warning;
            }
            else if (iconType == MessageBoxImage.Asterisk)
            {
                _iconType = MessageBoxIcon.Asterisk;
            }
            else if (iconType == MessageBoxImage.Information)
            {
                _iconType = MessageBoxIcon.Information;
            }

            Int32 count = ChooseButtons(_buttonType);

            ChooseIcons(_iconType);

            if (count == 1)
            {
                Button11.Focus();
            }

            if (count == 2)
            {
                switch (defaultButton)
                {
                case 1:
                {
                    Button21.Focus();
                    break;
                }

                case 2:
                {
                    Button22.Focus();
                    break;
                }

                default:
                {
                    Button21.Focus();
                    break;
                }
                }
            }

            if (count == 3)
            {
                switch (defaultButton)
                {
                case 1:
                {
                    Button31.Focus();
                    break;
                }

                case 2:
                {
                    Button32.Focus();
                    break;
                }

                case 3:
                {
                    Button33.Focus();
                    break;
                }

                default:
                {
                    Button31.Focus();
                    break;
                }
                }
            }

            //this.ShowDialog();
            return(Value);
        }