Пример #1
0
        private void gbNumber_MouseClick(object sender, MouseEventArgs e)
        {
            GlassButton gb = (GlassButton)sender;

            if (op == Operation.enter)
            {
                Result = 0;
                op     = Operation.plus;
            }
            if (gb.TabIndex < 10)
            {
                strElem += gb.TextButton;
                if (strElem == "0")
                {
                    strElem = string.Empty;
                }
            }
            if ((!IsFract) && (gb.TabIndex == 10))
            {
                IsFract = true;
                if (strElem == string.Empty)
                {
                    strElem = "0.";
                }
                else
                {
                    strElem += ".";
                }
            }
            if (gb.TabIndex == 11)
            {
                IsMinus = !IsMinus;
            }
            Display(strElem);
        }
Пример #2
0
        private void gbOperation_MouseClick(object sender, MouseEventArgs e)
        {
            Element = StrToDbl(strElem);
            strElem = string.Empty;
            IsMinus = false;
            IsFract = false;
            if (op == Operation.enter)
            {
                Element = Result;
            }
            if (Element != 0)
            {
                switch (op)
                {
                case Operation.plus:
                    Result = Result + Element;
                    break;

                case Operation.minus:
                    Result = Result - Element;
                    break;

                case Operation.mult:
                    Result = Result * Element;
                    break;

                case Operation.div:
                    Result = Result / Element;
                    break;

                case Operation.pow:
                    Result = Math.Pow(Result, Element);
                    break;
                }
            }
            lbResult.Text = string.Format("{0}", Math.Round(Result, 3));
            GlassButton gb = (GlassButton)sender;

            if (gb.TabIndex == 0)
            {
                op = Operation.plus;
            }
            else if (gb.TabIndex == 1)
            {
                op = Operation.minus;
            }
            else if (gb.TabIndex == 2)
            {
                op = Operation.mult;
            }
            else if (gb.TabIndex == 3)
            {
                op = Operation.div;
            }
            else if (gb.TabIndex == 4)
            {
                op = Operation.pow;
            }
            else if (gb.TabIndex == 5)
            {
                op            = Operation.enter;
                Result        = Math.Sqrt(Math.Abs(Element));
                lbResult.Text = string.Format("{0}", Math.Round(Result, 3));
            }
            else
            {
                op = Operation.enter;
            }
            if (gb.TabIndex < 5)
            {
                lbOper.Text = gb.TextButton;
            }
            else
            {
                lbOper.Text = "=";
            }
        }