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; } } }
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; } } }
public async Task SendControl(byte control) { OnControl?.Invoke(this, control); await Task.Delay(0); }