Example #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;
                }
            }
        }
Example #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;
                }
            }
        }
Example #3
0
 public async Task SendControl(byte control)
 {
     OnControl?.Invoke(this, control);
     await Task.Delay(0);
 }
Example #4
0
 public void DefaultOnControl()
 {
     onControl = bm.SetTarget;
 }
Example #5
0
 public void SetOnControl(OnControl onControl)
 {
     this.onControl = onControl;
 }