예제 #1
0
        public override void Handle(object sender, object args)
        {
            Button button = (Button)args;

            if (button.Tag is Operation)
            {
                OnOperation?.Invoke(this, button.Tag);
            }
            else
            {
                switch (button.Tag.GetType().Name.ToLower())
                {
                case "string":
                    switch ((string)button.Tag)
                    {
                    case "digit":
                        OnDigit?.Invoke(this, button.Text);
                        break;

                    case "control":
                        OnControl?.Invoke(this, button.AccessibleName);
                        break;
                    }
                    break;
                }
            }
        }
예제 #2
0
        public override void Handle(object sender, object args)
        {
            if (args == null)
            {
                throw new ArgumentNullException();
            }
            KeyPressEventArgs e = (KeyPressEventArgs)args;

            if (char.IsDigit(e.KeyChar) ||
                e.KeyChar == ',')
            {
                OnDigit?.Invoke(this, e.KeyChar);
            }
            else
            {
                switch (e.KeyChar)
                {
                case (char)Keys.Back:
                    OnControl?.Invoke(this, "backspace");
                    break;

                case (char)Keys.Escape:
                    OnControl?.Invoke(this, "clear");
                    break;

                case '+':
                    OnOperation?.Invoke(this, new Summation());
                    break;

                case '-':
                    OnOperation?.Invoke(this, new Subtraction());
                    break;

                case '*':
                    OnOperation?.Invoke(this, new Multiplication());
                    break;

                case '/':
                    OnOperation?.Invoke(this, new Division());
                    break;

                case (char)Keys.Return:
                case '=':
                    OnOperation?.Invoke(this, new Equals());
                    break;

                case '^':
                    OnOperation?.Invoke(this, new Power());
                    break;
                }
            }
        }
예제 #3
0
 public async Task SendControl(byte control)
 {
     OnControl?.Invoke(this, control);
     await Task.Delay(0);
 }