Example #1
0
 private void Keypad_KeyEvent(object sender, KeyPadEventArgs e)
 {
     System.Diagnostics.Debug.WriteLine(string.Format("Key = {0}, Event Type = {1}", e.KeyValue, e.KeyDownEventType));
 }
Example #2
0
        private void buttonKeyPad_Click(object sender, RoutedEventArgs e)
        {
            //************************************* DialPad key press event ****************************************************
            // This event will called when dial button (1-9) will tapped for dial pad.
            //******************************************************************************************************************

            RemoveIfPlaceHolderTextExist();
            int oldNumberLendth = _viewModel.RemotePartyNumber.Length;
            var key             = DialpadKey.DialpadKey_KeyNone;

            if (Equals(e.OriginalSource, buttonKeyPad0))  // 0 Number tapped
            {
                if (plusButtonHold)
                {
                    plusButtonHold = false;
                    return;
                }

                key = DialpadKey.DialpadKey_Key0;
            }
            else if (Equals(e.OriginalSource, buttonKeyPad1)) // 1 Number tapped
            {
                key = DialpadKey.DialpadKey_Key1;
            }
            else if (Equals(e.OriginalSource, buttonKeyPad2))  // 2 Number tapped
            {
                key = DialpadKey.DialpadKey_Key2;
            }
            else if (Equals(e.OriginalSource, buttonKeyPad3))  // 3 Number tapped
            {
                key = DialpadKey.DialpadKey_Key3;
            }
            else if (Equals(e.OriginalSource, buttonKeyPad4))  // 4 Number tapped
            {
                key = DialpadKey.DialpadKey_Key4;
            }
            else if (Equals(e.OriginalSource, buttonKeyPad5))  // 5 Number tapped
            {
                key = DialpadKey.DialpadKey_Key5;
            }
            else if (Equals(e.OriginalSource, buttonKeyPad6))  // 6 Number tapped
            {
                key = DialpadKey.DialpadKey_Key6;
            }
            else if (Equals(e.OriginalSource, buttonKeyPad7))  // 7 Number tapped
            {
                key = DialpadKey.DialpadKey_Key7;
            }
            else if (Equals(e.OriginalSource, buttonKeyPad8))  // 8 Number tapped
            {
                key = DialpadKey.DialpadKey_Key8;
            }
            else if (Equals(e.OriginalSource, buttonKeyPad9))  // 9 Number tapped
            {
                key = DialpadKey.DialpadKey_Key9;
            }
            else if (Equals(e.OriginalSource, buttonKeyPadStar))  // * Number tapped
            {
                key = DialpadKey.DialpadKey_KeyStar;
            }
            else if (Equals(e.OriginalSource, buttonKeyPadSharp))  // # Number tapped
            {
                key = DialpadKey.DialpadKey_KeyPound;
            }

            if (key != DialpadKey.DialpadKey_KeyNone)
            {
                _viewModel.RemotePartyNumber += Convert.ToChar(key);
                if (KeypadPressed != null)
                {
                    var args = new KeyPadEventArgs(key);
                    KeypadPressed(this, args);
                }
            }
        }
Example #3
0
        private async void Keypad_KeyEvent(object sender, KeyPadEventArgs e)
        {
            // ***
            // *** Select the button/border
            // ***
            Border button = null;

            switch (e.KeyValue)
            {
            case '0':
                button = this.Button_0;
                break;

            case '1':
                button = this.Button_1;
                break;

            case '2':
                button = this.Button_2;
                break;

            case '3':
                button = this.Button_3;
                break;

            case '4':
                button = this.Button_4;
                break;

            case '5':
                button = this.Button_5;
                break;

            case '6':
                button = this.Button_6;
                break;

            case '7':
                button = this.Button_7;
                break;

            case '8':
                button = this.Button_8;
                break;

            case '9':
                button = this.Button_9;
                break;

            case '*':
                button = this.Button_Star;
                break;

            case '#':
                button = this.Button_Pound;
                break;
            }

            // ***
            // *** Use the dispatcher to keep this on the foreground thread.
            // ***
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                // ***
                // *** Store the current properties for border brush
                // *** and thickness.
                // ***
                Brush previousBrush         = button.BorderBrush;
                Thickness previousThickness = button.BorderThickness;

                // ***
                // *** Changed the properties, delay a short time, and
                // *** then restore them.
                // ***
                button.BorderBrush     = new SolidColorBrush(e.KeyDownEventType == KeyDownEventType.ButtonDown ? Colors.Yellow : Colors.LightGreen);
                button.BorderThickness = new Thickness(8);

                await Task.Delay(150);

                button.BorderBrush     = previousBrush;
                button.BorderThickness = previousThickness;
            });
        }